jamod at SF

net.wimpi.modbus.io
Class ModbusASCIITransport

java.lang.Object
  extended bynet.wimpi.modbus.io.ModbusSerialTransport
      extended bynet.wimpi.modbus.io.ModbusASCIITransport
All Implemented Interfaces:
ModbusTransport

public class ModbusASCIITransport
extends ModbusSerialTransport

Class that implements the Modbus/ASCII transport flavor.

Version:
1.2rc1 (09/11/2004)
Author:
Dieter Wimberger, John Charlton

Field Summary
static int FRAME_END
          Defines a virtual number for the FRAME_END token (CR LF).
static int FRAME_START
          Defines a virtual number for the FRAME START token (COLON).
 
Fields inherited from class net.wimpi.modbus.io.ModbusSerialTransport
m_CommPort, m_Echo
 
Constructor Summary
ModbusASCIITransport()
          Constructs a new MobusASCIITransport instance.
 
Method Summary
 void close()
          The close method closes the serial input/output streams.
 void prepareStreams(java.io.InputStream in, java.io.OutputStream out)
          Prepares the input and output streams of this ModbusASCIITransport instance.
 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().
 ModbusResponse readResponse()
          readResponse reads a response message from the slave responding to a master writeMessage request.
 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 net.wimpi.modbus.io.ModbusSerialTransport
isEcho, readEcho, setCommPort, setEcho, setReceiveThreshold, setReceiveTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAME_START

public static final int FRAME_START
Defines a virtual number for the FRAME START token (COLON).

See Also:
Constant Field Values

FRAME_END

public static final int FRAME_END
Defines a virtual number for the FRAME_END token (CR LF).

See Also:
Constant Field Values
Constructor Detail

ModbusASCIITransport

public ModbusASCIITransport()
Constructs a new MobusASCIITransport instance.

Method Detail

close

public void close()
           throws java.io.IOException
Description copied from class: ModbusSerialTransport
The close method closes the serial input/output streams.

Specified by:
close in interface ModbusTransport
Specified by:
close in class ModbusSerialTransport
Throws:
java.io.IOException - if an error occurs

writeMessage

public void writeMessage(ModbusMessage msg)
                  throws ModbusIOException
Description copied from class: ModbusSerialTransport
The writeMessage method writes a modbus serial message to its serial output stream to a specified slave unit ID.

Specified by:
writeMessage in interface ModbusTransport
Specified by:
writeMessage in class ModbusSerialTransport
Parameters:
msg - a ModbusMessage value
Throws:
ModbusIOException - if an error occurs

readRequest

public ModbusRequest readRequest()
                          throws ModbusIOException
Description copied from class: ModbusSerialTransport
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().

Specified by:
readRequest in interface ModbusTransport
Specified by:
readRequest in class ModbusSerialTransport
Returns:
a ModbusRequest value
Throws:
ModbusIOException - if an error occurs

readResponse

public ModbusResponse readResponse()
                            throws ModbusIOException
Description copied from class: ModbusSerialTransport
readResponse reads a response message from the slave responding to a master writeMessage request.

Specified by:
readResponse in interface ModbusTransport
Specified by:
readResponse in class ModbusSerialTransport
Returns:
a ModbusResponse value
Throws:
ModbusIOException - if an error occurs

prepareStreams

public void prepareStreams(java.io.InputStream in,
                           java.io.OutputStream out)
                    throws java.io.IOException
Prepares the input and output streams of this ModbusASCIITransport instance. The raw input stream will be wrapped into a filtered DataInputStream.

Specified by:
prepareStreams in class ModbusSerialTransport
Parameters:
in - the input stream to be used for reading.
out - the output stream to be used for writing.
Throws:
java.io.IOException - if an I\O related error occurs.

jamod at SF

Copyright © 2002-2004 jamod development team.