Do not send debug NMEA to ulp

Checking in GnssAdapter::reportNmeaEvent to see if the
incoming nmea is debug, in which case we do not route
that to ULP. Debug NMEA is only for SystemStatus
consumption.

Change-Id: Ifb60b9a643ad6aeb732fcaf5a68f868cb55cd88a
CRs-Fixed: 2027134
This commit is contained in:
Kevin Tang 2017-03-24 17:39:20 -07:00
parent 905d69ef10
commit 8b98a565a5
3 changed files with 17 additions and 10 deletions

View file

@ -34,6 +34,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <pthread.h> #include <pthread.h>
#include <platform_lib_log_util.h> #include <platform_lib_log_util.h>
#include <loc_nmea.h>
#include <SystemStatus.h> #include <SystemStatus.h>
namespace loc_core namespace loc_core
@ -48,14 +49,10 @@ protected:
std::vector<std::string> mField; std::vector<std::string> mField;
timespec setUtcTime(std::string sutctime); 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) SystemStatusNmeaBase(const char *str_in, uint32_t len_in)
{ {
// check size and talker // 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; return;
} }
@ -83,6 +80,10 @@ public:
} }
virtual ~SystemStatusNmeaBase() { } 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) 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 SystemStatus::setNmeaString(const char *data, uint32_t len)
{ {
bool ret = false; bool ret = false;
if (NULL == data if (!loc_nmea_is_debug(data, len)) {
|| (len < SystemStatusNmeaBase::NMEA_MINSIZE)
|| (len > SystemStatusNmeaBase::NMEA_MAXSIZE)) {
return false; return false;
} }

View file

@ -39,6 +39,7 @@
#include <GnssAdapter.h> #include <GnssAdapter.h>
#include <string> #include <string>
#include <loc_log.h> #include <loc_log.h>
#include <loc_nmea.h>
#include <Agps.h> #include <Agps.h>
#include <SystemStatus.h> #include <SystemStatus.h>
@ -1987,9 +1988,8 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
void void
GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) 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 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)) { if (mUlpProxy->reportNmea(nmea, length)) {
return; return;
} }

View file

@ -43,4 +43,12 @@ void loc_nmea_generate_pos(const UlpLocation &location,
unsigned char generate_nmea, unsigned char generate_nmea,
std::vector<std::string> &nmeaArraystr); std::vector<std::string> &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 #endif // LOC_ENG_NMEA_H