jamod at SF

net.wimpi.modbus.net
Class SerialConnection

java.lang.Object
  extended bynet.wimpi.modbus.net.SerialConnection
All Implemented Interfaces:
java.util.EventListener, javax.comm.SerialPortEventListener

public class SerialConnection
extends java.lang.Object
implements javax.comm.SerialPortEventListener

Class that implements a serial connection which can be used for master and slave implementations.

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

Constructor Summary
SerialConnection(SerialParameters parameters)
          Creates a SerialConnection object and initilizes variables passed in as params.
 
Method Summary
 void close()
          Close the port and clean up associated elements.
 ModbusTransport getModbusTransport()
          Returns the ModbusTransport instance to be used for receiving and sending messages.
 boolean isOpen()
          Reports the open status of the port.
 void open()
          Opens the communication port.
 void serialEvent(javax.comm.SerialPortEvent e)
           
 void setConnectionParameters()
          Sets the connection parameters to the setting in the parameters object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialConnection

public SerialConnection(SerialParameters parameters)
Creates a SerialConnection object and initilizes variables passed in as params.

Parameters:
parameters - A SerialParameters object.
Method Detail

getModbusTransport

public ModbusTransport getModbusTransport()
Returns the ModbusTransport instance to be used for receiving and sending messages.

Returns:
a ModbusTransport instance.

open

public void open()
          throws java.lang.Exception
Opens the communication port.

Throws:
java.lang.Exception - if an error occurs.

setConnectionParameters

public void setConnectionParameters()
                             throws java.lang.Exception
Sets the connection parameters to the setting in the parameters object. If set fails return the parameters object to origional settings and throw exception.

Throws:
java.lang.Exception - if the configured parameters cannot be set properly on the port.

close

public void close()
Close the port and clean up associated elements.


isOpen

public boolean isOpen()
Reports the open status of the port.

Returns:
true if port is open, false if port is closed.

serialEvent

public void serialEvent(javax.comm.SerialPortEvent e)
Specified by:
serialEvent in interface javax.comm.SerialPortEventListener

jamod at SF

Copyright © 2002-2004 jamod development team.