public class Uart
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CTS
Helper for the flowControl parameter
|
static int |
EVEN
Helper for the parity parameter
|
static int |
NONE
Helper for the parity and flowControl parameters
|
static int |
ODD
Helper for the parity parameter
|
static int |
RTS
Helper for the flowControl parameter
|
static int |
RTS_CTS
Helper for the flowControl parameter
|
static int |
UART_ID_HOST
Helper for the uartId parameter
|
static int |
UART_ID_TARGET
Helper for the uartId parameter
|
Modifier | Constructor and Description |
---|---|
protected |
Uart()
Used in the derived ModbusRTU class
Reserved for IoTize
|
|
Uart(int baudRate,
int dataLength,
int numberOfStopBits,
int parity)
Creates a new UART interface, with the Tap as the UART host.
|
|
Uart(int baudRate,
int dataLength,
int numberOfStopBits,
int parity,
int flowControl,
int uartId)
Creates a new UART interface, with the Tap as the UART host.
|
Modifier and Type | Method and Description |
---|---|
void |
flushRecBuffer()
Flushes the reception buffer.
|
void |
format(java.lang.String format,
java.lang.Object... args)
Sends a formatted string to the UART.
|
int |
getBytes(byte[] buffer,
int maxNumberOfBytes,
int timeout)
Gets all data bytes until the the maximum number of bytes is reached or timeout has occured.
|
int |
getChar()
Read one char on the UART connection.
|
int |
getCountRec() |
int |
sendBytes(byte[] buffer)
Sends the given buffer on the UART connection.
|
void |
sendChar(byte val)
Sends one char on the UART connection
|
void |
setMode(int baudRate,
int dataLength,
int numberOfStopBits,
int parity,
int flowControl)
Sets the current UART connection with the provided communication parameters.The parity and
flowControl parameters can be set with the following helpers:
Parity Uart.NONE Uart.ODD Uart.EVEN Flow Control Uart.NONE Uart.RTS Uart.CTS Uart.RTS_CTS |
public static final int NONE
public static final int ODD
public static final int EVEN
public static final int RTS
public static final int CTS
public static final int RTS_CTS
public static final int UART_ID_TARGET
public static final int UART_ID_HOST
public Uart(int baudRate, int dataLength, int numberOfStopBits, int parity)
baudRate
- the baud rate of the connectiondataLength
- the number of bits of data in each framenumberOfStopBits
- the number of stop bitsparity
- the parity of the connectionpublic Uart(int baudRate, int dataLength, int numberOfStopBits, int parity, int flowControl, int uartId)
baudRate
- the baud rate of the connectiondataLength
- the number of bits of data in each framenumberOfStopBits
- the number of stop bitsparity
- the parity of the connectionflowControl
- the flow control mode of the connectionuartId
- the Id of the uart connectionprotected Uart()
public void setMode(int baudRate, int dataLength, int numberOfStopBits, int parity, int flowControl)
baudRate
- the baud rate of the connectiondataLength
- the number of bits of data in each framenumberOfStopBits
- the number of stop bitsparity
- the parity of the connectionflowControl
- the flow control mode of the connectionpublic int getChar()
public void sendChar(byte val)
val
- the char to sendpublic int getBytes(byte[] buffer, int maxNumberOfBytes, int timeout)
buffer
- the buffer that will receive the datamaxNumberOfBytes
- the maximum number of bytes to readtimeout
- the timeout of the command, in millisecondspublic int sendBytes(byte[] buffer)
buffer
- the buffer to bee sentpublic void flushRecBuffer()
public int getCountRec()
public void format(java.lang.String format, java.lang.Object... args)
format
- the string template to formatargs
- the arguments for the formatted string