|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.comm.NXTCommDevice lejos.nxt.comm.RS485
public class RS485
Low-level RS485/BitBus Network implementation This class provides simple low level access to the underlying RS485 hardware implemented on port 4 of the Lego NXT. It also supports a higher level network connection based on this hardware, in the form of a BitBus netowk node implmentation. For full details see the BitBus specifiaction at: http://www.bitbus.org/ Basically the network provides a simple master/slave implementation using SDLC packet framing with CRC-16-CITT error checking. In this implementation the on the wire format has been modified to use the Lego defined baud rate of 921600 bps and uses byte stuffing rather than bit stuffing (since there is no hardware support). The protocol has been integrated with the standard leJOS connection object and offers up to 7 connections. The BitBus broadcast mechanism is used to provide a higher level mapping between NXT address (we use the Bluetooth address of the nxt), or name and the underlying BitBus address (a single byte). The original implementation used Java for frame handling. However this was found to add considerable overhead to the process. To improve performance (by a factor of approximately 10), the lowest level routines have been re-implemented in C and moved into the firmware as native methods.
Field Summary | |
---|---|
static int |
BUFSZ
|
static int |
MAX_CONNECTIONS
|
Fields inherited from class lejos.nxt.comm.NXTCommDevice |
---|
ADDRESS_LEN, cs, NAME, NAME_LEN, SERIAL_NO |
Method Summary | |
---|---|
static RS485Connection |
connect(String target)
Connect to a remote device by name/address |
static RS485Connection |
connect(String target,
int mode)
Connect to a remote device either by name or by address. |
static NXTCommConnector |
getConnector()
Provides access to the singleton connection object. |
static void |
hsDisable()
Disable the RS485 hardware port. |
static void |
hsEnable()
Enable the RS485 hardware port. |
static int |
hsRead(byte[] buf,
int offset,
int len)
Low level read from the RS485 port |
static int |
hsWrite(byte[] buf,
int offset,
int len)
Low level write to the RS485 hardware port. |
static RS485Connection |
waitForConnection(int timeout,
int mode)
Wait for a connection from another nxt |
Methods inherited from class lejos.nxt.comm.NXTCommDevice |
---|
addressToString, getAddress, getName, isAddress, loadSettings, nameToString, setAddress, setName, stringToAddress, stringToName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BUFSZ
public static final int MAX_CONNECTIONS
Method Detail |
---|
public static RS485Connection connect(String target, int mode)
target
- The address/name of the remote device to connect tomode
- I/O mode to use for this connection
public static RS485Connection connect(String target)
target
- The name/address of the remote device
public static RS485Connection waitForConnection(int timeout, int mode)
timeout
- How long to wait for the connect 0 means wait forevermode
- The I/O mode to use for this connection
public static void hsEnable()
public static void hsDisable()
public static int hsRead(byte[] buf, int offset, int len)
buf
- offset
- len
-
public static int hsWrite(byte[] buf, int offset, int len)
buf
- offset
- len
-
public static NXTCommConnector getConnector()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |