mraa
2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
This file defines the UART interface for libmraa
Public Member Functions | |
Uart (int uart) | |
Uart (std::string path) | |
Uart (void *uart_context) | |
~Uart () | |
std::string | getDevicePath () |
int | read (char *data, int length) |
int | write (const char *data, int length) |
std::string | readStr (int length) |
int | writeStr (std::string data) |
bool | dataAvailable (unsigned int millis=0) |
Result | flush () |
Result | sendBreak (int duration) |
Result | setBaudRate (unsigned int baud) |
Result | setMode (int bytesize, UartParity parity, int stopbits) |
Result | setFlowcontrol (bool xonxoff, bool rtscts) |
Result | setTimeout (int read, int write, int interchar) |
Result | setNonBlocking (bool nonblock) |
|
inline |
Uart Constructor, takes a pin number which will map directly to the linux uart number, this 'enables' the uart, nothing more
uart | the index of the uart set to use |
|
inline |
Uart Constructor, takes a string to the path of the serial interface that is needed.
path | the index of the uart set to use |
|
inline |
Uart Constructor, takes a pointer to the UART context and initialises the UART class
uart_context | void * to a UART context |
|
inline |
Get string with tty device path within Linux For example. Could point to "/dev/ttyS0"
|
inline |
Read bytes from the device into char* buffer
data | buffer pointer |
length | maximum size of buffer |
|
inline |
Write bytes in char* buffer to a device
data | buffer pointer |
length | maximum size of buffer |
|
inline |
Read bytes from the device into a String object
length | to read |
std::bad_alloc | If there is no space left for read. |
|
inline |
Write bytes in String object to a device
data | string to write |
|
inline |
Check to see if data is available on the device for reading
millis | number of milliseconds to wait, or 0 to return immediately |
|
inline |
Flush the outbound data. Blocks until complete.
|
inline |
Send a break to the device. Blocks until complete.
duration | When 0, send a break lasting at least 250 milliseconds, and not more than 500 milliseconds. When non zero, the break duration is implementation specific. |
|
inline |
Set the baudrate. Takes an int and will attempt to decide what baudrate is to be used on the UART hardware.
baud | unsigned int of baudrate i.e. 9600 |
|
inline |
Set the transfer mode For example setting the mode to 8N1 would be "dev.setMode(8,UART_PARITY_NONE , 1)"
bytesize | data bits |
parity | Parity bit setting |
stopbits | stop bits |
|
inline |
Set the flowcontrol
xonxoff | XON/XOFF Software flow control. |
rtscts | RTS/CTS out of band hardware flow control |
|
inline |
Set the timeout for read and write operations <= 0 will disable that timeout
read | read timeout |
write | write timeout |
interchar | inbetween char timeout |
|
inline |
Set the blocking state for write operations
nonblock | new nonblocking state |