diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-10-29 07:57:14 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-29 07:57:14 -0400 |
commit | 28b6d4fbd4419e130e7da3a7f0b7a37e7b0a7abe (patch) | |
tree | 0b02b848e2cb154e46b746e5c11bd9f9165afea2 /ntpshm.c | |
parent | 3158efd89832be541fc187704756c7992e50b472 (diff) | |
download | gpsd-28b6d4fbd4419e130e7da3a7f0b7a37e7b0a7abe.tar.gz |
Another factoring step in ntpshm.c.
Diffstat (limited to 'ntpshm.c')
-rw-r--r-- | ntpshm.c | 43 |
1 files changed, 27 insertions, 16 deletions
@@ -365,7 +365,7 @@ int ntpshm_put(struct gps_device_t *session, double fixtime, double fudge) * ts is the time we saw the pulse */ static int ntpshm_pps(struct gps_device_t *session, struct timeval *actual_tv, - struct timespec *ts, double edge_offset) + struct timespec *ts) { volatile struct shmTime *shmTime = NULL, *shmTimeP = NULL; struct timeval tv; @@ -474,7 +474,7 @@ static void chrony_init(struct gps_device_t *session) /* offset is actual_tv - tv */ static void chrony_send(struct gps_device_t *session, struct timeval *actual_tv, - struct timespec *ts, double offset) + struct timespec *ts UNUSED, double offset) { struct sock_sample sample; @@ -495,6 +495,27 @@ static void chrony_wrap(struct gps_device_t *session) (void)close(session->chronyfd); } +static char *time_report(struct gps_device_t *session, + struct timeval *actual_tv, + struct timespec *ts, + long edge_offset) +/* ship the time of a PPS event to ntpd and/or chrony */ +{ + char *log1; + + if (session->ship_to_ntpd) { + log1 = "accepted"; + if ( 0 <= session->chronyfd ) { + log1 = "accepted chrony sock"; + chrony_send(session, actual_tv, ts, edge_offset); + } + (void)ntpshm_pps(session, actual_tv, ts); + } else { + log1 = "skipped ship_to_ntp=0"; + } + return log1; +} + /* pure thread-bashing begins here - someday, goes to seperate module */ #if defined(HAVE_SYS_TIMEPPS_H) @@ -1025,23 +1046,13 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) * GPS serial input then use that */ l_offset = (long)edge_offset; if (0 > l_offset || 1000000 < l_offset) { - /* timestamp out of range */ gpsd_report(session->context->debug, LOG_RAW, - "PPS ntpshm_pps: no current GPS seconds: %ld\n", + "PPS: no current GPS seconds: %ld\n", (long)l_offset); - session->ship_to_ntpd = 0; - } - - if (session->ship_to_ntpd) { - log1 = "accepted"; - if ( 0 <= session->chronyfd ) { - log1 = "accepted chrony sock"; - chrony_send(session, &actual_tv, &ts, edge_offset); - } - (void)ntpshm_pps(session, &actual_tv, &ts, edge_offset); - } else { - log1 = "skipped ship_to_ntp=0"; + log1 = "timestamp out of range"; } + else + log1 = time_report(session, &actual_tv, &ts, edge_offset); gpsd_report(session->context->debug, LOG_RAW, "PPS edge %.20s %lu.%06lu offset %.9f\n", log1, |