summaryrefslogtreecommitdiff
path: root/gpsd.c
Commit message (Collapse)AuthorAgeFilesLines
* timeservice=yes: Fix the doc matches the code.Gary E. Miller2019-03-081-13/+17
| | | | | | | | The doc said timeservice=yes forced gpsd option -n, which it did not. That option also force building of ntpshmmon, cgps and gpsmon, even if disabled by gpsdclients=no. So it essentually did nothing when used per the clockmaker script.
* gpsd.c: sort system includes.Gary E. Miller2018-12-271-22/+23
| | | | Yeah, an OCD thing to do.
* Factor most uses of pselect(2) into a new utility function named 'nanowait'.Eric S. Raymond2018-12-271-3/+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.
* LICENSE: Update licenses for consistency. No functional changes.Gary E. Miller2018-11-191-1/+1
|
* gpsd.c: fix compiler warning.Gary E. Miller2018-09-221-1/+1
|
* gpsd: Allow zerk/ubxtools to work when another client is running.Gary E. Miller2018-09-221-5/+3
|
* Savannah issue #53671: policy_t -> gps_policy_t.Gary E. Miller2018-07-261-4/+4
| | | | | | This is to prevent a conflict with Boost version 1.67. No functional change.
* gpsd: fix SHM() output.Gary E. Miller2018-07-241-2/+2
| | | | | | | SHM() output got broken in 1744cd9f87006c85492edf1f476e054bdb744ea1. many thanks to Paul Theodoropoulos <paul@anastrophe.com> for tracking this down.
* gpsd.c: fix gpsd master/slave modeGary E. Miller2018-07-241-18/+19
| | | | | | | | | | | | | The gpsd command parser was splitting the ? from commands (WATCH, POLL, etc.), and then sending the ? to the gpsd master in a separate packet. But the gpsd is not buffering network data, so failing to recognize The two packets of ? and WATCH as one complete command. Adding full buffering to the gpsd master looks a lot harder than just sending the ?WATCH in one packet. Also leading to some code simplification in the gpsd slave. Been broken since 2013 at least. Many thanks to Virgin Orbit for the support finding and fixing this.
* gpsd.c: finish moving redundant write code to write_gps().Gary E. Miller2018-07-241-36/+4
|
* update gpsd to send arbitrary data to GPS from clientGary E. Miller2018-07-141-0/+38
| | | | New ?DEVICE:{"hexdata":"data" option.
* gpsd.c: isnan() -> isfinite()Gary E. Miller2018-07-141-2/+2
| | | | Thanks to Virgin Orbit for their support on this patch.
* SPDXify the licerse references.Eric S. Raymond2018-03-081-1/+1
|
* isfinite(): Another try at getting Ubuntu to see isfinite()Gary E. Miller2018-02-131-4/+2
| | | | | Their man page says _POSIX_C_SOURCE >= 200112L should work. It did not.
* isfinite(): add define for POSIX 2011LGary E. Miller2018-02-131-0/+3
| | | | Almost 20 years after C99, Ubuntu still does not use it as default...
* Clean up C and Python code-checker warnings.Eric S. Raymond2017-09-061-0/+1
|
* Alphabetize gpsd usage message. Add -r option.Gary E. Miller2017-06-301-9/+10
|
* Add the -r option to gpsd.Larry Boyd2017-06-301-2/+7
| | | | | | | | -r allows gpsd to use the time from a GPS even if the GPS has no valid fix. This is useful on devices like the Raspberry Pi that have not battery backed RTC, but have a GPS with a battery backed RTC. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Fixes spelling of "daemonization".Fred Wright2017-03-041-1/+1
| | | | | | | | Error messages related to daemonization failures had incorrect spelling. TESTED: Ran "scons build-all" on OSX.
* Fixes warning on CentOS build.Fred Wright2017-01-311-1/+2
| | | | | | | | | | Certain definitions (in this case, setgroups) need _BSD_SOURCE in older glibc versions, but _DEFAULT_SOURCE in newer versions. The recommended approach for compatibility across glibc versions (from feature_test_macros(7)) is to define both. TESTED: Now builds without warnings on Ubuntu 14, CentOS 7, and Fedora 25.
* Centralizes daemon() calls.Fred Wright2017-01-221-2/+2
| | | | | | | | | | | | | | | | This defines a new function os_daemon() (in os_compat.c), which is either the old replacement daemon() renamed, or a wrapper around the actual daemon() call. This allows any issues related to daemon() (which exist on some platforms) to be dealt with in one place. No such changes are present yet, so platforms giving warnings for the use of daemon() continue to do so, but now only in the compilation of os_compat.c. Unfortunately, the current build procedure typically compiles os_compat.c multiple times, so the warnings still appear multiple times. TESTED: Ran "scons build-all check" on OSX 10.9, OSX 10.12, Ubuntu 14, and FreeBSD 10.3.
* No need to escape the DARWIN defines.Gary E. Miller2016-09-071-1/+2
|
* Hack around FreeBSD stupidity.Gary E. Miller2016-09-071-5/+3
| | | | | | When FreeBSD turns on POSIX it disables BSd extenstions, with no possible workaraound. So just don;t ask for POSIX when then insanity becomes visible.
* Fix format nti, git hates rtailing spaces..Gary E. Miller2016-08-301-1/+1
|
* for INADDR_LOOPBACK() FreeBSD wants __BSD_VISIBLEGary E. Miller2016-08-161-0/+2
| | | | Oh what a tangled web...
* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999Gary E. Miller2016-08-161-0/+3
| | | | | Sad, C99 did not actually standardize the defines to invoke the standard.
* __DARWIN_C_LEVEL and _DARWIN_C_SOURCE to silence some warnings.Gary E. Miller2016-08-161-0/+4
| | | | vsnprintf() and strlcmp() are happier now.
* nice() needs _XOPEN_SOURCE 500, setgroups(), daemon() needs _DEFAULT_SOURCEGary E. Miller2016-08-151-0/+5
|
* uint was rmoved in C99. If gpsd enforce C99, then uint must go.Gary E. Miller2016-08-151-1/+2
| | | | uint is now unsigned int.
* usleep() is removed from POSIX-2008. Replace with nanosleep()Gary E. Miller2016-08-151-1/+7
| | | | I sure hope I did not drop a zero anywhere...
* gpsd was shipping NMEA time to SHM even when no valid fix.Gary E. Miller2016-07-161-2/+1
| | | | NMEA time can be wildly random with no fix.
* Don't daemonize gpsd if no good device or control socket.Nuno Gonçalves2016-06-141-0/+17
| | | | | | | This used to hang: gpsd -n /dev/ttyXXX Now it exits with an error. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Deal with some minor compiler warnings from FreeBSD.Eric S. Raymond2016-05-281-3/+3
|
* Make the gpsd usage message correct for timeservice builds.Eric S. Raymond2016-05-111-7/+11
|
* PPSTIME -> NTPTIMEGary E. Miller2016-04-241-2/+2
| | | | | NTPTIME is from the serial stream, it never had anything to do with PPS and it just confused everyone.
* Rename PPS_M IN_FIXES to NTP_MIN_FIXESGary E. Miller2016-04-131-1/+1
| | | | | | | | | This applies to not just PPS, but all NTP reportable time. Even with a valid fix, the frist 3 times may be off. Don't send bad time to ntp/chrony. Move the definition into gpsd.h to be widely available not depending on scons options.
* Also send SKY when GPGSA is received.Gary E. Miller2016-04-111-1/+1
| | | | | | | | Some GPS send GPGSV (sats in view) every 5 seconds by GPGSA (sats used) every second. gpsd was sending SKY only on GPGSV, so the more frequent updates to used sats were getting lost. Now send updates on GPGSA and GPGSV changes. The sat view is now more up to date.
* RTCM3 packets can be bigger than RTCM2 ones.Gary E. Miller2016-04-061-1/+7
| | | | I have seen up to about 490 in RTCM3.
* Bad NMEA time was still leaking, require 3 fixes for time.Gary E. Miller2016-04-051-1/+1
|
* Introduce the flag GOODTIME_IS...HTJ2016-03-221-1/+2
| | | | | | | | ...to mark that the device has a good time even if it does not report a position fix. Used by the OnCore driver, e.g. when in position hold mode. scons check passes
* Fix build on OS/X < 10.6Fred Wright2016-01-211-4/+8
| | | | | | | | | | | | | | | | | | | | | | OSX versions earlier than 10.6 fail to define IPV6_TCLASS, causing the compile of gpsd.c to fail. There is already a fallback definition for Gnu/Hurd. The attached patch: 1) Extends the existing Gnu/Hurd fallback definition to include a case for OSX. This is currently based on _APPLE_. Basing it on Darwin might be more appropriate, but that would need to be tested. 2) Duplicates this fallback setup in netlib.c, where it was missing. 3) Adds an ifdef to gpsd.c so that other cases that fail to define IPV6_TCLASS will simply omit the IPTOS_LOWDELAY setup, rather than failing to build. It's not entirely clear that sweeping the problem under the rug is preferable to getting an error and having the builder figure out what to do, but it is consistent with netlib.c, which includes a similar ifdef. The patch is originally from jeremyhu@macports.org, updated for 3.14 by ryandesign@macports.org, and then updated by me for 3.16.
* Address Savannah bug #46648: gpsd crashes and buffer overflow is reported...Eric S. Raymond2016-01-041-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...when terminated. Perttu Salmela writes: gpsd is started and terminated: gpsd:INFO: launching (Version 3.15~dev) gpsd:INFO: listening on port gpsd gpsd:PROG: NTP: shmat(0,0,0) succeeded, segment 0 gpsd:PROG: NTP: shmat(32769,0,0) succeeded, segment 1 gpsd:PROG: NTP: shmat(65538,0,0) succeeded, segment 2 gpsd:PROG: NTP: shmat(98307,0,0) succeeded, segment 3 gpsd:PROG: NTP: shmat(131076,0,0) succeeded, segment 4 gpsd:PROG: NTP: shmat(163845,0,0) succeeded, segment 5 gpsd:PROG: NTP: shmat(196614,0,0) succeeded, segment 6 gpsd:PROG: NTP: shmat(229383,0,0) succeeded, segment 7 gpsd:PROG: successfully connected to the DBUS system bus gpsd:PROG: shmget(0x47505344, 8928, 0666) for SHM export succeeded gpsd:PROG: shmat() for SHM export succeeded, segment 262152 gpsd:INFO: stashing device /dev/ttymxc2 at slot 0 gpsd:INFO: running with effective group ID 0 gpsd:INFO: running with effective user ID 0 gpsd:INFO: startup at 2015-10-31T11:04:55.000Z (1446289495) ^C*** buffer overflow detected ***: ./gpsd terminated Aborted (core dumped) This does not happen when gpsd is started with '-n' no-wait option. If started with '-n' device is opened fine and gpsd is terminated fine. The problem seems to be that function gpsd.c:gps_add_device sets devp->gpsdata.gps_fd = UNALLOCATED_FD (=-1) if no-wait ('-n') flag is not set. Next, in the main function around line 2166: case AWAIT_NOT_READY: for (device = devices; device < devices + MAX_DEVICES; device++) if (allocated_device(device) && FD_ISSET(device->gpsdata.gps_fd, &efds)) { FD_ISSET macro is called with invalid FD (-1). Adding the FD validity check before FD_ISSET fixes the crash: if (allocated_device(device) && (0 <= device->gpsdata.gps_fd && device->gpsdata.gps_fd < FD_SETSIZE) && FD_ISSET(device->gpsdata.gps_fd, &efds)) { It is still a bit unclear for me should free_device(device) be called even if FD is invalid. The issue occurs on embedded arm platform and may depend on implementation of FD_ISSET macro. The man page says "POSIX requires fd to be a valid file descriptor". I can see that FD_ISSET is called in couple of places elsewhere and FD validity is checked there. The issue does not happen if client is connected. E.g. if gpspipe is run and thereafter gpsd is terminated. This is expected since in such case the FD must be valid as gpsd connects to device. Output with proposed fix is: gpsd:INFO: launching (Version 3.15~dev) gpsd:INFO: listening on port gpsd gpsd:PROG: NTP: shmat(0,0,0) succeeded, segment 0 gpsd:PROG: NTP: shmat(32769,0,0) succeeded, segment 1 gpsd:PROG: NTP: shmat(65538,0,0) succeeded, segment 2 gpsd:PROG: NTP: shmat(98307,0,0) succeeded, segment 3 gpsd:PROG: NTP: shmat(131076,0,0) succeeded, segment 4 gpsd:PROG: NTP: shmat(163845,0,0) succeeded, segment 5 gpsd:PROG: NTP: shmat(196614,0,0) succeeded, segment 6 gpsd:PROG: NTP: shmat(229383,0,0) succeeded, segment 7 gpsd:PROG: successfully connected to the DBUS system bus gpsd:PROG: shmget(0x47505344, 8928, 0666) for SHM export succeeded gpsd:PROG: shmat() for SHM export succeeded, segment 262152 gpsd:INFO: stashing device /dev/ttymxc2 at slot 0 gpsd:INFO: running with effective group ID 0 gpsd:INFO: running with effective user ID 0 gpsd:INFO: startup at 2015-10-31T11:31:19.000Z (1446291079) ^Cgpsd:WARN: received terminating signal 2. gpsd:WARN: exiting.
* Add a FIXME comment abot the emergency fix.Eric S. Raymond2015-06-011-0/+1
|
* Copy structs using assignment, not memcpy().Zbigniew Chyla2015-05-311-1/+1
|
* Free a GPS if it fails to activate on awakening. Fixes crash-exit bug.Eric S. Raymond2015-05-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modified version of a patch by "Brian T (gmail)" <btuchten@gmail.com>. He reports: Using GPSd 3.14, if it is told to read TTY device, and then a USB GPS device is added, and then the USB device is removed, GPSd exits. I had seen others talk about this but never found an answer. The work around I found was the attached patch. I had it as a new command line option, but removed that part after reading the hacking guidelines. Tested this way: Device on /dev/ttyS4 gpsdctl add /dev/ttyUSB1 GPSd can be seen polling both devices Physically remove USB device GPSd continues processing ttyS4, removes ttyUSB1 Device on /dev/ttyS4 Add device on /dev/ttyUSB1 gpsdctl remove /dev/ttyS4 Physically remove USB device GPSd waits on select() gpsdctl add /dev/ttyS4 GPSd starts processing ttyS4, removes ttyUSB1 Insert USB device gpsdctl add /dev/ttyUSB1 GPSd polls both devices I did notice that if USB1 is the last device left in the list, and the USB is pulled, GPSd does not syslog the message it was removed until a new device (like ttyS4) is added back in. Then the syslog message shows up. The reason for this is some embedded cellular modules have embedded GPS. Sometimes the modules reset without notice, so the device is gone from the USB stack before a udev script can catch it and send a "gpsdctl remove xxxx", and then GPSd exits.
* Stop reporting bad GPS serial time to ntp/chrony.Gary E. Miller2015-05-281-0/+3
| | | | | | | | | | | When no fix present, GPS serial time, which is usually useless, was still sent to ntpshm and chrony sockets. Garmin was guarding the time properly, but no other driver. NMEA driver used to do this until commit a9f44d1cb9db5a27832782bbe2685e66433c6d3a in 2013. Other drivers had this bug a longer time. This shows up the need for time regression testing.
* A gaggle of whitespace gaffs.Gary E. Miller2015-04-301-7/+7
|
* Revert "Copy structs using assignment, not memcpy()."Gary E. Miller2015-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | This reverts commit d1965788249d7e22cdde4021d452cf0dc6c6b9bd. This breaks my build on Gentoo running gcc 4.9.2 libgps_shm.c: In function 'int gps_shm_read(gps_data_t*)': libgps_shm.c:122:12: error: no match for 'operator=' (operand types are 'gps_data_t' and 'volatile gps_data_t') noclobber = shared->gpsdata; ^ libgps_shm.c:122:12: note: candidate is: In file included from gpsd.h:350:0, from libgps_shm.c:30: gps.h:1918:8: note: gps_data_t& gps_data_t::operator=(const gps_data_t&) struct gps_data_t { ^ gps.h:1918:8: note: no known conversion for argument 1 from 'volatile gps_data_t' to 'const gps_data_t&'
* Copy structs using assignment, not memcpy().Zbigniew Chyla2015-04-281-1/+1
|