mraa
1.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
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.
Go to the source code of this file.
Functions | |
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_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_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) |
Typedefs | |
typedef struct _uart * | mraa_uart_context |
mraa_uart_context mraa_uart_init | ( | int | uart | ) |
Initialise uart_context, uses board mapping
uart | the index of the uart set to use |
mraa_uart_context mraa_uart_init_raw | ( | const char * | path | ) |
Initialise a raw uart_context. No board setup.
path | for example "/dev/ttyS0" |
mraa_result_t mraa_uart_flush | ( | mraa_uart_context | dev | ) |
Flush the outbound data. Blocks until complete.
dev | The UART context |
mraa_result_t mraa_uart_set_baudrate | ( | mraa_uart_context | dev, |
unsigned int | baud | ||
) |
Set the baudrate. Takes an int and will attempt to decide what baudrate is to be used on the UART hardware.
dev | The UART context |
baud | unsigned int of baudrate i.e. 9600 |
mraa_result_t mraa_uart_set_mode | ( | mraa_uart_context | dev, |
int | bytesize, | ||
mraa_uart_parity_t | parity, | ||
int | stopbits | ||
) |
Set the transfer mode For example setting the mode to 8N1 would be "mraa_uart_set_mode(dev, 8,MRAA_UART_PARITY_NONE , 1)"
dev | The UART context |
bytesize | data bits |
parity | Parity bit setting |
stopbits | stop bits |
mraa_result_t mraa_uart_set_flowcontrol | ( | mraa_uart_context | dev, |
mraa_boolean_t | xonxoff, | ||
mraa_boolean_t | rtscts | ||
) |
Set the flowcontrol
dev | The UART context |
xonxoff | XON/XOFF Software flow control. |
rtscts | RTS/CTS out of band hardware flow control |
mraa_result_t mraa_uart_set_timeout | ( | mraa_uart_context | dev, |
int | read, | ||
int | write, | ||
int | interchar | ||
) |
Set the timeout for read and write operations <= 0 will disable that timeout
dev | The UART context |
read | read timeout |
write | write timeout |
interchar | inbetween char timeout |
mraa_result_t mraa_uart_set_non_blocking | ( | mraa_uart_context | dev, |
mraa_boolean_t | nonblock | ||
) |
Set the blocking state for write operations
dev | The UART context |
nonblock | new nonblocking state |
const char* mraa_uart_get_dev_path | ( | mraa_uart_context | dev | ) |
Get Char pointer with tty device path within Linux For example. Could point to "/dev/ttyS0"
dev | uart context |
mraa_result_t mraa_uart_stop | ( | mraa_uart_context | dev | ) |
Destroy a mraa_uart_context
dev | uart context |
int mraa_uart_read | ( | mraa_uart_context | dev, |
char * | buf, | ||
size_t | length | ||
) |
Read bytes from the device into a buffer
dev | uart context |
buf | buffer pointer |
length | maximum size of buffer |
int mraa_uart_write | ( | mraa_uart_context | dev, |
const char * | buf, | ||
size_t | length | ||
) |
Write bytes in buffer to a device
dev | uart context |
buf | buffer pointer |
length | maximum size of buffer |
mraa_boolean_t mraa_uart_data_available | ( | mraa_uart_context | dev, |
unsigned int | millis | ||
) |
Check to see if data is available on the device for reading
dev | uart context |
millis | number of milliseconds to wait, or 0 to return immediately |