public class SerialConnection extends Object implements SerialPortEventListener
| Constructor and Description |
|---|
SerialConnection(SerialParameters parameters)
Creates a SerialConnection object and initilizes variables passed in as
params.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the port and clean up associated elements.
|
ModbusTransport |
getModbusTransport()
Returns the ModbusTransport instance to be used for receiving
and sending messages.
|
SerialPort |
getSerialPort()
Returns the reference to the SerialPort instance.
|
boolean |
isOpen()
Reports the open status of the port.
|
void |
open()
Opens the communication port.
|
void |
serialEvent(SerialPortEvent e)
Serial event.
|
void |
setConnectionParameters()
Sets the connection parameters to the setting in the parameters object.
|
void |
setReceiveTimeout(int ms)
Sets receive timeout.
|
public SerialConnection(SerialParameters parameters)
parameters - A SerialParameters object.public SerialPort getSerialPort()
public ModbusTransport getModbusTransport()
public void open()
throws Exception
Exception - if an error occurs.public void setReceiveTimeout(int ms)
ms - the mspublic void setConnectionParameters()
throws Exception
Exception - if the configured parameters cannot be set properly on the port.public void close()
throws IOException
IOExceptionpublic boolean isOpen()
public void serialEvent(SerialPortEvent e)
SerialPortEventListenerserialEvent in interface SerialPortEventListenere - the eventCopyright © 2017. All rights reserved.