summaryrefslogtreecommitdiff
path: root/gpsd.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Fix misleading PPS JSON documentation. Still needs work.Gary E. Miller2015-04-051-0/+2
|
* Add precision to the PPS JSON message.Gary E. Miller2015-04-011-2/+10
|
* Increase consistency of names. No code changes.Eric S. Raymond2015-04-011-1/+1
|
* Clean up PPS monitor interface with renames, and additional documentation.Eric S. Raymond2015-04-011-2/+2
|
* Propagate in-band time to PPS-only devices each time a fresh fix comes in.Eric S. Raymond2015-03-311-35/+12
| | | | All regression tests pass.
* Prefix two more PPS log outputs with PPS:Gary E. Miller2015-03-311-3/+4
|
* Document some return codes, one more small step at /dev/ppsX handling.Gary E. Miller2015-03-311-2/+20
|
* Write scan-build suppressions to it runs clean.Eric S. Raymond2015-03-301-0/+4
| | | | | | 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-90/+20
| | | | | | | | | | | | | | | | | | | 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.
* Defensive coding for the presence of NULs.Eric S. Raymond2015-03-301-3/+3
|
* Only you cabn prevent obscure magic numbers.Eric S. Raymond2015-03-301-2/+0
| | | | All regression tests pass.
* Improved code for associating a lone PPS to in-band time.Eric S. Raymond2015-03-291-13/+12
| | | | All regression tests pass.
* Minor splint annotation of new /dev/pps code.Eric S. Raymond2015-03-291-0/+2
|
* Attempt to support /dev/pps devices.Eric S. Raymond2015-03-291-1/+42
| | | | | | | | | | | | | | | | For these devices: 1. The hunt loop is disabled. 2. When emitting a PPS report, all other (non-/dev/pps) devices are checked for in-band time. If no time is found the report is not emitted. If time is ound its seconds field is incremented by 1 and it is used Every PPS from a device resets its online time, which should prevent /dev/pps devices from timing out too often. Not yet tested with a /dev/pps device. All regression tests oass.
* More offerings to the splint god.Gary E. Miller2015-03-281-1/+4
|
* Guard header files that raspbian splint hates.Gary E. Miller2015-03-261-5/+5
| | | | Trying to cherry pick instead of just +siip-sys-headers
* Remove redundant $ifndefGary E. Miller2015-03-261-2/+0
| | | | | | [...] Kinda obvious?
* Remove #ifdef with no body contentGary E. Miller2015-03-251-2/+0
|
* Acccept doing synchronization logging at only 1s granularity to remove floats.Eric S. Raymond2015-03-201-1/+1
| | | | All regression tests pass.
* Float elimination. All regression tests pass.Eric S. Raymond2015-03-201-4/+3
|
* Revert "Take a GPS file descriptor ourut of the read set when deactivating."Eric S. Raymond2015-03-171-1/+0
| | | | Ugh. Unnecessary, as rfds is set inside of gpsd_await_data().
* Take a GPS file descriptor ourut of the read set when deactivating.Eric S. Raymond2015-03-171-0/+1
| | | | All regression tests pass.
* splint/cppcheck/coverity prerelease cleanup.Eric S. Raymond2015-03-131-2/+3
|
* If command sockets weren't opend, a stale pidfile could linger.Eric S. Raymond2015-03-131-0/+1
| | | | All regression tests pass.
* Simplify the thread-monitor interface.Eric S. Raymond2015-03-111-1/+1
| | | | PPS observed live on GR601W.
* Float elimination. We only need integer time after timeouts.Eric S. Raymond2015-03-091-6/+10
| | | | | | | splint had a minor hissy fit after this change atround code that should have been completely unrelated. Shut it up, too. All regression tests pass.
* splint cleanup of new code.Eric S. Raymond2015-03-081-1/+1
|
* 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-4/+0
|
* gpsd-report() -> gpsd_log()Eric S. Raymond2015-03-071-264/+272
| | | | | | | | | | | | | | | | This change is done so we can add a "log" hook to the pps_thread_t structure (this is not done yet) and harmonize with the name of the outer logging function. If that name had been left as gpsd_report() there would have been scope for bad confusion with the report_hook member. Also, remove two stray duplicative printf calls from the NMEA2000 driver (drivers shouldn't have printfs!) and fix one typo. This is a step towards factoring out ntplib. For that to happen, the PPS thread code needs to be decoupled from the core session structure. No logic changes. Object compatibility preserved. All regression tests pass.
* Factor PPS-related members of struct gps_device_t into a pps_thread_t structure.Eric S. Raymond2015-03-071-1/+3
| | | | | | | | | | | 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 "ntplib extraction requires libgpsd object format bump to 23."Eric S. Raymond2015-03-071-1/+1
| | | | We need to sneak up on this in a more subtle way.
* ntplib extraction requires libgpsd object format bump to 23.Eric S. Raymond2015-03-071-1/+1
| | | | | | The new struct ppsthread_t isolates the interface to the PPS monitor loop. It will need more members before we're done, including some reporting hooks.
* Generqte -V messages in a uniform way.Eric S. Raymond2015-03-021-1/+1
| | | | All regression tests pass.
* Warning hunting cleanup unused variable af in gpsdJon Schlueter2015-02-271-4/+6
| | | | | | | for scons minimal=on clang identified af as assigned but never used. on closer inspection af is a file static and a parameter to one of the functions renamed file static and guarded it with SOCKET_EXPORT_ENABLED
* fix broken build scons minimal=on ntp=on in gpsd.cJon Schlueter2015-02-241-0/+3
| | | | Missing ifdef guard for SOCKET_EXPORT around usage of notify_watchers