public abstract class ModbusSerialTransport extends AbstractModbusTransport
| Constructor and Description |
|---|
ModbusSerialTransport() |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(AbstractSerialTransportListener listener)
Adds a listener to the transport to be called when an event occurs
|
void |
clearListeners()
Clears the list of listeners
|
void |
close()
Closes the comms port and any streams associated with it
|
ModbusTransaction |
createTransaction()
Creates a new transaction suitable for the serial port
|
AbstractSerialConnection |
getCommPort()
Returns the comms port being used for this transport
|
boolean |
isEcho()
isEcho method returns the output echo state. |
void |
notifyListenersDisconnected()
Calls any listeners with the given event and current port
|
ModbusRequest |
readRequest(AbstractModbusListener listener)
Reads a ModbusRequest from the
input stream of this ModbusTransport.
|
ModbusResponse |
readResponse()
Reads a ModbusResponse from the
input stream of this ModbusTransport.
|
void |
removeListener(AbstractSerialTransportListener listener)
Removes a listener from the event callback chain
|
void |
setCommPort(AbstractSerialConnection cp)
setCommPort sets the comm port member and prepares the input
and output streams to be used for reading from and writing to. |
void |
setEcho(boolean b)
setEcho method sets the output echo state. |
void |
setTimeout(int time)
Set the socket timeout
|
void |
writeRequest(ModbusRequest msg)
Writes a ModbusMessage to the
output stream of this ModbusTransport.
|
void |
writeResponse(ModbusResponse msg)
Writes a ModbusResponseMessage to the
output stream of this ModbusTransport.
|
public ModbusTransaction createTransaction()
createTransaction in class AbstractModbusTransportpublic void writeResponse(ModbusResponse msg) throws ModbusIOException
AbstractModbusTransportwriteResponse in class AbstractModbusTransportmsg - a ModbusMessage.ModbusIOException - data cannot be
written properly to the raw output stream of
this ModbusTransport.public void writeRequest(ModbusRequest msg) throws ModbusIOException
AbstractModbusTransportwriteRequest in class AbstractModbusTransportmsg - a ModbusMessage.ModbusIOException - data cannot be
written properly to the raw output stream of
this ModbusTransport.public ModbusRequest readRequest(AbstractModbusListener listener) throws ModbusIOException
AbstractModbusTransportreadRequest in class AbstractModbusTransportlistener - Listener the request was received byModbusIOException - data cannot be
read properly from the raw input stream of
this ModbusTransport.public ModbusResponse readResponse() throws ModbusIOException
AbstractModbusTransportreadResponse in class AbstractModbusTransportModbusIOException - data cannot be
read properly from the raw input stream of
this ModbusTransport.public void setTimeout(int time)
AbstractModbusTransportsetTimeout in class AbstractModbusTransporttime - Timeout in millisecondspublic void addListener(AbstractSerialTransportListener listener)
listener - Listner callbackpublic void removeListener(AbstractSerialTransportListener listener)
listener - Listener to removepublic void clearListeners()
public void notifyListenersDisconnected()
public void setCommPort(AbstractSerialConnection cp) throws IOException
setCommPort sets the comm port member and prepares the input
and output streams to be used for reading from and writing to.cp - the comm port to read from/write to.IOException - if an I/O related error occurs.public AbstractSerialConnection getCommPort()
public boolean isEcho()
isEcho method returns the output echo state.boolean valuepublic void setEcho(boolean b)
setEcho method sets the output echo state.b - a boolean valuepublic void close()
throws IOException
close in class AbstractModbusTransportIOException - Comm port close failedCopyright © 2025. All Rights Reserved.