summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-02 16:02:05 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-11-02 16:02:05 -0400
commit76508d80374ffaa85ac4a62f04272c61a2cb2d13 (patch)
tree2560b94088cca8533994ccf74f3eb583aaf47005
parentfa7fd7a281bcbec1a75fe783c9bc10bf7c94bf9c (diff)
downloadgpsd-76508d80374ffaa85ac4a62f04272c61a2cb2d13.tar.gz
Pretty up the PPS display in gpmon.
The idea is to make PPS visually obvious in the packed buffer. Time display should be on the monitor panel with the other derived data. The UBX monitor provides an example of how to do this.
-rw-r--r--gpsmon.c25
-rw-r--r--gpsmon.h1
-rw-r--r--monitor_ubx.c19
3 files changed, 32 insertions, 13 deletions
diff --git a/gpsmon.c b/gpsmon.c
index b9e6230a..f90cf934 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -45,6 +45,7 @@ extern struct monitor_object_t oncore_mmt, tnt_mmt, aivdm_mmt;
struct gps_device_t session;
WINDOW *devicewin;
bool serial;
+float timedelta = 0;
/* These are private */
static struct gps_context_t context;
@@ -836,16 +837,22 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
/*@+observertrans +nullpass +globstate@*/
#ifdef PPS_ENABLE
-/* The PPS thread_report_hook callback. This or a pps_hook callback is
- * needed to keep the PPS thread running.
- */
static char *pps_report(struct gps_device_t *session UNUSED,
- struct timeval *actual_tv,
- struct timespec *ts,
- double edge_offset) {
- packet_log("PPS time=%llu.%09lu; clock=%llu.%09lu; edge_offset=%.9f\n",
- (long long)actual_tv->tv_sec, actual_tv->tv_usec * 1000,
- (long long)ts->tv_sec, ts->tv_nsec, edge_offset);
+ struct timeval *pps_tv,
+ struct timespec *sysclock_ts,
+ double edge_offset UNUSED) {
+ /*
+ * Ugh. Access through a shared global is nasty.
+ * This may be a layer violation that needs to be fixed.
+ *
+ * Read access to timedelta is not thread-locked.
+ * Instead we're relying on access to floats to be atomic.
+ */
+ timedelta = (pps_tv->tv_sec + pps_tv->tv_usec / 1e6)
+ - (sysclock_ts->tv_sec + sysclock_ts->tv_nsec / 1e9);
+ packet_log("-------------------------------------"
+ " PPS "
+ "-------------------------------------\n");
return "gpsmon";
}
#endif /* PPS_ENABLE */
diff --git a/gpsmon.h b/gpsmon.h
index cb90da28..370926c3 100644
--- a/gpsmon.h
+++ b/gpsmon.h
@@ -35,6 +35,7 @@ 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 */
+extern float timedelta;
#endif /* _GPSD_GPSMON_H_ */
/* gpsmon.h ends here */
diff --git a/monitor_ubx.c b/monitor_ubx.c
index 6acd897f..9300b92d 100644
--- a/monitor_ubx.c
+++ b/monitor_ubx.c
@@ -12,7 +12,7 @@
#ifdef UBX_ENABLE
#include "driver_ubx.h"
extern const struct gps_type_t ubx_binary;
-static WINDOW *satwin, *navsolwin, *dopwin;
+static WINDOW *satwin, *navsolwin, *dopwin, *ppswin;
#define display (void)mvwprintw
static bool ubx_initialize(void)
@@ -34,7 +34,7 @@ static bool ubx_initialize(void)
/* "heavily inspired" by monitor_nmea.c */
if ((navsolwin = derwin(devicewin, 13, 51, 0, 28)) == NULL)
- return false;
+ return false;
(void)wborder(navsolwin, 0, 0, 0, 0, 0, 0, 0, 0),
(void)wattrset(navsolwin, A_BOLD);
(void)wmove(navsolwin, 1, 1);
@@ -62,13 +62,22 @@ static bool ubx_initialize(void)
if ((dopwin = derwin(devicewin, 3, 51, 13, 28)) == NULL)
return false;
- (void)wborder(dopwin, 0, 0, 0, 0, 0, 0, 0, 0),
- (void)wattrset(dopwin, A_BOLD);
+ (void)wborder(dopwin, 0, 0, 0, 0, 0, 0, 0, 0);
+ (void)wattrset(dopwin, A_BOLD);
(void)wmove(dopwin, 1, 1);
(void)wprintw(dopwin, "DOP [H] [V] [P] [T] [G]");
display(dopwin, 2, 20, " NAV_DOP ");
(void)wattrset(dopwin, A_NORMAL);
+ if ((ppswin = derwin(devicewin, 3, 51, 16, 28)) == NULL)
+ return false;
+ (void)wborder(ppswin, 0, 0, 0, 0, 0, 0, 0, 0);
+ (void)wattrset(ppswin, A_BOLD);
+ (void)wmove(ppswin, 1, 1);
+ (void)wprintw(ppswin, "DELTA: ");
+ display(ppswin, 2, 22, " PPS ");
+ (void)wattrset(ppswin, A_NORMAL);
+
return true;
}
@@ -230,6 +239,8 @@ static void ubx_update(void)
break;
}
+ if (timedelta != 0)
+ (void)mvwprintw(ppswin, 1, 8, "%f", timedelta);
}
static int ubx_command(char line[]UNUSED)