|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.nxt.remote.NXTCommand
public class NXTCommand
Sends LCP requests to the NXT and receives replies. Uses an object that implements the NXTComm interface for low-level communication.
Field Summary |
---|
Constructor Summary | |
---|---|
NXTCommand()
Create a NXTCommand object. |
Method Summary | |
---|---|
void |
boot()
Put the NXT into SAMBA mode, ready to update the firmware |
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()
A NXJ extension to defrag the file system |
byte |
delete(java.lang.String fileName)
Delete a file on the NXT |
byte |
deleteUserFlash()
Deletes user flash memory. |
FileInfo |
findFirst(java.lang.String wildCard)
Find the first file on the NXT. |
FileInfo |
findFirstNXJ(java.lang.String wildCard)
Find the first file on the NXT. |
FileInfo |
findNext(byte handle)
Find the next file on the NXT |
FileInfo |
findNextNXJ(byte handle)
Find the next file on the NXT. |
int |
getBatteryLevel()
Get the battery reading |
java.lang.String |
getCurrentProgramName()
Name of current running program. |
DeviceInfo |
getDeviceInfo()
Gets device information |
FirmwareInfo |
getFirmwareVersion()
Get the fimrware version. |
java.lang.String |
getFriendlyName()
Get the friendly name of the NXT |
InputValues |
getInputValues(int port)
Get input values for a specific NXT sensor port |
java.lang.String |
getLocalAddress()
Get the local address of the NXT. |
OutputState |
getOutputState(int port)
Retrieves the current output state for a port. |
static NXTCommand |
getSingleton()
Get the singleton NXTCommand object. |
int |
getTachoCount(int port)
Retrieves tacho count. |
boolean |
isOpen()
Test is connection is open |
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)
|
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. |
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[] |
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 |
setFriendlyName(java.lang.String name)
Set the friendly name of the NXT |
byte |
setInputMode(int port,
int sensorType,
int sensorMode)
Tells the NXT what type of sensor you are using and the mode to operate in. |
void |
setNXTComm(NXTCommRequest nxtComm)
Set the NXTComm used to communicate with the NXT. |
byte |
setOutputState(int port,
byte power,
int mode,
int regulationMode,
int turnRatio,
int runState,
int tachoLimit)
|
void |
setVerify(boolean verify)
Toggle the verify flag. |
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. |
java.lang.String |
uploadFile(java.io.File file,
java.lang.String nxtFileName)
Upload a file to the NXT |
byte |
writeFile(byte handle,
byte[] data)
Write data to the file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NXTCommand()
Method Detail |
---|
public void setNXTComm(NXTCommRequest nxtComm)
nxtComm
- a nxtComm instance which must be connected to a NXTpublic void setVerify(boolean verify)
verify
- true causes all commands to return a response.public byte startProgram(java.lang.String fileName) throws java.io.IOException
fileName
- the file name
java.io.IOException
public byte stopProgram() throws java.io.IOException
java.io.IOException
public java.lang.String getCurrentProgramName() throws java.io.IOException
java.io.IOException
public FileInfo openRead(java.lang.String fileName) throws java.io.IOException
fileName
- e.g. "Woops.wav"
java.io.IOException
public byte openWrite(java.lang.String fileName, int size) throws java.io.IOException
fileName
- e.g. "Woops.wav"
java.io.IOException
public byte closeFile(byte handle) throws java.io.IOException
handle
- File handle number.
java.io.IOException
public byte delete(java.lang.String fileName) throws java.io.IOException
fileName
- the name of the file
java.io.IOException
public FileInfo findFirstNXJ(java.lang.String wildCard) throws java.io.IOException
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
java.io.IOException
public FileInfo findFirst(java.lang.String wildCard) throws java.io.IOException
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
java.io.IOException
public FileInfo findNextNXJ(byte handle) throws java.io.IOException
handle
- Handle number from the previous found file or from the Find
First command.
java.io.IOException
public FileInfo findNext(byte handle) throws java.io.IOException
handle
- Handle number from the previous found file or from the Find
First command.
java.io.IOException
public int getBatteryLevel() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public void boot() throws java.io.IOException
java.io.IOException
public byte writeFile(byte handle, byte[] data) throws java.io.IOException
handle
- the file handledata
- the data to write
java.io.IOException
public java.lang.String uploadFile(java.io.File file, java.lang.String nxtFileName) throws java.io.IOException
file
- the file to uploadnxtFileName
- the name of the file on the NXT
java.io.IOException
public byte[] readFile(byte handle, int length) throws java.io.IOException
handle
- File handle number (from openRead method)length
- Number of bytes to read.
java.io.IOException
public byte defrag() throws java.io.IOException
java.io.IOException
public java.lang.String getFriendlyName() throws java.io.IOException
java.io.IOException
public byte setFriendlyName(java.lang.String name) throws java.io.IOException
name
- the friendly name
java.io.IOException
public java.lang.String getLocalAddress() throws java.io.IOException
java.io.IOException
public InputValues getInputValues(int port) throws java.io.IOException
port
- the port number
java.io.IOException
public OutputState getOutputState(int port) throws java.io.IOException
port
- - 0 to 3
java.io.IOException
public int getTachoCount(int port) throws java.io.IOException
port
- - 0 to 3
java.io.IOException
public byte setInputMode(int port, int sensorType, int sensorMode) throws java.io.IOException
port
- - 0 to 3sensorType
- - Enumeration for sensor type (see NXTProtocol)sensorMode
- - Enumeration for sensor mode (see NXTProtocol)
java.io.IOException
public byte[] LSGetStatus(byte port) throws java.io.IOException
port
- 0-3
java.io.IOException
public byte[] LSRead(byte port) throws java.io.IOException
port
-
java.io.IOException
public byte LSWrite(byte port, byte[] txData, byte rxDataLength) throws java.io.IOException
txData
- Transmitted data.rxDataLength
- Receive data length.port
- 0-3
java.io.IOException
public byte[] messageRead(byte remoteInbox, byte localInbox, boolean remove) throws java.io.IOException
remoteInbox
- 0-9localInbox
- 0-9remove
- True clears the message from the remote inbox.
java.io.IOException
public byte messageWrite(byte[] message, byte inbox) throws java.io.IOException
message
- String to send. A null termination is automatically appended.inbox
- Inbox Number 0 - 9
java.io.IOException
public byte playTone(int frequency, int duration) throws java.io.IOException
frequency
- - 100 to 2000?duration
- - In milliseconds.
java.io.IOException
public byte playSoundFile(java.lang.String fileName, boolean repeat) throws java.io.IOException
java.io.IOException
public byte stopSoundPlayback() throws java.io.IOException
java.io.IOException
public byte resetMotorPosition(int port, boolean relative) throws java.io.IOException
port
- Output port (0-2)relative
- TRUE: BlockTacho, FALSE: RotationCount
java.io.IOException
public byte setOutputState(int port, byte power, int mode, int regulationMode, int turnRatio, int runState, int tachoLimit) throws java.io.IOException
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.
java.io.IOException
public DeviceInfo getDeviceInfo() throws java.io.IOException
java.io.IOException
public FirmwareInfo getFirmwareVersion() throws java.io.IOException
java.io.IOException
public byte deleteUserFlash() throws java.io.IOException
java.io.IOException
public static NXTCommand getSingleton()
public boolean isOpen()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |