|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object icommand.nxt.comm.NXTCommand
public class NXTCommand
NXTCommand contains easily accessible commands for the Lego NXT.
Field Summary |
---|
Method Summary | |
---|---|
static 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 using iCommand. |
byte |
closeFile(byte handle)
Closes an open file. |
byte |
delete(java.lang.String fileName)
|
byte |
deleteUserFlash()
Deletes user flash memory (not including system modules). |
FileInfo |
findFirst(java.lang.String wildCard)
When no files exist within the system, an error message is returned in the package saying "File not found". |
FileInfo |
findNext(byte handle)
When no files exist within the system, an error message is returned in the package saying "File not found". |
int |
getBatteryLevel()
|
java.lang.String |
getCurrentProgramName()
Name of current running program. |
DeviceInfo |
getDeviceInfo()
|
FirmwareInfo |
getFirmwareVersion()
|
InputValues |
getInputValues(int port)
|
OutputState |
getOutputState(int port)
Retrieves the current output state for a port. |
static NXTCommand |
getSingleton()
|
boolean |
isVerify()
|
long |
keepAlive()
Keeps the NXT from shutting off. |
byte[] |
LSGetStatus(byte port)
Returns the status for an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
byte[] |
LSRead(byte port)
Reads data from an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
byte |
LSWrite(byte port,
byte[] txData,
byte rxDataLength)
Used to request data from an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
byte[] |
messageRead(byte remoteInbox,
byte localInbox,
boolean remove)
UNTESTED |
byte |
messageWrite(byte[] message,
byte inbox)
Sends a message to an inbox on the NXT for storage(?) For future reference, message size must be capped at 59 for USB. |
byte |
nxjDefrag()
Defrag the flash memory file system. |
byte |
nxjDisconnect()
Disconnects Bluetooth connection cleanly. |
static void |
open()
Opens a connection using iCommand. |
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 |
playSoundFile(java.lang.String fileName,
boolean repeat)
|
byte |
playTone(int frequency,
int duration)
Plays a tone on NXT speaker. |
byte[] |
poll(byte bufferNumber,
byte commandLength)
Reads bytes from the low-speed or high-speed buffer. |
byte |
pollLength(byte bufferNumber)
Returns the number of bytes for a command in the low-speed buffer or the high-speed buffer (0 = no command is ready). |
byte[] |
readFile(byte handle,
int length)
Returns requested number of bytes from a file. |
byte |
resetMotorPosition(int port,
boolean relative)
Resets either RotationCount or BlockTacho |
byte |
resetScaledInputValue(int port)
UNTESTED |
byte |
setBrickName(java.lang.String name)
|
byte |
setInputMode(int port,
int sensorType,
int sensorMode)
Tells the NXT what type of sensor you are using and the mode to operate in. |
byte |
setOutputState(int port,
byte power,
int mode,
int regulationMode,
int turnRatio,
int runState,
int tachoLimit)
|
static void |
setVerify(boolean verify)
|
byte |
startProgram(java.lang.String fileName)
Starts a program already on the NXT. |
byte |
stopProgram()
Forces the currently executing program to stop. |
byte |
stopSoundPlayback()
Stops sound file playing. |
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 |
---|
public byte startProgram(java.lang.String fileName)
fileName
-
public byte stopProgram()
public java.lang.String getCurrentProgramName()
public FileInfo openRead(java.lang.String fileName)
fileName
- e.g. "Woops.rso"
public byte openWrite(java.lang.String fileName, int size)
fileName
- e.g. "Woops.rso"
public byte[] readFile(byte handle, int length)
handle
- File handle number (from openRead method)length
- Number of bytes to read.
public byte writeFile(byte handle, byte[] data)
public byte closeFile(byte handle)
handle
- File handle number.
public byte delete(java.lang.String fileName)
public FirmwareInfo getFirmwareVersion()
public byte setBrickName(java.lang.String name)
public DeviceInfo getDeviceInfo()
public byte deleteUserFlash()
public byte pollLength(byte bufferNumber)
bufferNumber
- 0 = poll buffer (low-speed) 1 = high-speed buffer
public byte[] poll(byte bufferNumber, byte commandLength)
bufferNumber
- 0 = poll buffer (low-speed) 1 = high-speed buffercommandLength
- Number of bytes obtained from pollLength()
public FileInfo findFirst(java.lang.String wildCard)
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
public FileInfo findNext(byte handle)
handle
- Handle number from the previous found file or fromthe Find First command.
public byte playSoundFile(java.lang.String fileName, boolean repeat)
public byte stopSoundPlayback()
public byte setOutputState(int port, byte power, int mode, int regulationMode, int turnRatio, int runState, int tachoLimit)
port
- - Output port (0 - 2 or 0xFF for all three)power
- - Setpoint for power. (-100 to 100)mode
- - Setting the modes MOTORON, BRAKE, and/or REGULATED. This parameter is a bitfield, so to put it in brake mode and regulated, use BRAKEMODE + REGULATEDregulationMode
- - see NXTProtocol for enumerationsturnRatio
- - Need two motors? (-100 to 100)runState
- - see NXTProtocol for enumerationstachoLimit
- - Number of degrees(?) to rotate before stopping.public byte setInputMode(int port, int sensorType, int sensorMode)
port
- - 0 to 3sensorType
- - Enumeration for sensor type (see NXTProtocol)sensorMode
- - Enumeration for sensor mode (see NXTProtocol)public OutputState getOutputState(int port)
port
- - 0 to 3
public InputValues getInputValues(int port)
public byte resetScaledInputValue(int port)
port
-
public byte messageWrite(byte[] message, byte inbox)
message
- String to send. A null termination is automatically appended.inbox
- Inbox Number 0 - 9
public byte[] messageRead(byte remoteInbox, byte localInbox, boolean remove)
remoteInbox
- 0-9localInbox
- 0-9remove
- True clears the message from the remote inbox.
public byte resetMotorPosition(int port, boolean relative)
port
- Output port (0-2)relative
- TRUE: BlockTacho, FALSE: RotationCountpublic byte playTone(int frequency, int duration)
frequency
- - 100 to 2000?duration
- - In milliseconds.
public int getBatteryLevel()
public long keepAlive()
public byte[] LSGetStatus(byte port)
port
- 0-3
public byte LSWrite(byte port, byte[] txData, byte rxDataLength)
txData
- Transmitted data.rxDataLength
- Receive data length.port
- 0-3
public byte[] LSRead(byte port)
port
-
public boolean isVerify()
public static void setVerify(boolean verify)
public static void open() throws java.lang.RuntimeException
java.lang.Exception
- When open fails.
java.lang.RuntimeException
public static void close()
public byte nxjDisconnect()
public byte nxjDefrag()
public static NXTCommand getSingleton()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |