|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjosx.rcxcomm.Tower
public class Tower
Low-level interface to the Lego IR Tower Used by RCXPort to send and receive
messages to and from the RCX. Can be used to send any packet or any sequence
of bytes to the RCX. The tower is opened with a call to open() or open(port)
and closed by a call to close(). send
can be used to send a
packet, and receive to receive one. write
can read a sequence
of bytes, and read can read them.
Note that the methods that have returned error codes in former releases are throwing exceptions now
(in particular the open()
methods).
Additionally, the Tower()
constructor with no String argument for the port has beeen removed, for it lead to multiple errors.
The send(byte[],int)
method is deprecated now and no longer public.
Field Summary | |
---|---|
static int |
DEFAULT_READ_TIMEOUT
|
Constructor Summary | |
---|---|
Tower(java.lang.String tty)
Create the tower class. |
Method Summary | |
---|---|
protected int |
close()
Close the tower |
void |
closeTower()
Close tower. |
int |
getError()
Deprecated. use exception handling instead of status codes |
boolean |
isRCXAlive()
Check if RCX is alive |
boolean |
isUSB()
Is tower an usb tower?. |
protected int |
open(java.lang.String p,
boolean fastMode)
Open the tower |
void |
openTower(boolean fastMode)
Open the tower. |
protected int |
read(byte[] b,
int timeout)
Deprecated. do not call native methods, use #readBytes instead |
int |
readBytes(byte[] data)
Low-level read. |
int |
readBytes(byte[] data,
int timeout)
Low-level read. |
protected int |
receive(byte[] b,
int timeout)
Deprecated. do not call native methods, use #receivePacket instead |
int |
receivePacket(byte[] data)
Receive a packet. |
int |
receivePacket(byte[] data,
int timeout)
Receive a packet. |
protected int |
send(byte[] b,
int n)
Deprecated. do not call native methods, use #sendPacket instead |
void |
sendPacket(byte[] data)
Send a packet to the RCX, e.g 0x10 for ping. |
int |
sendPacketReceivePacket(byte[] data,
byte[] response,
int retries)
Send a packet and retrieve answer. |
int |
sendPacketReceivePacket(byte[] data,
byte[] response,
int retries,
int timeout)
Send a packet and retrieve answer. |
protected int |
write(byte[] b,
int n)
Deprecated. do not call native methods, use #writeBytes instead |
void |
writeBytes(byte[] data)
Write low-level bytes to the tower, e.g 0xff550010ef10ef for ping. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_READ_TIMEOUT
Constructor Detail |
---|
public Tower(java.lang.String tty)
Method Detail |
---|
public void openTower(boolean fastMode) throws TowerException
TowerException
public void closeTower() throws TowerException
TowerException
public int getError()
public void writeBytes(byte[] data) throws TowerException
data
- bytes to send
TowerException
public void sendPacket(byte[] data) throws TowerException
data
- packet to send
TowerException
public int readBytes(byte[] data) throws TowerException
data
- buffer to receive bytes
TowerException
public int readBytes(byte[] data, int timeout) throws TowerException
data
- buffer to receive bytestimeout
- read timeout in ms
TowerException
public int receivePacket(byte[] data) throws TowerException
data
- buffer to receive packet
TowerException
public int receivePacket(byte[] data, int timeout) throws TowerException
data
- buffer to receive packettimeout
- read timeout in ms
TowerException
public int sendPacketReceivePacket(byte[] data, byte[] response, int retries) throws TowerException
data
- bytes to sendresponse
- buffer to receive packet
TowerException
public int sendPacketReceivePacket(byte[] data, byte[] response, int retries, int timeout) throws TowerException
data
- bytes to sendresponse
- buffer to receive packettimeout
- read timeout in ms
TowerException
protected final int open(java.lang.String p, boolean fastMode)
p
- port to use, e.g. usb or COM1fastMode
- open port for fast mode transmissions?protected final int close()
public final boolean isRCXAlive()
public final boolean isUSB()
protected final int write(byte[] b, int n)
b
- bytes to sendn
- number of bytes
protected final int send(byte[] b, int n)
b
- packet to sendn
- number of bytes
protected final int read(byte[] b, int timeout)
b
- buffer to receive bytestimeout
- read timeout in ms
protected final int receive(byte[] b, int timeout)
b
- buffer to receive packettimeout
- read timeout in ms
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |