summaryrefslogtreecommitdiff
path: root/driver_zodiac.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-04-12 17:31:30 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-04-12 17:31:30 -0400
commit907b55b210310ca034730fb11869f4b131fcba08 (patch)
treebd2f9e0a7a314e6d9d365844c5fd6ccb805e3fb7 /driver_zodiac.c
parent54a5cf8604cd1c5a5235b8c8ef40353759eb6496 (diff)
downloadgpsd-907b55b210310ca034730fb11869f4b131fcba08.tar.gz
Refactor serial ntpshm_put() calls.
These calls move out of scattered places in the drivers into one spot in libgpsd_core.c where they can be guarded with consistent validity checks. Time offset is now computed by a new driver method, ntp_offset(), which has access through the session structure to the baud rate, the tag of the sentence last received, etc. If the ntp_offset() method returns NAN, no notification is shipped. The logic of these methods replicates the sentence and baud-rate specific computations that were embedded in individual sentence methods before. All regression tests pass.
Diffstat (limited to 'driver_zodiac.c')
-rw-r--r--driver_zodiac.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/driver_zodiac.c b/driver_zodiac.c
index 1b41bd5f..ba7447e3 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -161,14 +161,6 @@ static gps_mask_t handle1000(struct gps_device_t *session)
session->newdata.time =
(double)mkgmtime(&unpacked_date) + subseconds;
/*@ +compdef */
-#ifdef NTPSHM_ENABLE
- /* Removing/changing the magic number below is likely to disturb
- * the handling of the 1pps signal from the gps device. The regression
- * tests and simple gps applications do not detect this. A live test
- * with the 1pps signal active is required. */
- if (session->context->enable_ntpshm && session->newdata.mode > MODE_NO_FIX)
- (void)ntpshm_put(session, session->newdata.time, 1.1);
-#endif
/*@ -type @*/
session->newdata.latitude = ((long)getzlong(27)) * RAD_2_DEG * 1e-8;
session->newdata.longitude = ((long)getzlong(29)) * RAD_2_DEG * 1e-8;
@@ -516,6 +508,17 @@ static bool zodiac_speed_switch(struct gps_device_t *session,
}
#endif /* ALLOW_RECONFIGURE */
+#ifdef NTPSHM_ENABLE
+static double zodiac_ntp_offset(struct gps_device_t *session)
+{
+ /* Removing/changing the magic number below is likely to disturb
+ * the handling of the 1pps signal from the gps device. The regression
+ * tests and simple gps applications do not detect this. A live test
+ * with the 1pps signal active is required. */
+ return 1.1;
+}
+#endif /* NTPSHM_ENABLE */
+
/* this is everything we export */
const struct gps_type_t zodiac_binary =
{
@@ -537,6 +540,9 @@ const struct gps_type_t zodiac_binary =
#ifdef ALLOW_CONTROLSEND
.control_send = zodiac_control_send, /* for gpsctl and friends */
#endif /* ALLOW_CONTROLSEND */
+#ifdef NTPSHM_ENABLE
+ .ntp_offset = zodiac_ntp_offset, /* compute NTO fudge factor */
+#endif /* NTPSHM_ENABLE */
};
#endif /* ZODIAC_ENABLE */