public class I2cDeviceImpl extends I2cControllerPortDeviceImpl implements I2cDevice, HardwareDevice, I2cController.I2cPortReadyCallback
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
protected I2cController.I2cPortReadyCallback |
callback |
protected java.util.concurrent.atomic.AtomicInteger |
callbackCount |
controller, physicalPort
Constructor and Description |
---|
I2cDeviceImpl(I2cController controller,
int port)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clearI2cPortActionFlag()
Clears the flag that
I2cDevice.setI2cPortActionFlag() sets |
void |
close()
Closes this device
|
protected void |
controllerNowArmedOrPretending()
intended as a subclass hook
|
void |
copyBufferIntoWriteBuffer(byte[] buffer)
Copy a byte array into the buffer that is set to be written out to the device
|
void |
deregisterForPortReadyBeginEndCallback()
deregister for port-ready begin and cessation notifications
|
void |
deregisterForPortReadyCallback()
Unregister for a port-ready callback
|
void |
enableI2cReadMode(I2cAddr i2cAddr,
int memAddress,
int length)
Deprecated.
|
void |
enableI2cWriteMode(I2cAddr i2cAddr,
int memAddress,
int length)
Deprecated.
|
int |
getCallbackCount()
Returns the number of callbacks ever experienced by this I2cDevice instance, whether or not
they were ever seen by a registered callback.
|
java.lang.String |
getConnectionInfo()
Get connection information about this device in a human readable format
|
I2cController |
getController()
returns the I2cController on which this device is found
|
byte[] |
getCopyOfReadBuffer()
Get a copy of the most recent data read in from the device
|
byte[] |
getCopyOfWriteBuffer()
Get a copy of the data that is set to be written out to the device
|
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
I2cController.I2cPortReadyCallback |
getI2cPortReadyCallback()
returns the currently registered port-ready callback for this device
|
byte[] |
getI2cReadCache()
Get direct access to the read cache used by this I2C device
|
java.util.concurrent.locks.Lock |
getI2cReadCacheLock()
Get access to the read cache lock.
|
TimeWindow |
getI2cReadCacheTimeWindow()
Returns the time window object into which time stamps are written when the read cache is updated
|
byte[] |
getI2cWriteCache()
Get direct access to the write cache used by this I2C device
|
java.util.concurrent.locks.Lock |
getI2cWriteCacheLock()
Get access to the write cache lock.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
int |
getMaxI2cWriteLatency()
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.
|
int |
getPort()
returns the port number on the controller on which this device is found
|
I2cController.I2cPortReadyBeginEndNotifications |
getPortReadyBeginEndCallback()
returns the currently registered callback that will receive begin and cessation notifications
|
int |
getVersion()
Version
|
boolean |
isArmed()
Returns whether, as of this instant, this I2cDevice is alive and operational in
its normally expected mode; that is, whether it is currently in communication
with its underlying hardware or whether it is in some other state
|
boolean |
isI2cPortActionFlagSet()
Check whether or not the action flag is set for this I2C port
|
boolean |
isI2cPortInReadMode()
Query whether or not the port is in Read mode
|
boolean |
isI2cPortInWriteMode()
Query whether or not this port is in write mode
|
boolean |
isI2cPortReady()
Query whether or not this I2c port is ready
|
void |
portIsReady(int port) |
void |
readI2cCacheFromController()
Trigger a read of the I2C cache
|
void |
readI2cCacheFromModule()
Deprecated.
|
void |
registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback callback)
The method used to register for a port-ready callback
|
void |
registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications callback)
registers for notifications as to when port-ready callbacks begin or cease
|
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
setI2cPortActionFlag()
Set the port action flag; this flag tells the controller to send the
current data in its buffer to the I2C device
|
void |
writeI2cCacheToController()
Trigger a write of the I2C cache
|
void |
writeI2cCacheToModule()
Deprecated.
|
void |
writeI2cPortFlagOnlyToController()
Write only the action flag
|
void |
writeI2cPortFlagOnlyToModule()
Deprecated.
|
controllerNowDisarmed, finishConstruction, getI2cController, onModuleStateChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getI2cController
protected I2cController.I2cPortReadyCallback callback
protected java.util.concurrent.atomic.AtomicInteger callbackCount
public I2cDeviceImpl(I2cController controller, int port)
controller
- I2C controller this channel is attached toport
- port on the I2C controllerprotected void controllerNowArmedOrPretending()
I2cControllerPortDeviceImpl
controllerNowArmedOrPretending
in class I2cControllerPortDeviceImpl
public I2cController getController()
getController
in interface I2cDevice
public int getPort()
getPort
in interface I2cControllerPortDevice
getPort
in class I2cControllerPortDeviceImpl
@Deprecated public void enableI2cReadMode(I2cAddr i2cAddr, int memAddress, int length)
enableI2cReadMode
in interface I2cDevice
memAddress
- mem address at which to start readinglength
- number of bytes to readi2cAddr
- the address of the device on the I2c bus which should be readI2cDevice.writeI2cCacheToController()
@Deprecated public void enableI2cWriteMode(I2cAddr i2cAddr, int memAddress, int length)
enableI2cWriteMode
in interface I2cDevice
memAddress
- mem address at which to start writinglength
- number of bytes to writei2cAddr
- the address of the device on the I2c bus which should be writtenI2cDevice.writeI2cCacheToController()
public byte[] getCopyOfReadBuffer()
getCopyOfReadBuffer
in interface I2cDevice
I2cDevice.getI2cReadCache()
public byte[] getCopyOfWriteBuffer()
getCopyOfWriteBuffer
in interface I2cDevice
I2cDevice.getI2cWriteCache()
public void copyBufferIntoWriteBuffer(byte[] buffer)
copyBufferIntoWriteBuffer
in interface I2cDevice
buffer
- buffer to copyI2cDevice.getI2cWriteCache()
public void setI2cPortActionFlag()
setI2cPortActionFlag
in interface I2cDevice
I2cDevice.clearI2cPortActionFlag()
public void clearI2cPortActionFlag()
I2cDevice
I2cDevice.setI2cPortActionFlag()
setsclearI2cPortActionFlag
in interface I2cDevice
I2cDevice.setI2cPortActionFlag()
public boolean isI2cPortActionFlagSet()
isI2cPortActionFlagSet
in interface I2cDevice
public void readI2cCacheFromController()
readI2cCacheFromController
in interface I2cDevice
public void writeI2cCacheToController()
writeI2cCacheToController
in interface I2cDevice
public void writeI2cPortFlagOnlyToController()
writeI2cPortFlagOnlyToController
in interface I2cDevice
public boolean isI2cPortInReadMode()
isI2cPortInReadMode
in interface I2cDevice
public boolean isI2cPortInWriteMode()
isI2cPortInWriteMode
in interface I2cDevice
public boolean isI2cPortReady()
isI2cPortReady
in interface I2cDevice
I2cDeviceSynch
,
I2cDevice.registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback)
public java.util.concurrent.locks.Lock getI2cReadCacheLock()
This 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 I2cDevice
public java.util.concurrent.locks.Lock getI2cWriteCacheLock()
This is needed if you ace accessing the write cache directly. The write cache lock needs to be acquired before attempting to interact with the write cache
getI2cWriteCacheLock
in interface I2cDevice
public byte[] getI2cReadCache()
Please lock the cache before accessing it.
getI2cReadCache
in interface I2cDevice
I2cDevice.getI2cReadCacheLock()
,
I2cDevice.getCopyOfReadBuffer()
public TimeWindow getI2cReadCacheTimeWindow()
I2cDevice
getI2cReadCacheTimeWindow
in interface I2cDevice
I2cDevice.getI2cReadCache()
public byte[] getI2cWriteCache()
Please lock the cache before accessing it.
getI2cWriteCache
in interface I2cDevice
I2cDevice.getI2cWriteCacheLock()
,
I2cDevice.getCopyOfWriteBuffer()
public void portIsReady(int port)
portIsReady
in interface I2cController.I2cPortReadyCallback
public int getMaxI2cWriteLatency()
I2cDevice
getMaxI2cWriteLatency
in interface I2cDevice
public void registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback callback)
registerForI2cPortReadyCallback
in interface I2cDevice
callback
- pass in the I2C callback that will be called when the device is readyI2cDevice.getI2cPortReadyCallback()
,
I2cDevice.deregisterForPortReadyCallback()
public I2cController.I2cPortReadyCallback getI2cPortReadyCallback()
getI2cPortReadyCallback
in interface I2cDevice
public void deregisterForPortReadyCallback()
deregisterForPortReadyCallback
in interface I2cDevice
I2cDevice.registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback)
public int getCallbackCount()
I2cDevice
getCallbackCount
in interface I2cDevice
I2cDevice
instancepublic void registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications callback)
registerForPortReadyBeginEndCallback
in interface I2cDevice
callback
- the callback which will receive such notificationsI2cDevice.getPortReadyBeginEndCallback()
,
I2cDevice.deregisterForPortReadyBeginEndCallback()
public I2cController.I2cPortReadyBeginEndNotifications getPortReadyBeginEndCallback()
getPortReadyBeginEndCallback
in interface I2cDevice
I2cDevice.registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications)
public void deregisterForPortReadyBeginEndCallback()
deregisterForPortReadyBeginEndCallback
in interface I2cDevice
I2cDevice.registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications)
public boolean isArmed()
I2cDevice
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public java.lang.String getConnectionInfo()
HardwareDevice
getConnectionInfo
in interface HardwareDevice
public int getVersion()
HardwareDevice
getVersion
in interface HardwareDevice
public void resetDeviceConfigurationForOpMode()
HardwareDevice
resetDeviceConfigurationForOpMode
in interface HardwareDevice
public void close()
HardwareDevice
close
in interface HardwareDevice
@Deprecated public void readI2cCacheFromModule()
readI2cCacheFromModule
in interface I2cDevice
@Deprecated public void writeI2cCacheToModule()
writeI2cCacheToModule
in interface I2cDevice
@Deprecated public void writeI2cPortFlagOnlyToModule()
writeI2cPortFlagOnlyToModule
in interface I2cDevice