Source code for sensirion_i2c_sbn4x.commands

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2026 Sensirion AG, Switzerland
#
#     THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator:     sensirion-driver-generator 1.5.1
# Product:       sbn4x
# Model-Version: 2.0.0
#
"""
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


[docs] class StartPeriodicMeasurementMode(Transfer): """ Starts periodic measurement of O2, humidity, temperature, pressure and CO2. After starting the measurement, it takes some time (~20ms) until the first measurement results are available. The command 0x02 `read measured values` will return an error 0x20 `no measurement data available` until the first results are available. This command is only available in idle mode. If the device is already in any measure mode, or the requested sampling rate is not supported, this command has no effect. """ CMD_ID = 0x10 def __init__(self, sampling_rate): self._sampling_rate = sampling_rate
[docs] def pack(self): return self.tx_data.pack([self._sampling_rate])
tx = TxData(CMD_ID, '>HI', device_busy_delay=0.01, slave_address=None, ignore_ack=False)
[docs] class StopMeasurement(Transfer): """ Stops the measurement and returns to idle mode. The last measurement results can still be read out, if available. 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=0.1, slave_address=None, ignore_ack=False)
[docs] class ReadMeasurementsRaw(Transfer): """ Read the measured values O2, CO2 and ambient conditions from the sensor. Each set of measurements is identified by the measurement counter. """ CMD_ID = 0x260
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.003, slave_address=None, ignore_ack=False) rx = RxData('>HhhhI')
[docs] class ForceO2Recalibration(Transfer): """ Force a recalibration of the O2 sensor. This command is executed in measurement mode only. The measurement loop is interrupted until the recalibration is done and the new calibration value is written to flash. After this, the sensor resumes measuring using the updated configuration value. """ CMD_ID = 0x300
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.2, slave_address=None, ignore_ack=False)
[docs] class StartForcedCO2Recalibration(Transfer): """ Force a recalibration of the CO2 sensor. This command is executed only when the sensor is in periodic mode. There is no measurement data available until the recalibration is fully applied to the CO2 sensor. After this, the sensor resumes measuring using the updated calibration value. """ CMD_ID = 0x507
[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 GetForcedCO2RecalibrationStatus(Transfer): """ Get the status of the forced recalibration. This function can be polled after starting a forced CO2 recalibration. The returned value is 0xFFFF as long as the forced recalibration is running, and changes to 0 if the forced recalibration is completed. """ CMD_ID = 0x511
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, slave_address=None, ignore_ack=False) rx = RxData('>H')
[docs] class GetProductType(Transfer): """Gets the product type from the device.""" CMD_ID = 0xd002
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, slave_address=None, ignore_ack=False) rx = RxData('>10s')
[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.01, slave_address=None, ignore_ack=False) rx = RxData('>32s')
[docs] class GetArticleCode(Transfer): """Gets the article code from the device.""" CMD_ID = 0xd025
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, slave_address=None, ignore_ack=False) rx = RxData('>32s')
[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.01, slave_address=None, ignore_ack=False) rx = RxData('>32s')
[docs] class GetDeviceUid(Transfer): """Gets the device uid from the device.""" CMD_ID = 0xd051
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, slave_address=None, ignore_ack=False) rx = RxData('>12B')
[docs] class GetVersion(Transfer): """Gets the version information for the hardware, firmware and communication protocol.""" CMD_ID = 0xd100
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, slave_address=None, ignore_ack=False) rx = RxData('>BB?BBBBB')
[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. """ CMD_ID = 0xd206
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.01, 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.01, 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=0.1, slave_address=None, ignore_ack=False)