diff options
author | Fred Wright <fw@fwright.net> | 2017-01-19 17:49:59 -0800 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2017-01-19 18:19:27 -0800 |
commit | e91f750c1e9ac1e1340181febf89201cb3cce8bd (patch) | |
tree | b32fb93625942b67d727d8cf6463b6792dc2b8d2 /gpsmon.c | |
parent | 4dd216c55d2838f71a1c7e445a2f180393e04fb3 (diff) | |
download | gpsd-e91f750c1e9ac1e1340181febf89201cb3cce8bd.tar.gz |
Fixes some trouble with gpsmon and no PPS_ENABLE.
Until recently, PPS_ENABLE was always true by default, even on
platforms where it was intended to be forced off. Fixing this exposed
some issues in gpsmon. This generally related to confusion between
*displaying* PPS info versus *capturing* it. Since gpsmon can be run
against a remote target, it should be able to report PPS info even
when running on a host that doesn't support PPS, but the code was
conflating the two issues.
The changes here are:
1) There is now a PPS_DISPLAY_ENABLE, which is always true, and should
be used in place of PPS_ENABLE in code related to displaying PPS info,
to the extent possible.
2) The code related to processing remote TOFF and PPS events now uses
this new conditional. Aside from restoring the presence of the "PPS
offset" lines in the scrolling data, this also fixes a problem where
the display malfunctioned when this code was absent. The exact nature
of this dependency hasn't yet been determined, but there's a FIXME to
document the issue.
3) The reporting of PPS offsets in the windowed area still doesn't
work without PPS_ENABLE, due to the entanglement between that code and
the pps_thread code. There are now a couple of FIXMEs related to that
issue, which is being left for future work.
4) A couple of unnecessary PPS_ENABLE conditionals were eliminated by
making use of the existing conditionally-defined lock/unlock
functions.
TESTED:
Ran gpsmon on OSX 10.9 (where PPS_ENABLE is off) against three
receivers (one local and two remote), with the expected results. Also
ran it on Ubuntu 14 (where PPS_ENABLE is on) against the same three
receivers (again one local and two remote), again with the expected
results.
Diffstat (limited to 'gpsmon.c')
-rw-r--r-- | gpsmon.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -169,6 +169,9 @@ static inline void report_unlock(void) { } " PPS " \ "-------------------------------------\n" +/* Dummy conditional for *display* of (possibly remote) PPS events */ +#define PPS_DISPLAY_ENABLE 1 + /****************************************************************************** * * Visualization helpers @@ -258,6 +261,7 @@ void toff_update(WINDOW *win, int y, int x) } #endif /* NTP_ENABLE */ +/* FIXME: Decouple this reporting from local PPS monitoring. */ #ifdef PPS_ENABLE void pps_update(WINDOW *win, int y, int x) { @@ -354,7 +358,7 @@ static void packet_vlog(char *buf, size_t len, const char *fmt, va_list ap) gpsmon_report(buf2); report_unlock(); } -#endif +#endif /* PPS_ENABLE */ #ifdef RECONFIGURE_ENABLE static void announce_log(const char *fmt, ...) @@ -735,7 +739,8 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED) { char buf[BUFSIZ]; -#if defined(SOCKET_EXPORT_ENABLE) && defined(PPS_ENABLE) +/* FIXME: If the following condition is false, the display is screwed up. */ +#if defined(SOCKET_EXPORT_ENABLE) && defined(PPS_DISPLAY_ENABLE) if (!serial && str_starts_with((char*)device->lexer.outbuffer, "{\"class\":\"TOFF\",")) { const char *end = NULL; int status = json_toff_read((const char *)device->lexer.outbuffer, @@ -792,6 +797,8 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED) (void)snprintf(buf, sizeof(buf), "------------------- PPS offset: %.20s ------\n", timedelta_str); +/* FIXME: Decouple this from the pps_thread code. */ +#ifdef PPS_ENABLE /* * In direct mode this would be a bad idea, but we're not actually * watching for handshake events on a spawned thread here. @@ -800,10 +807,11 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED) session.pps_thread.pps_out = noclobber.pps; /* coverity[missing_lock] */ session.pps_thread.ppsout_count++; +#endif /* PPS_ENABLE */ } } else -#endif /* PPS_ENABLE */ +#endif /* SOCKET_EXPORT_ENABLE && PPS_DISPLAY_ENABLE */ { #ifdef __future__ if (!serial) @@ -1434,9 +1442,7 @@ int main(int argc, char **argv) ssize_t st = read(0, &inbuf, 1); if (st == 1) { -#ifdef PPS_ENABLE - gpsd_acquire_reporting_lock(); -#endif /* PPS_ENABLE*/ + report_lock(); (void)tcflush(0, TCIFLUSH); (void)tcsetattr(0, TCSANOW, &cooked); (void)fputs("gpsmon: ", stdout); @@ -1453,9 +1459,7 @@ int main(int argc, char **argv) if (!curses_active) { (void)sleep(2); (void)tcsetattr(0, TCSANOW, &rare); -#ifdef PPS_ENABLE - gpsd_release_reporting_lock(); -#endif /* PPS_ENABLE*/ + report_unlock(); } } } |