Source code for sensirion_uart_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 = 259 OUTPUT_FORMAT_UINT16 = 261 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 = 0x0 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, '>BH', 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 = 0x1
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class ReadMeasurementValuesUint16(Transfer): """ Reads the measured values from the module. If no new measurement values are available, the module returns an empty response frame. """ CMD_ID = 0x3
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>HHHHHHHHHH')
[docs]class ReadMeasurementValuesFloat(Transfer): """ Reads the measured values from the module. If no new measurement values are available, the module returns an empty response frame. """ CMD_ID = 0x3
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>ffffffffff')
[docs]class Sleep(Transfer): """Enters the Sleep-Mode with minimum power consumption. This will also deactivate the UART interface.""" CMD_ID = 0x10
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.005, slave_address=None, ignore_ack=False)
[docs]class WakeUpCommunication(Transfer): """""" CMD_ID = 0xff
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.0, slave_address=None, ignore_ack=True)
[docs]class WakeUp(Transfer): """ Use this command to switch from Sleep-Mode to Idle-Mode. In Sleep-Mode the UART interface is disabled and must first be activated by sending a low pulse on the RX pin. This pulse is generated by sending a single byte with the value 0xFF. 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. Alternatively, if the software implementation does not allow to send a single byte with the value 0xFF, 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 = 0x11
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.005, slave_address=None, ignore_ack=False)
[docs]class StartFanCleaning(Transfer): """Starts fan cleaning manually""" CMD_ID = 0x56
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False)
[docs]class ReadAutoCleaningInterval(Transfer): """Reads auto cleaning interval of the periodic fan-cleaning""" CMD_ID = 0x80
[docs] def pack(self): return self.tx_data.pack([0x0])
tx = TxData(CMD_ID, '>BB', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>I')
[docs]class WriteAutoCleaningInterval(Transfer): """Writes auto cleaning interval of the periodic fan-cleaning""" CMD_ID = 0x80 def __init__(self, auto_cleaning_interval): self._auto_cleaning_interval = auto_cleaning_interval
[docs] def pack(self): return self.tx_data.pack([0x0, self._auto_cleaning_interval])
tx = TxData(CMD_ID, '>BBI', 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 = 0xd0
[docs] def pack(self): return self.tx_data.pack([0x0])
tx = TxData(CMD_ID, '>BB', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>9s')
[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 = 0xd0
[docs] def pack(self): return self.tx_data.pack([0x3])
tx = TxData(CMD_ID, '>BB', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>32s')
[docs]class ReadVersion(Transfer): """Gets version information about the firmware, hardware, and SHDLC protocol.""" CMD_ID = 0xd1
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>BBBBBBB')
[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 = 0xd2 def __init__(self, clear_status_register): self._clear_status_register = clear_status_register
[docs] def pack(self): return self.tx_data.pack([self._clear_status_register])
tx = TxData(CMD_ID, '>B?', device_busy_delay=0.02, slave_address=None, ignore_ack=False) rx = RxData('>IB')
[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 = 0xd3
[docs] def pack(self): return self.tx_data.pack([])
tx = TxData(CMD_ID, '>B', device_busy_delay=0.02, slave_address=None, ignore_ack=False)