#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2026 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 1.6.2
# Product: sfa4x
# Model-Version: 2.1.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 StartContinuousMeasurement(Transfer):
"""Start a continuous measurement (interval 1 s)."""
CMD_ID = 0xac
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H')
[docs]
class ReadMeasurementDataRaw(Transfer):
"""Read HCHO, relative humidity, temperature, sensor info, sensor status, after calling *start_continous_measurement()*"""
CMD_ID = 0xc0eb
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.001, slave_address=None, ignore_ack=False)
rx = RxData('>HHHH')
[docs]
class StopContinuousMeasurement(Transfer):
"""Stop continuous measurement to run other i2c commands or to save power."""
CMD_ID = 0x50d2
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.7, slave_address=None, ignore_ack=False)
[docs]
class GetSerialNumber(Transfer):
"""Read the sensor's unique serial number."""
CMD_ID = 0x2ce
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.001, slave_address=None, ignore_ack=False)
rx = RxData(descriptor='>3H', convert_to_int=True)
[docs]
class StartSelftest(Transfer):
"""
The self-test is a special autonomous test, able to detect certain malfunctions, e.g. due to bad soldering during
assembly. The test checks the integrity of electric connections between the user interface and the sensor cell.
It is recommended to run the self-test once, after the sensor has been soldered to the PCB.
After powering on the device, it is in idle state. The start_selftest command initiates a special measurement
mode. Refer to the read_selftest_data command for instructions on how to read out the sensor data after starting the self-test.
The self-test brings the sensor into special measurement mode for 5 – 6 minutes.
"""
CMD_ID = 0x60a
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H')
[docs]
class ReadSelftestData(Transfer):
"""
After starting the self-test, the read_selftest_data command is used to obtain the selftest status and result.
It is recommended to trigger a readout e.g. every 10 seconds, until the output is different from 65535 (hex: FFFF).
Interpretation of the result:
* 65535 (hex: FFFF): Test is still running. Wait longer.
* 0: Test successful.
* other: Test failed.
"""
CMD_ID = 0xc0eb
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H')
rx = RxData('>H')
[docs]
class GetProductId(Transfer):
"""Read the sensor's product id."""
CMD_ID = 0x3ff
[docs]
def pack(self):
return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.001, slave_address=None, ignore_ack=False)
rx = RxData('>I')