summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-24 06:48:33 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-24 06:48:33 -0500
commit34df72ab62d8b00e1ba3b4c71559dd381d9540d6 (patch)
tree7199e0f316f4fd3391eb215a1308fdd497b3ea56
parent2816615018ca0c329246bf10fe7ec7e08e82bcf0 (diff)
downloadgpsd-34df72ab62d8b00e1ba3b4c71559dd381d9540d6.tar.gz
TOFF display in gpsmon.
-rw-r--r--gpsmon.c11
-rw-r--r--gpsmon.h3
-rw-r--r--monitor_nmea0183.c17
3 files changed, 18 insertions, 13 deletions
diff --git a/gpsmon.c b/gpsmon.c
index 6629d964..bfa854c4 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -47,7 +47,9 @@ extern const struct gps_type_t driver_nmea0183;
/* These are public */
struct gps_device_t session;
WINDOW *devicewin;
+#ifdef NTP_ENABLE
struct timedelta_t time_offset;
+#endif /* NTP_ENABLE */
bool serial;
/* These are private */
@@ -645,9 +647,6 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
/* per-packet hook */
{
char buf[BUFSIZ];
-#ifdef NTP_ENABLE
- struct timedelta_t td;
-#endif /* NTP_ENABLE */
#if defined(SOCKET_EXPORT_ENABLE) && defined(PPS_ENABLE)
if (!serial && str_starts_with((char*)device->lexer.outbuffer, "{\"class\":\"TOFF\",")) {
@@ -658,17 +657,17 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
if (status != 0) {
/* FIXME: figure out why using json_error_string() core dumps */
complain("Ill-formed TOFF packet: %d", status);
- buf[0] = '\0';
} else {
/*@-type -noeffect@*/ /* splint is confused about struct timespec */
if (!curses_active)
(void)fprintf(stderr,
- "TOFF clock=%ld.%09ld real=%ld.%09ld\n",
+ "TOFF=%ld.%09ld real=%ld.%09ld\n",
(long)session.gpsdata.toff.clock.tv_sec,
(long)session.gpsdata.toff.clock.tv_nsec,
(long)session.gpsdata.toff.real.tv_sec,
(long)session.gpsdata.toff.real.tv_nsec);
/*@+type +noeffect@*/
+ time_offset = session.gpsdata.toff;
}
} else if (!serial && str_starts_with((char*)device->lexer.outbuffer, "{\"class\":\"PPS\",")) {
const char *end = NULL;
@@ -759,7 +758,7 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
} else if (device->newdata.time == device->last_fixtime.real) {
// "NTP: Not a new time
} else
- ntp_latch(device, &td);
+ ntp_latch(device, &time_offset);
#endif /* NTP_ENABLE */
}
/*@+observertrans +nullpass +globstate +compdef +uniondef@*/
diff --git a/gpsmon.h b/gpsmon.h
index cb90da28..5e7665fb 100644
--- a/gpsmon.h
+++ b/gpsmon.h
@@ -35,6 +35,9 @@ extern void monitor_complain(const char *fmt, ...);
extern WINDOW *devicewin;
extern struct gps_device_t session;
extern bool serial; /* True - direct mode, False - daemon mode */
+#ifdef NTP_ENABLE
+extern struct timedelta_t time_offset;
+#endif /* NTP_ENABLE */
#endif /* _GPSD_GPSMON_H_ */
/* gpsmon.h ends here */
diff --git a/monitor_nmea0183.c b/monitor_nmea0183.c
index cf79f23b..39eae9d7 100644
--- a/monitor_nmea0183.c
+++ b/monitor_nmea0183.c
@@ -98,11 +98,14 @@ static bool nmea_initialize(void)
(void)mvwprintw(gpgsawin, SATS_LINE, SATS_COL, "Sats: ");
#define DOP_LINE 2
(void)mvwprintw(gpgsawin, DOP_LINE, 1, "DOP: H= V= P=");
-#define PPS_LINE 4
- (void)mvwprintw(gpgsawin, PPS_LINE, 1, "PPS: ");
#define TOFF_LINE 3
(void)mvwprintw(gpgsawin, TOFF_LINE, 1, "TOFF: ");
#ifndef PPS_ENABLE
+ (void)mvwaddstr(gpgsawin, TOS_LINE, 7, "N/A");
+#endif /* PPS_ENABLE */
+#define PPS_LINE 4
+ (void)mvwprintw(gpgsawin, PPS_LINE, 1, "PPS: ");
+#ifndef PPS_ENABLE
(void)mvwaddstr(gpgsawin, PPS_LINE, 6, "N/A");
#endif /* PPS_ENABLE */
(void)mvwprintw(gpgsawin, 5, 9, " GSA + PPS ");
@@ -316,13 +319,14 @@ static void nmea_update(void)
monitor_fixframe(gpgsawin);
}
+#ifdef NTP_ENABLE
/*@-compdef@*/
/*@-type -noeffect@*/ /* splint is confused about struct timespec */
- if ((session.gpsdata.set & TOFF_SET) != 0) {
+ if (time_offset.real.tv_sec != 0)
+ {
/* NOTE: can not use double here due to precision requirements */
struct timespec timedelta;
- TS_SUB(&timedelta,
- &session.gpsdata.toff.clock, &session.gpsdata.toff.real);
+ TS_SUB(&timedelta, &time_offset.clock, &time_offset.real);
if ( 86400 < (long)labs(timedelta.tv_sec) ) {
/* more than one day off, overflow */
/* need a bigger field to show it */
@@ -332,11 +336,10 @@ static void nmea_update(void)
timespec_str( &timedelta, buf, sizeof(buf) );
(void)mvwprintw(gpgsawin, TOFF_LINE, 7, "%s", buf);
}
- (void)wnoutrefresh(gpgsawin);
}
/*@+type +noeffect@*/
/*@+compdef@*/
-
+#endif /* NTP_ENABLE */
if (strcmp(fields[0], "GPGGA") == 0
|| strcmp(fields[0], "GNGGA") == 0