lejos.rcxcomm
Class Serial

java.lang.Object
  extended by lejos.rcxcomm.Serial

public class Serial
extends Object

Emulation of the RCX Serial class with Mindsensors NRLINK adapter.

Author:
Lawrie Griffiths

WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS. DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.

Method Summary
static RCXLink getLink()
          Get the RCXLink object associated with the Serial class
static boolean isPacketAvailable()
          Test if a packet is available
static int readPacket(byte[] aBuffer)
          Read an assembled packet.
static void resetSerial()
          Reset the link - null
static boolean sendPacket(byte[] aBuffer, int aOffset, int aLen)
          Send a packet
static void setPort(SensorPort port)
          Set the sensor port
static void setRangeLong()
          Set long range
static void setRangeShort()
          Set short range
static void waitTillSent()
          Wait until the packet is sent - null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPort

public static void setPort(SensorPort port)
Set the sensor port

Parameters:
port - the sensor port the link is connected to

readPacket

public static int readPacket(byte[] aBuffer)
Read an assembled packet. NRLink only seems to read one byte at a time reliably, and does not return zero bytes.

Parameters:
aBuffer - the buffer to return the packet into
Returns:
the number of bytes in the packet

isPacketAvailable

public static boolean isPacketAvailable()
Test if a packet is available

Returns:
true iff a packiet is available

sendPacket

public static boolean sendPacket(byte[] aBuffer,
                                 int aOffset,
                                 int aLen)
Send a packet

Parameters:
aBuffer - the buffer containing the packet
aOffset - the offset in the buffer - must be zero
aLen - the length of the packet
Returns:
true iff the packet was successfully sent

setRangeLong

public static void setRangeLong()
Set long range


setRangeShort

public static void setRangeShort()
Set short range


resetSerial

public static void resetSerial()
Reset the link - null


waitTillSent

public static void waitTillSent()
Wait until the packet is sent - null


getLink

public static RCXLink getLink()
Get the RCXLink object associated with the Serial class

Returns:
the link