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:
-
uartNumberthe 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:
-
pathStringthe 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:
-
lengthNumberSize of read in bytes to make
Returns:
Data read
write
-
length
Write length bytes to the device
Parameters:
-
lengthNumberSize of buffer to send
Returns:
Result of operation
readStr
-
length
Read bytes from the device into a String object
Parameters:
-
lengthNumberto read
Returns:
string of data
writeStr
-
data
Write bytes in String object to a device
Parameters:
-
dataStringstring 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:
-
millisNumbernumber 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:
-
durationNumberWhen 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:
-
baudNumberunsigned 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:
-
bytesizeNumberdata bits
-
parityEnum UartParityParity bit setting
-
stopbitsNumberstop bits
Returns:
Result of operation
setFlowcontrol
-
xonxoff -
rtscts
Set the flowcontrol
Parameters:
-
xonxoffBooleanXON/XOFF Software flow control.
-
rtsctsBooleanRTS/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:
-
readNumberread timeout
-
writeNumberwrite timeout
-
intercharNumberinbetween char timeout
Returns:
Result of operation
setNonBlocking
-
nonblock
Set the blocking state for write operations
Parameters:
-
nonblockBooleannew nonblocking state
Returns:
Result of operation