|
jamod at SF | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.wimpi.modbus.io.ModbusSerialTransport
Abstract base class for serial ModbusTransport implementations.
Field Summary | |
protected javax.comm.CommPort |
m_CommPort
|
protected boolean |
m_Echo
|
Constructor Summary | |
ModbusSerialTransport()
|
Method Summary | |
abstract void |
close()
The close method closes the serial input/output streams. |
boolean |
isEcho()
isEcho method returns the output echo state. |
abstract void |
prepareStreams(java.io.InputStream in,
java.io.OutputStream out)
prepareStreams prepares the input and output streams of this
ModbusSerialTransport instance. |
void |
readEcho(int len)
Reads the own message echo produced in RS485 Echo Mode within the given time frame. |
abstract ModbusRequest |
readRequest()
The readRequest method listens continuously on the serial
input stream for master request messages and replies if the request slave
ID matches its own set in ModbusCoupler.getUnitID(). |
abstract ModbusResponse |
readResponse()
readResponse reads a response message from the slave
responding to a master writeMessage request. |
void |
setCommPort(javax.comm.CommPort 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 |
setReceiveThreshold(int th)
Describe setReceiveThreshold method here. |
void |
setReceiveTimeout(int ms)
Describe setReceiveTimeout method here. |
abstract void |
writeMessage(ModbusMessage msg)
The writeMessage method writes a modbus serial message to
its serial output stream to a specified slave unit ID. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected javax.comm.CommPort m_CommPort
protected boolean m_Echo
Constructor Detail |
public ModbusSerialTransport()
Method Detail |
public abstract void prepareStreams(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
prepareStreams
prepares the input and output streams of this
ModbusSerialTransport instance.
in
- the input stream to be read from.out
- the output stream to write to.
java.io.IOException
- if an I\O error occurs.public abstract ModbusResponse readResponse() throws ModbusIOException
readResponse
reads a response message from the slave
responding to a master writeMessage request.
readResponse
in interface ModbusTransport
ModbusResponse
value
ModbusIOException
- if an error occurspublic abstract ModbusRequest readRequest() throws ModbusIOException
readRequest
method listens continuously on the serial
input stream for master request messages and replies if the request slave
ID matches its own set in ModbusCoupler.getUnitID().
readRequest
in interface ModbusTransport
ModbusRequest
value
ModbusIOException
- if an error occurspublic abstract void writeMessage(ModbusMessage msg) throws ModbusIOException
writeMessage
method writes a modbus serial message to
its serial output stream to a specified slave unit ID.
writeMessage
in interface ModbusTransport
msg
- a ModbusMessage
value
ModbusIOException
- if an error occurspublic abstract void close() throws java.io.IOException
close
method closes the serial input/output streams.
close
in interface ModbusTransport
java.io.IOException
- if an error occurspublic void setCommPort(javax.comm.CommPort cp) throws java.io.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.
java.io.IOException
- if an I/O related error occurs.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 setReceiveThreshold(int th)
setReceiveThreshold
method here.
th
- an int
valuepublic void setReceiveTimeout(int ms)
setReceiveTimeout
method here.
ms
- an int
valuepublic void readEcho(int len) throws java.io.IOException
len
- is the length of the echo to read. Timeout will occur if the
echo is not received in the time specified in the SerialConnection.
java.io.IOException
- if a I/O error occurred.
|
jamod at SF | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |