public interface UARTPort extends IOPort, BasicSensorPort
| Modifier and Type | Field and Description |
|---|---|
static int |
UART_RAW_MODE |
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW| Modifier and Type | Method and Description |
|---|---|
byte |
getByte()
read a single byte from the device
|
void |
getBytes(byte[] vals,
int offset,
int len)
read a number of bytes from the device
|
java.lang.String |
getModeName(int mode)
Get the string name of the specified mode.
|
int |
getShort()
read a single short from the device.
|
void |
getShorts(short[] vals,
int offset,
int len)
read a number of shorts from the device
|
boolean |
initialiseSensor(int mode)
Initialise the attached sensor and set it to the required operating mode.
Note: This method is not normally needed as the sensor will be initialised when it is opened. |
int |
rawRead(byte[] buffer,
int offset,
int len)
Read bytes from the uart port.
|
int |
rawWrite(byte[] buffer,
int offset,
int len)
Attempt to write a series of bytes to the uart port.
|
void |
resetSensor()
Reset the attached sensor.
|
void |
setBitRate(int bitRate)
Set the bit rate of the port when operating in RAW mode.
|
java.lang.String |
toString()
Return the current sensor reading to a string.
|
int |
write(byte[] buffer,
int offset,
int len)
Write bytes to the sensor
|
close, getName, setPinModegetMode, getType, setMode, setType, setTypeAndModestatic final int UART_RAW_MODE
byte getByte()
void getBytes(byte[] vals,
int offset,
int len)
vals - byte array to accept the dataoffset - offset at which to store the datalen - number of bytes to readint getShort()
void getShorts(short[] vals,
int offset,
int len)
vals - short array to accept the dataoffset - offset at which to store the datalen - number of shorts to readjava.lang.String getModeName(int mode)
TODO: Make other mode data available.
mode - mode to lookupjava.lang.String toString()
toString in class java.lang.Objectboolean initialiseSensor(int mode)
mode - target modevoid resetSensor()
int write(byte[] buffer,
int offset,
int len)
buffer - bytes to be writtenoffset - offset to the start of the writelen - length of the writeint rawRead(byte[] buffer,
int offset,
int len)
Note: The port must have been set into RAW mode to use this method.
buffer - The buffer to store the read bytesoffset - The offset at which to start storing the byteslen - The maximum number of bytes to readint rawWrite(byte[] buffer,
int offset,
int len)
Note: The port must have been set into RAW mode before attempting to use the method.
buffer - The buffer containing the bytes to writeoffset - The offset of the first bytelen - The number of bytes to attempt to writevoid setBitRate(int bitRate)
bitRate - The new bit rate