From 9110ff86910bc15036ef6091575a0987b92fa08d Mon Sep 17 00:00:00 2001 From: 1624952103 Date: Fri, 23 Jan 2026 18:23:50 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8DGPS=E5=85=B3=E9=97=ADbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../gnss/sample/pgnss_sample/pgnss_sample.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c b/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c index 5cc7e97d5..16bd8df41 100644 --- a/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c +++ b/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c @@ -65,7 +65,7 @@ static char *pgnss_log = NULL; // GPS停止等待定时器相关变量 static osTimerId_t g_stop_wait_timer = NULL; static int g_stop_wait_count = 0; -static const int MAX_WAIT_COUNT = 80; // 最多等待8秒 (80 * 100ms) +static const int MAX_WAIT_COUNT = 8; // 最多等待8秒 (80 * 100ms) // 全局变量,存储当前有效的时间戳文件夹路径 static char *g_current_agnss_folder = NULL; @@ -693,8 +693,8 @@ static void gps_stop_wait_timer_callback(int data) g_stop_wait_count++; // 检查数据监听是否已停止 - if (g_is_listening_data == 0) { - printf("PGnssServerStop: Data listening stopped, executing cleanup...\r\n"); + if (g_is_listening_data == 1) { + printf("PGnssServerStop: GPS has initialized and is listening, executing safe cleanup...\r\n"); // 停止定时器 if (g_stop_wait_timer != NULL) { @@ -710,9 +710,9 @@ static void gps_stop_wait_timer_callback(int data) } // 打印等待进度(每1秒打印一次) - if (g_stop_wait_count % 10 == 0) { - printf("PGnssServerStop: Waiting for data listening to stop... (%d/%d ms)\r\n", - g_stop_wait_count * 100, MAX_WAIT_COUNT * 100); + if (g_stop_wait_count % 2 == 0) { + printf("PGnssServerStop: Waiting for data listening to stop... (%d/%d s)\r\n", + g_stop_wait_count * 2, MAX_WAIT_COUNT * 2); } // 超时处理:如果等待时间超过最大值,强制执行清理 @@ -743,7 +743,7 @@ void PGnssServerStop(void) } // 如果数据监听已经停止,直接执行清理 - if (g_is_listening_data == 0) { + if (g_is_listening_data == 1) { printf("PGnssServerStop: Data listening already stopped, executing cleanup immediately\r\n"); do_gps_stop_cleanup(); return; @@ -769,7 +769,7 @@ void PGnssServerStop(void) } // 启动定时器(100ms间隔) - int tick = osMs2Tick(100); + int tick = osMs2Tick(1000); osStatus_t ret = osTimerStart(g_stop_wait_timer, tick); if (ret != osOK) { printf("PGnssServerStop: Failed to start wait timer (ret=%d), executing cleanup immediately\r\n", ret); -- 2.17.1