diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-27 08:23:40 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-27 08:23:40 -0500 |
commit | 19e122503210f00e2b30d69161a12333ac1eed9c (patch) | |
tree | b203f217b8780d3f5e0726bdf87b171fca0b728c /timebase.c | |
parent | 75af80361c87ce0f76c2ca0e2863b2db245f9a9d (diff) | |
download | gpsd-19e122503210f00e2b30d69161a12333ac1eed9c.tar.gz |
Refactor NMEA0183 century handling.
No logic changes. All regression tests pass.
The real point here is to get all the code for time-related edge cases
into timebase.c so it can be reviewed as a unit.
Diffstat (limited to 'timebase.c')
-rw-r--r-- | timebase.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -204,6 +204,31 @@ timestamp_t gpsd_utc_resolve(/*@in@*/struct gps_device_t *session) return t; } + +void gpsd_century_update(/*@in@*/struct gps_device_t *session, int century) +{ + session->context->valid |= CENTURY_VALID; + 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(session->context->debug, LOG_WARN, + "century rollover detected.\n"); + session->context->century = century; + } else if (session->context->start_time >= GPS_EPOCH && century < session->context->century) { + /* + * This looks like a GPS week-counter rollover. + */ + gpsd_report(session->context->debug, LOG_WARN, + "ZDA year less than clock year, " + "probable GPS week rollover lossage\n"); + session->context->valid &=~ CENTURY_VALID; + } +} #endif /* NMEA_ENABLE */ timestamp_t gpsd_gpstime_resolve(/*@in@*/struct gps_device_t *session, |