josx.rcxcomm
Class RCXPort

java.lang.Object
  |
  +--josx.rcxcomm.RCXPort

public class RCXPort
extends Object

RCXPort provides an interface similar to java.net.Socket Adapted from original code created by the LEGO3 Team at DTU-IAU

Author:
Brian Bagnall, Lawrie Griffiths

Field Summary
static int DEFAULT_TIMEOUT
          The default time-out for the RCXPort.
protected  IOException ioe
           
protected  Object monitor
           
protected  josx.rcxcomm.RCXPort.RCXInputStream rcxin
           
protected  josx.rcxcomm.RCXPort.RCXOutputStream rcxout
           
 
Constructor Summary
RCXPort()
          Parameterless constructor for the RCXPort.
 
Method Summary
 void close()
          Closes this RCXPort.
protected  boolean dataAvailable()
          Check if data is available using RCX Serial Class.
 InputStream getInputStream()
          Returns an input stream for this RCXPort.
 OutputStream getOutputStream()
          Returns an output stream for this RCXPort.
 int getTimeOut()
          Getter for property timeOut.
protected  byte receiveByte()
           
protected  void sendByte(byte b)
           
protected  void sendPacket(byte b)
          Send a packet using this RCXPort.
 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

rcxin

protected josx.rcxcomm.RCXPort.RCXInputStream rcxin

rcxout

protected josx.rcxcomm.RCXPort.RCXOutputStream rcxout

monitor

protected Object monitor

ioe

protected IOException ioe

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
The default time-out for the RCXPort.
Constructor Detail

RCXPort

public RCXPort()
        throws IOException
Parameterless constructor for the RCXPort. Opens the port.
Method Detail

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.

close

public void close()
Closes this RCXPort.

sendPacket

protected void sendPacket(byte b)
                   throws IOException
Send a packet using this RCXPort. This method is used by the RCXOutputStream to send data.
Parameters:
b - a byte to send
Throws:
IOException - if the packet could not be sent.
See Also:
RCXOutputStream

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.

sendByte

protected void sendByte(byte b)
                 throws IOException

dataAvailable

protected boolean dataAvailable()
Check if data is available using RCX Serial Class.

receiveByte

protected byte receiveByte()
                    throws IOException