diff options
author | Gary E. Miller <gem@rellim.com> | 2015-02-02 19:42:41 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-02-02 19:42:41 -0800 |
commit | 941818328ea28dacd238f0b38208c039e4b6e9fc (patch) | |
tree | a293d9aa050465deb19cd5211519fdc3b1d6537c /monitor_sirf.c | |
parent | af4afebe84d1f0523ee0c91f829c515f1a1ddecb (diff) | |
download | gpsd-941818328ea28dacd238f0b38208c039e4b6e9fc.tar.gz |
Fix sign of PPS offset in gpsmon.
In gpsmon client mode the u-blox now exactly matches what
I see in ntpq -p.
Diffstat (limited to 'monitor_sirf.c')
-rw-r--r-- | monitor_sirf.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/monitor_sirf.c b/monitor_sirf.c index ba8bb9f2..6ef24c19 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -9,6 +9,7 @@ #include <stdbool.h> #include <string.h> #include <math.h> +#include <stdlib.h> /* for labs() */ #include <assert.h> #include <time.h> #include <sys/time.h> @@ -592,15 +593,20 @@ static void sirf_update(void) if (pps_thread_lastpps(&session, &drift) > 0) { /* NOTE: can not use double here due to precision requirements */ struct timespec timedelta; - TS_SUB( &timedelta, &drift.real, &drift.clock); - if ( 86400 < (long)timedelta.tv_sec ) { + int sign = ' '; + TS_SUB( &timedelta, &drift.clock, &drift.real); + if ( 86400 < (long)labs(timedelta.tv_sec) ) { /* more than one day off, overflow */ /* need a bigger field to show it */ (void)mvwprintw(mid7win, 2, 39, "> 1 day"); } else { - (void)mvwprintw(mid7win, 4, 39, "%ld.%09ld", - (long)timedelta.tv_sec, - (long)timedelta.tv_nsec); + if ( 0 > timedelta.tv_nsec ) { + sign = '-'; + } + (void)mvwprintw(mid7win, 4, 39, "%c%ld.%09ld", + sign, + (long)timedelta.tv_sec, + (long)labs(timedelta.tv_nsec)); } (void)wnoutrefresh(mid7win); } |