From 06a6a992c2f6efb1a5cee698ac78ff922fac1a31 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 2 Aug 2023 10:08:59 -0500 Subject: [PATCH] GPS Fixes for nrf52 (#2675) Expands board serial buffer from 64 (!) to 1024 Adds some debugging messages when problems are detected. --- arch/nrf52/nrf52.ini | 4 +++- src/gps/NMEAGPS.cpp | 15 +++++++++++++-- src/gps/NMEAGPS.h | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 858dcdc9c..7f61a04c8 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -5,7 +5,9 @@ extends = arduino_base build_type = debug ; I'm debugging with ICE a lot now build_flags = - ${arduino_base.build_flags} -Wno-unused-variable + ${arduino_base.build_flags} + -DSERIAL_BUFFER_SIZE=1024 + -Wno-unused-variable -Isrc/platform/nrf52 build_src_filter = diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp index 0632164e9..b2cbcfa81 100644 --- a/src/gps/NMEAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -107,6 +107,14 @@ bool NMEAGPS::lookForLocation() // At a minimum, use the fixQuality indicator in GPGGA (FIXME?) fixQual = reader.fixQuality(); +#ifndef TINYGPS_OPTION_NO_STATISTICS + if (reader.failedChecksum() > lastChecksumFailCount) { + LOG_WARN("Warning, %u new GPS checksum failures, for a total of %u.\n", reader.failedChecksum() - lastChecksumFailCount, + reader.failedChecksum()); + lastChecksumFailCount = reader.failedChecksum(); + } +#endif + #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS fixType = atoi(gsafixtype.value()); // will set to zero if no data // LOG_DEBUG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType); @@ -174,8 +182,10 @@ bool NMEAGPS::lookForLocation() #endif // Discard incomplete or erroneous readings - if (reader.hdop.value() == 0) + if (reader.hdop.value() == 0) { + LOG_WARN("BOGUS hdop.value() REJECTED: %d\n", reader.hdop.value()); return false; + } p.latitude_i = toDegInt(loc.lat); p.longitude_i = toDegInt(loc.lng); @@ -243,7 +253,8 @@ bool NMEAGPS::hasFlow() bool NMEAGPS::whileIdle() { bool isValid = false; - + // if (_serial_gps->available() > 0) + // LOG_DEBUG("GPS Bytes Waiting: %u\n", _serial_gps->available()); // First consume any chars that have piled up at the receiver while (_serial_gps->available() > 0) { int c = _serial_gps->read(); diff --git a/src/gps/NMEAGPS.h b/src/gps/NMEAGPS.h index 82e691717..85521077a 100644 --- a/src/gps/NMEAGPS.h +++ b/src/gps/NMEAGPS.h @@ -13,6 +13,7 @@ class NMEAGPS : public GPS { TinyGPSPlus reader; uint8_t fixQual = 0; // fix quality from GPGGA + uint32_t lastChecksumFailCount = 0; #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS // (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field @@ -53,4 +54,4 @@ class NMEAGPS : public GPS virtual bool hasLock() override; virtual bool hasFlow() override; -}; +}; \ No newline at end of file