Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.pc.comm
Class NXTCommand

    java.lang.Object
      lejos.pc.comm.NXTCommand

All Implemented Interfaces:
  NXTProtocol

    public class NXTCommand

extends java.lang.Object
implements NXTProtocol

Sends LCP requests to the NXT and receives replies. Uses an object that implements the NXTComm interface for low-level communication.

Field Summary

Fields inherited from interface lejos.pc.comm.NXTProtocol
`ANGLE, ANGLESTEPSMODE, BOOLEANMODE, BOOT, BRAKE, CELSIUSMODE, CLOSE, CUSTOM, DELETE, DELETE_USER_FLASH, DIRECT_COMMAND_NOREPLY, DIRECT_COMMAND_REPLY, FAHRENHEITMODE, FIND_FIRST, FIND_NEXT, GET_BATTERY_LEVEL, GET_CURRENT_PROGRAM_NAME, GET_DEVICE_INFO, GET_FIRMWARE_VERSION, GET_INPUT_VALUES, GET_OUTPUT_STATE, HIGH_SPEED_BUFFER, KEEP_ALIVE, LIGHT_ACTIVE, LIGHT_INACTIVE, LOWSPEED, LOWSPEED_9V, LS_GET_STATUS, LS_READ, LS_WRITE, MESSAGE_READ, MESSAGE_WRITE, MODEMASK, MOTOR_RUN_STATE_IDLE, MOTOR_RUN_STATE_RAMPDOWN, MOTOR_RUN_STATE_RAMPUP, MOTOR_RUN_STATE_RUNNING, MOTORON, NO_OF_SENSOR_TYPES, NO_SENSOR, NXJ_DEFRAG, NXJ_DISCONNECT, NXJ_FIND_FIRST, NXJ_FIND_NEXT, OPEN_APPEND_DATA, OPEN_READ, OPEN_READ_LINEAR, OPEN_WRITE, OPEN_WRITE_DATA, OPEN_WRITE_LINEAR, PCTFULLSCALEMODE, PERIODCOUNTERMODE, PLAY_SOUND_FILE, PLAY_TONE, POLL, POLL_BUFFER, POLL_LENGTH, RAWMODE, READ, REFLECTION, REGULATED, REGULATION_MODE_IDLE, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_MOTOR_SYNC, REPLY_COMMAND, RESET_MOTOR_POSITION, RESET_SCALED_INPUT_VALUE, SET_BRICK_NAME, SET_INPUT_MODE, SET_OUTPUT_STATE, SLOPEMASK, SOUND_DB, SOUND_DBA, START_PROGRAM, STOP_PROGRAM, STOP_SOUND_PLAYBACK, SWITCH, SYSTEM_COMMAND_NOREPLY, SYSTEM_COMMAND_REPLY, TEMPERATURE, TRANSITIONCNTMODE, WRITE`

Method Summary
`void` | `addLogListener(NXTCommLogListener listener)` register log listener
`void` | `close()` Call the close() command when your program ends, otherwise you will have to turn the NXT brick off/on before you run another program.
`byte` | `closeFile(byte handle)` Closes an open file.
`byte` | `defrag()`
`byte` | `delete(java.lang.String fileName)`
`FileInfo` | `findFirst(java.lang.String wildCard)`
`FileInfo` | `findNext(byte handle)`
`int` | `getBatteryLevel()`
`java.lang.String` | `getFriendlyName()`
`InputValues` | `getInputValues(int port)`
`java.lang.String` | `getLocalAddress()`
`OutputState` | `getOutputState(int port)` Retrieves the current output state for a port.
`static NXTCommand` | `getSingleton()`
`byte[]` | `messageRead(byte remoteInbox, byte localInbox, boolean remove)`
`boolean` | `open(NXTInfo nxt)`
`FileInfo` | `openRead(java.lang.String fileName)` Opens a file on the NXT for reading.
`byte` | `openWrite(java.lang.String fileName, int size)` Opens a file on the NXT for writing.
`byte[]` | `readFile(byte handle, int length)` Returns requested number of bytes from a file.
`void` | `removeLogListener(NXTCommLogListener listener)` unregister log listener
`NXTInfo[]` | `search(java.lang.String name, int protocol)`
`byte` | `setFriendlyName(java.lang.String name)`
`void` | `setNXTCommBlueTooth()`
`void` | `setVerify(boolean verify)`
`byte` | `startProgram(java.lang.String fileName)` Starts a program already on the NXT.
`byte` | `writeFile(byte handle, byte[] data)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### search

    public NXTInfo[] search(java.lang.String name,
                            int protocol)
                     throws NXTCommException

  Throws:
    `NXTCommException`

### setNXTCommBlueTooth

    public void setNXTCommBlueTooth()
                             throws NXTCommException

  Throws:
    `NXTCommException`

### open

    public boolean open(NXTInfo nxt)
                 throws NXTCommException

  Throws:
    `NXTCommException`

### setVerify

    public void setVerify(boolean verify)

### startProgram

    public byte startProgram(java.lang.String fileName)
                      throws java.io.IOException

  Starts a program already on the NXT.

  Parameters:
    `fileName` -
  Returns:
    the status
  Throws:
    `java.io.IOException`

### openRead

    public FileInfo openRead(java.lang.String fileName)
                      throws java.io.IOException

  Opens a file on the NXT for reading. Returns a handle number and file size, enclosed in a FileInfo object.

  Parameters:
    `fileName` - e.g. "Woops.wav"
  Returns:
    fileInfo object giving details of the file
  Throws:
    `java.io.IOException`

### openWrite

    public byte openWrite(java.lang.String fileName,
                          int size)
                   throws java.io.IOException

  Opens a file on the NXT for writing.

  Parameters:
    `fileName` - e.g. "Woops.rso"
  Returns:
    File Handle number
  Throws:
    `java.io.IOException`

### closeFile

    public byte closeFile(byte handle)
                   throws java.io.IOException

  Closes an open file.

  Parameters:
    `handle` - File handle number.
  Returns:
    Error code 0 = success
  Throws:
    `java.io.IOException`

### delete

    public byte delete(java.lang.String fileName)
                throws java.io.IOException

  Throws:
    `java.io.IOException`

### findFirst

    public FileInfo findFirst(java.lang.String wildCard)
                       throws java.io.IOException

  Parameters:
    `wildCard` - [filename].[extension], *.[extension], [filename].*, *.*
  Returns:
    fileInfo object giving details of the file
  Throws:
    `java.io.IOException`

### findNext

    public FileInfo findNext(byte handle)
                      throws java.io.IOException

  Parameters:
    `handle` - Handle number from the previous found file or fromthe Find First command.
  Returns:
    fileInfo object giving details of the file
  Throws:
    `java.io.IOException`

### getBatteryLevel

    public int getBatteryLevel()
                        throws java.io.IOException

  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Call the close() command when your program ends, otherwise you will have to turn the NXT brick off/on before you run another program.

  Throws:
    `java.io.IOException`

### writeFile

    public byte writeFile(byte handle,
                          byte[] data)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### readFile

    public byte[] readFile(byte handle,
                           int length)
                    throws java.io.IOException

  Returns requested number of bytes from a file. File must first be opened using the openRead() command.

  Parameters:
    `handle` - File handle number (from openRead method)
    `length` - Number of bytes to read.
  Returns:
    the bytes requested
  Throws:
    `java.io.IOException`

### defrag

    public byte defrag()
                throws java.io.IOException

  Throws:
    `java.io.IOException`

### getFriendlyName

    public java.lang.String getFriendlyName()
                                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### setFriendlyName

    public byte setFriendlyName(java.lang.String name)
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### getLocalAddress

    public java.lang.String getLocalAddress()
                                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### getInputValues

    public InputValues getInputValues(int port)
                               throws java.io.IOException

  Throws:
    `java.io.IOException`

### getOutputState

    public OutputState getOutputState(int port)
                               throws java.io.IOException

  Retrieves the current output state for a port.

  Parameters:
    `port` - - 0 to 3
  Returns:
    OutputState - returns a container object for output state variables.
  Throws:
    `java.io.IOException`

### messageRead

    public byte[] messageRead(byte remoteInbox,
                              byte localInbox,
                              boolean remove)
                       throws java.io.IOException

  Parameters:
    `remoteInbox` - 0-9
    `localInbox` - 0-9
    `remove` - True clears the message from the remote inbox.
  Returns:
    the message as an array of bytes
  Throws:
    `java.io.IOException`

### getSingleton

    public static NXTCommand getSingleton()

### addLogListener

    public void addLogListener(NXTCommLogListener listener)

  register log listener

  Parameters:
    `listener` -

### removeLogListener

    public void removeLogListener(NXTCommLogListener listener)

  unregister log listener

  Parameters:
    `listener` -

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD