def write(self, registerAddress: int, data: int) -> bool: """Execute a write transaction with the device. Write a single byte to a register on a device and wait until the transaction is complete. :param registerAddress: The address of the register on the device to be written. :param data: The byte to write to the register on the device. :returns: Transfer Aborted... False for success, True for aborted. """ try: hal.writeI2C(self.port, self.deviceAddress, [registerAddress, data]) except IOError: return True return False
def writeBulk(self, data: bytes) -> bool: """Execute a write transaction with the device. Write multiple bytes to a register on a device and wait until the transaction is complete. :param data: The data to write to the device. :returns: Transfer Aborted... False for success, True for aborted. Usage:: # send byte string failed = i2c.writeBulk(b'stuff') # send list of integers failed = i2c.write([0x01, 0x02]) """ try: hal.writeI2C(self.port, self.deviceAddress, data) except IOError: return True return False