|
59 | 59 | // An incompatibility was introduced with version 7
|
60 | 60 | // and again with 9 and again with 10.
|
61 | 61 |
|
62 |
| -#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 10 |
| 62 | +#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 11 |
63 | 63 | #error libgps API version might be incompatible.
|
64 | 64 | #endif
|
65 | 65 |
|
@@ -348,6 +348,15 @@ static void * read_gpsd_thread (void *arg)
|
348 | 348 | #define stupid_status status
|
349 | 349 | #endif
|
350 | 350 |
|
| 351 | + |
| 352 | + if (s_debug >= 3) { |
| 353 | + text_color_set(DW_COLOR_DEBUG); |
| 354 | + dw_printf ("gpsdata: status=%d, mode=%d, lat=%.6f, lon=%.6f, track=%.1f, speed=%.1f, alt=%.0f\n", |
| 355 | + gpsdata.stupid_status, gpsdata.fix.mode, |
| 356 | + gpsdata.fix.latitude, gpsdata.fix.longitude, |
| 357 | + gpsdata.fix.track, gpsdata.fix.speed, gpsdata.fix.stupid_altitude); |
| 358 | + } |
| 359 | + |
351 | 360 | // Inform user about change in fix status.
|
352 | 361 |
|
353 | 362 | switch (gpsdata.fix.mode) {
|
@@ -378,23 +387,25 @@ static void * read_gpsd_thread (void *arg)
|
378 | 387 | break;
|
379 | 388 | }
|
380 | 389 |
|
381 |
| - if (gpsdata.stupid_status >= STATUS_FIX && gpsdata.fix.mode >= MODE_2D) { |
382 | 390 |
|
383 |
| - info.dlat = isnan(gpsdata.fix.latitude) ? G_UNKNOWN : gpsdata.fix.latitude; |
384 |
| - info.dlon = isnan(gpsdata.fix.longitude) ? G_UNKNOWN : gpsdata.fix.longitude; |
385 |
| - info.track = isnan(gpsdata.fix.track) ? G_UNKNOWN : gpsdata.fix.track; |
386 |
| - info.speed_knots = isnan(gpsdata.fix.speed) ? G_UNKNOWN : (MPS_TO_KNOTS * gpsdata.fix.speed); |
| 391 | +// Oct. 2020 - 'status' is always zero for latest version of libgps so we can't use that anymore. |
387 | 392 |
|
| 393 | + if (/*gpsdata.stupid_status >= STATUS_FIX &&*/ gpsdata.fix.mode >= MODE_2D) { |
| 394 | + |
| 395 | + info.dlat = isfinite(gpsdata.fix.latitude) ? gpsdata.fix.latitude : G_UNKNOWN; |
| 396 | + info.dlon = isfinite(gpsdata.fix.longitude) ? gpsdata.fix.longitude : G_UNKNOWN; |
| 397 | + // When stationary, track is NaN which is not finite. |
| 398 | + info.track = isfinite(gpsdata.fix.track) ? gpsdata.fix.track : G_UNKNOWN; |
| 399 | + info.speed_knots = isfinite(gpsdata.fix.speed) ? (MPS_TO_KNOTS * gpsdata.fix.speed) : G_UNKNOWN; |
388 | 400 | if (gpsdata.fix.mode >= MODE_3D) {
|
389 |
| - info.altitude = isnan(gpsdata.fix.stupid_altitude) ? G_UNKNOWN : gpsdata.fix.stupid_altitude; |
| 401 | + info.altitude = isfinite(gpsdata.fix.stupid_altitude) ? gpsdata.fix.stupid_altitude : G_UNKNOWN; |
390 | 402 | }
|
| 403 | + // Otherwise keep last known altitude when we downgrade from 3D to 2D fix. |
| 404 | + // Caller knows altitude is outdated if info.fix == DWFIX_2D. |
391 | 405 | }
|
392 |
| - else { |
393 |
| - // Keep the last known location. |
394 |
| - // Using info.fix, the caller knows if the location is current (DWFIX_[23]D), |
395 |
| - // last known (DWFIX_NONE), or never known (DWFIX_NOT_SEEN). |
396 |
| - info.fix = DWFIX_NO_FIX; |
397 |
| - } |
| 406 | + // Otherwise keep the last known location which is better than totally lost. |
| 407 | + // Caller knows location is outdated if info.fix == DWFIX_NO_FIX. |
| 408 | + |
398 | 409 |
|
399 | 410 | info.timestamp = time(NULL);
|
400 | 411 | if (s_debug >= 2) {
|
|
0 commit comments