PER.rover.control
Class Reliagram

java.lang.Object
  extended byjava.lang.Thread
      extended byPER.rover.control.Reliagram
All Implemented Interfaces:
java.lang.Runnable

public class Reliagram
extends java.lang.Thread

External class for RoverController to handle communication.


Field Summary
static int DEBUG
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Reliagram()
          Creates a new instance of Reliagram
 
Method Summary
 boolean close()
           
 boolean connect(java.lang.String ipAddr, int port, int timeout)
           
static void debug(int level, java.lang.String msg)
           
 void quit()
          Quits the thread that handles the receives; only call this if destroying a copy of Reliagram.
 Datapack receive()
          Waits for a new packet.
 Datapack receive(int seqNum)
          Waits for a new packet.
 Datapack receive(int seqNum, int timeout)
           
 Datapack receiveWithTimeout(int timeout)
          Waits for a new packet with the specified timeout in milliseconds.
 void run()
           
 int send(byte[] cmd, int len)
           
 int send(byte[] cmd, int len, Datapack resp)
           
 boolean wasReceived(int seqNum)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static final int DEBUG
See Also:
Constant Field Values
Constructor Detail

Reliagram

public Reliagram()
Creates a new instance of Reliagram

Method Detail

connect

public boolean connect(java.lang.String ipAddr,
                       int port,
                       int timeout)
Parameters:
timeout - How long to wait for received data. 0=infinity, a negative number will cause the function to return immediately

close

public boolean close()

quit

public void quit()
Quits the thread that handles the receives; only call this if destroying a copy of Reliagram.


send

public int send(byte[] cmd,
                int len)

send

public int send(byte[] cmd,
                int len,
                Datapack resp)

receive

public Datapack receive(int seqNum)
Waits for a new packet. Uses the timeout that was used the last time connect was called.


receive

public Datapack receive(int seqNum,
                        int timeout)
Parameters:
timeout - How long to wait for - 0 means infinite timeout

receive

public Datapack receive()
Waits for a new packet. Uses the timeout that was used the last time connect was called.


receiveWithTimeout

public Datapack receiveWithTimeout(int timeout)
Waits for a new packet with the specified timeout in milliseconds. If timeout is 0, it will block until new data is available


run

public void run()

debug

public static void debug(int level,
                         java.lang.String msg)

wasReceived

public boolean wasReceived(int seqNum)