Package lejos.remote.rcx
Class Serial
- java.lang.Object
-
- lejos.remote.rcx.Serial
-
public class Serial extends java.lang.ObjectEmulation of the RCX Serial class with Mindsensors NRLINK adapter.- Author:
- Lawrie Griffiths
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RCXLinkgetLink()Get the RCXLink object associated with the Serial classstatic booleanisPacketAvailable()Test if a packet is availablestatic intreadPacket(byte[] aBuffer)Read an assembled packet.static voidresetSerial()Reset the link - nullstatic booleansendPacket(byte[] aBuffer, int aOffset, int aLen)Send a packetstatic voidsetPort(I2CPort port)Set the sensor portstatic voidsetRangeLong()Set long rangestatic voidsetRangeShort()Set short rangestatic voidwaitTillSent()Wait until the packet is sent - null
-
-
-
Method Detail
-
setPort
public static void setPort(I2CPort 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 packetaOffset- the offset in the buffer - must be zeroaLen- 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
-
-