From 27a1e6681ed043bd9b41c4c36ce6378ee38cc6c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AD=99=E6=98=A5=E9=98=B3?= Date: Sun, 5 Oct 2025 17:00:36 +0800 Subject: [PATCH] =?utf8?q?ppp=E4=B8=AD=E6=96=AD=E5=A4=84=E7=90=86=E4=BC=98?= =?utf8?q?=E5=8C=96=EF=BC=8C=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E5=AE=8C?= =?utf8?q?=E6=88=90tcp=20=E6=B5=8B=E8=AF=95=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- code/sdk/zhihui/4gTest/cat1_at_cmd.c | 79 +++++ code/sdk/zhihui/ppp/example/ppp_at_cmd.c | 76 +++++ code/sdk/zhihui/ppp/src/ppp_interrupt.c | 355 +++++++++++++++++------ 3 files changed, 419 insertions(+), 91 deletions(-) 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=,,,