I'm writing a code that involves an i2c
this is the function for writing to the i2c
Code: Select all
# write to device
def _write(self, data, memaddr, addr):
# perform a memory write. caller should trap OSError.
self._ccs811_i2c.writeto_mem(addr, memaddr, self.buf1)
the operation has to be done in one single write sequence
doing so results in error: cannot convert bytearray to int.
I then convert data to int using struct.unpack which results in a signed int value
when i try to perform the write operation, i get TypeError: object with buffer protocol required
How is a buffer protocol done for i2c ??
thanks