Source code for sensirion_i2c_sps30.commands

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
#
#     THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator:     sensirion-driver-generator 1.3.3
# Product:       sps30
# Model-Version: 1.0.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 enum import Enum
from sensirion_driver_adapters.transfer import Transfer
from sensirion_driver_adapters.rx_tx_data import TxData, RxData


[docs]class OutputFormat(Enum): OUTPUT_FORMAT_FLOAT = 768 OUTPUT_FORMAT_UINT16 = 1280 def __int__(self): return self.value
[docs]class StartMeasurement(Transfer): """ Starts the measurement. After power up, the module is in Idle-Mode. Before any measurement values can be read, the Measurement-Mode needs to be started using this command. """ CMD_ID = 0x10 def __init__(self, measurement_output_format): self._measurement_output_format = int(measurement_output_format)
[docs] def pack(self): return self.tx_data.pack([self._measurement_output_format])
tx = TxData(CMD_ID, '>HH', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class StopMeasurement(Transfer): """Use this command to return to the Idle-Mode.""" CMD_ID = 0x104
[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 ReadDataReadyFlag(Transfer): """ This command can be used for polling to find out when new measurements are available. The pointer address only has to be set once. Repeated read requests get the status of the Data-Ready Flag. """ CMD_ID = 0x202
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>H')
[docs]class ReadMeasurementValuesUint16(Transfer): """ Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values. """ CMD_ID = 0x300
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>HHHHHHHHHH')
[docs]class ReadMeasurementValuesFloat(Transfer): """ Reads the measured values from the sensor module and resets the “Data-Ready Flag”. If the sensor module is in Measurement-Mode, an updated measurement value is provided every second and the “Data-Ready Flag” is set. If no synchronized readout is desired, the “Data-Ready Flag” can be ignored. The command “Read Measured Values” always returns the latest measured values. """ CMD_ID = 0x300
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>ffffffffff')
[docs]class Sleep(Transfer): """Enters the Sleep-Mode with minimum power consumption. This will also deactivate the I2C interface.""" CMD_ID = 0x1001
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.005, slave_address=None, ignore_ack=False)
[docs]class WakeUp(Transfer): """ In Sleep-Mode the I2C interface is disabled and must first be activated by sending a low pulse on the SDA line. A low pulse can be generated by sending a I2C-Start-Condition followed by a Stop-Condition. If then a Wake-up command follows within 100ms, the module will switch on again and is ready for further commands in the Idle-Mode. If the low pulse is not followed by the Wake-up command, the microcontroller returns after 100ms to Sleep-Mode and the interface is deactivated again. Alternatively, if the software implementation does not allow to send a I2C-Start-Condition followed by a Stop-Condition, the Wake-up command can be sent twice in succession. In this case the first Wake-up command is ignored, but causes the interface to be activated. """ CMD_ID = 0x1103
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.005, slave_address=None, ignore_ack=True)
[docs]class StartFanCleaning(Transfer): """Starts fan cleaning manually""" CMD_ID = 0x5607
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.005, slave_address=None, ignore_ack=False)
[docs]class ReadAutoCleaningInterval(Transfer): """Reads auto cleaning interval of the periodic fan-cleaning""" CMD_ID = 0x8004
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.005, slave_address=None, ignore_ack=False) rx = RxData('>I')
[docs]class WriteAutoCleaningInterval(Transfer): """Writes auto cleaning interval of the periodic fan-cleaning""" CMD_ID = 0x8004 def __init__(self, auto_cleaning_interval): self._auto_cleaning_interval = auto_cleaning_interval
[docs] def pack(self): return self.tx_data.pack([self._auto_cleaning_interval])
tx = TxData(CMD_ID, '>HI', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class ReadProductType(Transfer): """ This command returns the product type. It is defined as a string value with a length of 8 ASCII characters (excluding terminating null-character) """ CMD_ID = 0xd002
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>8s')
[docs]class ReadSerialNumber(Transfer): """ This command returns the serial number. It is defined as a string value with a maximum length of 32 ASCII characters (including terminating null-character) """ CMD_ID = 0xd033
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>32s')
[docs]class ReadFirmwareVersion(Transfer): """Gets firmware major.minor firmware version.""" CMD_ID = 0xd100
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>BB')
[docs]class ReadDeviceStatusRegister(Transfer): """Use this command to read the device status register. For more details, check explanations given in chapter 4.4 of the datasheet.""" CMD_ID = 0xd206
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H') rx = RxData('>I')
[docs]class ClearDeviceStatusRegister(Transfer): """Use this command to clear the device status register. For more details, check explanations given in chapter 4.4 of the datasheet.""" CMD_ID = 0xd210
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>H', device_busy_delay=0.005, slave_address=None, ignore_ack=False)
[docs]class DeviceReset(Transfer): """Device software reset command. After calling this command, the module is in the same state as after a power reset.""" 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)