Class SerialPortControl

java.lang.Object
  extended bySerialPortControl
All Implemented Interfaces:
java.util.EventListener, java.lang.Runnable, javax.comm.SerialPortEventListener

public class SerialPortControl
extends java.lang.Object
implements java.lang.Runnable, javax.comm.SerialPortEventListener

Class declaration


Constructor Summary
SerialPortControl(javax.comm.CommPortIdentifier commPort)
          Constructor declaration
 
Method Summary
 void clearStream()
          This clears the input serial port input stream.
 byte[] getResponsePacket()
          This returns the response packet from the OCU to you.
 void run()
          Method declaration
 void sendCommand(byte[] packet)
          Sends a packet of bytes over a serial port.
 void serialEvent(javax.comm.SerialPortEvent event)
          Method declaration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialPortControl

public SerialPortControl(javax.comm.CommPortIdentifier commPort)
Constructor declaration

Parameters:
commPort - A commPort object. This specifies what comm port you will use. See the JavaDoc for the commAPI for details on the commPort object.
Method Detail

run

public void run()
Method declaration

Specified by:
run in interface java.lang.Runnable

serialEvent

public void serialEvent(javax.comm.SerialPortEvent event)
Method declaration

Specified by:
serialEvent in interface javax.comm.SerialPortEventListener
Parameters:
event - A serial port event
See Also:
the JavaDoc for the Java CommAPI

sendCommand

public void sendCommand(byte[] packet)
Sends a packet of bytes over a serial port.

Parameters:
packet - This is the command packet to be sent to the VGTV OCU.

getResponsePacket

public byte[] getResponsePacket()
This returns the response packet from the OCU to you.

Returns:
This byte array is the response packet. Give it to decodeResponsePacket() in CPC.

clearStream

public void clearStream()
This clears the input serial port input stream. I use this to clear incomplete data from the buffer.