|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.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(String fileName)
Delete a file on the NXT |
byte |
deleteUserFlash()
Deletes user flash memory. |
FileInfo |
findFirst(String wildCard)
Find the first file on the NXT. |
FileInfo |
findFirstNXJ(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 |
String |
getCurrentProgramName()
Name of current running program. |
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 |
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(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. |
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(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(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)
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(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 findFirstNXJ(String wildCard) throws IOException
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
IOException
public FileInfo findFirst(String wildCard) throws IOException
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
IOException
public FileInfo findNextNXJ(byte handle) throws IOException
handle
- Handle number from the previous found file or from the Find
First command.
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
public void close() throws IOException
IOException
public void boot() throws IOException
IOException
public byte writeFile(byte handle, byte[] data) 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 byte[] readFile(byte handle, int length) throws IOException
handle
- File handle number (from openRead method)length
- 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 static NXTCommand getSingleton()
public boolean isOpen()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |