summaryrefslogtreecommitdiff
path: root/gpsmon.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a warning from gcc: vwprintw is deprecatedSanjeev Gupta2019-01-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function vwprintw, declared in curses.h is called out by gcc because of its use of varargs.h . The actaul implementation uses stdarg.h , however GCC does not know this. Switch to the newer calling form to make gcc happy. gcc -o gpsmon.o -c -pthread -Wall -Wcast-align -Wextra -Wimplicit-fallthrough -Wmissing-declarations -Wmissing-prototypes -Wno-missing-field-initializers -Wno-uninitialized -Wpointer-arith -Wreturn-type -Wstrict-prototypes -Wvla -O2 -pthread -DHAVE_SYS_TIMEPPS_H=1 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/dbus-1.0 -I/usr/lib/i386-linux-gnu/dbus-1.0/include -I/usr/include/libusb-1.0 gpsmon.c gpsmon.c: In function 'monitor_vcomplain': gpsmon.c:392:5: warning: 'vwprintw' is deprecated [-Wdeprecated-declarations] (void)vwprintw(cmdwin, (char *)fmt, ap); ^ In file included from gpsmon.h:11, from gpsmon.c:31: /usr/include/curses.h:816:28: note: declared here extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ ^~~~~~~~ gpsmon.c: In function 'monitor_log': gpsmon.c:419:2: warning: 'vwprintw' is deprecated [-Wdeprecated-declarations] (void)vwprintw(packetwin, (char *)fmt, ap); ^ In file included from gpsmon.h:11, from gpsmon.c:31: /usr/include/curses.h:816:28: note: declared here extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ ^~~~~~~~ Signed-off-by: Gary E. Miller <gem@rellim.com>
* Factor most uses of pselect(2) into a new utility function named 'nanowait'.Eric S. Raymond2018-12-271-2/+1
| | | | | Also, remove sime header inclusions discovered to be unnecessary during the change.
* Eliminate effectively all uses of struct timeval.Eric S. Raymond2018-12-261-2/+2
| | | | | Outide of one Mac portability shim, anyway. Associated select(2) calls become pselect(2) calls.
* Removed variable length arrays, added -Wvla compiler option.vla-removalIan Bruene2018-11-261-1/+1
|
* LICENSE: Update licenses for consistency. No functional changes.Gary E. Miller2018-11-191-1/+1
|
* gpsmon: Expand a too small buffer.Gary E. Miller2018-07-261-1/+1
| | | | Bug found by gcc 7.3.0.
* gpsmon.c: isnan() -> isfinite(). Fix a buffer size.Gary E. Miller2018-07-141-2/+2
| | | | Thanks to Virgin Orbit for their support on this patch.
* gpsmon: fix NULL pointer dereference.Gary E. Miller2018-06-171-3/+10
| | | | Thanks to a report from <alexc@sbrella.com>
* SPDXify the licerse references.Eric S. Raymond2018-03-081-1/+1
|
* gpsmon, promptgen: buffer was too small.Gary E. Miller2018-02-081-1/+1
| | | | 135 > 128.
* Fixes some trouble with gpsmon and no PPS_ENABLE.Fred Wright2017-01-191-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Adds Linux "fake PPS" detection and avoidance.Fred Wright2016-12-231-6/+8
| | | | | | | | | | | | | | | | | | | | | If the Linux kernel is built with CONFIG_PPS_CLIENT_KTIMER=y, then a synthetic PPS source is added to allow testing without a real PPS source. However, this source doesn't even run at exactly 1Hz, so any attempt to use it for real time synchronization is disastrous. To make matters worse, this is usually the first PPS driver configured, causing it to appear as /dev/pps0, which is the implied PPS device used by the "Magic HAT" kludge. This change adds detection for the fake source (based on its name), both to provide a warning if it is configured explicitly, and to skip over it when applying the "Magic HAT" kludge. TESTED: Tested both gpsmon and gpsd on a Beaglebone Black with added symlinks for testing "Magic HAT". Did this with kernels with and without the KTIMER enabled. Verified that the proper PPS device is selected by "Magic HAT", and that a warning is generated when expected.
* Makes MAGIC_HAT kludge optional.Fred Wright2016-12-221-2/+4
| | | | | | | | | | | | | | This adds a build option called 'magic_hat', and makes the code for MAGIC_HAT_GPS and MAGIC_LINK_GPS conditional on it. It currently defaults to True on Linux and False otherwise. It's meaningless on non-Linux platforms, though at present there are no conditionally-present options, so this one is also present on all platforms. TESTED: Tested on a Beaglebone Black with suitable symlinks added (and running a kernel with PPS_CLIENT_KTIMER turned off. Verified that the kludge behaves as intended when enabled, and is inoperative when disabled.
* Fixes inverted offset signs in gpsmon's PPS lines.Fred Wright2016-09-221-1/+1
| | | | | | | | | | | | | | | In gpsmon, the PPS offsets reported in the display pane and in the scrolling packet data has opposite signs. Since the display version is consistent with the value reported by the ppswatch utility (from the pps-tools package), this is assumed to be the correct version, and the "text" version is corrected to match. TESTED: Ran gpsmon on both OSX and Linux, verifying that the two forms of PPS offset reported by gpsmon and the ppswatch version are all consistent. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Fixes crash when quitting gpsmon in -a mode.Fred Wright2016-09-221-2/+3
| | | | | | | | | | | | | | | | | | | | | There were two bugs in the alternate input code used in -a mode: 1) It was using strlen() instead of sizeof() to determine the available space in the input buffer. This is uninitialized data, making the result nondeterministic, though it would return zero in the case observed. 2) It was failing to handle the NULL return from fgets() correctly, resulting in a call to do_command() with a garbage argument. This caused a segfault. Also, casting the strlen/sizeof value to int was superfluous. TESTED: Typing a "q" in -a mode now outputs a prompt (an incorrect one, but that's another story) and can then quits without crashing. Signed-off-by: Gary E. Miller <gem@rellim.com>
* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999Gary E. Miller2016-08-161-0/+4
| | | | | Sad, C99 did not actually standardize the defines to invoke the standard.
* usleep() is removed from POSIX-2008. Replace with nanosleep()Gary E. Miller2016-08-151-2/+12
| | | | I sure hope I did not drop a zero anywhere...
* FreeBSD wants to force us to call sysconf(). Foil it.Eric S. Raymond2016-05-281-0/+5
|
* gpsmon now includes the hostname with the device display.Eric S. Raymond2016-05-181-5/+8
|
* Im[p;ement and document /dev/gpsd0 side effect.Eric S. Raymond2016-05-101-1/+2
|
* Give ODROID C2 users some hope of getting HAT autodetection of pps0 right.Eric S. Raymond2016-04-261-4/+5
|
* Autoconfiguration kluge for Raspberry Pi.Eric S. Raymond2016-04-251-0/+8
| | | | | | | | | When a serial device to be opened is /dev/ttyAMA0, and /dev/pps0 exists, and we have read-write access to it (which implies running as root), substitute /dev/pps0 for the device name in the thread context so we use KPPS. Should be safe because /dev/ttyAMA0 is so specific to the Raspberry Pi.
* Fix minor typos.Hal Murray2016-02-011-1/+1
| | | | Signed-off-by: Gary E. Miller <gem@rellim.com>
* Prevent a memory leak in long-running gpsmon instances.Eric S. Raymond2016-01-051-0/+2
|
* Address Savannah bug #46082 - Can't explicitly build with NMEA drivers.Eric S. Raymond2015-10-011-8/+8
|
* Remove a BSD-ism.Gary E. Miller2015-06-231-1/+5
| | | | | | | | | CTRL('L') is a BSD-ism. CTRL() is defined in sys/ttydefaults.h which does not always exist. Instead of adding scons tests for needing CTRL() and its include files just replace with a simple constant. Needed for musl and found by Baruch Siach <baruch@tkos.co.il>
* A gaggle of whitespace gaffs.Gary E. Miller2015-04-301-13/+13
|
* Stop infinite loop in gpsmon for /dev/pps0Gary E. Miller2015-04-021-5/+7
| | | | Also fix debug output gsmon: -> gpsmon:
* Improved error messages in gpsmon.Eric S. Raymond2015-04-011-4/+2
|
* Eliminate some duplication code for timespec arithmetic.Eric S. Raymond2015-04-011-1/+1
|
* Clean up PPS monitor interface with renames, and additional documentation.Eric S. Raymond2015-04-011-2/+6
|
* Write scan-build suppressions to it runs clean.Eric S. Raymond2015-03-301-0/+3
| | | | | | Promote scan-build to be onere of the stock pre-release checks. Fix one minor cppcheck nit.
* Retire splint from our set of static analyzers.Eric S. Raymond2015-03-301-65/+13
| | | | | | | | | | | | | | | | | | | The proximate cause was that we've been seing emission of error messages that were randomly and disturbingly variable across different environments - notably Raspbian and Gentoo splint gave nontrivially different results than Ubuntu 14.10 splint. And this was *not* due to Ubuntu patches! A pristine splint built from the 3.1.2 tarball on Ubuntu didn't match the Raspbian and Gentoo results either. But this has been coming for a while. Easy access to more modern static analyzers such as coverity, scan-build and cppcheck has been decreasing the utility of splint, which is unmaintained and somewhat buggy and not easy to use. Only file not cleaned is ppsthread.c, because Gary has been working on it during this cleanup. All regression tests pass. PPS observed live on GR601-W.
* In gpsmon, omit hexdumping trailing CR/LF when dumping textual packets.Eric S. Raymond2015-03-301-0/+6
|
* Clean up most spint errors. All regression tests pass.Eric S. Raymond2015-03-281-3/+5
|
* Fix a display glitch in gpsmon.Eric S. Raymond2015-03-191-12/+20
|
* Address Savannah bug #44566: Unused variable warnings with -DNDEBUGKurt Schwehr2015-03-171-1/+1
| | | | | | With -Werror -DNDEBUG, these two cases end up failing with unused variables (gcc 4.9 with lots of patches on Linux). The attached patch solves the issue for me, but it's possible that it might be better with the UNUSEDs wrapped in
* Simplify the thread-monitor interface.Eric S. Raymond2015-03-111-2/+2
| | | | PPS observed live on GR601W.
* splint cleanup of new code.Eric S. Raymond2015-03-081-1/+1
|
* Fix a display glitch when there is a field after TOFF or PPS...Eric S. Raymond2015-03-081-2/+6
| | | | ...but on the same line.
* ppsthread.c is now fully decoupled from the libgpsd_core.c structures.Eric S. Raymond2015-03-081-0/+1
| | | | | | | | | | | | | | | | | The files ntpshm.h ntpshmread.c ntpshmwrite.c ppsthread.[ch] timespec_str.[ch] now form a standalone group which can be used for NTP communication and PPS thread monitoring. Separation is not yet perfect, as ppsthread.c requires gpsd_config.h for HAVE_SYS_TIMEPPS_H and npshmread.c/ntpshmwrite.c both require compiler.h. All regression tests pass. PPS is live on a GR-601W.
* Eliminate timestamp-T use from PPS thread code.Eric S. Raymond2015-03-081-1/+1
| | | | PPS observed live on GR-601W. All regression yests pass.
* Eliminate a potential source of defects by using static mutex initialization.Eric S. Raymond2015-03-081-3/+0
|
* Decouple (mostly) the PPS thread-monitor from the session structure.Eric S. Raymond2015-03-081-4/+4
| | | | | | | | | | | | This is the big step towards ntplib. A couple of minor issues remain to be ironed out, the most significant of which is what to do about the timestamp_t type. This changes some field offsets of private fields in struct gps_device_t. Probably does not require a version bump as access to them is all through the libgpsd API. All regression tests pass. PPS observed live in gpsmon direct mode.
* Factor PPS-related members of struct gps_device_t into a pps_thread_t structure.Eric S. Raymond2015-03-071-4/+6
| | | | | | | | | | | No logic changes, though it looks like there are two because two guards that would always have failed when the code was compiled with pps=off are now conditioned out. Also, this code is offset-preserving so as not to break link-time compatibility of libgpsd. (This is the subtler approach...) All regression tests pass.
* Revert "Another step in prying ntplib loose. Partly decouple ppsthread.c ↵Eric S. Raymond2015-03-071-15/+3
| | | | | | fom sessions." Previous approch was a bit too frontal.
* Another step in prying ntplib loose. Partly decouple ppsthread.c fom sessions.Eric S. Raymond2015-03-071-3/+15
| | | | All regression tests pass.
* Generqte -V messages in a uniform way.Eric S. Raymond2015-03-021-1/+1
| | | | All regression tests pass.
* Pre-release splint/cppcheck/coverity cleanup. All regression tests pass.Eric S. Raymond2015-02-261-1/+1
|
* Warning hunting cleanup in gpsmon.c for visiblize not always usedJon Schlueter2015-02-251-0/+2
| | | | visiblize only used under PPS_ENABLE guard