public abstract class AbstractSerialConnection extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
EVEN_PARITY |
static int |
FLOW_CONTROL_CTS_ENABLED |
static int |
FLOW_CONTROL_DISABLED
Flow control values
|
static int |
FLOW_CONTROL_DSR_ENABLED |
static int |
FLOW_CONTROL_DTR_ENABLED |
static int |
FLOW_CONTROL_RTS_ENABLED |
static int |
FLOW_CONTROL_XONXOFF_IN_ENABLED |
static int |
FLOW_CONTROL_XONXOFF_OUT_ENABLED |
static int |
MARK_PARITY |
static int |
NO_PARITY
Parity values
|
static int |
ODD_PARITY |
static int |
ONE_POINT_FIVE_STOP_BITS |
static int |
ONE_STOP_BIT
Stop bits values
|
static int |
OPEN_DELAY
Open delay (msec)
|
static int |
SPACE_PARITY |
static int |
TIMEOUT_NONBLOCKING
Timeout
|
static int |
TIMEOUT_READ_BLOCKING |
static int |
TIMEOUT_READ_SEMI_BLOCKING |
static int |
TIMEOUT_SCANNER |
static int |
TIMEOUT_WRITE_BLOCKING |
static int |
TWO_STOP_BITS |
| Constructor and Description |
|---|
AbstractSerialConnection() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
bytesAvailable()
Bytes available to read
|
abstract void |
close()
Close the port and clean up associated elements
|
abstract int |
getBaudRate()
Returns current baud rate
|
abstract Set<String> |
getCommPorts()
Returns a set of all the available comm port names
|
abstract String |
getDescriptivePortName()
Returns a descriptive name of the port
|
abstract AbstractModbusTransport |
getModbusTransport()
Returns the ModbusTransport instance to be used for receiving
and sending messages.
|
abstract int |
getNumDataBits()
Returns current data bits value
|
abstract int |
getNumStopBits()
Returns current stop bits
|
abstract int |
getParity()
Returns current parity
|
abstract String |
getPortName()
Returns a name of the port
|
abstract int |
getTimeout()
Returns the timeout for this connection
|
abstract boolean |
isOpen()
Reports the open status of the port
|
abstract void |
open()
Opens the port and throws an error if it cannot for some reason
|
abstract int |
readBytes(byte[] buffer,
int bytesToRead)
Read a specified number of bytes from the serial port
|
abstract void |
setComPortTimeouts(int newTimeoutMode,
int newReadTimeout,
int newWriteTimeout)
Set port timeouts
|
abstract void |
setTimeout(int timeout)
Sets the timeout for this connection.
|
abstract int |
writeBytes(byte[] buffer,
int bytesToWrite)
Write a specified number of bytes to the serial port
|
public static final int NO_PARITY
public static final int ODD_PARITY
public static final int EVEN_PARITY
public static final int MARK_PARITY
public static final int SPACE_PARITY
public static final int ONE_STOP_BIT
public static final int ONE_POINT_FIVE_STOP_BITS
public static final int TWO_STOP_BITS
public static final int FLOW_CONTROL_DISABLED
public static final int FLOW_CONTROL_RTS_ENABLED
public static final int FLOW_CONTROL_CTS_ENABLED
public static final int FLOW_CONTROL_DSR_ENABLED
public static final int FLOW_CONTROL_DTR_ENABLED
public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED
public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED
public static final int OPEN_DELAY
public static final int TIMEOUT_NONBLOCKING
public static final int TIMEOUT_READ_SEMI_BLOCKING
public static final int TIMEOUT_READ_BLOCKING
public static final int TIMEOUT_WRITE_BLOCKING
public static final int TIMEOUT_SCANNER
public abstract void open()
throws IOException
IOException - If the port is not available or cannot be openedpublic abstract AbstractModbusTransport getModbusTransport()
public abstract int readBytes(byte[] buffer,
int bytesToRead)
buffer - Buffer to recieve bytes from the portbytesToRead - Number of bytes to readpublic abstract int writeBytes(byte[] buffer,
int bytesToWrite)
buffer - Bytes to send to the portbytesToWrite - How many bytes to sendpublic abstract int bytesAvailable()
public abstract void close()
public abstract int getBaudRate()
public abstract int getNumDataBits()
public abstract int getNumStopBits()
public abstract int getParity()
public abstract String getPortName()
public abstract String getDescriptivePortName()
public abstract void setComPortTimeouts(int newTimeoutMode,
int newReadTimeout,
int newWriteTimeout)
newTimeoutMode - Timeout modenewReadTimeout - Read timeout (milliseconds)newWriteTimeout - Write timeout (milliseconds)public abstract boolean isOpen()
public abstract int getTimeout()
public abstract void setTimeout(int timeout)
timeout - the timeout as int millisecondsCopyright © 2025. All Rights Reserved.