Exemplo n.º 1
0
    def writeBulk(self, data):
        """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.
        """
        try:
            hal.i2CWrite(self.port, self.deviceAddress, data)
        except IOError:
            return True
        return False
Exemplo n.º 2
0
    def writeBulk(self, data):
        """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.
        """
        try:
            hal.i2CWrite(self.port, self.deviceAddress, data)
        except IOError:
            return True
        return False
Exemplo n.º 3
0
    def write(self, registerAddress, data):
        """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.i2CWrite(self.port, self.deviceAddress, [registerAddress, data])
        except IOError:
            return True
        return False
Exemplo n.º 4
0
    def write(self, registerAddress, data):
        """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.i2CWrite(self.port, self.deviceAddress, [registerAddress, data])
        except IOError:
            return True
        return False
Exemplo n.º 5
0
    def writeBulk(self, data):
        """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.
        :type data: iterable of bytes
        :returns: Transfer Aborted... False for success, True for aborted.
        
        Usage::
        
            # send byte string
            failed = spi.writeBulk(b'stuff')
            
            # send list of integers
            failed = spi.write([0x01, 0x02])
        """
        try:
            hal.i2CWrite(self.port, self.deviceAddress, data)
        except IOError:
            return True
        return False