From aeb0b331b53bb79cd285735aef9be974dc668f05 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 30 Apr 2021 07:57:59 +0200 Subject: [PATCH] uart: Fix software flow control management Rather than updating IXON/IXOFF in termios, mraa_uart_set_flowcontrol was incorrectly issuing a stop or start character on mode changes. This lead to spurious transmission in setups that actually wanted to disable software flow control. And it prevented enabling it (which could have been checked also by reading back the state via mraa_uart_settings). Signed-off-by: Jan Kiszka --- src/uart/uart.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/uart/uart.c b/src/uart/uart.c index f1a76d2..8522e01 100644 --- a/src/uart/uart.c +++ b/src/uart/uart.c @@ -616,16 +616,6 @@ mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_bo } } - // hardware flow control - int action = TCIOFF; - if (xonxoff) { - action = TCION; - } - if (tcflow(dev->fd, action)) { - return MRAA_ERROR_FEATURE_NOT_SUPPORTED; - } - - // rtscts struct termios termio; // get current modes @@ -634,6 +624,12 @@ mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_bo return MRAA_ERROR_INVALID_RESOURCE; } + if (xonxoff) { + termio.c_iflag |= IXON|IXOFF; + } else { + termio.c_iflag &= ~(IXON|IXOFF); + } + if (rtscts) { termio.c_cflag |= CRTSCTS; } else {