API Documentation¶
Channel:¶
-
class
sensirion_i2c_adapter.channel.
TxRxChannel
¶ This is the abstract base class for any channel. A channel is a transportation medium to transfer data from any source to any destination
-
write_read
(tx_bytes, payload_offset, response, device_busy_delay=0.0, slave_address=None, ignore_errors=False)¶ Transfers the data to and from sensor.
Parameters: - tx_bytes – Raw bytes to be transmitted
- payload_offset – The data my contain a header that needs to be left untouched, pushing the date through the protocol stack. The Payload offset points to the end of the header and the beginning of the data
- response – The response is an object that is able to unpack a raw response. It has to provide a method ‘interpret_response.
- device_busy_delay – Indication how long the receiver of the message will be busy until processing of the data has been completed.
- slave_address – Used for i2c addressing. Denotes the i2c address of the receiving slave
- ignore_errors – Some transfers may generate an exception even when they execute properly. In these situations the exception is swallowed and an empty result is returned
Returns: Return a tuple of the interpreted data or None if there is no response at all
-
-
class
sensirion_i2c_adapter.channel.
TxRxRequest
(channel, tx_bytes=None, response=None, device_busy_delay=0.0, receive_length=0)¶ This class is an adapter to the class I2cConnection. It keeps compatibility with the SensirionI2cCommand
I2C-Channel¶
-
class
sensirion_i2c_adapter.i2c_channel.
I2cChannel
(connection, slave_address=0, crc=None)¶ This is the concrete channel implementation to be used with I2cConnection of the package sensirion-i2c-driver
-
strip_protocol
(data)¶ Validates the CRCs of the received data from the device and returns the data with all CRCs removed.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received bytes without crc, or None if there is no data received. Return type: bytes or None Raises: I2cChecksumError – If a received CRC was wrong.
-
write_read
(tx_bytes, payload_offset, response, device_busy_delay=0.0, slave_address=None, ignore_errors=False)¶ Transfers the data to and from sensor.
Parameters: - tx_bytes – Raw bytes to be transmitted
- payload_offset – The data my contain a header that needs to be left untouched, pushing the date through the protocol stack. The Payload offset points to the end of the header and the beginning of the data
- response – The response is an object that is able to unpack a raw response. It has to provide a method ‘interpret_response.
- device_busy_delay – Indication how long the receiver of the message will be busy until processing of the data has been completed.
- slave_address – Used for i2c addressing. Denotes the i2c address of the receiving slave
- ignore_errors – Some transfers may generate an exception even when they execute properly. In these situations the exception is swallowed and an empty result is returned
Returns: Return a tuple of the interpreted data or None if there is no response at all
-
Transfer:¶
-
class
sensirion_i2c_adapter.transfer.
RxData
(descriptor=None)¶ Descriptor for data to be received
-
class
sensirion_i2c_adapter.transfer.
Transfer
¶ A transfer abstracts the data that is exchanged between host and sensor
-
class
sensirion_i2c_adapter.transfer.
TxData
(cmd_id, descriptor, device_busy_delay=0.0, slave_address=None, ignore_ack=False)¶ Models the tx data that is exchanged. It it primarily a descriptor that knows how to convert structured data into a list of raw bytes
-
sensirion_i2c_adapter.transfer.
execute_transfer
(channel: sensirion_i2c_adapter.channel.TxRxChannel, *args)¶ Executes a transfer consisting of one or more Transfer objects. :param channel: The channel that is used to transfer the data :param args: a variable list of transfers to be transmitted :return: a tuple of data if the last transfer has a response