Interface that provides the methods that may be used to interact with the I2C bus on a device.

interface IDeviceI2C {
    read(address, length, buffer): Promise<number>;
    write(address, length, data): Promise<number>;
}

Methods

Methods

  • Reads data from the target I2C address.

    Parameters

    • address: number

      I2C address of the target device.

    • length: number

      Length of data to read in bytes.

    • buffer: ArrayBuffer

      The buffer to store the data that is read.

    Returns Promise<number>

    • A promise that resolves when the data has been read indicating the number of bytes that were successfully read.
  • Writes data to the target I2C address.

    Parameters

    • address: number

      I2C address of the target device.

    • length: number

      Length of data to write in bytes.

    • data: ArrayBuffer

      The buffer containing the data to write.

    Returns Promise<number>

    • A promise that resolves when the data has been written indicating the number of bytes that were successfully written.