diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp index a7f282df..3310b8bb 100644 --- a/core/SystemStatus.cpp +++ b/core/SystemStatus.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include namespace loc_core @@ -48,14 +49,10 @@ protected: std::vector mField; timespec setUtcTime(std::string sutctime); -public: - static const uint32_t NMEA_MINSIZE = 6; - static const uint32_t NMEA_MAXSIZE = 256; - SystemStatusNmeaBase(const char *str_in, uint32_t len_in) { // check size and talker - if (len_in > NMEA_MAXSIZE || len_in < NMEA_MINSIZE || (str_in[0] != '$')) { + if (!loc_nmea_is_debug(str_in, len_in)) { return; } @@ -83,6 +80,10 @@ public: } virtual ~SystemStatusNmeaBase() { } + +public: + static const uint32_t NMEA_MINSIZE = DEBUG_NMEA_MINSIZE; + static const uint32_t NMEA_MAXSIZE = DEBUG_NMEA_MAXSIZE; }; timespec SystemStatusNmeaBase::setUtcTime(std::string sutctime) @@ -1316,9 +1317,7 @@ static uint32_t cnt_s1 = 0; bool SystemStatus::setNmeaString(const char *data, uint32_t len) { bool ret = false; - if (NULL == data - || (len < SystemStatusNmeaBase::NMEA_MINSIZE) - || (len > SystemStatusNmeaBase::NMEA_MAXSIZE)) { + if (!loc_nmea_is_debug(data, len)) { return false; } diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 1c195c2c..377a0781 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -1987,9 +1988,8 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify) void GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) { - // if this event is not called from ULP, then try to call into ULP and return if successfull - if (!fromUlp) { + if (!fromUlp && !loc_nmea_is_debug(nmea, length)) { if (mUlpProxy->reportNmea(nmea, length)) { return; } diff --git a/utils/loc_nmea.h b/utils/loc_nmea.h index 92f997ea..d182e419 100644 --- a/utils/loc_nmea.h +++ b/utils/loc_nmea.h @@ -43,4 +43,12 @@ void loc_nmea_generate_pos(const UlpLocation &location, unsigned char generate_nmea, std::vector &nmeaArraystr); +#define DEBUG_NMEA_MINSIZE 6 +#define DEBUG_NMEA_MAXSIZE 256 +inline bool loc_nmea_is_debug(const char* nmea, int length) { + return ((nullptr != nmea) && + (length >= DEBUG_NMEA_MINSIZE) && (length <= DEBUG_NMEA_MAXSIZE) && + (nmea[0] == '$') && (nmea[1] == 'P') && (nmea[2] == 'Q') && (nmea[3] == 'W')); +} + #endif // LOC_ENG_NMEA_H