public class UartFtdi extends SerialCommunicator
Constructor and Description |
---|
UartFtdi(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
addReadListener(ReadLisener listener)
Adds read listener
|
void |
clearBuffer()
Clears read buffer
|
void |
clearReadListener()
Clears read listener
|
boolean |
close()
Closes a device
|
int |
getBaudrate()
Gets baud-rate
|
int |
getDataBits()
Gets Data bits
|
boolean |
getDtr()
Gets flow control DTR
|
int |
getParity()
Gets Parity bit
|
boolean |
getRts()
Gets flow control RTS
|
int |
getStopBits()
Gets Stop bits
|
UartConfig |
getUartConfig()
Gets Uart configurations
|
boolean |
isOpened()
Checks device is opened
|
boolean |
open()
Opens a device
|
int |
read(byte[] buf,
int size)
Reads byte array
|
boolean |
setBaudrate(int baudrate)
Sets baudrate
|
boolean |
setDataBits(int dataBits)
Sets Data bits
|
boolean |
setDtrRts(boolean dtrOn,
boolean rtsOn)
Sets flow control DTR/RTS
|
boolean |
setParity(int parity)
Sets Parity bit
|
boolean |
setStopBits(int stopBits)
Sets Stop bits
|
boolean |
setUartConfig(UartConfig config)
Sets Uart configurations
|
void |
startReadListener()
Starts read listener (default is started)
|
void |
stopReadListener()
Stops read listener (default is started)
|
int |
write(byte[] buf,
int size)
Writes byte array
|
public boolean open()
SerialCommunicator
open
in class SerialCommunicator
public boolean close()
SerialCommunicator
close
in class SerialCommunicator
public int read(byte[] buf, int size)
SerialCommunicator
read
in class SerialCommunicator
buf
- byte arraysize
- read sizepublic int write(byte[] buf, int size)
SerialCommunicator
write
in class SerialCommunicator
buf
- byte arraysize
- write sizepublic boolean setUartConfig(UartConfig config)
SerialCommunicator
setUartConfig
in class SerialCommunicator
config
- configurationspublic boolean isOpened()
SerialCommunicator
isOpened
in class SerialCommunicator
public boolean setBaudrate(int baudrate)
SerialCommunicator
setBaudrate
in class SerialCommunicator
baudrate
- baudrate e.g. 9600public boolean setDataBits(int dataBits)
SerialCommunicator
setDataBits
in class SerialCommunicator
dataBits
- data bits e.g. UartConfig.DATA_BITS8public boolean setParity(int parity)
SerialCommunicator
setParity
in class SerialCommunicator
parity
- parity bits e.g. UartConfig.PARITY_NONEpublic boolean setStopBits(int stopBits)
SerialCommunicator
setStopBits
in class SerialCommunicator
stopBits
- stop bits e.g. UartConfig.STOP_BITS1public boolean setDtrRts(boolean dtrOn, boolean rtsOn)
SerialCommunicator
setDtrRts
in class SerialCommunicator
dtrOn
- true then DTR onrtsOn
- true then RTS onpublic UartConfig getUartConfig()
SerialCommunicator
getUartConfig
in class SerialCommunicator
public int getBaudrate()
SerialCommunicator
getBaudrate
in class SerialCommunicator
public int getDataBits()
SerialCommunicator
getDataBits
in class SerialCommunicator
public int getParity()
SerialCommunicator
getParity
in class SerialCommunicator
public int getStopBits()
SerialCommunicator
getStopBits
in class SerialCommunicator
public boolean getDtr()
SerialCommunicator
getDtr
in class SerialCommunicator
public boolean getRts()
SerialCommunicator
getRts
in class SerialCommunicator
public void clearBuffer()
SerialCommunicator
clearBuffer
in class SerialCommunicator
public void addReadListener(ReadLisener listener)
SerialCommunicator
addReadListener
in class SerialCommunicator
listener
- ReadListenerpublic void clearReadListener()
SerialCommunicator
clearReadListener
in class SerialCommunicator
public void startReadListener()
SerialCommunicator
startReadListener
in class SerialCommunicator
public void stopReadListener()
SerialCommunicator
stopReadListener
in class SerialCommunicator