From 11e65ee9bf284bad487f177e1a742ae2f9dca0f5 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 30 Apr 2021 08:40:27 +0200 Subject: [PATCH] uart: Convert rtscts and xonxoff in mraa_uart_settings into mraa_boolean_t This aligns the getter with the setter (mraa_uart_set_flowcontrol). Signed-off-by: Jan Kiszka --- api/mraa/uart.h | 8 ++++---- src/uart/uart.c | 6 +++--- tools/mraa-uart.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/mraa/uart.h b/api/mraa/uart.h index 3495b2f..64835a8 100644 --- a/api/mraa/uart.h +++ b/api/mraa/uart.h @@ -171,8 +171,8 @@ const char* mraa_uart_get_dev_path(mraa_uart_context dev); * @param databits pointer to an integer to contain the number databits (5--8) * @param stopbits pointer to an integer to contain the number stopbits (1--2) * @param parity will contain the current parity mode - * @param rtscts will point to non-zero if CTS/RTS flow control is enabled, zero otherwise - * @param xonxoff will point to a non-zero value if xon/xoff flow control is enabled + * @param rtscts will point to true if CTS/RTS flow control is enabled + * @param xonxoff will point to a true if xon/xoff flow control is enabled * @return result */ mraa_result_t @@ -183,8 +183,8 @@ mraa_uart_settings(int index, int* databits, int* stopbits, mraa_uart_parity_t* parity, - unsigned int* rtscts, - unsigned int* xonxoff); + mraa_boolean_t* rtscts, + mraa_boolean_t* xonxoff); /** * Destroy a mraa_uart_context diff --git a/src/uart/uart.c b/src/uart/uart.c index 8522e01..36517fa 100644 --- a/src/uart/uart.c +++ b/src/uart/uart.c @@ -337,7 +337,7 @@ mraa_uart_stop(mraa_uart_context dev) } mraa_result_t -mraa_uart_settings(int index, const char **devpath, const char **name, int* baudrate, int* databits, int* stopbits, mraa_uart_parity_t* parity, unsigned int* ctsrts, unsigned int* xonxoff) { +mraa_uart_settings(int index, const char **devpath, const char **name, int* baudrate, int* databits, int* stopbits, mraa_uart_parity_t* parity, mraa_boolean_t* ctsrts, mraa_boolean_t* xonxoff) { struct termios term; int fd; @@ -415,11 +415,11 @@ mraa_uart_settings(int index, const char **devpath, const char **name, int* baud } if (ctsrts != NULL) { - *ctsrts = term.c_cflag & CRTSCTS; + *ctsrts = (term.c_cflag & CRTSCTS) != 0; } if (xonxoff != NULL) { - *xonxoff = term.c_iflag & (IXON|IXOFF); + *xonxoff = (term.c_iflag & (IXON|IXOFF)) != 0; } close(fd); diff --git a/tools/mraa-uart.c b/tools/mraa-uart.c index 77123f5..384f13b 100644 --- a/tools/mraa-uart.c +++ b/tools/mraa-uart.c @@ -106,7 +106,7 @@ main(int argc, const char** argv) { int baudrate = 115200, stopbits = 1, databits = 8; mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE; - unsigned int ctsrts = FALSE, xonxoff = FALSE; + mraa_boolean_t ctsrts = FALSE, xonxoff = FALSE; const char *name = NULL, *dev = NULL; double recieve_timeout = 0.0;