From ef1d52ca04d42c7a993e6ab92196a0c6c83c2c0a Mon Sep 17 00:00:00 2001 From: a-f-G-U-C <65810997+a-f-G-U-C@users.noreply.github.com> Date: Sun, 24 Oct 2021 13:02:31 +0000 Subject: [PATCH] update log message, sanity check --- src/GPSStatus.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/GPSStatus.h b/src/GPSStatus.h index 6023a6db8..7399d7e20 100644 --- a/src/GPSStatus.h +++ b/src/GPSStatus.h @@ -99,6 +99,10 @@ class GPSStatus : public Status bool matches(const GPSStatus *newStatus) const { +#if GPS_EXTRAVERBOSE + DEBUG_MSG("GPSStatus.match() new pos@%x to old pos@%x\n", + newStatus->p.pos_timestamp, p.pos_timestamp); +#endif return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected || newStatus->p.latitude_i != p.latitude_i || @@ -109,25 +113,33 @@ class GPSStatus : public Status newStatus->p.ground_track != p.ground_track || newStatus->p.sats_in_view != p.sats_in_view); } + int updateStatus(const GPSStatus *newStatus) { // Only update the status if values have actually changed - bool isDirty; - { - isDirty = matches(newStatus); - initialized = true; - hasLock = newStatus->hasLock; - isConnected = newStatus->isConnected; + bool isDirty = matches(newStatus); - p = newStatus->p; + if (isDirty && p.pos_timestamp && + (newStatus->p.pos_timestamp == p.pos_timestamp)) { + // We can NEVER be in two locations at the same time! (also PR #886) + DEBUG_MSG("BUG!! positional timestamp unchanged from prev solution\n"); } + + initialized = true; + hasLock = newStatus->hasLock; + isConnected = newStatus->isConnected; + + p = newStatus->p; + if (isDirty) { - if (hasLock) - DEBUG_MSG("New GPS pos lat=%f, lon=%f, alt=%d, pdop=%.2f, heading=%.2f, sats=%d\n", + if (hasLock) { + // In debug logs, identify position by @timestamp:stage (stage 3 = notify) + DEBUG_MSG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, sats=%d\n", + p.pos_timestamp, p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5, p.sats_in_view); - else + } else DEBUG_MSG("No GPS lock\n"); onNewStatus.notifyObservers(this); }