From: snickersun@163.com Date: Thu, 18 Sep 2025 02:39:40 +0000 (+0000) Subject: Merge #2283 into sdk650pathc0423 from refs/changes/2283/head X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~60^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=923d89c45fa4180b131457409216f5287ccf6178;p=mirrors%2FFD230.git Merge #2283 into sdk650pathc0423 from refs/changes/2283/head 雷鸟 ai_old添加编译配置 * refs/changes/2283/head: (4 commits squashed) - 雷鸟 ai_old添加编译配置 - 添加AT^PPPDEBUGSET动态修改打印等级指令 - 添加tcp client测试用例 - Merge branch 'sdk650pathc0423' of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423 Signed-off-by: snickersun@163.com Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/2283 --- diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 1cbb4c4d5..dff9169ae 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -1277,6 +1277,7 @@ target = { # 'AILPAY_SUPPORT', # 'SUPPORT_FACTORY_SERVICE', # 'MEMORY_CORRUPTION', + 'SUPPORT_AI_SERVICE', 'SAP_EFFECT_SWS_SUPPORT', 'AUDIO_SMARTPA_AW88082', 'LCD_JD9885', diff --git a/code/sdk/zhihui/ppp/CMakeLists.txt b/code/sdk/zhihui/ppp/CMakeLists.txt index 41539d69a..4e83333a7 100644 --- a/code/sdk/zhihui/ppp/CMakeLists.txt +++ b/code/sdk/zhihui/ppp/CMakeLists.txt @@ -10,6 +10,7 @@ set(PPP_AT_CMD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_example.c # ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_power_example.c ${CMAKE_CURRENT_SOURCE_DIR}/example/api_shell.c + ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_tcp_test.c ) # 源文件列表 set(SOURCES @@ -19,6 +20,7 @@ set(SOURCES src/ppp_lwip.c src/ppp_lwip_thread.c src/ppp_debug.c + src/ppp_debug_manager.c src/ppp_power_ctl.c src/ppp_cat1_api.c src/ppp_stub_functions.c @@ -75,6 +77,7 @@ set(PUBLIC_DEFINES # PPP_OPTIONS=1 SUPPORT_PPP_SERVICE SUPPORT_AT_PPP + SUPPORT_TCP_TEST ) set(PRIVATE_DEFINES diff --git a/code/sdk/zhihui/ppp/doc/dynamic_debug_usage.md b/code/sdk/zhihui/ppp/doc/dynamic_debug_usage.md new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/code/sdk/zhihui/ppp/doc/dynamic_debug_usage.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/example/Makefile b/code/sdk/zhihui/ppp/example/Makefile new file mode 100644 index 000000000..208b52e11 --- /dev/null +++ b/code/sdk/zhihui/ppp/example/Makefile @@ -0,0 +1,83 @@ +# Makefile for PPP TCP Test Client +# 基于Python版本tcp_test_client.py实现的C语言版本 + +# 编译器设置 +CC = gcc +CFLAGS = -Wall -Wextra -std=c99 -O2 -g +LDFLAGS = -pthread + +# 目录设置 +SRC_DIR = . +INC_DIR = ../include +BUILD_DIR = build + +# 目标程序 +TARGET = ppp_tcp_test + +# 源文件 +SRCS = ppp_tcp_test.c ppp_tcp_test_main.c + +# 目标文件 +OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o) + +# 头文件依赖 +INCLUDES = -I$(INC_DIR) -I. + +# 默认目标 +all: $(BUILD_DIR)/$(TARGET) + +# 创建构建目录 +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +# 编译目标程序 +$(BUILD_DIR)/$(TARGET): $(BUILD_DIR) $(OBJS) + $(CC) $(OBJS) -o $@ $(LDFLAGS) + @echo "Build complete: $@" + +# 编译源文件 +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ + +# 清理 +clean: + rm -rf $(BUILD_DIR) + +# 安装 +install: $(BUILD_DIR)/$(TARGET) + cp $(BUILD_DIR)/$(TARGET) /usr/local/bin/$(TARGET) + @echo "Installed to /usr/local/bin/$(TARGET)" + +# 卸载 +uninstall: + rm -f /usr/local/bin/$(TARGET) + @echo "Uninstalled $(TARGET)" + +# 测试运行 +test: $(BUILD_DIR)/$(TARGET) + @echo "Running basic test..." + $(BUILD_DIR)/$(TARGET) --help + +# 示例运行 +example: $(BUILD_DIR)/$(TARGET) + @echo "Running example test (需要服务器支持)..." + $(BUILD_DIR)/$(TARGET) --host 127.0.0.1 --port 8910 --connections 2 --time 10 --verbose + +# 显示帮助 +help: + @echo "Available targets:" + @echo " all - Build the TCP test client" + @echo " clean - Remove build files" + @echo " install - Install to /usr/local/bin" + @echo " uninstall - Remove from /usr/local/bin" + @echo " test - Run basic functionality test" + @echo " example - Run example test (needs server)" + @echo " help - Show this help" + @echo "" + @echo "Usage examples:" + @echo " make" + @echo " make test" + @echo " make example" + @echo " ./build/$(TARGET) --host 192.168.1.100 --port 8080 --connections 5 --time 30" + +.PHONY: all clean install uninstall test example help \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/example/README_TCP_TEST.md b/code/sdk/zhihui/ppp/example/README_TCP_TEST.md new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/code/sdk/zhihui/ppp/example/README_TCP_TEST.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c index 3ceb0ff57..f34636a41 100644 --- a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c +++ b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c @@ -12,6 +12,8 @@ #include "ppp_types.h" #include "ppp_api.h" #include "ppp_at_handler.h" +#include "ppp_debug_manager.h" +#include "ppp_tcp_test.h" #include "ppp_example.h" @@ -1591,6 +1593,321 @@ static errcode_t at_ppp_test_uart_performance(uint8_t *para, uint32_t paraLen) return ERRCODE_SUCC; } +/** + * @brief AT^PPPDEBUGSET - 设置PPP调试级别 + * @param para 参数: 调试级别 (0=NONE, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG) 或级别名称 + * @param paraLen 参数长度 + */ +static errcode_t at_ppp_debug_set_level(uint8_t *para, uint32_t paraLen) +{ + if (!para || paraLen == 0) { + PRINT("[PPP_ERR]PPP DEBUG SET: Missing debug level parameter\r\n"); + PRINT("[PPP_INFO]Usage: AT^PPPDEBUGSET=\r\n"); + PRINT("[PPP_INFO]Levels: 0=NONE, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG\r\n"); + PRINT("[PPP_INFO]Or use names: NONE, ERROR, WARN, INFO, DEBUG\r\n"); + return ERRCODE_FAIL; + } + + // 将参数转换为字符串 + char level_str[16] = {0}; + uint32_t copy_len = (paraLen < sizeof(level_str) - 1) ? paraLen : sizeof(level_str) - 1; + memcpy(level_str, para, copy_len); + level_str[copy_len] = '\0'; + + PRINT("[PPP_INFO]PPP DEBUG SET: Setting debug level to '%s'...\r\n", level_str); + + ppp_error_t ret = PPP_ERR_OK; + + // 尝试按数字设置 + if (level_str[0] >= '0' && level_str[0] <= '4' && level_str[1] == '\0') { + int level = level_str[0] - '0'; + ret = ppp_debug_set_level(level); + if (ret == PPP_ERR_OK) { + PRINT("[PPP_INFO]PPP DEBUG SET: Debug level set to %d (%s)\r\n", + level, ppp_debug_get_level_name(level)); + } + } else { + // 尝试按名称设置 + ret = ppp_debug_set_level_by_name(level_str); + if (ret == PPP_ERR_OK) { + int current_level = ppp_debug_get_level(); + PRINT("[PPP_INFO]PPP DEBUG SET: Debug level set to %s (%d)\r\n", + ppp_debug_get_level_name(current_level), current_level); + } + } + + if (ret != PPP_ERR_OK) { + PRINT("[PPP_ERR]PPP DEBUG SET: Invalid debug level '%s'\r\n", level_str); + PRINT("[PPP_INFO]Valid levels: 0=NONE, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG\r\n"); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; +} + +/** + * @brief AT^PPPDEBUGGET - 获取当前PPP调试级别 + */ +static errcode_t at_ppp_debug_get_level(uint8_t *para, uint32_t paraLen) +{ + (void)para; + (void)paraLen; + + int current_level = ppp_debug_get_level(); + const char *level_name = ppp_debug_get_level_name(current_level); + + PRINT("[PPP_INFO]PPP DEBUG GET: Current debug level is %d (%s)\r\n", + current_level, level_name); + + // 显示各级别的含义 + PRINT("[PPP_INFO]Debug levels:\r\n"); + PRINT("[PPP_INFO] 0=NONE - No debug output\r\n"); + PRINT("[PPP_INFO] 1=ERROR - Error messages only\r\n"); + PRINT("[PPP_INFO] 2=WARN - Warnings and errors\r\n"); + PRINT("[PPP_INFO] 3=INFO - Info, warnings and errors\r\n"); + PRINT("[PPP_INFO] 4=DEBUG - All debug messages\r\n"); + + return ERRCODE_SUCC; +} +#include "ppp_debug.h" +/** + * @brief AT^PPPDEBUGTEST - 测试各级别调试输出 + */ +static errcode_t at_ppp_debug_test_output(uint8_t *para, uint32_t paraLen) +{ + (void)para; + (void)paraLen; + + int current_level = ppp_debug_get_level(); + + PRINT("[PPP_INFO]PPP DEBUG TEST: Testing debug output at level %d (%s)\r\n", + current_level, ppp_debug_get_level_name(current_level)); + + // 测试各级别输出 + PPP_DEBUG_ERROR("This is an ERROR message (level 1)"); + PPP_DEBUG_WARN("This is a WARN message (level 2)"); + PPP_DEBUG_INFO("This is an INFO message (level 3)"); + PPP_DEBUG_DEBUG("This is a DEBUG message (level 4)"); + PPP_DEBUG_CRITICAL("This is a CRITICAL message (always shown)"); + + PRINT("[PPP_INFO]PPP DEBUG TEST: Test completed\r\n"); + + return ERRCODE_SUCC; +} + +/** + * @brief AT^PPPDEBUGDEFAULT - 重置调试级别为默认值 + */ +static errcode_t at_ppp_debug_reset_level(uint8_t *para, uint32_t paraLen) +{ + (void)para; + (void)paraLen; + + ppp_error_t ret = ppp_debug_reset_level(); + if (ret == PPP_ERR_OK) { + int current_level = ppp_debug_get_level(); + PRINT("[PPP_INFO]PPP DEBUG RESET: Debug level reset to default %d (%s)\r\n", + current_level, ppp_debug_get_level_name(current_level)); + return ERRCODE_SUCC; + } else { + PRINT("[PPP_ERR]PPP DEBUG RESET: Failed to reset debug level\r\n"); + return ERRCODE_FAIL; + } +} + +/** + * @brief AT^PPPTCPPERF - PPP TCP性能测试 + * @param para 参数: 服务器地址,端口,连接数,测试时间 + * @param paraLen 参数长度 + */ +static errcode_t at_ppp_tcp_performance_test(uint8_t *para, uint32_t paraLen) +{ + if (!para || paraLen == 0) { + PRINT("[PPP_ERR]PPP TCP PERF: Missing parameters\r\n"); + PRINT("[PPP_INFO]Usage: AT^PPPTCPPERF=,,,