josx.rcxcomm
Class RCXAbstractPort

java.lang.Object
  extended byjosx.rcxcomm.RCXAbstractPort
Direct Known Subclasses:
RCXF7Port, RCXLNPAddressingPort, RCXLNPPort, RCXPort

public abstract class RCXAbstractPort
extends Object

RCXAbstractPort provides an interface similar to java.net.Socket Adapted from original code created by the LEGO3 Team at DTU-IAU RCXAbstractPort implements input and output stream handling and input buffering. It uses a packet handler for sending and receivng packets. This version is abstract because it has no packet handler defined. Specific versions of RCXAbstractPort override the constructor and set up the packet handler to use a specific protocol stack.


Field Summary
protected  PacketHandler packetHandler
           
 
Constructor Summary
RCXAbstractPort(PacketHandler handler)
          Constructor for the RCXAbstractPort.
RCXAbstractPort(String port, PacketHandler handler)
          Constructor for a named port (eg com1 or usb).
 
Method Summary
 void close()
          Closes this RCXPort, stopping the Listener thread.
 InputStream getInputStream()
          Returns an input stream for this RCXPort.
 OutputStream getOutputStream()
          Returns an output stream for this RCXPort.
 int getTimeOut()
          Getter for property timeOut.
 void reset()
          Resets sequence numbers for this port
 void setListen(boolean listen)
          Switch listening on and off on the PC, for a serial tower.
 void setTimeOut(int timeOut)
          Setter for property timeOut.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Field Detail

packetHandler

protected PacketHandler packetHandler
Constructor Detail

RCXAbstractPort

public RCXAbstractPort(PacketHandler handler)
                throws IOException
Constructor for the RCXAbstractPort. Opens the port, and sets the protocol packet handler.

Parameters:
handler - the packet handler

RCXAbstractPort

public RCXAbstractPort(String port,
                       PacketHandler handler)
                throws IOException
Constructor for a named port (eg com1 or usb). The port name is ignored on the RCX.

Parameters:
port - the port name, eg com1 or usb
Method Detail

setListen

public void setListen(boolean listen)
Switch listening on and off on the PC, for a serial tower.

Parameters:
listen - true to listen, else false

getInputStream

public InputStream getInputStream()
Returns an input stream for this RCXPort.

Returns:
an input stream for reading bytes from this RCXPort.

getOutputStream

public OutputStream getOutputStream()
Returns an output stream for this RCXPort.

Returns:
an output stream for writing bytes to this RCXPort.

reset

public void reset()
Resets sequence numbers for this port


close

public void close()
Closes this RCXPort, stopping the Listener thread.


getTimeOut

public int getTimeOut()
Getter for property timeOut.

Returns:
Value of property timeOut.

setTimeOut

public void setTimeOut(int timeOut)
Setter for property timeOut.

Parameters:
timeOut - New value of property timeOut.