fix a positional timestamp reading bug (#886)

* fix a positional timestamp reading bug

* lying about fixType is no longer required
1.2-legacy
a-f-G-U-C 2021-10-23 23:31:44 +00:00 zatwierdzone przez GitHub
rodzic a914ee133c
commit 3893810b76
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -170,28 +170,30 @@ bool UBloxGPS::lookForLocation()
{
bool foundLocation = false;
// catch fixType changes here, instead of whileActive()
if (ublox.moduleQueried.fixType) {
fixType = ublox.getFixType();
}
// check if GPS has an acceptable lock
if (! hasLock()) {
return false;
}
// check if a complete GPS solution set is available for reading
// (some of these, like lat/lon are redundant and can be removed)
if ( ! (ublox.moduleQueried.latitude &&
if ( ! (ublox.moduleQueried.fixType &&
ublox.moduleQueried.latitude &&
ublox.moduleQueried.longitude &&
ublox.moduleQueried.altitude &&
ublox.moduleQueried.pDOP &&
ublox.moduleQueried.gpsiTOW))
ublox.moduleQueried.gpsDay))
{
// Not ready? No problem! We'll try again later.
return false;
}
fixType = ublox.getFixType();
#ifdef UBLOX_EXTRAVERBOSE
DEBUG_MSG("FixType=%d\n", fixType);
#endif
// check if GPS has an acceptable lock
if (! hasLock()) {
ublox.flushPVT(); // reset ALL freshness flags
return false;
}
// read lat/lon/alt/dop data into temporary variables to avoid
// overwriting global variables with potentially invalid data
int32_t tmp_dop = ublox.getPDOP(0); // PDOP (an accuracy metric) is reported in 10^2 units so we have to scale down when we use it
@ -241,9 +243,13 @@ bool UBloxGPS::lookForLocation()
pos_timestamp = tmp_ts;
dop = tmp_dop;
} else {
DEBUG_MSG("Invalid location discarded\n");
// INVALID solution - should never happen
DEBUG_MSG("Invalid location lat/lon/hae/dop %d/%d/%d/%d - discarded\n",
tmp_lat, tmp_lon, tmp_alt_hae, tmp_dop);
}
ublox.flushPVT(); // reset ALL freshness flags at the end
return foundLocation;
}