lejos.nxt.comm
Class LCP

java.lang.Object
  extended by lejos.nxt.comm.LCP

public class LCP
extends Object

Implements the Lego Communication Protocol, with some extensions for lejos NXJ.


Field Summary
static byte BOOT
           
static byte CLOSE
           
static byte DELETE
           
static byte DELETE_USER_FLASH
           
static byte DIRECT_COMMAND_NOREPLY
           
static byte DIRECT_COMMAND_REPLY
           
static byte FIND_FIRST
           
static byte FIND_NEXT
           
static byte GET_BATTERY_LEVEL
           
static byte GET_CURRENT_PROGRAM_NAME
           
static byte GET_DEVICE_INFO
           
static byte GET_FIRMWARE_VERSION
           
static byte GET_INPUT_VALUES
           
static byte GET_OUTPUT_STATE
           
static InBox[] inBoxes
           
static byte KEEP_ALIVE
           
static byte LS_GET_STATUS
           
static byte LS_READ
           
static byte LS_WRITE
           
static byte MESSAGE_READ
           
static byte MESSAGE_WRITE
           
static byte NXJ_DEFRAG
           
static byte NXJ_DISCONNECT
           
static byte NXJ_GET_AUTO_RUN
           
static byte NXJ_GET_DEFAULT_PROGRAM
           
static byte NXJ_GET_KEY_CLICK_VOLUME
           
static byte NXJ_GET_SLEEP_TIME
           
static byte NXJ_GET_VERSION
           
static byte NXJ_GET_VOLUME
           
static byte NXJ_PACKET_MODE
           
static byte NXJ_SET_AUTO_RUN
           
static byte NXJ_SET_DEFAULT_PROGRAM
           
static byte NXJ_SET_KEY_CLICK_VOLUME
           
static byte NXJ_SET_SLEEP_TIME
           
static byte NXJ_SET_VOLUME
           
static byte OPEN_APPEND_DATA
           
static byte OPEN_READ
           
static byte OPEN_READ_LINEAR
           
static byte OPEN_WRITE
           
static byte OPEN_WRITE_DATA
           
static byte OPEN_WRITE_LINEAR
           
static byte PLAY_SOUND_FILE
           
static byte PLAY_TONE
           
static byte POLL
           
static byte POLL_LENGTH
           
static byte READ
           
static byte REPLY_COMMAND
           
static byte RESET_MOTOR_POSITION
           
static byte RESET_SCALED_INPUT_VALUE
           
static byte SET_BRICK_NAME
           
static byte SET_INPUT_MODE
           
static byte SET_OUTPUT_STATE
           
static byte START_PROGRAM
           
static byte STOP_PROGRAM
           
static byte STOP_SOUND_PLAYBACK
           
static byte SYSTEM_COMMAND_NOREPLY
           
static byte SYSTEM_COMMAND_REPLY
           
static byte WRITE
           
 
Method Summary
static void addMessageListener(LCPMessageListener aListener)
          Add a listener for incoming LCP messages.
static int emulateCommand(byte[] cmd, int cmdLen, byte[] reply)
          Emulates a Lego firmware Direct or System command
static void messageWrite(int mailbox, String msg)
          Write a message to a remote inbox
static void setMenuVersion(int version, int revision)
          Store the menu version and revision
static void updateMsg(int mailbox, String key, String msg)
          Update a message in the inbox, or add a new one if no match
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inBoxes

public static InBox[] inBoxes

DIRECT_COMMAND_REPLY

public static final byte DIRECT_COMMAND_REPLY
See Also:
Constant Field Values

SYSTEM_COMMAND_REPLY

public static final byte SYSTEM_COMMAND_REPLY
See Also:
Constant Field Values

REPLY_COMMAND

public static final byte REPLY_COMMAND
See Also:
Constant Field Values

DIRECT_COMMAND_NOREPLY

public static final byte DIRECT_COMMAND_NOREPLY
See Also:
Constant Field Values

SYSTEM_COMMAND_NOREPLY

public static final byte SYSTEM_COMMAND_NOREPLY
See Also:
Constant Field Values

START_PROGRAM

public static final byte START_PROGRAM
See Also:
Constant Field Values

STOP_PROGRAM

public static final byte STOP_PROGRAM
See Also:
Constant Field Values

PLAY_SOUND_FILE

public static final byte PLAY_SOUND_FILE
See Also:
Constant Field Values

PLAY_TONE

public static final byte PLAY_TONE
See Also:
Constant Field Values

SET_OUTPUT_STATE

public static final byte SET_OUTPUT_STATE
See Also:
Constant Field Values

SET_INPUT_MODE

public static final byte SET_INPUT_MODE
See Also:
Constant Field Values

GET_OUTPUT_STATE

public static final byte GET_OUTPUT_STATE
See Also:
Constant Field Values

GET_INPUT_VALUES

public static final byte GET_INPUT_VALUES
See Also:
Constant Field Values

RESET_SCALED_INPUT_VALUE

public static final byte RESET_SCALED_INPUT_VALUE
See Also:
Constant Field Values

MESSAGE_WRITE

public static final byte MESSAGE_WRITE
See Also:
Constant Field Values

RESET_MOTOR_POSITION

public static final byte RESET_MOTOR_POSITION
See Also:
Constant Field Values

GET_BATTERY_LEVEL

public static final byte GET_BATTERY_LEVEL
See Also:
Constant Field Values

STOP_SOUND_PLAYBACK

public static final byte STOP_SOUND_PLAYBACK
See Also:
Constant Field Values

KEEP_ALIVE

public static final byte KEEP_ALIVE
See Also:
Constant Field Values

LS_GET_STATUS

public static final byte LS_GET_STATUS
See Also:
Constant Field Values

LS_WRITE

public static final byte LS_WRITE
See Also:
Constant Field Values

LS_READ

public static final byte LS_READ
See Also:
Constant Field Values

GET_CURRENT_PROGRAM_NAME

public static final byte GET_CURRENT_PROGRAM_NAME
See Also:
Constant Field Values

MESSAGE_READ

public static final byte MESSAGE_READ
See Also:
Constant Field Values

NXJ_DISCONNECT

public static final byte NXJ_DISCONNECT
See Also:
Constant Field Values

NXJ_DEFRAG

public static final byte NXJ_DEFRAG
See Also:
Constant Field Values

NXJ_SET_DEFAULT_PROGRAM

public static final byte NXJ_SET_DEFAULT_PROGRAM
See Also:
Constant Field Values

NXJ_SET_SLEEP_TIME

public static final byte NXJ_SET_SLEEP_TIME
See Also:
Constant Field Values

NXJ_SET_VOLUME

public static final byte NXJ_SET_VOLUME
See Also:
Constant Field Values

NXJ_SET_KEY_CLICK_VOLUME

public static final byte NXJ_SET_KEY_CLICK_VOLUME
See Also:
Constant Field Values

NXJ_SET_AUTO_RUN

public static final byte NXJ_SET_AUTO_RUN
See Also:
Constant Field Values

NXJ_GET_VERSION

public static final byte NXJ_GET_VERSION
See Also:
Constant Field Values

NXJ_GET_DEFAULT_PROGRAM

public static final byte NXJ_GET_DEFAULT_PROGRAM
See Also:
Constant Field Values

NXJ_GET_SLEEP_TIME

public static final byte NXJ_GET_SLEEP_TIME
See Also:
Constant Field Values

NXJ_GET_VOLUME

public static final byte NXJ_GET_VOLUME
See Also:
Constant Field Values

NXJ_GET_KEY_CLICK_VOLUME

public static final byte NXJ_GET_KEY_CLICK_VOLUME
See Also:
Constant Field Values

NXJ_GET_AUTO_RUN

public static final byte NXJ_GET_AUTO_RUN
See Also:
Constant Field Values

OPEN_READ

public static final byte OPEN_READ
See Also:
Constant Field Values

OPEN_WRITE

public static final byte OPEN_WRITE
See Also:
Constant Field Values

READ

public static final byte READ
See Also:
Constant Field Values

WRITE

public static final byte WRITE
See Also:
Constant Field Values

CLOSE

public static final byte CLOSE
See Also:
Constant Field Values

DELETE

public static final byte DELETE
See Also:
Constant Field Values

FIND_FIRST

public static final byte FIND_FIRST
See Also:
Constant Field Values

FIND_NEXT

public static final byte FIND_NEXT
See Also:
Constant Field Values

GET_FIRMWARE_VERSION

public static final byte GET_FIRMWARE_VERSION
See Also:
Constant Field Values

OPEN_WRITE_LINEAR

public static final byte OPEN_WRITE_LINEAR
See Also:
Constant Field Values

OPEN_READ_LINEAR

public static final byte OPEN_READ_LINEAR
See Also:
Constant Field Values

OPEN_WRITE_DATA

public static final byte OPEN_WRITE_DATA
See Also:
Constant Field Values

OPEN_APPEND_DATA

public static final byte OPEN_APPEND_DATA
See Also:
Constant Field Values

BOOT

public static final byte BOOT
See Also:
Constant Field Values

SET_BRICK_NAME

public static final byte SET_BRICK_NAME
See Also:
Constant Field Values

GET_DEVICE_INFO

public static final byte GET_DEVICE_INFO
See Also:
Constant Field Values

DELETE_USER_FLASH

public static final byte DELETE_USER_FLASH
See Also:
Constant Field Values

POLL_LENGTH

public static final byte POLL_LENGTH
See Also:
Constant Field Values

POLL

public static final byte POLL
See Also:
Constant Field Values

NXJ_PACKET_MODE

public static final byte NXJ_PACKET_MODE
See Also:
Constant Field Values
Method Detail

addMessageListener

public static void addMessageListener(LCPMessageListener aListener)
Add a listener for incoming LCP messages. Currently only one listener is supported.

Parameters:
aListener - the LCP message listener

emulateCommand

public static int emulateCommand(byte[] cmd,
                                 int cmdLen,
                                 byte[] reply)
Emulates a Lego firmware Direct or System command

Parameters:
cmd - the buffer containing the command
cmdLen - the length of the command

messageWrite

public static void messageWrite(int mailbox,
                                String msg)
Write a message to a remote inbox

Parameters:
mailbox - the remote inbox
msg - the message

updateMsg

public static void updateMsg(int mailbox,
                             String key,
                             String msg)
Update a message in the inbox, or add a new one if no match

Parameters:
mailbox - the remote mail box
key - an initial prefix of the string
msg - the new message

setMenuVersion

public static void setMenuVersion(int version,
                                  int revision)
Store the menu version and revision

Parameters:
version - the menu version number
revision - the menu revision number