Issue 295 - Yet another incompatible change for the libgps API.

This commit is contained in:
wb2osz 2020-10-27 18:04:07 -04:00
parent 512e8f88a9
commit 7cd027fcda
1 changed files with 24 additions and 13 deletions

View File

@ -59,7 +59,7 @@
// An incompatibility was introduced with version 7 // An incompatibility was introduced with version 7
// and again with 9 and again with 10. // and again with 9 and again with 10.
#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 10 #if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 11
#error libgps API version might be incompatible. #error libgps API version might be incompatible.
#endif #endif
@ -348,6 +348,15 @@ static void * read_gpsd_thread (void *arg)
#define stupid_status status #define stupid_status status
#endif #endif
if (s_debug >= 3) {
text_color_set(DW_COLOR_DEBUG);
dw_printf ("gpsdata: status=%d, mode=%d, lat=%.6f, lon=%.6f, track=%.1f, speed=%.1f, alt=%.0f\n",
gpsdata.stupid_status, gpsdata.fix.mode,
gpsdata.fix.latitude, gpsdata.fix.longitude,
gpsdata.fix.track, gpsdata.fix.speed, gpsdata.fix.stupid_altitude);
}
// Inform user about change in fix status. // Inform user about change in fix status.
switch (gpsdata.fix.mode) { switch (gpsdata.fix.mode) {
@ -378,23 +387,25 @@ static void * read_gpsd_thread (void *arg)
break; break;
} }
if (gpsdata.stupid_status >= STATUS_FIX && gpsdata.fix.mode >= MODE_2D) {
info.dlat = isnan(gpsdata.fix.latitude) ? G_UNKNOWN : gpsdata.fix.latitude; // Oct. 2020 - 'status' is always zero for latest version of libgps so we can't use that anymore.
info.dlon = isnan(gpsdata.fix.longitude) ? G_UNKNOWN : gpsdata.fix.longitude;
info.track = isnan(gpsdata.fix.track) ? G_UNKNOWN : gpsdata.fix.track;
info.speed_knots = isnan(gpsdata.fix.speed) ? G_UNKNOWN : (MPS_TO_KNOTS * gpsdata.fix.speed);
if (/*gpsdata.stupid_status >= STATUS_FIX &&*/ gpsdata.fix.mode >= MODE_2D) {
info.dlat = isfinite(gpsdata.fix.latitude) ? gpsdata.fix.latitude : G_UNKNOWN;
info.dlon = isfinite(gpsdata.fix.longitude) ? gpsdata.fix.longitude : G_UNKNOWN;
// When stationary, track is NaN which is not finite.
info.track = isfinite(gpsdata.fix.track) ? gpsdata.fix.track : G_UNKNOWN;
info.speed_knots = isfinite(gpsdata.fix.speed) ? (MPS_TO_KNOTS * gpsdata.fix.speed) : G_UNKNOWN;
if (gpsdata.fix.mode >= MODE_3D) { if (gpsdata.fix.mode >= MODE_3D) {
info.altitude = isnan(gpsdata.fix.stupid_altitude) ? G_UNKNOWN : gpsdata.fix.stupid_altitude; info.altitude = isfinite(gpsdata.fix.stupid_altitude) ? gpsdata.fix.stupid_altitude : G_UNKNOWN;
} }
// Otherwise keep last known altitude when we downgrade from 3D to 2D fix.
// Caller knows altitude is outdated if info.fix == DWFIX_2D.
} }
else { // Otherwise keep the last known location which is better than totally lost.
// Keep the last known location. // Caller knows location is outdated if info.fix == DWFIX_NO_FIX.
// Using info.fix, the caller knows if the location is current (DWFIX_[23]D),
// last known (DWFIX_NONE), or never known (DWFIX_NOT_SEEN).
info.fix = DWFIX_NO_FIX;
}
info.timestamp = time(NULL); info.timestamp = time(NULL);
if (s_debug >= 2) { if (s_debug >= 2) {