public class TransportUART extends BaseTransport
_address, _byteQueue, _connState, _connType, _devName, _devType, _macAddress, DUMP, INFO, IO, TAG
Constructor and Description |
---|
TransportUART(DeviceType deviceType,
java.lang.String path,
int baudRate) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the length of data that can be read with the read method.
|
void |
changeState(ConnectState state,
java.lang.Object params) |
boolean |
connect()
Attempts to connect to the appliance using an instance of the Transport class.
|
void |
destroy()
Destroys the instance and returns the resource.
|
void |
disconnect()
An instance of the Transport class closes the connection to the device to which the device
is connected.
|
int |
getBaudRate() |
java.lang.String |
getPath() |
void |
listen()
An instance of the BaseTransport class waits for the device to connect.
|
int |
read(byte[] data,
int offset,
int length)
Read data received from the device.
|
int |
read(byte[] data,
int offset,
int length,
int timeout)
Read data received from the device.
|
int |
write(byte[] data,
int offset,
int length)
Transfer data to the device.
|
int |
write(byte[] data,
int offset,
int length,
int timeout)
Transfer data to the device.
|
checkBufferSize, getAddress, getConnectType, getDeviceName, getDeviceType, getMacAddress, getState, read, read, setAddress, setDeviceName, setDeviceType, setMacAddress, setState, setStateListener, toString, write, write
public TransportUART(DeviceType deviceType, java.lang.String path, int baudRate)
public boolean connect()
BaseTransport
connect
in class BaseTransport
public void disconnect()
BaseTransport
disconnect
in class BaseTransport
public void listen()
BaseTransport
listen
in class BaseTransport
public void destroy()
BaseTransport
destroy
in class BaseTransport
public int write(byte[] data, int offset, int length)
BaseTransport
write
in class BaseTransport
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.public int write(byte[] data, int offset, int length, int timeout)
BaseTransport
write
in class BaseTransport
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.timeout
- An integer specifying the timeout of data transmission to the device.public int available()
BaseTransport
available
in class BaseTransport
public int read(byte[] data, int offset, int length)
BaseTransport
read
in class BaseTransport
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will
begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the
device can be stored in a byte array.public int read(byte[] data, int offset, int length, int timeout)
BaseTransport
read
in class BaseTransport
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will
begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the
device can be stored in a byte array.timeout
- An integer that specifies the timeout for reading data received from the device.public java.lang.String getPath()
public int getBaudRate()
public void changeState(ConnectState state, java.lang.Object params)