summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2016-05-11 14:53:39 -0400
committerEric S. Raymond <esr@thyrsus.com>2016-05-11 14:53:39 -0400
commitf4dc590bf6561545af4a7784ac198c11fd928726 (patch)
tree9b8083b69c913419afc4560f64e3c209a4117bfe /serial.c
parent807ba61ffadb4311bbbb0dc24b926cc708ad51a0 (diff)
downloadgpsd-f4dc590bf6561545af4a7784ac198c11fd928726.tar.gz
Drop the logic to restore old tty parameters on device close.
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.
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c35
1 files changed, 2 insertions, 33 deletions
diff --git a/serial.c b/serial.c
index d8bdd8c7..cce4371d 100644
--- a/serial.c
+++ b/serial.c
@@ -216,7 +216,7 @@ speed_t gpsd_get_speed(const struct gps_device_t *dev)
speed_t gpsd_get_speed_old(const struct gps_device_t *dev)
{
- return gpsd_get_speed_termios(&dev->ttyset_old);
+ return gpsd_get_speed_termios(&dev->ttyset);
}
char gpsd_get_parity(const struct gps_device_t *dev)
@@ -541,10 +541,6 @@ int gpsd_serial_open(struct gps_device_t *session)
session->lexer.type = BAD_PACKET;
if (isatty(session->gpsdata.gps_fd) != 0) {
- /* Save original terminal parameters */
- if (tcgetattr(session->gpsdata.gps_fd, &session->ttyset_old) != 0)
- return UNALLOCATED_FD;
- session->ttyset = session->ttyset_old;
memset(session->ttyset.c_cc, 0, sizeof(session->ttyset.c_cc));
//session->ttyset.c_cc[VTIME] = 1;
/*
@@ -559,7 +555,7 @@ int gpsd_serial_open(struct gps_device_t *session)
* over all devices.
*/
session->ttyset.c_cflag &= ~(PARENB | PARODD | CRTSCTS | CSTOPB);
- session->ttyset.c_cflag |= CREAD | CLOCAL;
+ session->ttyset.c_cflag |= CREAD | CLOCAL| HUPCL;
session->ttyset.c_iflag = session->ttyset.c_oflag =
session->ttyset.c_lflag = (tcflag_t) 0;
@@ -702,33 +698,6 @@ void gpsd_close(struct gps_device_t *session)
(void)ioctl(session->gpsdata.gps_fd, (unsigned long)TIOCNXCL);
#endif /* TIOCNXCL */
(void)tcdrain(session->gpsdata.gps_fd);
- if (isatty(session->gpsdata.gps_fd) != 0) {
- /* force hangup on close on systems that don't do HUPCL properly */
- (void)cfsetispeed(&session->ttyset, (speed_t) B0);
- (void)cfsetospeed(&session->ttyset, (speed_t) B0);
- (void)tcsetattr(session->gpsdata.gps_fd, TCSANOW,
- &session->ttyset);
- }
- /* this is the clean way to do it */
- session->ttyset_old.c_cflag |= HUPCL;
- /*
- * Don't revert the serial parameters if we didn't have to mess with
- * them the first time. Economical, and avoids tripping over an
- * obscure Linux 2.6 kernel bug that disables threaded
- * ioctl(TIOCMWAIT) on a device after tcsetattr() is called.
- */
- if (cfgetispeed(&session->ttyset_old) != cfgetispeed(&session->ttyset) || (session->ttyset_old.c_cflag & CSTOPB) != (session->ttyset.c_cflag & CSTOPB)) {
- /*
- * If we revert, keep the most recent baud rate.
- * Cuts down on autobaud overhead the next time.
- */
- (void)cfsetispeed(&session->ttyset_old,
- (speed_t) session->gpsdata.dev.baudrate);
- (void)cfsetospeed(&session->ttyset_old,
- (speed_t) session->gpsdata.dev.baudrate);
- (void)tcsetattr(session->gpsdata.gps_fd, TCSANOW,
- &session->ttyset_old);
- }
gpsd_log(&session->context->errout, LOG_SPIN,
"close(%d) in gpsd_close(%s)\n",
session->gpsdata.gps_fd, session->gpsdata.dev.path);