com.qualcomm.robotcore.hardware

## Interface I2cController

- All Superinterfaces:
    HardwareDevice
  All Known Subinterfaces:
    DeviceInterfaceModule, LegacyModule

      public interface I2cController
      extends HardwareDevice

  Interface for working with Digital Channel Controllers

  Different digital channel controllers will implement this interface.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `I2cController.I2cPortReadyBeginEndNotifications` A callback interface through which a client can learn when portIsReady callbacks begin and then later end.
    `static interface` | `I2cController.I2cPortReadyCallback` Callback interface for I2C port ready notifications

    - ### Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

      `HardwareDevice.Manufacturer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static byte` | `I2C_BUFFER_START_ADDRESS`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearI2cPortActionFlag(int port)` 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
    `void` | `deregisterForPortReadyBeginEndCallback(int port)` Deregisters any existing notifications callback for the given port
    `void` | `deregisterForPortReadyCallback(int port)` De-register for port ready notifications.
    `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
    `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
    `I2cController.I2cPortReadyCallback` | `getI2cPortReadyCallback(int port)` Returns the callback currently registered to receive portIsReady notifications for the indicated port
    `byte[]` | `getI2cReadCache(int port)` Get direct access to the cache that I2C reads will be populated into
    `java.util.concurrent.locks.Lock` | `getI2cReadCacheLock(int port)` Get access to the read cache lock.
    `TimeWindow` | `getI2cReadCacheTimeWindow(int port)` Returns the time window object into which timestamps are placed as the read cache is populated
    `byte[]` | `getI2cWriteCache(int port)` Get direct access to the cache that I2C writes will be populated into
    `java.util.concurrent.locks.Lock` | `getI2cWriteCacheLock(int port)` Get access to the write cache lock.
    `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.
    `I2cController.I2cPortReadyBeginEndNotifications` | `getPortReadyBeginEndCallback(int port)` Returns the current callback registered for a given port
    `SerialNumber` | `getSerialNumber()` Serial Number
    `boolean` | `isArmed()` Returns whether, as of this instant, this controller 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(int port)` Get the port action flag; this flag is set if the particular port is busy.
    `boolean` | `isI2cPortInReadMode(int port)` Is the port in read mode?
    `boolean` | `isI2cPortInWriteMode(int port)` Is the port in write mode?
    `boolean` | `isI2cPortReady(int port)` Determine if a physical port is ready
    `void` | `readI2cCacheFromController(int port)` 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 I2C port is ready.
    `void` | `registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications callback, int port)` Registers to be notification when portIsReady callbacks begin or cease
    `void` | `setI2cPortActionFlag(int port)` Set the port action flag; this flag tells the controller to send the current data in its buffer to the I2C device
    `void` | `writeI2cCacheToController(int port)` 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 port)` Write just the port action flag in the local cache to the I2C controller
    `void` | `writeI2cPortFlagOnlyToModule(int port)` Deprecated.

    - ### Methods inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

      `close, getConnectionInfo, getDeviceName, getManufacturer, getVersion, resetDeviceConfigurationForOpMode`

- - ### Field Detail

    - #### I2C_BUFFER_START_ADDRESS

          static final byte I2C_BUFFER_START_ADDRESS

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getSerialNumber

          SerialNumber getSerialNumber()

      Serial Number
      Returns:
        return the USB serial number of this device

    - #### enableI2cReadMode

          void enableI2cReadMode(int physicalPort,
                                 I2cAddr i2cAddress,
                                 int memAddress,
                                 int length)

      Enable read mode for a particular I2C device
      Parameters:
        `physicalPort` - the port the device is attached to
        `i2cAddress` - the i2c address of the device
        `memAddress` - mem address at which to start reading
        `length` - number of bytes to read

    - #### enableI2cWriteMode

          void enableI2cWriteMode(int physicalPort,
                                  I2cAddr i2cAddress,
                                  int memAddress,
                                  int length)

      Enable write mode for a particular I2C device
      Parameters:
        `physicalPort` - the port the device is attached to
        `i2cAddress` - the i2c address of the device
        `memAddress` - the memory address at which to start writing
        `length` - number of bytes to read

    - #### getCopyOfReadBuffer

          byte[] getCopyOfReadBuffer(int physicalPort)

      Get a copy of the most recent data read in from the device
      Parameters:
        `physicalPort` - the port the device is attached to
      Returns:
        a copy of the most recent data read in from the device

    - #### getCopyOfWriteBuffer

          byte[] getCopyOfWriteBuffer(int physicalPort)

      Get a copy of the data that is set to be written out to the device
      Parameters:
        `physicalPort` - the port the device is attached to
      Returns:
        a copy of the data set to be written out to the device

    - #### copyBufferIntoWriteBuffer

          void copyBufferIntoWriteBuffer(int physicalPort,
                                         byte[] buffer)

      Copy a byte array into the buffer that is set to be written out to the device
      Parameters:
        `physicalPort` - the port the device is attached to
        `buffer` - buffer to copy

    - #### setI2cPortActionFlag

          void setI2cPortActionFlag(int port)

      Set the port action flag; this flag tells the controller to send the current data in its buffer to the I2C device
      Parameters:
        `port` - physical port number on the device
      See Also:
        `clearI2cPortActionFlag(int)`

    - #### clearI2cPortActionFlag

          void clearI2cPortActionFlag(int port)

      Clears the port action flag, undoing the effect of previous setI2cPortActionFlag()
      Parameters:
        `port` - physical port number on the device
      See Also:
        `setI2cPortActionFlag(int)`

    - #### isI2cPortActionFlagSet

          boolean isI2cPortActionFlagSet(int port)

      Get the port action flag; this flag is set if the particular port is busy.
      Parameters:
        `port` - physical port number on the device

    - #### readI2cCacheFromController

          void readI2cCacheFromController(int port)

      Read the local cache in from the I2C Controller NOTE: unless this method is called the internal cache isn't updated
      Parameters:
        `port` - physical port number on the device

    - #### writeI2cCacheToController

          void writeI2cCacheToController(int port)

      Write the local cache to the I2C Controller NOTE: unless this method is called the internal cache isn't updated
      Parameters:
        `port` - physical port number on the device

    - #### writeI2cPortFlagOnlyToController

          void writeI2cPortFlagOnlyToController(int port)

      Write just the port action flag in the local cache to the I2C controller
      Parameters:
        `port` - physical port number on the device

    - #### isI2cPortInReadMode

          boolean isI2cPortInReadMode(int port)

      Is the port in read mode?
      Parameters:
        `port` - physical port number on the device
      Returns:
        true if in read mode; otherwise false

    - #### isI2cPortInWriteMode

          boolean isI2cPortInWriteMode(int port)

      Is the port in write mode?
      Parameters:
        `port` - physical port number on the device
      Returns:
        true if in write mode; otherwise false

    - #### isI2cPortReady

          boolean isI2cPortReady(int port)

      Determine if a physical port is ready
      Parameters:
        `port` - physical port number on the device
      Returns:
        true if ready for command; false otherwise

    - #### getI2cReadCacheLock

          java.util.concurrent.locks.Lock getI2cReadCacheLock(int port)

      Get access to the read cache lock.

      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

      Parameters:
        `port` - physical port number on the device
      Returns:
        lock

    - #### getI2cWriteCacheLock

          java.util.concurrent.locks.Lock getI2cWriteCacheLock(int port)

      Get access to the write cache lock.

      This 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

      Parameters:
        `port` - physical port number on the device
      Returns:
        lock

    - #### getI2cReadCache

          byte[] getI2cReadCache(int port)

      Get direct access to the cache that I2C reads will be populated into

      Please lock the cache before accessing it.

      Parameters:
        `port` - physical port number on the device
      Returns:
        byte array

    - #### getI2cReadCacheTimeWindow

          TimeWindow getI2cReadCacheTimeWindow(int port)

      Returns the time window object into which timestamps are placed as the read cache is populated
      Parameters:
        `port` - physical port number on the device
      Returns:
        the time window object into which timestamps are placed as the read cache is populated

    - #### getI2cWriteCache

          byte[] getI2cWriteCache(int port)

      Get direct access to the cache that I2C writes will be populated into

      Please lock the cache before accessing it.

      Parameters:
        `port` - physical port number on the device
      Returns:
        byte array

    - #### getMaxI2cWriteLatency

          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.
      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.

    - #### registerForI2cPortReadyCallback

          void registerForI2cPortReadyCallback(I2cController.I2cPortReadyCallback callback,
                                               int port)

      Register to be notified when a given I2C port is ready. The callback method will be called after the latest data has been read from the I2C Controller. Only one callback can be registered for a given port. Last to register wins.
      Parameters:
        `callback` - register a callback
        `port` - port to be monitored

    - #### getI2cPortReadyCallback

          I2cController.I2cPortReadyCallback getI2cPortReadyCallback(int port)

      Returns the callback currently registered to receive portIsReady notifications for the indicated port
      Parameters:
        `port` - the port of interest
      Returns:
        the currently registered callback, if any

    - #### deregisterForPortReadyCallback

          void deregisterForPortReadyCallback(int port)

      De-register for port ready notifications.
      Parameters:
        `port` - port no longer being monitored.

    - #### registerForPortReadyBeginEndCallback

          void registerForPortReadyBeginEndCallback(I2cController.I2cPortReadyBeginEndNotifications callback,
                                                    int port)

      Registers to be notification when portIsReady callbacks begin or cease
      Parameters:
        `callback` - the callback to register
        `port` - the port number to register the callback on

    - #### getPortReadyBeginEndCallback

          I2cController.I2cPortReadyBeginEndNotifications getPortReadyBeginEndCallback(int port)

      Returns the current callback registered for a given port
      Parameters:
        `port` - the port in question
      Returns:
        the current callback for that port, or null if none presently exists

    - #### deregisterForPortReadyBeginEndCallback

          void deregisterForPortReadyBeginEndCallback(int port)

      Deregisters any existing notifications callback for the given port
      Parameters:
        `port` - the port in question

    - #### isArmed

          boolean isArmed()

      Returns whether, as of this instant, this controller 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
      Returns:
        the arming status of this controller

    - #### readI2cCacheFromModule

          @Deprecated
          void readI2cCacheFromModule(int port)

      Deprecated.
      Deprecated, use readI2cCacheFromController(port)
      Parameters:
        `port` - physical port number on the device

    - #### writeI2cCacheToModule

          @Deprecated
          void writeI2cCacheToModule(int port)

      Deprecated.
      Deprecated, use writeI2cCacheToController(port)
      Parameters:
        `port` - physical port number on the device

    - #### writeI2cPortFlagOnlyToModule

          @Deprecated
          void writeI2cPortFlagOnlyToModule(int port)

      Deprecated.
      Deprecated, use writeI2cPortFlagOnlyToController(port)
      Parameters:
        `port` - physical port number on the device