Uart Class
This file defines the UART interface for libmraa
Item Index
Methods
Uart
-
uart
Uart Constructor, takes a pin number which will map directly to the linux uart number, this 'enables' the uart, nothing more
Parameters:
-
uart
Numberthe index of the uart set to use
Returns:
Uart
-
path
Uart Constructor, takes a string to the path of the serial interface that is needed.
Parameters:
-
path
Stringthe index of the uart set to use
Returns:
getDevicePath
()
String
Get string with tty device path within Linux For example. Could point to "/dev/ttyS0"
Returns:
char pointer of device path
read
-
length
Read length bytes from the device
Parameters:
-
length
NumberSize of read in bytes to make
Returns:
Data read
write
-
length
Write length bytes to the device
Parameters:
-
length
NumberSize of buffer to send
Returns:
Result of operation
readStr
-
length
Read bytes from the device into a String object
Parameters:
-
length
Numberto read
Returns:
string of data
writeStr
-
data
Write bytes in String object to a device
Parameters:
-
data
Stringstring to write
Returns:
the number of bytes written, or -1 if an error occurred
dataAvailable
-
millis
Check to see if data is available on the device for reading
Parameters:
-
millis
Numbernumber of milliseconds to wait, or 0 to return immediately
Returns:
true if there is data available to read, false otherwise
flush
()
Enum Result
Flush the outbound data. Blocks until complete.
Returns:
Result of operation
sendBreak
-
duration
Send a break to the device. Blocks until complete.
Parameters:
-
duration
NumberWhen 0, send a break lasting at least 250 milliseconds, and not more than 500 milliseconds. When non zero, the break duration is implementation specific.
Returns:
Result of operation
setBaudRate
-
baud
Set the baudrate. Takes an int and will attempt to decide what baudrate is to be used on the UART hardware.
Parameters:
-
baud
Numberunsigned int of baudrate i.e. 9600
Returns:
Result of operation
setMode
-
bytesize
-
parity
-
stopbits
Set the transfer mode For example setting the mode to 8N1 would be "dev.setMode(8,UART_PARITY_NONE , 1)"
Parameters:
-
bytesize
Numberdata bits
-
parity
Enum UartParityParity bit setting
-
stopbits
Numberstop bits
Returns:
Result of operation
setFlowcontrol
-
xonxoff
-
rtscts
Set the flowcontrol
Parameters:
-
xonxoff
BooleanXON/XOFF Software flow control.
-
rtscts
BooleanRTS/CTS out of band hardware flow control
Returns:
Result of operation
setTimeout
-
read
-
write
-
interchar
Set the timeout for read and write operations <= 0 will disable that timeout
Parameters:
-
read
Numberread timeout
-
write
Numberwrite timeout
-
interchar
Numberinbetween char timeout
Returns:
Result of operation
setNonBlocking
-
nonblock
Set the blocking state for write operations
Parameters:
-
nonblock
Booleannew nonblocking state
Returns:
Result of operation