UART is the Universal asynchronous receiver/transmitter interface to libmraa. It allows the exposure of UART pins on supported boards. With functionality to expand at a later date.
if (uart == NULL) {
fprintf(stderr, "Failed to initialize UART\n");
goto err_exit;
}
while (flag) {
sleep(1);
}
|
mraa_uart_context | mraa_uart_init (int uart) |
|
mraa_uart_context | mraa_uart_init_raw (const char *path) |
|
mraa_result_t | mraa_uart_flush (mraa_uart_context dev) |
|
mraa_result_t | mraa_uart_sendbreak (mraa_uart_context dev, int duration) |
|
mraa_result_t | mraa_uart_set_baudrate (mraa_uart_context dev, unsigned int baud) |
|
mraa_result_t | mraa_uart_set_mode (mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits) |
|
mraa_result_t | mraa_uart_set_flowcontrol (mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts) |
|
mraa_result_t | mraa_uart_set_timeout (mraa_uart_context dev, int read, int write, int interchar) |
|
mraa_result_t | mraa_uart_set_non_blocking (mraa_uart_context dev, mraa_boolean_t nonblock) |
|
const char * | mraa_uart_get_dev_path (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 *rtscts, unsigned int *xonxoff) |
|
mraa_result_t | mraa_uart_stop (mraa_uart_context dev) |
|
int | mraa_uart_read (mraa_uart_context dev, char *buf, size_t length) |
|
int | mraa_uart_write (mraa_uart_context dev, const char *buf, size_t length) |
|
mraa_boolean_t | mraa_uart_data_available (mraa_uart_context dev, unsigned int millis) |
|
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 * |
rtscts, |
|
|
unsigned int * |
xonxoff |
|
) |
| |
Get the current settings of an UART. This is an unintrusive function. Meaning it intends not to change anything, only read the values without disturbing.
All but the first index parameter are "outparameters". That means they can contain values on return. If any parameter is not interesting, a null pointer can be sent instead as a placeholder. The devpath parameter can be either in or out parameter. In case of a negative index, the UART is identified using *devpath instead. This functionality is intended for and needed by for instance USB serial adapters.
In case of a non-success return value, the outparameters are undefined.
- Parameters
-
index | uart index to look up, if negative, *devpath will be used instead |
devpath | points to the device path of the UART, eg: /dev/ttyS0 |
name | outparameter that on return will point to the name of the UART |
baudrate | pointer to an integer to contain the current baudrate (0–4M) |
databits | pointer to an integer to contain the number databits (5–8) |
stopbits | pointer to an integer to contain the number stopbits (1–2) |
parity | will contain the current parity mode |
rtscts | will point to non-zero if CTS/RTS flow control is enabled, zero otherwise |
xonxoff | will point to a non-zero value if xon/xoff flow control is enabled |
- Returns
- result