summaryrefslogtreecommitdiff
path: root/timebase.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-01-21 02:55:25 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-01-21 02:55:25 -0500
commit0737b7e794d4dc48a2003d6dfd67ec85b5d6499e (patch)
tree9d1641b3dedbf7e4eb5b34d3e3561b05d6beb002 /timebase.c
parenta83fa99d978681bf9c43ea93a422c5ad409b5995 (diff)
downloadgpsd-0737b7e794d4dc48a2003d6dfd67ec85b5d6499e.tar.gz
Improve documentation comments. All regression tests pass.
Diffstat (limited to 'timebase.c')
-rw-r--r--timebase.c28
1 files changed, 11 insertions, 17 deletions
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 {