From 0737b7e794d4dc48a2003d6dfd67ec85b5d6499e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 21 Jan 2011 02:55:25 -0500 Subject: Improve documentation comments. All regression tests pass. --- timebase.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'timebase.c') diff --git a/timebase.c b/timebase.c index 827d9a15..38a191e6 100644 --- a/timebase.c +++ b/timebase.c @@ -26,9 +26,9 @@ subframe broadcast. GPS date and time are subject to a rollover problem in the 10-bit week number counter, which will re-zero every 1024 weeks (roughly every 20 years). The last rollover (and the first since GPS went live in 1980) -was in 1999; the next would fall in 2019, but plans are afoot to -upgrade the satellite counters to 13 bits; this will delay the next -rollover until 2173. +was 0000 22 August 1999; the next would fall in 2019, but plans are +afoot to upgrade the satellite counters to 13 bits; this will delay +the next rollover until 2173. For accurate time reporting, therefore, a GPS requires a supplemental time references sufficient to identify the current rollover period, @@ -128,20 +128,6 @@ static int gpsd_check_utc(const int leap, const double unixtime) return 0; /* leap second inconsistent, probable rollover error */ } -/* - * The 'week' part of GPS dates are specified in weeks since 0000 on 06 - * January 1980, with a rollover at 1024. At time of writing the last - * rollover happened at 0000 22 August 1999. Time-of-week is in seconds. - * - * This code copes with both conventional GPS weeks and the "extended" - * 15-or-16-bit version with no wraparound that appears in Zodiac - * chips and is supposed to appear in the Geodetic Navigation - * Information (0x29) packet of SiRF chips. Some SiRF firmware versions - * (notably 231) actually ship the wrapped 10-bit week, despite what - * the protocol reference claims. - * - * Note: This time will need to be corrected for leap seconds. - */ #define SECS_PER_WEEK (60*60*24*7) /* seconds per week */ #define GPS_ROLLOVER (1024*SECS_PER_WEEK) /* rollover period */ @@ -217,6 +203,14 @@ double gpsd_resolve_time(/*@in@*/struct gps_device_t *session, session->context->gps_tow = tow; session->context->valid |= GPS_TIME_VALID; + /* + * This code copes with both conventional GPS weeks and the "extended" + * 15-or-16-bit version with no wraparound that appears in Zodiac + * chips and is supposed to appear in the Geodetic Navigation + * Information (0x29) packet of SiRF chips. Some SiRF firmware versions + * (notably 231) actually ship the wrapped 10-bit week, despite what + * the protocol reference claims. + */ if (week >= 1024) t = GPS_EPOCH + (week * SECS_PER_WEEK) + tow; else { -- cgit v1.2.1