FreeCalypso > hg > freecalypso-tools
changeset 608:9d9c241f2c84
libserial-newlnx experimental change to set ASYNC_LOW_LATENCY
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Feb 2020 06:23:22 +0000 |
parents | d5abcbbf7432 |
children | ffd606adb039 |
files | libserial-newlnx/openport.c |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libserial-newlnx/openport.c Tue Feb 11 21:27:40 2020 +0000 +++ b/libserial-newlnx/openport.c Wed Feb 12 06:23:22 2020 +0000 @@ -5,6 +5,7 @@ #include <sys/types.h> #include <sys/file.h> #include <sys/ioctl.h> +#include <linux/serial.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -14,11 +15,25 @@ open_serial_port(ttyport) char *ttyport; { + struct serial_struct kernel_serial_settings; + target_fd = open(ttyport, O_RDWR|O_NONBLOCK); if (target_fd < 0) { perror(ttyport); exit(1); } ioctl(target_fd, TIOCEXCL); + /* + * It appears that some miscreants have modified recent Linux kernel + * versions (newer than linux-4.4.14 of Slackware 14.2) to insert + * a delay of 10 ms before select system call returns when serial + * input is ready; this Linux kernel misbehaviour majorly slows down + * many of our operations. It appears that we need to set the + * ASYNC_LOW_LATENCY flag in TIOCSSERIAL in order to get the old + * sane behaviour back. + */ + ioctl(target_fd, TIOCGSERIAL, &kernel_serial_settings); + kernel_serial_settings.flags |= ASYNC_LOW_LATENCY; + ioctl(target_fd, TIOCSSERIAL, &kernel_serial_settings); return 0; }