From: SnickerSun Date: Thu, 26 Dec 2024 22:43:27 +0000 (+0800) Subject: 更新gnss,取消低功耗,方便调试射频 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=41cd295b3b9ebc0d886a31c7ca349b663177722f;p=mirrors%2FFD230.git 更新gnss,取消低功耗,方便调试射频 --- diff --git a/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_cfg_h7s1.bin b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_cfg_h7s1.bin new file mode 100644 index 000000000..112cc67dd --- /dev/null +++ b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_cfg_h7s1.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d7d87f5f81edbcb9647b7bdf27773fe9f43343a71345bebcd5a96d3534dd9b9 +size 55883 diff --git a/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.c b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.c index 38f9a485c..bdf476a3c 100644 --- a/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.c +++ b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.c @@ -1,19 +1,26 @@ /** - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved. - * - * Description: gnss firmware dummy file arrays. + * Copyright (c) @CompanyNameMagicTag 2024-2024. All rights reserved. * + * Description: gnss firmware file arrays. + * Author: @CompanyNameTag * History: - * 2023-11-01, Create file. + * 2024-01-08, Create file. */ #include "gnss_fw_file_array.h" #include "tiot_types.h" /* 仅用于SDK,无文件系统使用文件数组时,替换此目录下文件. */ -#define GNSS_FW_ATTR +#define GNSS_FW_ATTR +#if 1 +/** $Achilles,H7S1,Q35,F1P26.0,0*72 */ #define GNSS_CFG_BIN "gnss_cfg.bin" +#else +/** $Achilles,H7S1,Q35,F1P10.0,0*77 */ +#define GNSS_CFG_BIN "gnss_cfg_h7s1.bin" +#endif + GNSS_FW_ATTR const char g_gnss_cfg_file[] = { #include GNSS_CFG_BIN }; diff --git a/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.h b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.h index 36312d908..a13dc6172 100644 --- a/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.h +++ b/code/sdk/zhihui/services/gnss/driver/device/gnss/firmware/gnss_fw_file_array.h @@ -1,10 +1,10 @@ /** - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved. + * Copyright (c) @CompanyNameMagicTag 2024-2024. All rights reserved. * * Description: gnss firmware file arrays. - * + * Author: @CompanyNameTag * History: - * 2023-11-01, Create file. + * 2024-01-08, Create file. */ #ifndef GNSS_FW_FILE_ARRAY_H diff --git a/code/sdk/zhihui/services/gnss/inc/NMEA0183.h b/code/sdk/zhihui/services/gnss/inc/NMEA0183.h index 9f0adb611..996f09be6 100644 --- a/code/sdk/zhihui/services/gnss/inc/NMEA0183.h +++ b/code/sdk/zhihui/services/gnss/inc/NMEA0183.h @@ -162,6 +162,11 @@ QZSS L1C/A 1~4 193~196 PRN-192 unsigned char term_offset; /* 字段域数据偏移量 */ unsigned char gps_data_good; /* GPS数据有效状态 */ unsigned int sentence_type; /* 字段类别,见枚举 sentence_types*/ + /* 数据信号分析 */ + unsigned char th001_errorcode; /**PNTH001 语句,定位错误码(第 6 字段)1:表示卫星跟踪数量不足,不满足定位条件;2:表示有效星历数量不足,不满足定位条件;3:定位精度不足,定位结果被拦截。*/ + unsigned char th001_trace_star_count; /*实际跟踪卫星数量(第 7 字段)显示了当前实际跟踪的卫星数量。*/ + unsigned char th001_valid_star_count; /*有效星历数量(第 8 字段)显示了当前有效的星历数量。*/ + float th001_quality; /**PNTH001 语句,定位质量评估因子(第 5 字段)显示了当前评估出的定位精度,定位过程中,有效范围为 3~200,值越小定位精度越好。*/ /* 数据解析结果 */ unsigned int new_time; /* UTC时间 */ unsigned int new_date; /* UTC日期 */ @@ -214,6 +219,11 @@ QZSS L1C/A 1~4 193~196 PRN-192 unsigned char num_sats; /* 可见卫星颗数 */ unsigned char have_gps_yaw; /* GPHDT航向字段有效 */ unsigned int last_gps_time_ms; /* 最后获取GPS信息时的时间 ms */ + /* 数据信号分析 */ + unsigned char th001_errorcode; /**PNTH001 语句,定位错误码(第 6 字段)1:表示卫星跟踪数量不足,不满足定位条件;2:表示有效星历数量不足,不满足定位条件;3:定位精度不足,定位结果被拦截。*/ + unsigned char th001_trace_star_count; /*实际跟踪卫星数量(第 7 字段)显示了当前实际跟踪的卫星数量。*/ + unsigned char th001_valid_star_count; /*有效星历数量(第 8 字段)显示了当前有效的星历数量。*/ + float th001_quality; /**PNTH001 语句,定位质量评估因子(第 5 字段)显示了当前评估出的定位精度,定位过程中,有效范围为 3~200,值越小定位精度越好。*/ }gps_data_t; /* NMEA0183结构体对象 */ diff --git a/code/sdk/zhihui/services/gnss/sample/gnss_sample/gnss_sample.c b/code/sdk/zhihui/services/gnss/sample/gnss_sample/gnss_sample.c index afa4dd9eb..296ad89c3 100644 --- a/code/sdk/zhihui/services/gnss/sample/gnss_sample/gnss_sample.c +++ b/code/sdk/zhihui/services/gnss/sample/gnss_sample/gnss_sample.c @@ -28,6 +28,20 @@ static uint8_t g_gnssServiceBuff[REPORT_MAX_BYTES] = { 0 }; typedef int32_t (*GnssCfgFunc)(tiot_handle handle); +//配置使能 TRK 轨迹低功耗(芯片默认)。 +const uint8_t CFG_TRK_LPW_ENABLE[] = {0x03 ,0x00 ,0x0a ,0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x05 ,0x00 ,0x02 ,0x00 ,0x01 ,0x02 }; +//配置禁用 TRK 轨迹低功耗。 +const uint8_t CFG_TRK_LPW_DISABLE[] = {0x03 ,0x00 ,0x07 ,0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x05 ,0x00 ,0x02 ,0x00 ,0x00 ,0x00}; + +//配置使能 ACQ 捕获低功耗(芯片默认)。 +const uint8_t CFG_ACQ_LPW_ENABLE[] = {0x03 ,0x00 ,0x09 ,0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x04 ,0x00 ,0x02 ,0x00 ,0x01 ,0x02 }; +//配置禁用 ACQ 捕获低功耗。 +const uint8_t CFG_ACQ_LPW_DISABLE[] = {0x03 ,0x00 ,0x06 ,0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x04 ,0x00 ,0x02 ,0x00 ,0x00 ,0x00}; + + + + + typedef struct { uint16_t sampleId; GnssCfgFunc cfgHandle; @@ -60,6 +74,18 @@ int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle) printf("\nerror: cfgNmeaAllCmd error: %d\n", ret); return 0; } + + ret = tiot_service_write(handle, CFG_TRK_LPW_DISABLE, sizeof(CFG_TRK_LPW_DISABLE)); + if (ret < 0) { + printf("\nerror: CFG_TRK_LPW_DISABLE error: %d\n", ret); + return 0; + } + + ret = tiot_service_write(handle, CFG_ACQ_LPW_DISABLE, sizeof(CFG_ACQ_LPW_DISABLE)); + if (ret < 0) { + printf("\nerror: CFG_ACQ_LPW_DISABLE error: %d\n", ret); + return 0; + } return 1; } @@ -72,6 +98,9 @@ int32_t CfgAutoStartFixModeAllNmeaDefault(tiot_handle handle) const uint8_t cfgNmeaDefaultCmd[] = {0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x02, 0x00, 0x11, 0x00}; + const uint8_t cfgAltCstrCmd[] = {0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x05, 0x00, 0x12, 0x10, 0x01, 0x00, 0x00}; + + // 配置启动模式:自动模式。 int32_t ret = tiot_service_write(handle, cfgAutoStartCmd, sizeof(cfgAutoStartCmd)); if (ret < 0) { @@ -92,6 +121,18 @@ int32_t CfgAutoStartFixModeAllNmeaDefault(tiot_handle handle) printf("\nerror: cfgNmeaDefaultCmd error: %d\n", ret); return 0; } + + ret = tiot_service_write(handle, CFG_TRK_LPW_DISABLE, sizeof(CFG_TRK_LPW_DISABLE)); + if (ret < 0) { + printf("\nerror: CFG_TRK_LPW_DISABLE error: %d\n", ret); + return 0; + } + + ret = tiot_service_write(handle, CFG_ACQ_LPW_DISABLE, sizeof(CFG_ACQ_LPW_DISABLE)); + if (ret < 0) { + printf("\nerror: CFG_ACQ_LPW_DISABLE error: %d\n", ret); + return 0; + } return 1; } diff --git a/code/sdk/zhihui/services/gnss/src/NMEA0183.c b/code/sdk/zhihui/services/gnss/src/NMEA0183.c index 5d0fda707..28c07c8a0 100644 --- a/code/sdk/zhihui/services/gnss/src/NMEA0183.c +++ b/code/sdk/zhihui/services/gnss/src/NMEA0183.c @@ -176,6 +176,13 @@ static unsigned char nmea_term_complete(gps_nmea_t* pnmea, gps_data_t* pdata) case GPS_SENTENCE_ZDA: pnmea->last_ZDA_ms = now; break; + case GPS_SENTENCE_TH001: + pdata->th001_errorcode = pnmea->th001_errorcode; + pdata->th001_quality = pnmea->th001_quality; + pdata->th001_trace_star_count = pnmea->th001_trace_star_count; + pdata->th001_valid_star_count = pnmea->th001_valid_star_count; + pdata->last_gps_time_ms = now; + printf("th001 copy to pdata \r\n" ); case GPS_SENTENCE_TH002: pdata->last_gps_time_ms = now; break; @@ -404,6 +411,28 @@ static unsigned char nmea_term_complete(gps_nmea_t* pnmea, gps_data_t* pdata) case GPS_SENTENCE_VTG + 1: // Course (VTG) pnmea->new_course = string_to_float((const char*)pnmea->term, (void*)0); break; + case GPS_SENTENCE_TH001 + 4: + /*$PNTH001,0.000000,0.00,0.00,0.00,1,0,0*2E*/ + /***PNTH001 语句,定位质量评估因子(第 5 字段)显示了当前评估出的定位精度,定位过程中,有效范围为 3~200,值越小定位精度越好。*/ + pnmea->th001_quality = string_to_float((const char*)pnmea->term, (void*)0); + // printf("th001 quality 5 %f,%s\n",pnmea->th001_quality,pnmea->term); + break; + case GPS_SENTENCE_TH001 + 5: + /**PNTH001 语句,定位错误码(第 6 字段) 1:表示卫星跟踪数量不足,不满足定位条件;2:表示有效星历数量不足,不满足定位条件;3:定位精度不足,定位结果被拦截。*/ + pnmea->th001_errorcode = (unsigned int)sring_to_int((const char*)pnmea->term, (void*)0); + // printf("th001 th001_errorcode 6 %d,%s\n",pnmea->th001_errorcode,pnmea->term); + break; + case GPS_SENTENCE_TH001 + 6: + /**PNTH001 语句,实际跟踪卫星数量(第 7 字段)显示了当前实际跟踪的卫星数量。**/ + pnmea->th001_trace_star_count = (unsigned int)sring_to_int((const char*)pnmea->term, (void*)0); + // printf("th001 th001_trace_star_count 7 %d,%s\n",pnmea->th001_trace_star_count,pnmea->term); + break; + case GPS_SENTENCE_TH001 + 7: + /**PNTH001 语句,有效星历数量(第 8 字段)显示了当前有效的星历数量*/ + pnmea->th001_valid_star_count = (unsigned int)sring_to_int((const char*)pnmea->term, (void*)0); + // printf("th001 th001_valid_star_count 8 %d,%s\n",pnmea->th001_valid_star_count,pnmea->term); + pnmea->gps_data_good = 1; + break; } } @@ -807,6 +836,15 @@ void dump_location_data_to_buf(gps_data_t *locationdata,char* buf,int max_buflen }else{ strcat_s(buf,max_buflen,"无卫星数据\n"); } + memset_s(tmpbuf,DUMP_BUF_SIZE,0,DUMP_BUF_SIZE); + sprintf_s(tmpbuf,DUMP_BUF_SIZE,"定位质量信息,失败原因(%s),精度(%f),跟踪星(%d),有效星(%d)\n", + locationdata->th001_errorcode==1?"跟踪数量不足":(locationdata->th001_errorcode==2?"有效星历数量不足":(locationdata->th001_errorcode==3?"定位精度不足":"无")), + locationdata->th001_quality, + locationdata->th001_trace_star_count, + locationdata->th001_valid_star_count + ); + strcat_s(buf,max_buflen,tmpbuf); + #else strcat(buf,"\r\n"); memset(tmpbuf,0,DUMP_BUF_SIZE); @@ -849,6 +887,14 @@ void dump_location_data_to_buf(gps_data_t *locationdata,char* buf,int max_buflen strcat(buf,"无卫星数据\r\n"); } strcat(buf,"\r\n"); + memset(tmpbuf,0,DUMP_BUF_SIZE); + sprintf(tmpbuf,"定位质量信息,失败原因(%s),精度(%f),跟踪星(%d),有效星(%d)\n", + locationdata->th001_errorcode==1?"跟踪数量不足":(locationdata->th001_errorcode==2?"有效星历数量不足":(locationdata->th001_errorcode==3?"定位精度不足":"无")), + locationdata->th001_quality, + locationdata->th001_trace_star_count, + locationdata->th001_valid_star_count + ); + strcat(buf,tmpbuf); #endif free(tmpbuf); }