From 930b6dc00c61f6e7e8f989007a496016623e55dc Mon Sep 17 00:00:00 2001 From: Caisking Date: Sat, 24 Jan 2026 16:55:53 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8Dgps=E6=AD=BB=E6=9C=BA=EF=BC=8C?= =?utf8?q?=E4=BC=98=E5=8C=96=E5=BF=83=E7=8E=87=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c | 4 + .../gnss/sample/pgnss_sample/pgnss_sample.c | 118 +++++++++--------- .../sdk/zhihui/services/gnss/src/decodenmea.c | 4 +- code/sdk/zhihui/services/gnss/src/uart_gnss.c | 2 +- 4 files changed, 66 insertions(+), 62 deletions(-) diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c index f30fe8694..e35d83a7e 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c +++ b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c @@ -1575,6 +1575,10 @@ void hx3695_ppg_Int_handle(ppg_sensor_data_t *ppg_sensor_dat) // printf("count:%d\n",count); if(count > 0) { + if(work_mode_flag == HRS_MODE && count > 9) + { + count = 8; + } hx3695_check_wear(ppg_sensor_dat,count); if(wear_status == MSG_WEAR) { 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 7ffc61cb0..b1cf10f19 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 @@ -511,7 +511,7 @@ static void ListenGnssData(tiot_handle handle) { int32_t i = 0; int32_t timeout_count = 0; // 连续超时计数器 - char temp_buf[512] = {0}; + // char temp_buf[512] = {0}; // 初始化GNSS服务缓冲区 if (init_gnss_service_buffer() != 0) { @@ -587,30 +587,30 @@ static void ListenGnssData(tiot_handle handle) { if (decode_nmea(pbuf[index])==1) { - dump_location_data(&g_global_gpsData); - memset_s(temp_buf,sizeof(temp_buf),0,sizeof(temp_buf)); + // dump_location_data(&g_global_gpsData); + // memset_s(temp_buf,sizeof(temp_buf),0,sizeof(temp_buf)); // char *temp_buf = (char *)malloc(512); // if (temp_buf == NULL) { // printf("error: malloc temp_buf failed!\n"); // continue; // } - dump_location_data_to_buf(&g_global_gpsData, temp_buf, 512); + // dump_location_data_to_buf(&g_global_gpsData, temp_buf, 512); // printf("temp_buf : %s\n",temp_buf); // 追加到pgnss_log中 - if (pgnss_log != NULL) { - int current_len = strlen(pgnss_log); - int data_len = strlen(temp_buf); - if (current_len + data_len < 2047) { // 留1字节给字符串结束符 - snprintf(pgnss_log + current_len, 2048 - current_len, "%s", temp_buf); - } else { - // 内存满了,清空从头开始存储 - printf("pgnss_log memory full, clearing and restarting\n"); - memset(pgnss_log, 0, 2048); - snprintf(pgnss_log, 2048, "%s", temp_buf); - } - } + // if (pgnss_log != NULL) { + // int current_len = strlen(pgnss_log); + // int data_len = strlen(temp_buf); + // if (current_len + data_len < 2047) { // 留1字节给字符串结束符 + // snprintf(pgnss_log + current_len, 2048 - current_len, "%s", temp_buf); + // } else { + // // 内存满了,清空从头开始存储 + // printf("pgnss_log memory full, clearing and restarting\n"); + // memset(pgnss_log, 0, 2048); + // snprintf(pgnss_log, 2048, "%s", temp_buf); + // } + // } // printf("decode_nmea done\r\n"); // free(temp_buf); @@ -837,10 +837,10 @@ void PGnssServerStartAutoModeStart(void) g_is_pgnss_poweron = 0; g_is_pgnss_start = 0; g_pgnss_stopflag = 1; - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } @@ -850,10 +850,10 @@ void PGnssServerStartAutoModeStart(void) g_gnssLogFp = fopen("/user/userdata/gnsslog.txt", "w"); if (g_gnssLogFp == NULL) { printf("error: open log file error\n"); - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } // 写入日志开启时间戳 @@ -869,10 +869,10 @@ void PGnssServerStartAutoModeStart(void) g_is_pgnss_poweron = 0; g_is_pgnss_start = 0; g_pgnss_stopflag = 1; - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } printf("open tiot service success for auto start\n"); @@ -942,11 +942,11 @@ void PGnssServerStartAutoModeStart(void) // 释放pgnss_log内存 - if (pgnss_log != NULL) { - printf("gnss_log: %s\r\n", pgnss_log); - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // printf("gnss_log: %s\r\n", pgnss_log); + // free(pgnss_log); + // pgnss_log = NULL; + // } } // 辅助函数:检查指定文件夹的文件数量 @@ -1307,15 +1307,15 @@ void PGnssServerStart(void) printf("\nenter gnss samples\r\n"); - if (pgnss_log == NULL) - { - pgnss_log = (char *)malloc(2048); - if (pgnss_log == NULL) { - printf("error: malloc pgnss_log failed!\n"); - return; - } - memset(pgnss_log, 0, 2048); - } + // if (pgnss_log == NULL) + // { + // pgnss_log = (char *)malloc(2048); + // if (pgnss_log == NULL) { + // printf("error: malloc pgnss_log failed!\n"); + // return; + // } + // memset(pgnss_log, 0, 2048); + // } uapi_pm_add_sleep_veto(PM_ID_SYS); @@ -1341,10 +1341,10 @@ void PGnssServerStart(void) g_is_pgnss_poweron = 0; g_is_pgnss_start = 0; g_pgnss_stopflag = 1; - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } @@ -1354,10 +1354,10 @@ void PGnssServerStart(void) g_gnssLogFp = fopen("/user/userdata/gnsslog.txt", "w"); if (g_gnssLogFp == NULL) { printf("error: open log file error\n"); - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } // 写入日志开启时间戳 @@ -1374,10 +1374,10 @@ void PGnssServerStart(void) g_is_pgnss_start = 0; g_pgnss_stopflag = 1; g_cold_start_pgnss_stopflag = 1; - if (pgnss_log != NULL) { - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // free(pgnss_log); + // pgnss_log = NULL; + // } return; } printf("open tiot service success\r\n"); @@ -1448,11 +1448,11 @@ void PGnssServerStart(void) // 释放pgnss_log内存 - if (pgnss_log != NULL) { - printf("pgnss_log:%s\r\n",pgnss_log); - free(pgnss_log); - pgnss_log = NULL; - } + // if (pgnss_log != NULL) { + // printf("pgnss_log:%s\r\n",pgnss_log); + // free(pgnss_log); + // pgnss_log = NULL; + // } if(g_cold_start_pgnss_stopflag == 1) { PGnssServerStartAutoModeStart(); diff --git a/code/sdk/zhihui/services/gnss/src/decodenmea.c b/code/sdk/zhihui/services/gnss/src/decodenmea.c index b45018bf7..0889589b2 100644 --- a/code/sdk/zhihui/services/gnss/src/decodenmea.c +++ b/code/sdk/zhihui/services/gnss/src/decodenmea.c @@ -65,14 +65,14 @@ int decode_nmea(char c) // printf("%c",c); if(nmea_decode(&g_nmeadata,c) ==1) ///调用解析函数 { - printf("%s\r\n",tmpbuf); + // printf("%s\r\n",tmpbuf); memset(tmpbuf,0,sizeof(tmpbuf)); count=0; dump_nmea_str(&(g_nmeadata.gpsParse)); if (g_nmeadata.gpsParse.sentence_type == GPS_SENTENCE_TH002) { //一组数据最后一条 - dump_location_data(&(g_nmeadata.gpsData)); + // dump_location_data(&(g_nmeadata.gpsData)); memset(&g_nmeadata,0,sizeof(g_nmeadata)); } } diff --git a/code/sdk/zhihui/services/gnss/src/uart_gnss.c b/code/sdk/zhihui/services/gnss/src/uart_gnss.c index 33a073bef..9e7aa8f95 100644 --- a/code/sdk/zhihui/services/gnss/src/uart_gnss.c +++ b/code/sdk/zhihui/services/gnss/src/uart_gnss.c @@ -219,7 +219,7 @@ void gnss_receive_handler(uint8_t *buffer, int32_t size) } #define GNSS_CMD_TASK_MSG_COUNT 128 -#define GNSS_CMD_TASK_SIZE (0x2500) +#define GNSS_CMD_TASK_SIZE (0x3000) #define GNSS_CMD_TASK_PRIO 4 void create_gnss_uart_queue(void) { -- 2.17.1