diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-03-07 05:50:01 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-03-07 05:50:01 -0500 |
commit | 61c16bebe1a56cb1c211733b92474bf866eba87d (patch) | |
tree | 8b078214f79fae9b8f9bdf608a6f69eebf334801 | |
parent | e92b21041e00778c72362620ad9d62ffa94613db (diff) | |
download | gpsd-61c16bebe1a56cb1c211733b92474bf866eba87d.tar.gz |
ntplib extraction requires libgpsd object format bump to 23.
The new struct ppsthread_t isolates the interface to the PPS monitor loop.
It will need more members before we're done, including some reporting
hooks.
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | gpsd.c | 2 | ||||
-rw-r--r-- | gpsd.h-tail | 3 | ||||
-rw-r--r-- | libgpsd_core.c | 14 | ||||
-rw-r--r-- | ppsthread.c | 21 | ||||
-rw-r--r-- | ppsthread.h | 20 |
6 files changed, 26 insertions, 36 deletions
@@ -30,7 +30,7 @@ gpsd_version = "3.14~dev" libgps_version_current = 22 libgps_version_revision = 0 libgps_version_age = 0 -libgpsd_version_current = 22 +libgpsd_version_current = 23 libgpsd_version_revision = 0 libgpsd_version_age = 0 @@ -1519,7 +1519,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) //gpsd_report(&context.errout, LOG_PROG, "NTP: No time this packet\n"); } else if (isnan(device->newdata.time)) { //gpsd_report(&context.errout, LOG_PROG, "NTP: bad new time\n"); - } else if (device->newdata.time == device->last_fixtime.real) { + } else if (device->newdata.time == device->pps_thread.fixin_real) { //gpsd_report(&context.errout, LOG_PROG, "NTP: Not a new time\n"); } else if (!device->ship_to_ntpd) { //gpsd_report(&context.errout, LOG_PROG, "NTP: No precision time report\n"); diff --git a/gpsd.h-tail b/gpsd.h-tail index 318ebf37..911cd5d1 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -500,7 +500,6 @@ struct gps_device_t { volatile /*@null@*/ struct shmTime *shm_pps; # endif /* PPS_ENABLE */ #endif /* NTP_ENABLE */ - volatile struct pps_fixtime_t last_fixtime; /* so updates happen once */ #ifdef PPS_ENABLE #if defined(HAVE_SYS_TIMEPPS_H) pps_handle_t kernelpps_handle; @@ -509,7 +508,7 @@ struct gps_device_t { /*@null@*/ char *(*thread_report_hook)(struct gps_device_t *, struct timedelta_t *); /*@null@*/ void (*thread_wrap_hook)(struct gps_device_t *); - struct pps_state_t pps_state; + volatile struct pps_thread_t pps_thread; #endif /* PPS_ENABLE */ double mag_var; /* magnetic variation in degrees */ bool back_to_nmea; /* back to NMEA on revert? */ diff --git a/libgpsd_core.c b/libgpsd_core.c index d9db154a..26560cb6 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -303,11 +303,8 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, /* initialize GPS polling */ { /* clear some times */ - session->last_fixtime.real = 0.0; - /*@i2@*/session->last_fixtime.clock.tv_sec = 0; - /*@i2@*/session->last_fixtime.clock.tv_nsec = 0; #ifdef PPS_ENABLE - memset((void *)&session->pps_state, 0, sizeof(session->pps_state)); + memset((void *)&session->pps_thread, 0, sizeof(session->pps_thread)); #endif /* PPS_ENABLE */ /*@ -mayaliasunique @*/ @@ -400,12 +397,9 @@ void gpsd_clear(struct gps_device_t *session) /* clear the private data union */ memset( (void *)&session->driver, '\0', sizeof(session->driver)); - /* clear some times */ - session->last_fixtime.real = 0.0; - /*@i2@*/session->last_fixtime.clock.tv_sec = 0; - /*@i2@*/session->last_fixtime.clock.tv_nsec = 0; #ifdef PPS_ENABLE - memset((void *)&session->pps_state, 0, sizeof(session->pps_state)); + /* clear some times */ + memset((void *)&session->pps_thread, 0, sizeof(session->pps_thread)); #endif /* PPS_ENABLE */ session->opentime = timestamp(); @@ -1647,7 +1641,7 @@ void ntp_latch(struct gps_device_t *device, struct timedelta_t /*@out@*/*td) #ifdef PPS_ENABLE /* thread-safe update */ /*@-compdef@*/ - status = pps_thread_stash_fixtime(&device->last_fixtime, + status = pps_thread_stash_fixtime(&device->pps_thread, device->newdata.time, td->clock); /*@+compdef@*/ if (status == PPS_LOCK_ERR) { diff --git a/ppsthread.c b/ppsthread.c index 52512bc8..ff25b81c 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -350,8 +350,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) "PPS: pthread_mutex_lock() : %s\n", errbuf); } /*@ +unrecog @*/ - last_fixtime_real = session->last_fixtime.real; - last_fixtime_clock = session->last_fixtime.clock; + last_fixtime_real = session->pps_thread.fixin_real; + last_fixtime_clock = session->pps_thread.fixin_clock; /*@ -unrecog (splint has no pthread declarations as yet) @*/ pthread_err = pthread_mutex_unlock(&ppslast_mutex); if ( 0 != pthread_err ) { @@ -704,9 +704,9 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) } /*@ +unrecog @*/ /*@-type@*/ /* splint is confused about struct timespec */ - session->pps_state.ppslast = ppstimes; + session->pps_thread.ppsout_last = ppstimes; /*@+type@*/ - session->pps_state.ppscount++; + session->pps_thread.ppsout_count++; /*@ -unrecog (splint has no pthread declarations as yet) @*/ pthread_err = pthread_mutex_unlock(&ppslast_mutex); if ( 0 != pthread_err ) { @@ -787,7 +787,7 @@ void pps_thread_deactivate(struct gps_device_t *session) /*@+nullstate +mustfreeonly@*/ } -int pps_thread_stash_fixtime(volatile struct pps_fixtime_t *last_fixtime, +int pps_thread_stash_fixtime(volatile struct pps_thread_t *pps_thread, timestamp_t realtime, struct timespec clocktime) /* thread-safe update of last fix time - only way we pass data in */ { @@ -799,8 +799,8 @@ int pps_thread_stash_fixtime(volatile struct pps_fixtime_t *last_fixtime, ret = PPS_LOCK_ERR; else { /*@ +unrecog @*/ - last_fixtime->real = realtime; - last_fixtime->clock = clocktime; + pps_thread->fixin_real = realtime; + pps_thread->fixin_clock = clocktime; } /*@ -unrecog (splint has no pthread declarations as yet) @*/ pthread_err = pthread_mutex_unlock(&ppslast_mutex); @@ -811,7 +811,8 @@ int pps_thread_stash_fixtime(volatile struct pps_fixtime_t *last_fixtime, return ret; } -int pps_thread_lastpps(struct pps_state_t *pps_state, struct timedelta_t *td) +int pps_thread_lastpps(volatile struct pps_thread_t *pps_thread, + struct timedelta_t *td) /* return the delta at the time of the last PPS - only way we pass data out */ { volatile int ret; @@ -824,8 +825,8 @@ int pps_thread_lastpps(struct pps_state_t *pps_state, struct timedelta_t *td) ret = PPS_LOCK_ERR; else { /*@ +unrecog @*/ - *td = pps_state->ppslast; - ret = pps_state->ppscount; + *td = pps_thread->ppsout_last; + ret = pps_thread->ppsout_count; } /*@ -unrecog (splint has no pthread declarations as yet) @*/ pthread_err = pthread_mutex_unlock(&ppslast_mutex); diff --git a/ppsthread.h b/ppsthread.h index ae7bd886..719239aa 100644 --- a/ppsthread.h +++ b/ppsthread.h @@ -22,25 +22,21 @@ struct timedelta_t { #define HAVE_TIMEDELTA #endif /* HAVE_TIMEDELTA */ -struct pps_state_t { - volatile struct timedelta_t ppslast; - volatile int ppscount; -}; - -struct pps_fixtime_t { - timestamp_t real; - /* clock must be a timespec as it is in nSec and - * a timestamp_t will lose precision */ - struct timespec clock; /* system clock time when last fix received */ +struct pps_thread_t { + timestamp_t fixin_real; + struct timespec fixin_clock; /* system clock time when last fix received */ + struct timedelta_t ppsout_last; + int ppsout_count; }; #define PPS_THREAD_OK 0 #define PPS_LOCK_ERR -1 #define PPS_UNLOCK_ERR -2 -extern int pps_thread_stash_fixtime(volatile struct pps_fixtime_t *, +extern int pps_thread_stash_fixtime(volatile struct pps_thread_t *, timestamp_t, struct timespec); -extern int pps_thread_lastpps(struct pps_state_t *, struct timedelta_t *); +extern int pps_thread_lastpps(volatile struct pps_thread_t *, + struct timedelta_t *); #endif /* PPSTHREAD_H */ |