#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2024 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.0.1
# Product: sen66
# Model-Version: 1.3.1
#
"""
The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes
are used by the driver class and not intended for direct use.
"""
from sensirion_driver_adapters.transfer import Transfer
from sensirion_driver_adapters.rx_tx_data import TxData, RxData
from sensirion_driver_support_types.bitfield import BitField, BitfieldContainer
[docs]class DeviceStatus(BitfieldContainer):
reserved1 = BitField(offset=0, width=4)
fan_error = BitField(offset=4, width=1)
reserved2 = BitField(offset=5, width=1)
rht_error = BitField(offset=6, width=1)
gas_error = BitField(offset=7, width=1)
reserved3 = BitField(offset=8, width=1)
co2_2_error = BitField(offset=9, width=1)
reserved4 = BitField(offset=10, width=1)
pm_error = BitField(offset=11, width=1)
reserved5 = BitField(offset=12, width=1)
reserved6 = BitField(offset=13, width=8)
fan_speed_warning = BitField(offset=21, width=1)
[docs]class StartContinuousMeasurement(Transfer):
"""
Starts a continuous measurement.
After starting the measurement, it takes some time (~1.1s) until the
first measurement results are available. You could poll with the command
"Get Data Ready" to check when the results are ready to read.
This command is only available in idle mode. If the device is already
in any measure mode, this command has no effect.
"""
CMD_ID = 0x21
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.05, slave_address=None, ignore_ack=False)
[docs]class StopMeasurement(Transfer):
"""
Stops the measurement and returns to idle mode. After sending this
command, wait at least 1000 ms before starting a new measurement.
If the device is already in idle mode, this command has no effect.
"""
CMD_ID = 0x104
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=1.0, slave_address=None, ignore_ack=False)
[docs]class GetDataReady(Transfer):
"""
This command can be used to check if new measurement results are ready to read. The data ready flag
is automatically reset after reading the measurement values.
"""
CMD_ID = 0x202
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>B?')
[docs]class ReadMeasuredValuesAsIntegers(Transfer):
"""
Returns the measured values.
The command "Get Data Ready" can be used to check if new
data is available since the last read operation. If no new data is
available, the previous values will be returned again. If no data
is available at all (e.g. measurement not running for at least one
second), all values will be at their upper limit (0xFFFF for uint16,
0x7FFF for int16).
"""
CMD_ID = 0x300
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>HHHHhhhhH')
[docs]class ReadNumberConcentrationValuesAsIntegers(Transfer):
"""
Returns the measured number concentration values.
The command "Get Data Ready" can be used to check if new
data is available since the last read operation. If no new data is
available, the previous values will be returned again. If no data
is available at all (e.g. measurement not running for at least one
second), all values will be at their upper limit (0xFFFF for uint16).
"""
CMD_ID = 0x316
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>HHHHH')
[docs]class ReadMeasuredRawValues(Transfer):
"""
Returns the measured raw values.
The command "Get Data Ready" can be used to check if new
data is available since the last read operation. If no new data is
available, the previous values will be returned again. If no data
is available at all (e.g. measurement not running for at least one
second), all values will be at their upper limit (0xFFFF for uint16,
0x7FFF for int16).
"""
CMD_ID = 0x405
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>hhHHH')
[docs]class StartFanCleaning(Transfer):
"""
This command triggers fan cleaning. The fan is set to the maximum
speed for 10 seconds and then automatically stopped. Wait at least 10s
after this command before starting a measurement.
"""
CMD_ID = 0x5607
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class SetTemperatureOffsetParameters(Transfer):
"""
This command allows to compensate temperature effects of the
design-in at customer side by applying custom temperature offsets
to the ambient temperature. The compensated ambient temperature is
calculated as follows:
T_Ambient_Compensated = T_Ambient + (slope * T_Ambient) + offset
Where slope and offset are the values set with this command,
smoothed with the specified time constant.
All temperatures (T_Ambient_Compensated, T_Ambient and offset)
are represented in °C.
There are 5 temperature offset slots available that all contribute
additively to T_Ambient_Compensated. The default values for
the temperature offset parameters are all zero, meaning that
T_Ambient_Compensated is equal to T_Ambient by default.
The parameters can be changed in any state of the device, i.e. both in
idle mode and in measure mode.
"""
CMD_ID = 0x60b2
def __init__(self, offset, slope, time_constant, slot):
self._offset = offset
self._slope = slope
self._time_constant = time_constant
self._slot = slot
[docs] def pack(self):
return self.tx_data.pack([self._offset, self._slope, self._time_constant, self._slot])
tx = TxData(CMD_ID, '>HhhHH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class SetVocAlgorithmTuningParameters(Transfer):
"""
Sets the parameters to customize the VOC algorithm.
This configuration is volatile, i.e. the parameters will be
reverted to their default values after a device reset.
"""
CMD_ID = 0x60d0
def __init__(self, index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes,
std_initial, gain_factor):
self._index_offset = index_offset
self._learning_time_offset_hours = learning_time_offset_hours
self._learning_time_gain_hours = learning_time_gain_hours
self._gating_max_duration_minutes = gating_max_duration_minutes
self._std_initial = std_initial
self._gain_factor = gain_factor
[docs] def pack(self):
return self.tx_data.pack([self._index_offset, self._learning_time_offset_hours, self._learning_time_gain_hours,
self._gating_max_duration_minutes, self._std_initial, self._gain_factor])
tx = TxData(CMD_ID, '>Hhhhhhh', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class GetVocAlgorithmTuningParameters(Transfer):
"""Gets the parameters to customize the VOC algorithm."""
CMD_ID = 0x60d0
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>hhhhhh')
[docs]class SetNoxAlgorithmTuningParameters(Transfer):
"""
Sets the parameters to customize the NOx algorithm.
This configuration is volatile, i.e. the parameters will be
reverted to their default values after a device reset.
"""
CMD_ID = 0x60e1
def __init__(self, index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes,
std_initial, gain_factor):
self._index_offset = index_offset
self._learning_time_offset_hours = learning_time_offset_hours
self._learning_time_gain_hours = learning_time_gain_hours
self._gating_max_duration_minutes = gating_max_duration_minutes
self._std_initial = std_initial
self._gain_factor = gain_factor
[docs] def pack(self):
return self.tx_data.pack([self._index_offset, self._learning_time_offset_hours, self._learning_time_gain_hours,
self._gating_max_duration_minutes, self._std_initial, self._gain_factor])
tx = TxData(CMD_ID, '>Hhhhhhh', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class GetNoxAlgorithmTuningParameters(Transfer):
"""Gets the parameters to customize the NOx algorithm."""
CMD_ID = 0x60e1
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>hhhhhh')
[docs]class SetTemperatureAccelerationParameters(Transfer):
"""
This command allows to set custom temperature acceleration parameters of the RH/T engine.
It overwrites the default temperature acceleration parameters of the RH/T engine with custom values. This
configuration is volatile, i.e. the parameters will be reverted to their default values after a device reset.
"""
CMD_ID = 0x6100
def __init__(self, k, p, t1, t2):
self._k = k
self._p = p
self._t1 = t1
self._t2 = t2
[docs] def pack(self):
return self.tx_data.pack([self._k, self._p, self._t1, self._t2])
tx = TxData(CMD_ID, '>HHHHH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class SetVocAlgorithmState(Transfer):
"""
Sets the VOC algorithm state previously received with "Get VOC Algorithm State" command.
Allows restoration of the VOC algorithm state to resume operation after a power cycle or device
reset, skipping initial learning phase. By default, the VOC Engine is reset, and the algorithm state is retained if
a measurement is stopped and started again. If the VOC algorithm state shall be reset, a device reset, or a
power cycle can be executed.
"""
CMD_ID = 0x6181
def __init__(self, state):
self._state = state
[docs] def pack(self):
return self.tx_data.pack([self._state])
tx = TxData(CMD_ID, '>H8B')
[docs]class GetVocAlgorithmState(Transfer):
"""
Gets the current VOC algorithm state.
Allows to backup and restore the VOC algorithm state to resume operation after a power cycle or
device reset, skipping initial learning phase. By default, the VOC Engine is reset and the algorithm
state is retained if a measurement is stopped and started again. If the VOC algorithm
state shall be reset, a device reset or a power cycle can be executed.
"""
CMD_ID = 0x6181
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>8B')
[docs]class SetCo2SensorAutomaticSelfCalibration(Transfer):
"""
Sets the status of the CO₂ sensor automatic self-calibration (ASC).
The CO₂ sensor supports automatic self calibration (ASC) for long-term
stability of the CO₂ output. This feature can be enabled or disabled.
By default it is enabled.
This configuration is volatile, i.e. the parameter will be
reverted to its default value after a device restart.
"""
CMD_ID = 0x6711
def __init__(self, status):
self._status = status
[docs] def pack(self):
return self.tx_data.pack([self._status])
tx = TxData(CMD_ID, '>HH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class GetCo2SensorAutomaticSelfCalibration(Transfer):
"""
The CO₂ sensor supports automatic self calibration (ASC) for long-term
stability of the CO₂ output. This feature can be enabled or disabled.
By default it is enabled.
This configuration is volatile, i.e. the parameter will be
reverted to its default value after a device restart.
"""
CMD_ID = 0x6711
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>B?')
[docs]class SetAmbientPressure(Transfer):
"""
The ambient pressure can be used for pressure compensation in the CO₂
sensor. Setting an ambient pressure overrides any pressure compensation
based on a previously set sensor altitude. Use of this command is
recommended for applications experiencing significant ambient pressure
changes to ensure CO₂ sensor accuracy. Valid input values are between
700 to 1'200 hPa. The default value is 1013 hPa.
This configuration is volatile, i.e. the parameter will be
reverted to its default value after a device restart.
"""
CMD_ID = 0x6720
def __init__(self, ambient_pressure):
self._ambient_pressure = ambient_pressure
[docs] def pack(self):
return self.tx_data.pack([self._ambient_pressure])
tx = TxData(CMD_ID, '>HH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class GetAmbientPressure(Transfer):
"""
Gets the ambient pressure value.
The ambient pressure can be used for pressure compensation in the CO₂
sensor.
"""
CMD_ID = 0x6720
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>H')
[docs]class SetSensorAltitude(Transfer):
"""
The sensor altitude can be used for pressure compensation in the CO₂
sensor. The default sensor altitude value is set to 0 meters above sea
level. Valid input values are between 0 and 3000m.
This configuration is volatile, i.e. the parameter will be
reverted to its default value after a device reset.
"""
CMD_ID = 0x6736
def __init__(self, altitude):
self._altitude = altitude
[docs] def pack(self):
return self.tx_data.pack([self._altitude])
tx = TxData(CMD_ID, '>HH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class GetSensorAltitude(Transfer):
"""
Gets the current sensor altitude.
The sensor altitude can be used for pressure compensation in the CO₂
sensor.
"""
CMD_ID = 0x6736
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>H')
[docs]class ActivateShtHeater(Transfer):
"""
This command allows to use the inbuilt heater in SHT sensor
to reverse creep at high humidity.
This command activates the SHT sensor heater with 200mW for 1s.
The heater is then automatically deactivated again.
Wait at least 20s after this command before starting a measurement to get
coherent temperature values (heating consequence to disappear).
"""
CMD_ID = 0x6765
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=1.3, slave_address=None, ignore_ack=False)
[docs]class GetProductName(Transfer):
"""Gets the product name from the device."""
CMD_ID = 0xd014
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>32B')
[docs]class GetSerialNumber(Transfer):
"""Gets the serial number from the device."""
CMD_ID = 0xd033
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>32B')
[docs]class ReadDeviceStatus(Transfer):
"""
Reads the current device status.
Use this command to get detailed information about the device status.
The device status is encoded in flags. Each device status flag
represents a single bit in a 32-bit integer value. If more than one
error is present, the device status register value is the sum of the
corresponding flag values. For details about the available flags,
refer to the device status flags documentation in the data sheet.
"""
CMD_ID = 0xd206
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>I')
[docs]class ReadAndClearDeviceStatus(Transfer):
"""
Reads the current device status (like command 0xD206 "Read Device Status") and afterwards clears
all flags.
"""
CMD_ID = 0xd210
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
rx = RxData('>I')
[docs]class DeviceReset(Transfer):
"""Executes a reset on the device. This has the same effect as a power cycle."""
CMD_ID = 0xd304
[docs] def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=1.2, slave_address=None, ignore_ack=False)