com.meiglobal.ebds.api
Class WrappedSerialPort

java.lang.Object
  extended by com.meiglobal.ebds.api.WrappedSerialPort
All Implemented Interfaces:
gnu.io.SerialPortEventListener, java.util.EventListener
Direct Known Subclasses:
EBDS_SerialPort

public class WrappedSerialPort
extends java.lang.Object
implements gnu.io.SerialPortEventListener

WrappedSerialPort class is a wrapper for the gnu.io.serialPort class. It contains the basic operations for opening, closing, sending and receiving data. It is expected that this class be subclassed in order to properly process the incomming data.


Field Summary
protected  byte[] _buffer
           
protected  int _iRead
           
protected  int _iWrite
           
protected  java.lang.String _strPortName
           
 
Constructor Summary
WrappedSerialPort()
          Wrapped Serial port is a serial port object that is wrapped for the convienence of timeout detection.
 
Method Summary
 void close()
          Closes the connection to the currently opened port.
protected  void flushInputStream()
          Clears out any bytes in the input stream
 boolean isOpen()
          Determines if the port is open and can be used.
static java.lang.String[] listPorts()
          Method used to retrieve the available ports.
 boolean openPort(java.lang.String portName)
          Opens communication with a port.
 void send(byte[] data)
          Sends a byte array out the serial port.
 void serialEvent(gnu.io.SerialPortEvent event)
          This functions handles all the events raised by the serial port object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_strPortName

protected java.lang.String _strPortName

_buffer

protected byte[] _buffer

_iRead

protected int _iRead

_iWrite

protected int _iWrite
Constructor Detail

WrappedSerialPort

public WrappedSerialPort()
Wrapped Serial port is a serial port object that is wrapped for the convienence of timeout detection.

Method Detail

isOpen

public boolean isOpen()
Determines if the port is open and can be used.

Returns:
True if the port is open.

listPorts

public static java.lang.String[] listPorts()
Method used to retrieve the available ports.

Returns:
A list of the available ports.

openPort

public boolean openPort(java.lang.String portName)
                 throws AcceptorException
Opens communication with a port.

Parameters:
portName - The name of the port to open. Ex. COM1
Returns:
True if the connection is successful. Will never return false, throws an exception instead.
Throws:
AcceptorException - If there is any reason the port cannot be opened.

close

public void close()
Closes the connection to the currently opened port. No effect if not connected.


send

public void send(byte[] data)
          throws java.io.IOException
Sends a byte array out the serial port.

Parameters:
data - The byte array to send
Throws:
java.io.IOException

flushInputStream

protected void flushInputStream()
Clears out any bytes in the input stream


serialEvent

public void serialEvent(gnu.io.SerialPortEvent event)
This functions handles all the events raised by the serial port object. Only handles the events that signal when data is available.

Specified by:
serialEvent in interface gnu.io.SerialPortEventListener
Parameters:
event - SerialPortEvent that was raised.