From 13ce6ea4461238137f2960152f428e9e025e71f3 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 30 Apr 2021 08:49:12 +0200 Subject: [PATCH] examples: uart: Fix port configuration mraa_uart_settings retrieves the settings, it does not apply them. Signed-off-by: Jan Kiszka --- examples/c/uart_advanced.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/c/uart_advanced.c b/examples/c/uart_advanced.c index 140408d..002491e 100644 --- a/examples/c/uart_advanced.c +++ b/examples/c/uart_advanced.c @@ -46,7 +46,6 @@ main(int argc, char** argv) int baudrate = 9600, stopbits = 1, databits = 8; mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE; unsigned int ctsrts = FALSE, xonxoff = FALSE; - const char* name = NULL; /* install signal handler */ signal(SIGINT, sig_handler); @@ -63,8 +62,15 @@ main(int argc, char** argv) } /* set serial port parameters */ - status = - mraa_uart_settings(-1, &dev_path, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff); + status = mraa_uart_set_baudrate(uart, baudrate); + if (status != MRAA_SUCCESS) { + goto err_exit; + } + status = mraa_uart_set_mode(uart, databits, parity, stopbits); + if (status != MRAA_SUCCESS) { + goto err_exit; + } + status = mraa_uart_set_flowcontrol(uart, xonxoff, ctsrts); if (status != MRAA_SUCCESS) { goto err_exit; }