summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-08 09:35:03 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-03-08 09:35:03 -0400
commitc82fe00247bd9fcbf5a70901c3b022e8ddd5ab0f (patch)
treef6876e6cc50dd166e94c30851804bb7911c0e613
parent2144fc0fde0b5ba35bc252beaef753c2e07e9fd8 (diff)
downloadgpsd-c82fe00247bd9fcbf5a70901c3b022e8ddd5ab0f.tar.gz
Eliminate timestamp-T use from PPS thread code.
PPS observed live on GR-601W. All regression yests pass.
-rw-r--r--gpsd.c2
-rw-r--r--gpsmon.c2
-rw-r--r--libgpsd_core.c3
-rw-r--r--ppsthread.c25
-rw-r--r--ppsthread.h6
5 files changed, 19 insertions, 19 deletions
diff --git a/gpsd.c b/gpsd.c
index 9149fa97..9c19bfa1 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1527,7 +1527,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
} else if (isnan(device->newdata.time)) {
//gpsd_log(&context.errout, LOG_PROG, "NTP: bad new time\n");
#ifdef PPS_ENABLE
- } else if (device->newdata.time == device->pps_thread.fixin_real) {
+ } else if (device->newdata.time <= device->pps_thread.fixin_real.tv_sec) {
//gpsd_log(&context.errout, LOG_PROG, "NTP: Not a new time\n");
#endif /* PPS_ENABLE */
} else if (!device->ship_to_ntpd) {
diff --git a/gpsmon.c b/gpsmon.c
index 4b9484f8..b39eee94 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -848,7 +848,7 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
if ( 0 != isnan(device->newdata.time)) {
// "NTP: bad new time
#ifdef PPS_ENABLE
- } else if (device->newdata.time == device->pps_thread.fixin_real) {
+ } else if (device->newdata.time <= device->pps_thread.fixin_real.tv_sec) {
// "NTP: Not a new time
#endif /* PPS_ENABLE */
} else
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 0dbaf6b7..e8ed6852 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -1688,8 +1688,7 @@ void ntp_latch(struct gps_device_t *device, struct timedelta_t /*@out@*/*td)
#ifdef PPS_ENABLE
/* thread-safe update */
/*@-compdef@*/
- pps_thread_stash_fixtime(&device->pps_thread,
- device->newdata.time, td->clock);
+ pps_thread_stash_fixtime(&device->pps_thread, td->real, td->clock);
/*@+compdef@*/
#endif /* PPS_ENABLE */
}
diff --git a/ppsthread.c b/ppsthread.c
index ac39c67a..ccc0f2bf 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -254,15 +254,15 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
{
char ts_str1[TIMESPEC_LEN], ts_str2[TIMESPEC_LEN];
volatile struct pps_thread_t *thread_context = (struct pps_thread_t *)arg;
- double last_fixtime_real = 0;
/* the system clock time, to the nSec, when the last fix received */
/* using a double would cause loss of precision */
struct timespec last_fixtime_clock = {0, 0};
+ struct timespec last_fixtime_real = {0, 0};
struct timespec clock_ts = {0, 0};
time_t last_second_used = 0;
#if defined(TIOCMIWAIT)
int cycle, duration;
- /* state is the last state of the tty control ssignals */
+ /* state is the last state of the tty control signals */
int state = 0, unchanged = 0;
/* state_last is previous state */
int state_last = 0;
@@ -373,13 +373,14 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
thread_context->devicename);
/*
- * If there was no valid time from the GPS when the PPS event was
- * asserted, we can do nothing further. Some GPS like Garmin
- * always send a PPS, valid or not. Other GPS like some uBlox
- * may only send PPS when valid.
- * It is common to get PPS, and no fixtime, while autobauding.
+ * If there has not yet bben any valid in-band time stashed
+ * from the GPS when the PPS event was asserted, we can do
+ * nothing further. Some GPSes like Garmin always send a PPS,
+ * valid or not. Other GPSes like some uBlox may only send
+ * PPS when time is valid. It is common to get PPS, and no
+ * fixtime, while autobauding.
*/
- if (isnan(last_fixtime_real))
+ if (last_fixtime_real.tv_sec == 0)
continue;
/* mask for monitored lines */
@@ -596,7 +597,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
log = "Too long for 0.5Hz\n";
}
#endif /* TIOCMIWAIT */
- if ( ok && last_second_used >= last_fixtime_real ) {
+ if ( ok && last_second_used >= last_fixtime_real.tv_sec ) {
/* uh, oh, this second already handled */
ok = 0;
log = "this second already handled\n";
@@ -645,7 +646,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
*/
/*@+relaxtypes@*/
- ppstimes.real.tv_sec = (time_t)trunc(last_fixtime_real) + 1;
+ ppstimes.real.tv_sec = (time_t)last_fixtime_real.tv_sec + 1;
ppstimes.real.tv_nsec = 0; /* need to be fixed for 5Hz */
ppstimes.clock = clock_ts;
/*@-relaxtypes@*/
@@ -672,7 +673,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
log1 = "timestamp out of range";
} else {
/*@-compdef@*/
- last_second_used = last_fixtime_real;
+ last_second_used = last_fixtime_real.tv_sec;
if (thread_context->report_hook != NULL)
log1 = thread_context->report_hook(thread_context, &ppstimes);
else
@@ -773,7 +774,7 @@ void pps_thread_deactivate(volatile struct pps_thread_t *pps_thread)
}
void pps_thread_stash_fixtime(volatile struct pps_thread_t *pps_thread,
- timestamp_t realtime, struct timespec clocktime)
+ struct timespec realtime, struct timespec clocktime)
/* thread-safe update of last fix time - only way we pass data in */
{
/*@ -unrecog (splint has no pthread declarations as yet) @*/
diff --git a/ppsthread.h b/ppsthread.h
index ea83d04f..73c8720b 100644
--- a/ppsthread.h
+++ b/ppsthread.h
@@ -23,8 +23,8 @@
#endif /* S_SPLINT_S */
struct pps_thread_t {
- timestamp_t fixin_real;
- struct timespec fixin_clock; /* system clock time when last fix received */
+ struct timespec fixin_real; /* in-band time of the fix */
+ struct timespec fixin_clock; /* system clock time when fix received */
#if defined(HAVE_SYS_TIMEPPS_H)
pps_handle_t kernelpps_handle;
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
@@ -50,7 +50,7 @@ struct pps_thread_t {
extern void pps_thread_activate(volatile struct pps_thread_t *);
extern void pps_thread_deactivate(volatile struct pps_thread_t *);
extern void pps_thread_stash_fixtime(volatile struct pps_thread_t *,
- timestamp_t, struct timespec);
+ struct timespec, struct timespec);
extern int pps_thread_lastpps(volatile struct pps_thread_t *,
struct timedelta_t *);