|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
rcx.josx.rcxcomm.LNP
public class LNP
An interface for sending and receiving Lego Network Protocol addressing and integrity layer packets. It uses an integrity packet handler to send and receive integrity and addressing packet. Listeners can be registered to process incoming broadcasts of integrity packets or addressing packets on multiple ports. Currently assumes that the most significant nibble of the address byte is the machine and the least significant nibble is the port number. The machine addresses is defined by the startListening call, but is also part of the source address sent with addressing packets.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary | |
---|---|
static void |
addAddressingHandler(AddressingHandler handler,
byte port)
Register an integrity handler to process incoming addressing packets for a specific port. |
static void |
addIntegrityHandler(IntegrityHandler handler)
Register an integrity handler to process incoming broadcasts |
static boolean |
addressingWrite(byte[] packet,
int len,
byte dest,
byte source)
Sends packet of up to 255 bytes to the destination address from the source address. |
static boolean |
integrityWrite(byte[] packet,
int len)
Broadcasts an integrity packet |
void |
run()
Background thread to listen for incoming packets and call the appropriate listeners. |
static void |
startListening(byte addr)
Start listening for incoming broadcasts and addressing packets. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static boolean addressingWrite(byte[] packet, int len, byte dest, byte source)
packet
- the packet to sendlen
- the length of the packetdest
- the destination machine and portsource
- the source machine and address
public static boolean integrityWrite(byte[] packet, int len)
packet
- the packet to broadcastlen
- the length of the packet
public static void addIntegrityHandler(IntegrityHandler handler)
handler
- the integrity handlerpublic static void addAddressingHandler(AddressingHandler handler, byte port)
handler
- the addressing handlerpublic static void startListening(byte addr)
addr
- the address of this machine. The least significant 4 bits should be zero.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |