summaryrefslogtreecommitdiff
path: root/driver_nmea.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-19 18:19:10 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-19 18:19:10 -0500
commitbead04eba70affd5dc6e22fd2da5d7bea8861fc0 (patch)
tree56961f8deb7d7480bc6bf4cd6c992567b7d62df9 /driver_nmea.c
parent0d1d9e9a01fb18f3206053cd8821c129b4b10684 (diff)
downloadgpsd-bead04eba70affd5dc6e22fd2da5d7bea8861fc0.tar.gz
Detect GPS week rollover in ZDA sentences. All regression tests pass.
Diffstat (limited to 'driver_nmea.c')
-rw-r--r--driver_nmea.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/driver_nmea.c b/driver_nmea.c
index 8d08303f..14345711 100644
--- a/driver_nmea.c
+++ b/driver_nmea.c
@@ -676,30 +676,28 @@ static gps_mask_t processGPZDA(int c UNUSED, char *field[],
gpsd_report(LOG_WARN, "malformed ZDA month: %s\n", field[3]);
} else if ( (1 > mday ) || (31 < mday ) ) {
gpsd_report(LOG_WARN, "malformed ZDA day: %s\n", field[2]);
- } else if (century > session->context->century) {
- /*
- * This mismatch is almost certainly not due to a GPS week
- * rollover, because that would throw the ZDA report backward
- * into the last rollover period instead of forward. Almost
- * certainly it means that a century mark has passed while
- * gpsd was running, and we should trust the new ZDA year.
- */
- gpsd_report(LOG_WARN, "century rollover detected.\n");
- session->context->century = century;
-#if 0
- } else if (century < session->context->century) {
- /*
- * This looks like a GPS week-counter rollover. Hidden
- * assumption in the above test is that a bogus (small positive
- * or negative) system clock value will always fail the
- * above guard and thus never trigger this error message.
- */
- gpsd_report(LOG_ERROR, "ZDA year %s less than clock year, "
- "probable GPS week rollover lossage\n", field[2]);
-#endif
} else {
- year -= 1900;
- session->driver.nmea.date.tm_year = year;
+ if (century > session->context->century) {
+ /*
+ * This mismatch is almost certainly not due to a GPS week
+ * rollover, because that would throw the ZDA report backward
+ * into the last rollover period instead of forward. Almost
+ * certainly it means that a century mark has passed while
+ * gpsd was running, and we should trust the new ZDA year.
+ */
+ gpsd_report(LOG_WARN, "century rollover detected.\n");
+ session->context->century = century;
+ } else if (century < session->context->century) {
+ /*
+ * This looks like a GPS week-counter rollover. Hidden
+ * assumption in the above test is that a bogus (small positive
+ * or negative) system clock value will always fail the
+ * above guard and thus never trigger this error message.
+ */
+ gpsd_report(LOG_WARN, "ZDA year %d less than clock year, "
+ "probable GPS week rollover lossage\n", year);
+ }
+ session->driver.nmea.date.tm_year = year- 1900;
session->driver.nmea.date.tm_mon = mon - 1;
session->driver.nmea.date.tm_mday = mday;
mask = TIME_IS;