From: 孙春阳 Date: Sun, 5 Oct 2025 09:00:36 +0000 (+0800) Subject: ppp中断处理优化,可以正常完成tcp 测试了 X-Git-Tag: V1.0.9_20251128_194606_LN~279 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=27a1e6681ed043bd9b41c4c36ce6378ee38cc6c2;p=mirrors%2FFD230.git ppp中断处理优化,可以正常完成tcp 测试了 --- diff --git a/code/sdk/zhihui/4gTest/cat1_at_cmd.c b/code/sdk/zhihui/4gTest/cat1_at_cmd.c index bdb57afc4..0bac7e0d6 100644 --- a/code/sdk/zhihui/4gTest/cat1_at_cmd.c +++ b/code/sdk/zhihui/4gTest/cat1_at_cmd.c @@ -10,6 +10,7 @@ #include #include #include "cat1_log.h" +#include "osal_task.h" #ifdef __cplusplus @@ -660,6 +661,57 @@ static uint32_t at_ws_multi_test_status(uint8_t *para, uint32_t paraLen, char *s return ERRCODE_SUCC; } #endif + +#ifdef SUPPORT_TCP_TEST +/** + * @brief TCP测试监控线程 - 自动停止测试 + */ +static int tcp_test_monitor_thread_4g(void *arg) +{ + uint32_t test_duration = *(uint32_t*)arg; + free(arg); // 释放参数内存 + + PRINT("[4G_INFO]4G TCP MONITOR: Started, will auto-stop after %d seconds\r\n", test_duration); + + uint32_t elapsed = 0; + while (tcp_test_is_running() && elapsed < test_duration) { + osal_msleep(1000); // 每秒检查一次 + elapsed++; + + // 每10秒打印一次剩余时间 + if (elapsed % 10 == 0 && elapsed < test_duration) { + PRINT("[4G_INFO]4G TCP MONITOR: %d seconds remaining\r\n", test_duration - elapsed); + } + } + + // 检查测试是否还在运行 + if (tcp_test_is_running()) { + PRINT("[4G_INFO]4G TCP MONITOR: Test duration reached, stopping test...\r\n"); + + errcode_t ret = tcp_test_stop(); + if (ret == ERRCODE_SUCC) { + PRINT("[4G_INFO]4G TCP MONITOR: Test stopped successfully\r\n"); + + // 等待一段时间确保所有线程退出 + osal_msleep(500); + + // 打印最终统计 + tcp_test_print_report(); + + // 清理资源 + tcp_test_deinit(); + PRINT("[4G_INFO]4G TCP MONITOR: Test cleanup completed\r\n"); + } else { + PRINT("[4G_ERR]4G TCP MONITOR: Failed to stop test: %d\r\n", ret); + } + } else { + PRINT("[4G_INFO]4G TCP MONITOR: Test already stopped externally\r\n"); + } + + return 0; +} +#endif + /** * @brief AT^PPPTCPPERF - TCP性能测试 * 格式: AT^PPPTCPPERF=,,,