summaryrefslogtreecommitdiff
path: root/monitor_ubx.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-02-02 19:42:41 -0800
committerGary E. Miller <gem@rellim.com>2015-02-02 19:42:41 -0800
commit941818328ea28dacd238f0b38208c039e4b6e9fc (patch)
treea293d9aa050465deb19cd5211519fdc3b1d6537c /monitor_ubx.c
parentaf4afebe84d1f0523ee0c91f829c515f1a1ddecb (diff)
downloadgpsd-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_ubx.c')
-rw-r--r--monitor_ubx.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/monitor_ubx.c b/monitor_ubx.c
index 69de6f27..a50d5d3f 100644
--- a/monitor_ubx.c
+++ b/monitor_ubx.c
@@ -3,6 +3,7 @@
* BSD terms apply: see the file COPYING in the distribution root for details.
*/
#include <math.h>
+#include <stdlib.h> /* for labs() */
#include <time.h>
#include "gpsd.h"
@@ -259,15 +260,20 @@ static void ubx_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(ppswin, 1, 13, "> 1 day");
} else {
- (void)mvwprintw(ppswin, 1, 13, "%ld.%09ld",
+ if ( 0 > timedelta.tv_nsec ) {
+ sign = '-';
+ }
+ (void)mvwprintw(ppswin, 1, 13, "%c%ld.%09ld",
+ sign,
(long)timedelta.tv_sec,
- (long)timedelta.tv_nsec);
+ (long)labs(timedelta.tv_nsec));
}
(void)wnoutrefresh(ppswin);
}