|
|||||||||
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 | |
---|---|
static int |
MAX_FILENAMELENGTH
|
Constructor Summary | |
---|---|
NXTCommand(NXTCommRequest nxtComm)
Create a NXTCommand object. |
Method Summary | |
---|---|
void |
boot()
Put the NXT into SAMBA mode, ready to update the firmware. |
void |
close()
Deprecated. call disconnect, then close the underlying NXTComm |
byte |
closeFile(byte handle)
Closes an open file. |
byte |
defrag()
A NXJ extension to defrag the file system |
byte |
delete(String fileName)
Delete a file on the NXT |
byte |
deleteUserFlash()
Deletes user flash memory. |
void |
disconnect()
Tell the NXT that the connection is aborted. |
FileInfo |
findFirst(String wildCard)
Find the first file on the NXT. |
FileInfo |
findNext(byte handle)
Find the next file on the NXT |
boolean |
getAutoRun()
leJOS-specific command to get the auto run setring |
int |
getBatteryLevel()
Get the battery reading |
String |
getCurrentProgramName()
Name of current running program. |
String |
getDefaultProgram()
leJOS-specific command to get the default program name |
DeviceInfo |
getDeviceInfo()
Gets device information |
FirmwareInfo |
getFirmwareVersion()
Get the fimrware version. |
String |
getFriendlyName()
Get the friendly name of the NXT |
InputValues |
getInputValues(int port)
Get input values for a specific NXT sensor port |
int |
getKeyClickVolume()
leJOS-specific command to get the master volume level |
String |
getLocalAddress()
Get the local address of the NXT. |
NXJFirmwareInfo |
getNXJFirmwareInfo()
leJOS-specific command to get the NXJ firmware and menu information |
String |
getNXJFirmwareVersion()
leJOS-specific command to get the NXJ firmware version |
String |
getNXJMenuVersion()
leJOS-specific command to get the NXJ start-up menu version |
OutputState |
getOutputState(int port)
Retrieves the current output state for a port. |
int |
getSleepTime()
leJOS-specific method to get the menu sleep time |
int |
getTachoCount(int port)
Retrieves tacho count. |
int |
getVolume()
leJOS-specific command to get the master volume level |
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(String fileName)
Opens a file on the NXT for reading. |
byte |
openWrite(String fileName,
int size)
Opens a file on the NXT for writing. |
byte |
playSoundFile(String fileName,
boolean repeat)
|
byte |
playTone(int frequency,
int duration)
Plays a tone on NXT speaker. |
int |
readFile(byte handle,
byte[] data,
int offset,
int length)
Returns requested number of bytes from a file. |
byte |
resetMotorPosition(int port,
boolean relative)
Resets either RotationCount or BlockTacho |
byte |
setAutoRun(boolean on)
leJOS-specific command to set auto-run on or off |
byte |
setDefaultProgram(String name)
leJOS-specific command to set the default program |
byte |
setFriendlyName(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. |
byte |
setKeyClickVolume(byte volume)
leJOS-specific command to set the key click volume level |
byte |
setOutputState(int port,
byte power,
int mode,
int regulationMode,
int turnRatio,
int runState,
int tachoLimit)
|
byte |
setSleepTime(byte seconds)
leJOS-specific command to the the sleep time for the menu |
void |
setVerify(boolean verify)
Toggle the verify flag. |
byte |
setVolume(byte volume)
leJOS-specific command to set the master volume level |
byte |
startProgram(String fileName)
Starts a program already on the NXT. |
byte |
stopProgram()
Forces the currently executing program to stop. |
byte |
stopSoundPlayback()
Stops sound file playing. |
String |
uploadFile(File file,
String nxtFileName)
Upload a file to the NXT |
byte |
writeFile(byte handle,
byte[] data,
int offset,
int length)
Write data to the file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_FILENAMELENGTH
Constructor Detail |
---|
public NXTCommand(NXTCommRequest nxtComm)
Method Detail |
---|
public void setVerify(boolean verify)
verify
- true causes all commands to return a response.public byte startProgram(String fileName) throws IOException
fileName
- the file name
IOException
public byte stopProgram() throws IOException
IOException
public String getCurrentProgramName() throws IOException
IOException
public FileInfo openRead(String fileName) throws IOException
fileName
- e.g. "Woops.wav"
IOException
public byte openWrite(String fileName, int size) throws IOException
fileName
- e.g. "Woops.wav"
IOException
public byte closeFile(byte handle) throws IOException
handle
- File handle number.
IOException
public byte delete(String fileName) throws IOException
fileName
- the name of the file
IOException
public FileInfo findFirst(String wildCard) throws IOException
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
IOException
public FileInfo findNext(byte handle) throws IOException
handle
- Handle number from the previous found file or from the Find
First command.
IOException
public int getBatteryLevel() throws IOException
IOException
@Deprecated public void close() throws IOException
IOException
public void disconnect() throws IOException
IOException
public void boot() throws IOException
IOException
public byte writeFile(byte handle, byte[] data, int offset, int length) throws IOException
handle
- the file handledata
- the data to write
IOException
public String uploadFile(File file, String nxtFileName) throws IOException
file
- the file to uploadnxtFileName
- the name of the file on the NXT
IOException
public int readFile(byte handle, byte[] data, int offset, int length) throws IOException
handle
- File handle number (from openRead method)data
- Buffer to which data is writtenoffset
- Index of first byte to be overwrittenlength
- Number of bytes to read
IOException
public byte defrag() throws IOException
IOException
public String getFriendlyName() throws IOException
IOException
public byte setFriendlyName(String name) throws IOException
name
- the friendly name
IOException
public String getLocalAddress() throws IOException
IOException
public InputValues getInputValues(int port) throws IOException
port
- the port number
IOException
public OutputState getOutputState(int port) throws IOException
port
- - 0 to 3
IOException
public int getTachoCount(int port) throws IOException
port
- - 0 to 3
IOException
public byte setInputMode(int port, int sensorType, int sensorMode) throws IOException
port
- - 0 to 3sensorType
- - Enumeration for sensor type (see NXTProtocol)sensorMode
- - Enumeration for sensor mode (see NXTProtocol)
IOException
public byte[] LSGetStatus(byte port) throws IOException
port
- 0-3
IOException
public byte[] LSRead(byte port) throws IOException
port
-
IOException
public byte LSWrite(byte port, byte[] txData, byte rxDataLength) throws IOException
txData
- Transmitted data.rxDataLength
- Receive data length.port
- 0-3
IOException
public byte[] messageRead(byte remoteInbox, byte localInbox, boolean remove) throws IOException
remoteInbox
- 0-9localInbox
- 0-9remove
- True clears the message from the remote inbox.
IOException
public byte messageWrite(byte[] message, byte inbox) throws IOException
message
- String to send. A null termination is automatically appended.inbox
- Inbox Number 0 - 9
IOException
public byte playTone(int frequency, int duration) throws IOException
frequency
- - 100 to 2000?duration
- - In milliseconds.
IOException
public byte playSoundFile(String fileName, boolean repeat) throws IOException
IOException
public byte stopSoundPlayback() throws IOException
IOException
public byte resetMotorPosition(int port, boolean relative) throws IOException
port
- Output port (0-2)relative
- TRUE: BlockTacho, FALSE: RotationCount
IOException
public byte setOutputState(int port, byte power, int mode, int regulationMode, int turnRatio, int runState, int tachoLimit) throws 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.
IOException
public DeviceInfo getDeviceInfo() throws IOException
IOException
public FirmwareInfo getFirmwareVersion() throws IOException
IOException
public byte deleteUserFlash() throws IOException
IOException
public byte setDefaultProgram(String name) throws IOException
name
- the default program name
IOException
public byte setVolume(byte volume) throws IOException
volume
- the master volume level
IOException
public byte setKeyClickVolume(byte volume) throws IOException
volume
- the key click volume level
IOException
public byte setAutoRun(boolean on) throws IOException
on
- true = on, false = off
IOException
public int getVolume() throws IOException
IOException
public int getKeyClickVolume() throws IOException
IOException
public boolean getAutoRun() throws IOException
IOException
public String getNXJFirmwareVersion() throws IOException
IOException
public String getNXJMenuVersion() throws IOException
IOException
public NXJFirmwareInfo getNXJFirmwareInfo() throws IOException
IOException
public int getSleepTime() throws IOException
IOException
public String getDefaultProgram() throws IOException
IOException
public byte setSleepTime(byte seconds) throws IOException
seconds
- the number of seconds before shutdown
IOException
public boolean isOpen()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |