public class RXTXSerialPort
extends org.jflux.api.common.rk.property.PropertyChangeNotifier
| Modifier and Type | Field and Description |
|---|---|
static String |
DEVICE_ERROR
Device Error error string.
|
static String |
INVALID_PORT_ERROR
Invalid Port error string.
|
static String |
PORT_IN_USE_ERROR
Port In Use error string.
|
static String |
PORT_NOT_FOUND_ERROR
Port Not Found error string.
|
static String |
PROP_ERRORS
Property string for RXTXSerialPort Errors.
|
static String |
READ_ERROR
Port Read Error error string.
|
static String |
TIMEOUT_ERROR
Timeout error string.
|
static String |
WRITE_ERROR
Port Write Error error string.
|
| Constructor and Description |
|---|
RXTXSerialPort(String portName)
Creates a new RXTXSerialPort using the given port.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addError(String error)
Adds an error to the RXTXSerialPort.
|
protected void |
addError(String error,
String message)
Adds an error to the RXTXSerialPort.
|
void |
addError(String error,
String message,
Throwable t)
Adds an error to the RXTXSerialPort.
|
protected void |
addError(String error,
Throwable t)
Adds an error to the RXTXSerialPort.
|
void |
clearErrors()
Clears all port errors.
|
void |
clearReader()
Clears any available data from the port reader.
|
boolean |
connect(int baudRate,
int dataBtis,
int stopBits,
int parity)
Connects to the serial port using the given parameters.
|
boolean |
disconnect()
Disconnect the serial port.
|
boolean |
flushWriter()
Flushes the serial port's OutputStream.
|
ConnectionStatus |
getConnectionStatus()
Returns the port's ConnectionStatus.
|
List<String> |
getErrors()
Returns a List of the port's errors.
|
gnu.io.SerialPort |
getPort()
Returns underlying SerialPort.
|
InputStream |
getReader()
Returns underlying InputStream.
|
int |
getTimeoutLength()
Returns port timeout length.
|
OutputStream |
getWriter()
Returns underlying OutputStream.
|
boolean |
hasErrors()
Returns true if the port has errors.
|
int |
read()
Reads a single byte.
|
int |
read(byte[] data,
int offset,
int len)
Reads a number of bytes from the serial port.
|
int |
read(byte[] data,
int offset,
int len,
int timeout) |
byte[] |
read(int len)
Reads a number of bytes from the serial port.
|
byte[] |
read(int len,
int timeout) |
boolean |
reconnect() |
void |
setTimeoutLength(int len)
Sets the timeout length.
|
boolean |
write(byte... data)
Writes the data to the serial port.
|
boolean |
write(byte[] data,
int offset,
int len)
Writes the data to the serial port.
|
addPropertyChangeListener, addPropertyChangeListener, clearAllListeners, clearListeners, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListenerpublic static final String PROP_ERRORS
public static final String TIMEOUT_ERROR
public static final String PORT_NOT_FOUND_ERROR
public static final String PORT_IN_USE_ERROR
public static final String INVALID_PORT_ERROR
public static final String READ_ERROR
public static final String WRITE_ERROR
public static final String DEVICE_ERROR
public RXTXSerialPort(String portName)
portName - port identifierpublic void setTimeoutLength(int len)
len - timeout length in millisecondspublic int getTimeoutLength()
public gnu.io.SerialPort getPort()
public OutputStream getWriter()
public InputStream getReader()
public boolean connect(int baudRate,
int dataBtis,
int stopBits,
int parity)
baudRate - port baud ratedataBtis - number of data bitsstopBits - number of stop bitsparity - paritypublic boolean disconnect()
public boolean reconnect()
public boolean write(byte[] data,
int offset,
int len)
data - bytes to writeoffset - data array offsetlen - data write lengthpublic boolean write(byte... data)
data - bytes to writepublic boolean flushWriter()
public byte[] read(int len)
len - number of bytes to readpublic byte[] read(int len,
int timeout)
public int read(byte[] data,
int offset,
int len)
data - array to filloffset - data array offsetlen - number of bytes to readpublic int read(byte[] data,
int offset,
int len,
int timeout)
public int read()
public void clearReader()
public ConnectionStatus getConnectionStatus()
protected void addError(String error)
error - error string to addprotected void addError(String error, String message)
error - error string to addmessage - error messageprotected void addError(String error, Throwable t)
error - error string to addt - error Throwablepublic void addError(String error, String message, Throwable t)
error - error string to addmessage - error messaget - error Throwablepublic List<String> getErrors()
public void clearErrors()
public boolean hasErrors()
Copyright © 2011-2014. All Rights Reserved.