org.openmuc.j62056
public class Connection extends java.lang.Object
Constructor and Description |
---|
Connection(java.lang.String serialPort)
Creates a Connection object.
|
Connection(java.lang.String serialPort,
boolean handleEcho,
boolean noBaudrateChange)
Creates a Connection object.
|
public Connection(java.lang.String serialPort, boolean handleEcho, boolean noBaudrateChange)
open()
before calling read()
in order to
read data.serialPort
- examples for serial port identifiers on Linux are "/dev/ttyS0" or "/dev/ttyUSB0" and on Windows "COM1"handleEcho
- tells the connection to throw away echos of outgoing messages. Echos are caused by some optical
transceivers.noBaudrateChange
- tells the connection not change the baud rate during message exchange and stay at 300 instead.
Normally the connection will change the baud rate after an initial handshake with the remote device.
This may cause problems if the serial port does not change its baud rate quickly enough to receive the
full data message from the remote device. Therefore the baud rate change can be disabled using this
setting.public Connection(java.lang.String serialPort)
serialPort
- examples for serial port identifiers on Linux are "/dev/ttyS0" or "/dev/ttyUSB0" and on Windows "COM1"public void open() throws java.io.IOException
java.io.IOException
- if any kind of error occurs opening the serial port.public java.util.List<DataSet> read(int timeout) throws java.io.IOException
timeout
- the maximum time in milliseconds that the function shall wait for a response. A timeout of zero is
interpreted as an infinite timeout.null
if
the specified waiting time elapses before a data message was received.java.io.IOException
- if any kind of error occurs while trying to read the remote device. The connection is not closed when
an IOException is thrown.public void close()