diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-04-12 17:31:30 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-04-12 17:31:30 -0400 |
commit | 907b55b210310ca034730fb11869f4b131fcba08 (patch) | |
tree | bd2f9e0a7a314e6d9d365844c5fd6ccb805e3fb7 /driver_tsip.c | |
parent | 54a5cf8604cd1c5a5235b8c8ef40353759eb6496 (diff) | |
download | gpsd-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_tsip.c')
-rw-r--r-- | driver_tsip.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/driver_tsip.c b/driver_tsip.c index e5e31707..e8a49676 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -194,12 +194,8 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->context->leap_seconds = (int)round(f2); session->context->valid |= LEAP_SECOND_VALID; - -#ifdef NTPSHM_ENABLE - d1 = gpstime_to_unix((int)s1, f1) - f2; - if (session->context->enable_ntpshm) - (void)ntpshm_put(session,d1,0.075); -#endif + session->newdata.time = gpstime_to_unix((int)s1, f1) - f2; + mask |= TIME_IS; } gpsd_report(LOG_INF, "GPS Time %f %d %f\n",f1,s1,f2); break; @@ -743,10 +739,6 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->newdata.time = gpstime_to_unix((int)s1, (double)ul1) - (double)s2; -#ifdef NTPSHM_ENABLE - if (session->context->enable_ntpshm) - (void)ntpshm_put(session,session->newdata.time,0.075); -#endif mask |= TIME_IS; gpsd_report(LOG_DATA, "SP-TTS 0xab time=%.2f mask={TIME}\n", session->newdata.time); @@ -1088,6 +1080,14 @@ static void tsip_mode(struct gps_device_t *session, int mode) } #endif /* ALLOW_RECONFIGURE */ +#ifdef NTPSHM_ENABLE +static double tsip_ntp_offset(struct gps_device_t *session) +{ + /* FIXME: is a constant offset right here? */ + return 0.075; +} +#endif /* NTPSHM_ENABLE */ + /* this is everything we export */ const struct gps_type_t tsip_binary = { @@ -1109,6 +1109,9 @@ const struct gps_type_t tsip_binary = #ifdef ALLOW_CONTROLSEND .control_send = tsip_control_send,/* how to send commands */ #endif /* ALLOW_CONTROLSEND */ +#ifdef NTPSHM_ENABLE + .ntp_offset = tsip_ntp_offset, +#endif /* NTPSHM_ENABLE */ }; #endif /* TSIP_ENABLE */ |