Private
Public Access
2
0

examples: uart: Fix port configuration

mraa_uart_settings retrieves the settings, it does not apply them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka
2021-04-30 08:49:12 +02:00
committed by Tom Ingleby
parent 11e65ee9bf
commit 13ce6ea446

View File

@@ -46,7 +46,6 @@ main(int argc, char** argv)
int baudrate = 9600, stopbits = 1, databits = 8; int baudrate = 9600, stopbits = 1, databits = 8;
mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE; mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE;
unsigned int ctsrts = FALSE, xonxoff = FALSE; unsigned int ctsrts = FALSE, xonxoff = FALSE;
const char* name = NULL;
/* install signal handler */ /* install signal handler */
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
@@ -63,8 +62,15 @@ main(int argc, char** argv)
} }
/* set serial port parameters */ /* set serial port parameters */
status = status = mraa_uart_set_baudrate(uart, baudrate);
mraa_uart_settings(-1, &dev_path, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff); 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) { if (status != MRAA_SUCCESS) {
goto err_exit; goto err_exit;
} }