diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-05-04 10:51:44 +0200 |
---|---|---|
committer | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-05-04 11:52:09 +0200 |
commit | 4757db946fd5c4372899bee3e73b504db3c22055 (patch) | |
tree | 5aa31f032dcebc6fa673a7938180ddcb504325d8 | |
parent | d82825c25a651c8202a7d836c6ca3612adf3e67f (diff) | |
download | microcom-4757db946fd5c4372899bee3e73b504db3c22055.tar.gz microcom-4757db946fd5c4372899bee3e73b504db3c22055.tar.xz |
serial: configure CLOCAL/CREAD for non-Linux compatibility
While Linux configures both CLOCAL and CREAD on UARTs by default[1],
other *nix systems might not.
E.g. macOS only sets CREAD, but not CLOCAL with the result that
write(2) indefinitely returns with errno = EAGAIN, waiting for a DCD
activation that never happens.
Fix this by explicitly OR'ing CLOCAL. On Linux, this doesn't
matter, but on macOS, it enables microcom to output user input.
CREAD is added as well to account for systems that don't set it by
default. This is in-line with what Michael R. Sweet's
"Serial Programming Guide for POSIX Operating Systems"[1] suggests.
Patch tested on macOS 10.14.1 and Linux 4.20.13.
[1]: https://github.com/torvalds/linux/blob/v4.20/drivers/tty/serial/serial_core.c#L2513
[2]: https://www.cmrr.umn.edu/~strupp/serial.html
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
-rw-r--r-- | serial.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -34,7 +34,7 @@ static void init_comm(struct termios *pts) /* some things we want to set arbitrarily */ pts->c_lflag &= ~ICANON; pts->c_lflag &= ~(ECHO | ECHOCTL | ECHONL); - pts->c_cflag |= HUPCL; + pts->c_cflag |= HUPCL | CREAD | CLOCAL; pts->c_iflag |= IGNBRK; pts->c_cc[VMIN] = 1; pts->c_cc[VTIME] = 0; |