summaryrefslogtreecommitdiff
path: root/serial.c
Commit message (Collapse)AuthorAgeFilesLines
* Doc fix to serial.cKai Harrekilde-Petersen2019-04-161-1/+1
| | | | | | | | I was messing around in serial.c and noticed that the link to Linus' git repo (for devices.txt) was stale. The below 1-liner updates the link to a valid one. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Address Savannah bug #53621: Invalid JSON generated for an unreadable deviceEric S. Raymond2018-12-261-2/+13
|
* LICENSE: Update licenses for consistency. No functional changes.Gary E. Miller2018-11-191-1/+1
|
* The Quectel EC25 device used with the Linux 3.10.20 usb/option driverJean Pierre TOSONI2018-05-021-1/+2
| | | | | | | | | | | | makes gpsd hang when it closes the serial port after receiving a SIGTERM. Hanging is caused by the call to tcdrain(), which happens even when gpsd is in read-only mode (-b argument). In this mode, since nothing is ever written to the serial port, the tcdrain call is not needed. Skip it. Signed-off-by: Gary E. Miller <gem@rellim.com>
* SPDXify the licerse references.Eric S. Raymond2018-03-081-1/+1
|
* serial.c: make sure procentry->d_name fits in procpathGary E. Miller2018-02-081-2/+3
|
* OS X has no sys/sysmacros.h, so hide it.Gary E. Miller2016-08-161-0/+2
|
* cfmakeraw() needs _DEFAULT_SOURCEGary E. Miller2016-08-151-0/+3
|
* With C99, macro() needs sys/sysmacros.hGary E. Miller2016-08-151-1/+2
|
* usleep() is removed from POSIX-2008. Replace with nanosleep()Gary E. Miller2016-08-151-1/+6
| | | | I sure hope I did not drop a zero anywhere...
* revert error cchecking of tcsetattr() in gpsd_set_speed().Gary E. Miller2016-05-261-4/+10
| | | | | | | | | As the comment now says: strangely this fails on non-serial ports, but if we do not try, we get other failures. so ignore for now, as we always have, until it can be nailed down.
* Basically revert 56a2a6eb494c6dbc454bad518df8861c9258ad5bGary E. Miller2016-05-261-3/+1
| | | | | | | | | This was the wrong place to stop calls to gpsd_set_speed(). Other places call gpsd_set_speed() so the check for devices that should not have their speed set with tcsetattr() should be in in gpsd_set_speed. More on this soon.
* Attempting to solve tty mode prblems that have suraced sudenty.Eric S. Raymond2016-05-261-2/+33
| | | | Possibly temporary revert of close simplification, which looks like the culprit.
* Fix a bogus address.Eric S. Raymond2016-05-261-4/+4
|
* Add info on sourcetype to the error log on failure.Gary E. Miller2016-05-251-2/+2
| | | | | | The old log, on some hosts, was: gpsd:ERROR: SER: error setting port attributes: Invalid argument
* Do not try to set the speed on non-tty's.Gary E. Miller2016-05-251-1/+5
| | | | | isatty() says a /dev/pts is a tty, but /dev/pts will not accept ttyset speed changes.
* Test return of every tcsetattr() in serial.cGary E. Miller2016-05-161-3/+10
| | | | | But, as the man page says, a return of success does not mean 100% success
* Prefix logs from serial.c with SER:Gary E. Miller2016-05-161-14/+14
| | | | | | This makes it easy to trace the serial.c code: gpsd -nND 8 /dev/ttyS0 |& fgrep SER:
* Drop the logic to restore old tty parameters on device close.Eric S. Raymond2016-05-111-33/+2
| | | | | | | | Gary thinks it was fighting the autobaud loop. He's probably right, and the way we were trying to force HUPCL on old systems (forcing baud rate to 0) seems to cause misbehavior on the Raspberry Pi under Jessie. Solution: shoot the whole mess through the head. See if anyone complains.
* Address Savannah bug #45270: serial driver does not work properly on pipes.Eric S. Raymond2016-01-041-1/+4
| | | | | | | | | | | | | Simon Artott wrote: When using a pipe with the serial driver (e.g. stdin from another process) to provide NMEA data, the fd is set to blocking mode and gpsd_poll() gets stuck in a loop calling get_packet() because read() always waits for more data. I have to remove the "Switch back to blocking I/O now that CLOCAL is set" code from serial.c to get it to work. The driver should detect if the fd is a pipe and keep it set to non-blocking.
* Copy structs using assignment, not memcpy().Zbigniew Chyla2015-05-311-2/+1
|
* Trailing whitespace fixup.Gary E. Miller2015-04-301-2/+2
|
* Revert "Copy structs using assignment, not memcpy()."Gary E. Miller2015-04-281-1/+2
| | | | | | | | | | | | | | | | | | | | 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-2/+1
|
* Add a minimal PPS driver.Gary E. Miller2015-04-021-0/+1
| | | | | Now gpsctl, and friends, can return a pretty device name. And avoids a segfault on empty *device.
* Comment /dev/ppsX open flow.Gary E. Miller2015-03-311-1/+6
|
* Retire splint from our set of static analyzers.Eric S. Raymond2015-03-301-19/+2
| | | | | | | | | | | | | | | | | | | 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.
* Only you cabn prevent obscure magic numbers.Eric S. Raymond2015-03-301-9/+9
| | | | All regression tests pass.
* Do not let gpsd_serial_open() try to open a /dev/ppsGary E. Miller2015-03-291-1/+6
| | | | | | | | | | | | | For some reason the ppsthread no longer tries to open /dev/pps0, Either before or after this patch. Here is the current status: root@raspberrypi:/usr/local/src/GPS/gpsd/gpsd# gpsd -nND 6 /dev/pps0 /dev/ttyAMA0 |& fgrep pps0 gpsd:INFO: stashing device /dev/pps0 at slot 0 gpsd:ERROR: initial GPS device /dev/pps0 open failed gpsd:INFO: KPPS:/dev/ttyAMA0 checking /sys/devices/virtual/pps/pps0/path, [... no more output]
* Attempt to support /dev/pps devices.Eric S. Raymond2015-03-291-0/+6
| | | | | | | | | | | | | | | | 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.
* Clean up most spint errors. All regression tests pass.Eric S. Raymond2015-03-281-4/+2
|
* splint cleanup. Fixes for minor but real issues...Eric S. Raymond2015-03-281-0/+2
| | | | | ...no attempt to address the weird cross-platfprm variability we've seen lately. All regression tests pass.
* splint can't play the BLUEZGary E. Miller2015-03-251-0/+3
|
* Float elimination. All regression tests pass.Eric S. Raymond2015-03-201-1/+1
|
* Include path in faInclude path in file open failure messages.Eric S. Raymond2015-03-101-3/+6
|
* OS X, fix warning of missing cast speed_t -> unsigned longGary E. Miller2015-03-091-2/+2
|
* gpsd-report() -> gpsd_log()Eric S. Raymond2015-03-071-43/+43
| | | | | | | | | | | | | | | | 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.
* HAVE_BLUEZ -> ENABLE_BLUEZ. It's a feature flag, not a platform quirk.Eric S. Raymond2015-03-011-3/+3
| | | | | All regression tests pass.
* splint cleanup. All regressiion tests pass.Eric S. Raymond2015-02-091-1/+1
|
* Reinstate blocking I/O; it no longer breaks test rebuilds.Eric S. Raymond2015-02-091-22/+17
| | | | All regression tests pass.
* Revert to non-blocking I/O. Blocking I/O broke gps-makeregress.Eric S. Raymond2015-02-061-17/+22
| | | | | | | | | Regression tests pass with nonblocking I/O, but a regression test *rebuild* fails with timing errors. Much as we want a solution to the select-buzz problem, this change must go on hold until the root cause of the timing problems is found and fixed. Regression tests still pass.
* Now we open with nonblock, set CLOCAL, and then turn off nonblock.Eric S. Raymond2015-02-021-2/+15
| | | | All regression tests pass.
* O_NONBLOCK was causing more grief than we knew. We don't need VTIME!Eric S. Raymond2015-02-021-1/+1
| | | | All regression tests pass.
* Revert mistaken use of CLOCAL in open(2).Eric S. Raymond2015-02-021-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All regression tests pass. Hal Murray thinks we should be opening the device, setting CLOCAL with tcsetattr() , closing it, and reopening. This is a good idea in principle but doing it right will require serious preparatory surgery on the serial.c code. According to StackOverflow, the specific thing CLOCAL does is disable signaling the process on CD drop. The Modem HOWTO says this: Normally a CD (Carrier Detect) signal (on the CD wire for an external modem) is [not] required before a serial port can be opened. But if stty has negated clocal (-clocal), then the port requires CD raised for the port to open and remain open. Actually, a skilled programmer can write the program in such a way as to force the port to open even when CD and clocal say not to. So if stty shows -clocal then there might be a problem with opening the port. But for dial-in, in some cases you may want -clocal so that when the remote modem stops sending a carrier and CD drops, the port will close and terminate all processes running on it. The above is internally inconsistent without the inserted "not". The Gnu C library documentation says: Macro: tcflag_t CLOCAL If this bit is set, it indicates that the terminal is connected "locally" and that the modem status lines (such as carrier detect) should be ignored. On many systems if this bit is not set and you call open without the O_NONBLOCK flag set, open blocks until a modem connection is established. If this bit is not set and a modem disconnect is detected, a SIGHUP signal is sent to the controlling process group for the terminal (if it has one). Normally, this causes the process to exit; see 24. Signal Handling. Reading from the terminal after a disconnect causes an end-of-file condition, and writing causes an EIO error to be returned. The terminal device must be closed and reopened to clear the condition.
* Open ttys with CLOCAL, following a suggestion by Hal Murray.Eric S. Raymond2015-02-021-2/+2
| | | | | | Also, zero in on shorter delays in the regression tests. All regression tests pass.
* Change to using blocking I/O and VTIME.Eric S. Raymond2015-02-021-20/+4
| | | | | | | This addresses the buzzing-select problem, but the cost is that the GPS regression tests require longer delays and may hang if the delays are too short. All regression tests pass.
* Back out the attempt to use VTIME.Eric S. Raymond2015-01-311-56/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Matthias Drochner at http://lists.lysator.liu.se/pipermail/lsh-bugs/2003q4/000151.html: I thought I'd give lsh a try, just to see how it compares to openssh... The client didn't work well on NetBSD, got a message like "unexpected EWOULDBLOCK" on each keystroke. Looked a bit deeper and found that stdin is set to O_NONBLOCK and a raw tty mode with c_cc[VMIN] > 1 and c_cc[VTIME] > 0. I'll append a little test program which does the same. I've tried it on 3 operating systems (Linux, NetBSD, Digital UNIX), and it behaves differently on each: -on Linux, if a key is pressed, the read returns immediately with that one character -on NetBSD, the read returns with no data but EWOULDBLOCK -on D'UNIX, the poll() doesn't teturn before 4 keypresses are done; the read() returns these 4 characters Indeed, in SUSv2's termios page is a sentence which says that if both O_NONBLOCK and VTIME>0 are set, the behaviour is more or less undefined. I've solved my immediate problems by setting VMIN to 1 instead of 4 in unix_interact.c:do_make_raw(), but VTIME is still pointless, so I wouldn't call this a clean solution. All regression tests pass.
* Add workaround for VMIN/VTIME situation.Greg Troxel2015-01-301-1/+15
| | | | | On NetBSD, there's something wrong between gpsd code, select and termios's VMIN/VTIME. Until debugged, avoid it.
* Alas, we can't use ICANON.Eric S. Raymond2015-01-291-1/+5
| | | | | | | | For the moment, we do nothing with the textual argument to gpsd_optimize_io(). We'd like to use it to set ICANON mode and let the kernel do all the line buffering itself. The problem with this is that VTIME stops working in ICANON, so a binary packet coming up the wire would result in no further input being seen.
* Rare I/O with timeout seems to work. This replaces the adaptive-delay code.Eric S. Raymond2015-01-291-4/+31
|