josx.rcxcomm
Class DataPort

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

public abstract class DataPort
extends Object

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

Author:
Brian Bagnall

Field Summary
static int DEFAULT_TIMEOUT
          The default time-out for the DataPort.
protected  Object monitor
           
protected  josx.rcxcomm.DataPort.RCXInputStream rcxin
           
protected  josx.rcxcomm.DataPort.RCXOutputStream rcxout
           
 
Constructor Summary
protected DataPort()
           
 
Method Summary
 void close()
          Closes this DataPort.
protected abstract  boolean dataAvailable()
           
 InputStream getInputStream()
          Returns an input stream for this DataPort.
 OutputStream getOutputStream()
          Returns an output stream for this DataPort.
 int getTimeOut()
          Getter for property timeOut.
protected abstract  byte receiveByte()
           
protected abstract  void sendByte(byte b)
           
protected  void sendPacket(byte[] b, int n)
          Send a packet using this DataPort.
 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.DataPort.RCXInputStream rcxin

rcxout

protected josx.rcxcomm.DataPort.RCXOutputStream rcxout

monitor

protected Object monitor

DEFAULT_TIMEOUT

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

DataPort

protected DataPort()
Method Detail

getInputStream

public InputStream getInputStream()
Returns an input stream for this DataPort.
Returns:
an input stream for reading bytes from this DataPort.

getOutputStream

public OutputStream getOutputStream()
Returns an output stream for this DataPort.
Returns:
an output stream for writing bytes to this DataPort.

close

public void close()
Closes this DataPort.

sendPacket

protected void sendPacket(byte[] b,
                          int n)
                   throws IOException
Send a packet using this DataPort. This method is used by the RCXOutputStream to send data.
Parameters:
b - a byte array with data.
n - the number of bytes 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 abstract void sendByte(byte b)
                          throws IOException

receiveByte

protected abstract byte receiveByte()
                             throws IOException

dataAvailable

protected abstract boolean dataAvailable()