Package lejos.remote.ev3
Class RemoteUARTPort
- java.lang.Object
-
- lejos.remote.ev3.RemoteIOPort
-
- lejos.remote.ev3.RemoteUARTPort
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BasicSensorPort,IOPort,UARTPort,EV3SensorConstants,SensorConstants
public class RemoteUARTPort extends RemoteIOPort implements UARTPort
-
-
Field Summary
Fields Modifier and Type Field Description protected RMIUARTPortrmiprotected RMIEV3rmiEV3-
Fields inherited from class lejos.remote.ev3.RemoteIOPort
currentMode, openPorts, port, ref, typ
-
Fields inherited from interface lejos.hardware.sensor.EV3SensorConstants
ADC_REF, ADC_RES, CMD_AUTOMATIC, CMD_COL_AMB, CMD_COL_BLU, CMD_COL_COL, CMD_COL_GRN, CMD_COL_RED, CMD_CONNECTED, CMD_DISCONNECTED, CMD_FLOAT, CMD_NONE, CMD_PIN1, CMD_PIN5, CMD_SET, CONN_DAISYCHAIN, CONN_ERROR, CONN_INPUT_DUMB, CONN_INPUT_UART, CONN_NONE, CONN_NXT_COLOR, CONN_NXT_DUMB, CONN_NXT_IIC, CONN_OUTPUT_DUMB, CONN_OUTPUT_INTELLIGENT, CONN_OUTPUT_TACHO, CONN_UNKNOWN, IIC_DATA_LENGTH, MAX_DEVICE_DATALENGTH, MOTORS, PORTS, STATUS_BUSY, STATUS_FAIL, STATUS_OK, STATUS_STOP, TYPE_ERROR, TYPE_IIC_UNKNOWN, TYPE_MINITACHO, TYPE_NEWTACHO, TYPE_NONE, TYPE_NXT_COLOR, TYPE_NXT_IIC, TYPE_NXT_LIGHT, TYPE_NXT_SOUND, TYPE_NXT_TEST, TYPE_NXT_TOUCH, TYPE_TACHO, TYPE_TERMINAL, TYPE_THIRD_PARTY_END, TYPE_THIRD_PARTY_START, TYPE_UNKNOWN, UART_MAX_MODES
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
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
-
Fields inherited from interface lejos.hardware.port.UARTPort
UART_RAW_MODE
-
-
Constructor Summary
Constructors Constructor Description RemoteUARTPort(RMIEV3 rmiEV3)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the port, the port can not be used after this call.bytegetByte()read a single byte from the devicevoidgetBytes(byte[] vals, int offset, int len)read a number of bytes from the devicejava.lang.StringgetModeName(int mode)Get the string name of the specified mode.intgetShort()read a single short from the device.voidgetShorts(short[] vals, int offset, int len)read a number of shorts from the devicebooleaninitialiseSensor(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.booleanopen(int typ, int portNum, RemotePort remotePort)intrawRead(byte[] buffer, int offset, int len)Read bytes from the uart port.intrawWrite(byte[] buffer, int offset, int len)Attempt to write a series of bytes to the uart port.voidresetSensor()Reset the attached sensor.voidsetBitRate(int bitRate)Set the bit rate of the port when operating in RAW mode.booleansetMode(int mode)Set the current operating mode for the sensor attached to the port.java.lang.StringtoString()Return the current sensor reading to a string.intwrite(byte[] buffer, int offset, int len)Write bytes to the sensor-
Methods inherited from class lejos.remote.ev3.RemoteIOPort
getMode, getName, getType, setPinMode, setType, setTypeAndMode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface lejos.hardware.port.BasicSensorPort
getMode, getType, setType, setTypeAndMode
-
Methods inherited from interface lejos.hardware.port.IOPort
getName, setPinMode
-
-
-
-
Field Detail
-
rmi
protected RMIUARTPort rmi
-
rmiEV3
protected RMIEV3 rmiEV3
-
-
Constructor Detail
-
RemoteUARTPort
public RemoteUARTPort(RMIEV3 rmiEV3)
-
-
Method Detail
-
open
public boolean open(int typ, int portNum, RemotePort remotePort)- Overrides:
openin classRemoteIOPort
-
close
public void close()
Description copied from interface:IOPortClose the port, the port can not be used after this call.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceIOPort- Overrides:
closein classRemoteIOPort
-
getByte
public byte getByte()
Description copied from interface:UARTPortread a single byte from the device
-
getBytes
public void getBytes(byte[] vals, int offset, int len)Description copied from interface:UARTPortread a number of bytes from the device
-
getShort
public int getShort()
Description copied from interface:UARTPortread a single short from the device.
-
getShorts
public void getShorts(short[] vals, int offset, int len)Description copied from interface:UARTPortread a number of shorts from the device
-
getModeName
public java.lang.String getModeName(int mode)
Description copied from interface:UARTPortGet the string name of the specified mode.TODO: Make other mode data available.
- Specified by:
getModeNamein interfaceUARTPort- Parameters:
mode- mode to lookup- Returns:
- String version of the mode name
-
initialiseSensor
public boolean initialiseSensor(int mode)
Description copied from interface:UARTPortInitialise 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. However it may be of use if the sensor needs to be reset or in other cases.- Specified by:
initialiseSensorin interfaceUARTPort- Parameters:
mode- target mode- Returns:
- true if ok false if error
-
resetSensor
public void resetSensor()
Description copied from interface:UARTPortReset the attached sensor. Following this the sensor must be initialised before it can be used.- Specified by:
resetSensorin interfaceUARTPort
-
toString
public java.lang.String toString()
Description copied from interface:UARTPortReturn the current sensor reading to a string.
-
setMode
public boolean setMode(int mode)
Description copied from interface:BasicSensorPortSet the current operating mode for the sensor attached to the port.- Specified by:
setModein interfaceBasicSensorPort- Overrides:
setModein classRemoteIOPort- Parameters:
mode- the new mode- Returns:
- true if the mode has been accepted
-
rawRead
public int rawRead(byte[] buffer, int offset, int len)Description copied from interface:UARTPortRead bytes from the uart port. If no bytes are available return 0.Note: The port must have been set into RAW mode to use this method.
-
rawWrite
public int rawWrite(byte[] buffer, int offset, int len)Description copied from interface:UARTPortAttempt to write a series of bytes to the uart port. This call is non-blocking if there is no space in the write buffer a count of 0 is returned.Note: The port must have been set into RAW mode before attempting to use the method.
-
setBitRate
public void setBitRate(int bitRate)
Description copied from interface:UARTPortSet the bit rate of the port when operating in RAW mode.- Specified by:
setBitRatein interfaceUARTPort- Parameters:
bitRate- The new bit rate
-
write
public int write(byte[] buffer, int offset, int len)Description copied from interface:UARTPortWrite bytes to the sensor
-
-