public class ModernRoboticsUsbLegacyModule extends ModernRoboticsUsbI2cController implements LegacyModule
HardwareDeviceManager to create an instance of this classModernRoboticsUsbDevice.CreateReadWriteRunnableI2cController.I2cPortReadyBeginEndNotifications, I2cController.I2cPortReadyCallbackHardwareDevice.Manufactureri2cPortReadyBeginEndCallbacks, notificationsActive, numberOfI2cPortscreateReadWriteRunnable, readWriteRunnable, readWriteServiceI2C_BUFFER_START_ADDRESS| Constructor and Description |
|---|
ModernRoboticsUsbLegacyModule(Context context,
SerialNumber serialNumber,
OpenRobotUsbDevice openRobotUsbDevice,
SyncdDevice.Manager manager)
Use ModernRoboticsUsbDeviceManager to create an instance of this class
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearI2cPortActionFlag(int physicalPort)
Clears the port action flag, undoing the effect of previous setI2cPortActionFlag()
|
void |
copyBufferIntoWriteBuffer(int physicalPort,
byte[] buffer)
Copy a byte array into the buffer that is set to be written out to the device
|
protected void |
createSegments() |
void |
deregisterForPortReadyCallback(int port)
De-register for port ready notifications.
|
protected void |
doArm() |
protected void |
doPretend() |
void |
enable9v(int physicalPort,
boolean enable)
Enable or disable 9V power on a port
|
void |
enableAnalogReadMode(int physicalPort)
Enable a physical port in analog read mode
|
void |
enableI2cReadMode(int physicalPort,
I2cAddr i2cAddress,
int memAddress,
int length)
Enable read mode for a particular I2C device
|
void |
enableI2cWriteMode(int physicalPort,
I2cAddr i2cAddress,
int memAddress,
int length)
Enable write mode for a particular I2C device
|
java.lang.String |
getConnectionInfo()
Get connection information about this device in a human readable format
|
byte[] |
getCopyOfReadBuffer(int physicalPort)
Get a copy of the most recent data read in from the device
|
byte[] |
getCopyOfWriteBuffer(int physicalPort)
Get a copy of the data that is set to be written out to the device
|
java.lang.String |
getDeviceName()
Device Name
|
I2cController.I2cPortReadyCallback |
getI2cPortReadyCallback(int port)
Returns the callback currently registered to receive portIsReady notifications for the
indicated port
|
byte[] |
getI2cReadCache(int physicalPort)
Get direct access to the cache that I2C reads will be populated into
|
java.util.concurrent.locks.Lock |
getI2cReadCacheLock(int physicalPort)
Get access to the read cache lock.
|
TimeWindow |
getI2cReadCacheTimeWindow(int physicalPort)
Returns the time window object into which timestamps are placed as the read cache is populated
|
byte[] |
getI2cWriteCache(int physicalPort)
Get direct access to the cache that I2C writes will be populated into
|
java.util.concurrent.locks.Lock |
getI2cWriteCacheLock(int physicalPort)
Get access to the write cache lock.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
double |
getMaxAnalogInputVoltage()
Returns the maximum voltage that can be read by our analog inputs
|
int |
getMaxI2cWriteLatency(int port)
Returns the maximum interval, in milliseconds, from when the controller receives an I2c write
transmission over USB to when that write is actually issued to the I2c device.
|
protected java.lang.String |
getTag() |
void |
initializeHardware() |
boolean |
isI2cPortActionFlagSet(int physicalPort)
Get the port action flag; this flag is set if the particular port is busy.
|
boolean |
isI2cPortInReadMode(int physicalPort)
Is the port in read mode?
|
boolean |
isI2cPortInWriteMode(int physicalPort)
Is the port in write mode?
|
boolean |
isI2cPortReady(int physicalPort)
Determine if a physical port is ready
|
byte[] |
readAnalogRaw(int physicalPort)
Read an analog value from a device; only works in analog read mode
|
double |
readAnalogVoltage(int physicalPort)
Reads the analog voltage from a device.
|
void |
readComplete() |
void |
readI2cCacheFromController(int physicalPort)
Read the local cache in from the I2C Controller
NOTE: unless this method is called the internal cache isn't updated
|
void |
readI2cCacheFromModule(int port)
Deprecated.
|
void |
registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback callback,
int port)
Register to be notified when a given port is ready.
|
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
setData(int physicalPort,
byte[] data,
int length) |
void |
setDigitalLine(int physicalPort,
int line,
boolean set)
Set the value of digital line 0 or 1 while in analog mode.
|
void |
setI2cPortActionFlag(int physicalPort)
Set the port action flag; this flag tells the controller to send the
current data in its buffer to the I2C device
|
void |
setReadMode(int physicalPort,
int i2cAddr,
int memAddr,
int memLen) |
void |
setWriteMode(int physicalPort,
int i2cAddress,
int memAddress) |
void |
writeI2cCacheToController(int physicalPort)
Write the local cache to the I2C Controller
NOTE: unless this method is called the internal cache isn't updated
|
void |
writeI2cCacheToModule(int port)
Deprecated.
|
void |
writeI2cPortFlagOnlyToController(int physicalPort)
Write just the port action flag in the local cache to the I2C controller
|
void |
writeI2cPortFlagOnlyToModule(int port)
Deprecated.
|
deregisterForPortReadyBeginEndCallback, getPortReadyBeginEndCallback, isArmed, registerForPortReadyBeginEndCallback, shutdownComplete, startupComplete, throwIfI2cPortIsInvalidarmDevice, disarmDevice, getCreateReadWriteRunnable, getOpenRobotUsbDevice, getPretendDevice, getReadWriteRunnable, getVersion, read, read8, readFromWriteCache, readFromWriteCache, write, write8, write8, write8, writeCompleteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitderegisterForPortReadyBeginEndCallback, getPortReadyBeginEndCallback, getSerialNumber, isArmed, registerForPortReadyBeginEndCallbackclose, getVersionpublic static final java.lang.String TAG
public static final double MAX_ANALOG_INPUT_VOLTAGE
public static final boolean DEBUG_LOGGING
public static final int MONITOR_LENGTH
public static final byte START_ADDRESS
public static final byte NUMBER_OF_PORTS
public static final byte I2C_ACTION_FLAG
public static final byte I2C_NO_ACTION_FLAG
public static final byte SIZE_ANALOG_BUFFER
public static final byte SIZE_I2C_BUFFER
public static final byte SIZE_OF_PORT_BUFFER
public static final byte NXT_MODE_ANALOG
public static final byte NXT_MODE_I2C
public static final byte NXT_MODE_9V_ENABLED
public static final byte NXT_MODE_DIGITAL_0
public static final byte NXT_MODE_DIGITAL_1
public static final byte NXT_MODE_READ
public static final byte NXT_MODE_WRITE
public static final byte BUFFER_FLAG_S0
public static final byte BUFFER_FLAG_S1
public static final byte BUFFER_FLAG_S2
public static final byte BUFFER_FLAG_S3
public static final byte BUFFER_FLAG_S4
public static final byte BUFFER_FLAG_S5
public static final int ADDRESS_BUFFER_STATUS
public static final int ADDRESS_ANALOG_PORT_S0
public static final int ADDRESS_ANALOG_PORT_S1
public static final int ADDRESS_ANALOG_PORT_S2
public static final int ADDRESS_ANALOG_PORT_S3
public static final int ADDRESS_ANALOG_PORT_S4
public static final int ADDRESS_ANALOG_PORT_S5
public static final int ADDRESS_I2C_PORT_SO
public static final int ADDRESS_I2C_PORT_S1
public static final int ADDRESS_I2C_PORT_S2
public static final int ADDRESS_I2C_PORT_S3
public static final int ADDRESS_I2C_PORT_S4
public static final int ADDRESS_I2C_PORT_S5
public static final byte OFFSET_I2C_PORT_MODE
public static final byte OFFSET_I2C_PORT_I2C_ADDRESS
public static final byte OFFSET_I2C_PORT_MEMORY_ADDRESS
public static final byte OFFSET_I2C_PORT_MEMORY_LENGTH
public static final byte OFFSET_I2C_PORT_MEMORY_BUFFER
public static final byte OFFSET_I2C_PORT_FLAG
public static final int[] ADDRESS_ANALOG_PORT_MAP
public static final int[] ADDRESS_I2C_PORT_MAP
public static final int[] BUFFER_FLAG_MAP
public static final int[] DIGITAL_LINE
public static final int[] PORT_9V_CAPABLE
protected final byte[] lastI2cPortModes
public ModernRoboticsUsbLegacyModule(Context context,
SerialNumber serialNumber,
OpenRobotUsbDevice openRobotUsbDevice,
SyncdDevice.Manager manager)
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionprotected java.lang.String getTag()
protected void doArm()
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionprotected void doPretend()
throws RobotCoreException,
java.lang.InterruptedException
RobotCoreExceptionjava.lang.InterruptedExceptionprotected void createSegments()
public void initializeHardware()
initializeHardware in class ModernRoboticsUsbDevicepublic HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
getDeviceName in interface HardwareDevicegetDeviceName in class ModernRoboticsUsbDevicepublic java.lang.String getConnectionInfo()
HardwareDevicegetConnectionInfo in interface HardwareDevicepublic void resetDeviceConfigurationForOpMode()
HardwareDeviceresetDeviceConfigurationForOpMode in interface HardwareDevicepublic int getMaxI2cWriteLatency(int port)
I2cControllergetMaxI2cWriteLatency in interface I2cControllerpublic void registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback callback, int port)
registerForI2cPortReadyCallback in interface I2cControllercallback - register a callbackport - port to be monitoredpublic I2cController.I2cPortReadyCallback getI2cPortReadyCallback(int port)
I2cControllergetI2cPortReadyCallback in interface I2cControllerport - the port of interestpublic void deregisterForPortReadyCallback(int port)
I2cControllerderegisterForPortReadyCallback in interface I2cControllerport - port no longer being monitored.public void enableI2cReadMode(int physicalPort,
I2cAddr i2cAddress,
int memAddress,
int length)
I2cControllerenableI2cReadMode in interface I2cControllerphysicalPort - the port the device is attached toi2cAddress - the i2c address of the devicememAddress - mem address at which to start readinglength - number of bytes to readpublic void enableI2cWriteMode(int physicalPort,
I2cAddr i2cAddress,
int memAddress,
int length)
I2cControllerenableI2cWriteMode in interface I2cControllerphysicalPort - the port the device is attached toi2cAddress - the i2c address of the devicememAddress - the memory address at which to start writinglength - number of bytes to readpublic void enableAnalogReadMode(int physicalPort)
LegacyModuleenableAnalogReadMode in interface LegacyModulephysicalPort - physical port number on the devicepublic void enable9v(int physicalPort,
boolean enable)
LegacyModuleenable9v in interface LegacyModulephysicalPort - physical port number on the deviceenable - true to enable; false to disablepublic void setReadMode(int physicalPort,
int i2cAddr,
int memAddr,
int memLen)
public void setWriteMode(int physicalPort,
int i2cAddress,
int memAddress)
public void setData(int physicalPort,
byte[] data,
int length)
public void setDigitalLine(int physicalPort,
int line,
boolean set)
LegacyModuleThese are port pins 5 and 6.
setDigitalLine in interface LegacyModulephysicalPort - physical port number on the deviceline - line 0 or 1set - true to set; otherwise falsepublic byte[] readAnalogRaw(int physicalPort)
LegacyModulereadAnalogRaw in interface LegacyModulephysicalPort - physical port number on the devicepublic double readAnalogVoltage(int physicalPort)
LegacyModulereadAnalogVoltage in interface LegacyModulephysicalPort - the port whose voltage is to be readpublic double getMaxAnalogInputVoltage()
LegacyModulegetMaxAnalogInputVoltage in interface LegacyModulepublic byte[] getCopyOfReadBuffer(int physicalPort)
I2cControllergetCopyOfReadBuffer in interface I2cControllerphysicalPort - the port the device is attached topublic byte[] getCopyOfWriteBuffer(int physicalPort)
I2cControllergetCopyOfWriteBuffer in interface I2cControllerphysicalPort - the port the device is attached topublic void copyBufferIntoWriteBuffer(int physicalPort,
byte[] buffer)
I2cControllercopyBufferIntoWriteBuffer in interface I2cControllerphysicalPort - the port the device is attached tobuffer - buffer to copypublic void setI2cPortActionFlag(int physicalPort)
I2cControllersetI2cPortActionFlag in interface I2cControllerphysicalPort - physical port number on the deviceI2cController.clearI2cPortActionFlag(int)public void clearI2cPortActionFlag(int physicalPort)
I2cControllerclearI2cPortActionFlag in interface I2cControllerphysicalPort - physical port number on the deviceI2cController.setI2cPortActionFlag(int)public boolean isI2cPortActionFlagSet(int physicalPort)
I2cControllerisI2cPortActionFlagSet in interface I2cControllerphysicalPort - physical port number on the devicepublic void readI2cCacheFromController(int physicalPort)
I2cControllerreadI2cCacheFromController in interface I2cControllerphysicalPort - physical port number on the devicepublic void writeI2cCacheToController(int physicalPort)
I2cControllerwriteI2cCacheToController in interface I2cControllerphysicalPort - physical port number on the devicepublic void writeI2cPortFlagOnlyToController(int physicalPort)
I2cControllerwriteI2cPortFlagOnlyToController in interface I2cControllerphysicalPort - physical port number on the devicepublic boolean isI2cPortInReadMode(int physicalPort)
I2cControllerisI2cPortInReadMode in interface I2cControllerphysicalPort - physical port number on the devicepublic boolean isI2cPortInWriteMode(int physicalPort)
I2cControllerisI2cPortInWriteMode in interface I2cControllerphysicalPort - physical port number on the devicepublic boolean isI2cPortReady(int physicalPort)
I2cControllerisI2cPortReady in interface I2cControllerphysicalPort - physical port number on the devicepublic void readComplete()
throws java.lang.InterruptedException
readComplete in interface ReadWriteRunnable.CallbackreadComplete in class ModernRoboticsUsbDevicejava.lang.InterruptedExceptionpublic java.util.concurrent.locks.Lock getI2cReadCacheLock(int physicalPort)
I2cControllerThis is needed if you are accessing the read cache directly. The read cache lock needs to be acquired before attempting to interact with the read cache
getI2cReadCacheLock in interface I2cControllerphysicalPort - physical port number on the devicepublic java.util.concurrent.locks.Lock getI2cWriteCacheLock(int physicalPort)
I2cControllerThis is needed if you are accessing the write cache directly. The write cache lock needs to be acquired before attempting to interact with the write cache
getI2cWriteCacheLock in interface I2cControllerphysicalPort - physical port number on the devicepublic byte[] getI2cReadCache(int physicalPort)
I2cControllerPlease lock the cache before accessing it.
getI2cReadCache in interface I2cControllerphysicalPort - physical port number on the devicepublic TimeWindow getI2cReadCacheTimeWindow(int physicalPort)
I2cControllergetI2cReadCacheTimeWindow in interface I2cControllerphysicalPort - physical port number on the devicepublic byte[] getI2cWriteCache(int physicalPort)
I2cControllerPlease lock the cache before accessing it.
getI2cWriteCache in interface I2cControllerphysicalPort - physical port number on the device@Deprecated public void readI2cCacheFromModule(int port)
I2cControllerreadI2cCacheFromModule in interface I2cControllerport - physical port number on the device@Deprecated public void writeI2cCacheToModule(int port)
I2cControllerwriteI2cCacheToModule in interface I2cControllerport - physical port number on the device@Deprecated public void writeI2cPortFlagOnlyToModule(int port)
I2cControllerwriteI2cPortFlagOnlyToModule in interface I2cControllerport - physical port number on the device