diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2020-12-02 07:02:20 -0800 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2020-12-02 07:02:20 -0800 |
commit | 7da1fb21a2b347871f557e24aa4694afd3cd015a (patch) | |
tree | 3bc26f105f252e531083d148bec222520e153651 | |
parent | 32674e1fe36ab03ce210bbd32254516ff705d1e9 (diff) | |
parent | 17923fd3f5c7dc1bce5296e9358fa8e4d1f7e534 (diff) |
Merge 17923fd3f5c7dc1bce5296e9358fa8e4d1f7e534 on remote branch
Change-Id: I3de683796fb32a4092753d54031e3e0de980fdeb
-rw-r--r-- | core/ContextBase.cpp | 3 | ||||
-rw-r--r-- | core/ContextBase.h | 1 | ||||
-rw-r--r-- | etc/gps.conf | 9 | ||||
-rw-r--r-- | gnss/GnssAdapter.cpp | 12 | ||||
-rw-r--r-- | utils/gps_extended_c.h | 1 | ||||
-rw-r--r-- | utils/loc_nmea.cpp | 202 | ||||
-rw-r--r-- | utils/loc_nmea.h | 3 |
7 files changed, 144 insertions, 87 deletions
diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 411c990..fb453cb 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -92,6 +92,7 @@ const loc_param_s_type ContextBase::mGps_conf_table[] = {"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'}, {"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED", &mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'}, + {"NMEA_TAG_BLOCK_GROUPING_ENABLED", &mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED, NULL, 'n'}, {"NI_SUPL_DENY_ON_NFW_LOCKED", &mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED, NULL, 'n'}, {"ENABLE_NMEA_PRINT", &mGps_conf.ENABLE_NMEA_PRINT, NULL, 'n'} }; @@ -191,6 +192,8 @@ void ContextBase::readConfig() /* default configuration QTI GNSS H/W */ mGps_conf.GNSS_DEPLOYMENT = 0; mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0; + /* default NMEA Tag Block Grouping is disabled */ + mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED = 0; /* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */ mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 1; /* By default NMEA Printing is disabled */ diff --git a/core/ContextBase.h b/core/ContextBase.h index 026ab49..6784c2b 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -77,6 +77,7 @@ typedef struct loc_gps_cfg_s uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED; uint32_t NI_SUPL_DENY_ON_NFW_LOCKED; uint32_t ENABLE_NMEA_PRINT; + uint32_t NMEA_TAG_BLOCK_GROUPING_ENABLED; } loc_gps_cfg_s_type; /* NOTE: the implementation of the parser casts number diff --git a/etc/gps.conf b/etc/gps.conf index 644eec9..75f12f2 100644 --- a/etc/gps.conf +++ b/etc/gps.conf @@ -95,6 +95,15 @@ DATUM_TYPE = 0 # NMEA provider (1=Modem Processor, 0=Application Processor) NMEA_PROVIDER=0 +################################ +# NMEA TAG BLOCK GROUPING +################################ +# NMEA tag block grouping is only applicable to GSA +# Default is disabled +# 0 - disabled +# 1 - enabled +NMEA_TAG_BLOCK_GROUPING_ENABLED = 0 + # Customized NMEA GGA fix quality that can be used to tell # whether SENSOR contributed to the fix. # diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 2c2e155..ab73dc9 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -841,6 +841,9 @@ GnssAdapter::setConfig() uint32_t mask = 0; if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) { mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + if (ContextBase::mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED) { + mask |= LOC_NMEA_MASK_TAGBLOCK_V02; + } } if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { mask |= LOC_NMEA_MASK_DEBUG_V02; @@ -920,6 +923,9 @@ GnssAdapter::setConfig() uint32_t mask = 0; if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) { mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK; + if (gpsConf.NMEA_TAG_BLOCK_GROUPING_ENABLED) { + mask |= LOC_NMEA_MASK_TAGBLOCK_V02; + } } if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) { mask |= LOC_NMEA_MASK_DEBUG_V02; @@ -3889,10 +3895,12 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation, (LOC_RELIABILITY_NOT_SET == locationExtended.horizontal_reliability)); uint8_t generate_nmea = (reportToGnssClient && status != LOC_SESS_FAILURE && !blank_fix); bool custom_nmea_gga = (1 == ContextBase::mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED); + bool isTagBlockGroupingEnabled = + (1 == ContextBase::mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED); std::vector<std::string> nmeaArraystr; int indexOfGGA = -1; - loc_nmea_generate_pos(ulpLocation, locationExtended, mLocSystemInfo, - generate_nmea, custom_nmea_gga, nmeaArraystr, indexOfGGA); + loc_nmea_generate_pos(ulpLocation, locationExtended, mLocSystemInfo, generate_nmea, + custom_nmea_gga, nmeaArraystr, indexOfGGA, isTagBlockGroupingEnabled); stringstream ss; for (auto itor = nmeaArraystr.begin(); itor != nmeaArraystr.end(); ++itor) { ss << *itor; diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 8e47ef7..60af1f5 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -915,6 +915,7 @@ typedef uint32_t NmeaSentenceTypesMask; #define LOC_NMEA_MASK_GQGSV_V02 ((NmeaSentenceTypesMask)0x10000000) /**< Enable GQGSV type */ #define LOC_NMEA_MASK_GIGSV_V02 ((NmeaSentenceTypesMask)0x20000000) /**< Enable GIGSV type */ #define LOC_NMEA_MASK_GNDTM_V02 ((NmeaSentenceTypesMask)0x40000000) /**< Enable GNDTM type */ +#define LOC_NMEA_MASK_TAGBLOCK_V02 ((NmeaSentenceTypesMask)0x80000000) /**< Enable TAGBLOCK type */ // all bitmasks of general supported NMEA sentenses - debug is not part of this diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp index 237910c..75e92c4 100644 --- a/utils/loc_nmea.cpp +++ b/utils/loc_nmea.cpp @@ -44,6 +44,7 @@ #define MAX_SATELLITES_IN_USE 12 #define MSEC_IN_ONE_WEEK 604800000ULL #define UTC_GPS_OFFSET_MSECS 315964800000ULL +#define MAX_TAG_BLOCK_GROUP_CODE (99999) // GNSS system id according to NMEA spec #define SYSTEM_ID_GPS 1 @@ -563,23 +564,28 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_nmea_put_checksum(char *pNmea, int maxSize) +static int loc_nmea_put_checksum(char *pNmea, int maxSize, bool isTagBlock) { uint8_t checksum = 0; int length = 0; + int checksumLength = 0; if(NULL == pNmea) return 0; - pNmea++; //skip the $ + pNmea++; //skip the $ or / for Tag Block while (*pNmea != '\0') { checksum ^= *pNmea++; length++; } - // length now contains nmea sentence string length not including $ sign. - int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum); - + if (isTagBlock) { + // length now contains tag block sentence string length not including / sign. + checksumLength = snprintf(pNmea, (maxSize-length-1), "*%02X\\", checksum); + } else { + // length now contains nmea sentence string length not including $ sign. + checksumLength = snprintf(pNmea, (maxSize-length-1), "*%02X\r\n", checksum); + } // total length of nmea sentence is length of nmea sentence inc $ sign plus // length of checksum (+1 is to cover the $ character in the length). return (length + checksumLength + 1); @@ -610,7 +616,8 @@ static uint32_t loc_nmea_generate_GSA(const GpsLocationExtended &locationExtende char* sentence, int bufSize, loc_nmea_sv_meta* sv_meta_p, - std::vector<std::string> &nmeaArraystr) + std::vector<std::string> &nmeaArraystr, + bool isTagBlockGroupingEnabled) { if (!sentence || bufSize <= 0 || !sv_meta_p) { @@ -621,9 +628,14 @@ static uint32_t loc_nmea_generate_GSA(const GpsLocationExtended &locationExtende char* pMarker = sentence; int lengthRemaining = bufSize; int length = 0; + int lengthTagBlock = 0; uint32_t svUsedCount = 0; uint32_t svUsedList[64] = {0}; + uint32_t sentenceCount = 0; + uint32_t sentenceNumber = 1; + size_t svNumber = 1; + static uint32_t code = 1; char fixType = '\0'; @@ -642,77 +654,98 @@ static uint32_t loc_nmea_generate_GSA(const GpsLocationExtended &locationExtende mask = mask >> 1; } - if (svUsedCount == 0) - return 0; - - if (sv_meta_p->totalSvUsedCount == 0) - fixType = '1'; // no fix - else if (sv_meta_p->totalSvUsedCount <= 3) - fixType = '2'; // 2D fix - else - fixType = '3'; // 3D fix - - // Start printing the sentence - // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v,s*cc - // a : Mode : A : Automatic, allowed to automatically switch 2D/3D - // x : Fixtype : 1 (no fix), 2 (2D fix), 3 (3D fix) - // xx : 12 SV ID - // p.p : Position DOP (Dilution of Precision) - // h.h : Horizontal DOP - // v.v : Vertical DOP - // s : GNSS System Id - // cc : Checksum value - length = snprintf(pMarker, lengthRemaining, "$%sGSA,A,%c,", talker, fixType); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); + if (svUsedCount == 0) { return 0; + } else { + sentenceNumber = 1; + sentenceCount = svUsedCount / 12 + (svUsedCount % 12 != 0); + svNumber = 1; } - pMarker += length; - lengthRemaining -= length; - - // Add first 12 satellite IDs - for (uint8_t i = 0; i < 12; i++) - { - if (i < svUsedCount) - length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]); + while (sentenceNumber <= sentenceCount) { + pMarker = sentence; + lengthRemaining = bufSize; + if (svUsedCount > 12 && isTagBlockGroupingEnabled) { + lengthTagBlock = snprintf(pMarker, lengthRemaining, "\\g:%d-%d-%d", sentenceNumber, + sentenceCount, code); + if (MAX_TAG_BLOCK_GROUP_CODE == code) { + code = 1; + } + lengthTagBlock = loc_nmea_put_checksum(sentence, bufSize, true); + pMarker += lengthTagBlock; + lengthRemaining -= lengthTagBlock; + } + if (sv_meta_p->totalSvUsedCount == 0) + fixType = '1'; // no fix + else if (sv_meta_p->totalSvUsedCount <= 3) + fixType = '2'; // 2D fix else - length = snprintf(pMarker, lengthRemaining, ","); - - if (length < 0 || length >= lengthRemaining) - { + fixType = '3'; // 3D fix + + // Start printing the sentence + // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v,s*cc + // a : Mode : A : Automatic, allowed to automatically switch 2D/3D + // x : Fixtype : 1 (no fix), 2 (2D fix), 3 (3D fix) + // xx : 12 SV ID + // p.p : Position DOP (Dilution of Precision) + // h.h : Horizontal DOP + // v.v : Vertical DOP + // s : GNSS System Id + // cc : Checksum value + length = snprintf(pMarker, lengthRemaining, "$%sGSA,A,%c,", talker, fixType); + if (length < 0 || length >= lengthRemaining) { LOC_LOGE("NMEA Error in string formatting"); return 0; } pMarker += length; lengthRemaining -= length; - } - // Add the position/horizontal/vertical DOP values - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) - { - length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f,", - locationExtended.pdop, - locationExtended.hdop, - locationExtended.vdop); - } - else - { // no dop - length = snprintf(pMarker, lengthRemaining, ",,,"); - } - pMarker += length; - lengthRemaining -= length; + // Add 12 satellite IDs + for (uint8_t i = 0; i < 12; i++, svNumber++) + { + if (svNumber <= svUsedCount) + length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[svNumber - 1]); + else + length = snprintf(pMarker, lengthRemaining, ","); - // system id - length = snprintf(pMarker, lengthRemaining, "%d", sv_meta_p->systemId); - pMarker += length; - lengthRemaining -= length; + if (length < 0 || length >= lengthRemaining) { + LOC_LOGE("NMEA Error in string formatting"); + return 0; + } + pMarker += length; + lengthRemaining -= length; + } + + // Add the position/horizontal/vertical DOP values + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f,", + locationExtended.pdop, + locationExtended.hdop, + locationExtended.vdop); + } + else + { // no dop + length = snprintf(pMarker, lengthRemaining, ",,,"); + } + pMarker += length; + lengthRemaining -= length; - /* Sentence is ready, add checksum and broadcast */ - length = loc_nmea_put_checksum(sentence, bufSize); - nmeaArraystr.push_back(sentence); + // system id + length = snprintf(pMarker, lengthRemaining, "%d", sv_meta_p->systemId); + pMarker += length; + lengthRemaining -= length; + /* Sentence is ready, add checksum and broadcast */ + length = loc_nmea_put_checksum(sentence + lengthTagBlock, bufSize - lengthTagBlock, false); + nmeaArraystr.push_back(sentence); + sentenceNumber++; + if (!isTagBlockGroupingEnabled) { + break; + } + } + if (svUsedCount > 12 && isTagBlockGroupingEnabled) { + code++; + } return svUsedCount; } @@ -862,7 +895,7 @@ static void loc_nmea_generate_GSV(const GnssSvNotification &svNotify, pMarker += length; lengthRemaining -= length; - length = loc_nmea_put_checksum(sentence, bufSize); + length = loc_nmea_put_checksum(sentence, bufSize, false); nmeaArraystr.push_back(sentence); sentenceNumber++; @@ -971,7 +1004,7 @@ static void loc_nmea_generate_DTM(const LocLla &ref_lla, pMarker += length; lengthRemaining -= length; - length = loc_nmea_put_checksum(sentence, bufSize); + length = loc_nmea_put_checksum(sentence, bufSize, false); } /*=========================================================================== @@ -1287,7 +1320,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, unsigned char generate_nmea, bool custom_gga_fix_quality, std::vector<std::string> &nmeaArraystr, - int& indexOfGGA) + int& indexOfGGA, + bool isTagBlockGroupingEnabled) { ENTRY_LOG(); @@ -1368,7 +1402,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GPS, - GNSS_SIGNAL_GPS_L1CA, true), nmeaArraystr); + GNSS_SIGNAL_GPS_L1CA, true), nmeaArraystr, isTagBlockGroupingEnabled); if (count > 0) { svUsedCount += count; @@ -1382,7 +1416,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GLONASS, - GNSS_SIGNAL_GLONASS_G1, true), nmeaArraystr); + GNSS_SIGNAL_GLONASS_G1, true), nmeaArraystr, isTagBlockGroupingEnabled); if (count > 0) { svUsedCount += count; @@ -1396,7 +1430,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_GALILEO, - GNSS_SIGNAL_GALILEO_E1, true), nmeaArraystr); + GNSS_SIGNAL_GALILEO_E1, true), nmeaArraystr, isTagBlockGroupingEnabled); if (count > 0) { svUsedCount += count; @@ -1409,7 +1443,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, // ---------------------------- count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_BEIDOU, - GNSS_SIGNAL_BEIDOU_B1I, true), nmeaArraystr); + GNSS_SIGNAL_BEIDOU_B1I, true), nmeaArraystr, isTagBlockGroupingEnabled); if (count > 0) { svUsedCount += count; @@ -1423,7 +1457,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, count = loc_nmea_generate_GSA(locationExtended, sentence, sizeof(sentence), loc_nmea_sv_meta_init(sv_meta, sv_cache_info, GNSS_SV_TYPE_QZSS, - GNSS_SIGNAL_QZSS_L1CA, true), nmeaArraystr); + GNSS_SIGNAL_QZSS_L1CA, true), nmeaArraystr, isTagBlockGroupingEnabled); if (count > 0) { svUsedCount += count; @@ -1435,7 +1469,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, // in this case, generate an empty GSA sentence if (svUsedCount == 0) { strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,,", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); } @@ -1502,7 +1536,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, length = snprintf(pMarker, lengthRemaining, "%c", vtgModeIndicator); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); memset(&ecef_w84, 0, sizeof(ecef_w84)); @@ -1706,7 +1740,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, // hardcode Navigation Status field to 'V' length = snprintf(pMarker, lengthRemaining, ",%c", 'V'); - length = loc_nmea_put_checksum(sentence_RMC, sizeof(sentence_RMC)); + length = loc_nmea_put_checksum(sentence_RMC, sizeof(sentence_RMC), false); // ------------------- // ------$--GNS------- @@ -1868,7 +1902,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, pMarker += length; lengthRemaining -= length; - length = loc_nmea_put_checksum(sentence_GNS, sizeof(sentence_GNS)); + length = loc_nmea_put_checksum(sentence_GNS, sizeof(sentence_GNS), false); // ------------------- // ------$--GGA------- @@ -2025,7 +2059,7 @@ void loc_nmea_generate_pos(const UlpLocation &location, lengthRemaining -= length; } - length = loc_nmea_put_checksum(sentence_GGA, sizeof(sentence_GGA)); + length = loc_nmea_put_checksum(sentence_GGA, sizeof(sentence_GGA), false); // ------$--DTM------- nmeaArraystr.push_back(sentence_DTM); @@ -2048,27 +2082,27 @@ void loc_nmea_generate_pos(const UlpLocation &location, //Send blank NMEA reports for non-final fixes else { strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,,", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); strlcpy(sentence, "$GPDTM,,,,,,,,", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N,V", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); strlcpy(sentence, "$GPGNS,,,,,,N,,,,,,,V", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence)); - length = loc_nmea_put_checksum(sentence, sizeof(sentence)); + length = loc_nmea_put_checksum(sentence, sizeof(sentence), false); nmeaArraystr.push_back(sentence); } diff --git a/utils/loc_nmea.h b/utils/loc_nmea.h index ef99e0f..2d98f42 100644 --- a/utils/loc_nmea.h +++ b/utils/loc_nmea.h @@ -81,7 +81,8 @@ void loc_nmea_generate_pos(const UlpLocation &location, unsigned char generate_nmea, bool custom_gga_fix_quality, std::vector<std::string> &nmeaArraystr, - int& indexOfGGA); + int& indexOfGGA, + bool isTagBlockGroupingEnabled); #define DEBUG_NMEA_MINSIZE 6 #define DEBUG_NMEA_MAXSIZE 4096 |