API Reference¶
Svm41ShdlcDevice¶
-
class
sensirion_shdlc_svm41.device.
Svm41ShdlcDevice
(connection, slave_address)[source]¶ SVM41 device.
This is a low-level driver which just provides all SHDLC commands as Python methods. Typically, calling a method sends one SHDLC request to the device and interprets its response. There is no higher level functionality available, please look for other drivers if you need a higher level interface.
There is no (or very few) caching functionality in this driver. For example if you call
get_serial_number()
100 times, it will send the command 100 times over the SHDLC interface to the device. This makes the driver (nearly) stateless.-
__init__
(connection, slave_address)[source]¶ Create an SVM41 device instance on an SHDLC connection.
Note
This constructor does not communicate with the device, so it’s possible to instantiate an object even if the device is not connected or powered yet.
Parameters: - connection (ShdlcConnection) – The connection used for the communication.
- slave_address (byte) – The address of the device. The default address of the SVM41 is 0.
-
get_product_type
(as_int=False)[source]¶ Get the product type. The product type (sometimes also called “device type”) can be used to detect what kind of SHDLC product is connected.
Parameters: as_int (bool) – If True
, the product type is returned as an integer, otherwise as a string of hexadecimal digits (default).Returns: The product type as an integer or string of hexadecimal digits. Return type: string/int
-
get_product_name
()[source]¶ Get the product name of the device.
Returns: The product name as an ASCII string. Return type: string
-
get_serial_number
()[source]¶ Get the serial number of the device.
Returns: The serial number as an ASCII string. Return type: string
-
get_version
()[source]¶ Get the version of the device firmware, hardware and SHDLC protocol.
Returns: The device version as a Version object. Return type: Version
-
get_system_up_time
()[source]¶ Get the system up time of the device.
Returns: The time since the last power-on or device reset [s]. Return type: int
-
get_compensation_temperature_offset
()[source]¶ Gets the temperature offset for RHT measurements.
Returns: Temperature offset in degrees celsius. Return type: float
-
set_compensation_temperature_offset
(t_offset)[source]¶ Sets the temperature offset for RHT measurements.
Note
Execute the command
store_nv_data()
command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.Parameters: t_offset (float) – Temperature offset in degrees celsius.
-
get_voc_tuning_parameters
()[source]¶ Gets the currently set parameters for customizing the VOC algorithm.
Returns: - voc_index_offset (int) - VOC index representing typical (average) conditions.
- learning_time_offset_hours (int) - Time constant to estimate the VOC algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time.
- learning_time_gain_hours (int) - Time constant to estimate the VOC algorithm gain from the history in hours. Past events will be forgotten after about twice the learning time.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating.
- std_initial (int) - Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations.
- gain_factor (int) - Gain factor to amplify or to attenuate the VOC index output.
Return type: tuple
-
set_voc_tuning_parameters
(voc_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Sets parameters to customize the VOC algorithm. This command is only available in idle mode.
Note
Execute the store command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.
Parameters: - voc_index_offset (int) – VOC index representing typical (average) conditions. Allowed values are in range 1..250. The default value is 100.
- learning_time_offset_hours (int) – Time constant to estimate the VOC algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- learning_time_gain_hours (int) – Time constant to estimate the VOC algorithm gain from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating. Allowed values are in range 0..3000. The default value is 180 minutes.
- std_initial (int) – Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. Allowed values are in range 10..5000. The default value is 50.
- gain_factor (int) – Gain factor to amplify or to attenuate the VOC index output. Allowed values are in range 1..1000. The default value is 230.
-
get_nox_tuning_parameters
()[source]¶ Gets the currently set parameters for customizing the NOx algorithm.
Returns: - nox_index_offset (int) - NOx index representing typical (average) conditions.
- learning_time_offset_hours (int) - Time constant to estimate the NOx algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time.
- learning_time_gain_hours (int) - The time constant to estimate the NOx algorithm gain from the history has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This getter will always return the default value.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high NOx index signal). Set to zero to disable the gating.
- std_initial (int) - The initial estimate for standard deviation has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This getter will always return the default value.
- gain_factor (int) - Gain factor to amplify or to attenuate the NOx index output.
Return type: tuple
-
set_nox_tuning_parameters
(nox_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Sets parameters to customize the NOx algorithm. This command is only available in idle mode.
Note
Execute the store command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.
Parameters: - nox_index_offset (int) – NOx index representing typical (average) conditions. Allowed values are in range 1..250. The default value is 1.
- learning_time_offset_hours (int) – Time constant to estimate the NOx algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- learning_time_gain_hours (int) – The time constant to estimate the NOx algorithm gain from the history has no impact for the NOx algorithm. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high NOx index signal). Set to zero to disable the gating. Allowed values are in range 0..3000. The default value is 720 minutes.
- std_initial (int) – The initial estimate for standard deviation parameter has no impact for the NOx algorithm. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 50.
- gain_factor (int) – Gain factor to amplify or to attenuate the NOx index output. Allowed values are in range 1..1000. The default value is 230.
-
get_voc_state
()[source]¶ Gets the current VOC algorithm state. Retrieved values can be used to set the VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available during measurement mode.
Note
This feature can only be used after at least 3 hours of continuous operation.
Returns: Current VOC algorithm state. Return type: bytes
-
set_voc_state
(state)[source]¶ Set previously retrieved VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available in idle mode.
Note
This feature should not be used after interruptions of more than 10 minutes.
Parameters: state (bytes) – Current VOC algorithm state.
-
start_measurement
()[source]¶ Starts continuous measurement.
Note
This command is only available in idle mode.
-
stop_measurement
()[source]¶ Leaves the measurement mode and returns to the idle mode.
Note
This command is only available in measurement mode.
-
read_measured_values
()[source]¶ Returns the new measurement results.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
Returns: The measured air quality, humidity and temperature. - humidity (
Humidity
) - Humidity response object. - temperature (
Temperature
) - Temperature response object. - air_quality_voc (
AirQualityVoc
) - Air quality voc response object. - air_quality_nox (
AirQualityNox
) - Air quality nox response object.
Return type: tuple - humidity (
-
read_measured_values_raw
()[source]¶ Returns the new measurement results with raw values added.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
Returns: The measured air quality, humidity and temperature including the raw values without algorithm compensation. - raw_humidity (
Humidity
) - Humidity response object. - raw_temperature (
Temperature
) - Temperature response object. - raw_voc_ticks (int) - Raw VOC output ticks as read from the SGP sensor.
- raw_nox_ticks (int) - Raw NOx output ticks as read from the SGP sensor.
Return type: tuple - raw_humidity (
-
update_firmware
(image, emergency=False, status_callback=None, progress_callback=None)[source]¶ Update the firmware on the device.
This method allows you to download a new firmware (provided as a *.hex file) to the device. A device reset is performed after the firmware update.
Note
This can take several minutes, don’t abort it! If aborted, the device stays in the bootloader and you need to restart the update with
emergency=True
to recover.Parameters: - image – The image to flash, either as a
:py:
Svm41FirmwareImage
object, a file-like object, or the filename (str
) to the *.hex file. - emergency (bool) – Must be set to
True
if the device is already in bootloader mode,False
otherwise. - status_callback (callable) – Optional callback for status report, taking a string as parameter.
- progress_callback (callable) – Optional callback for progress report, taking a float as parameter (progress in percent).
Raises: - ShdlcFirmwareImageIncompatibilityError – If the image is not compatible with the connected device.
- Exception – On other errors.
- image – The image to flash, either as a
:py:
-
connection
¶ Get the used SHDLC connection.
Returns: The used SHDLC connection. Return type: ShdlcConnection
-
execute
(command)¶ Execute an SHDLC command.
Parameters: command (ShdlcCommand) – The command to execute. Returns: The interpreted response of the executed command.
-
last_error_flag
¶ Get the error flag which was received with the last response of the device. So this flag gets updated with every command sent to the device. If the flag is True, typically the derived classes provide a method to read the exact error reason from the device (the corresponding SHDLC command is called “Get Device Status”).
Note
When creating an instance of
ShdlcDeviceBase
, this property is initialized withFalse
and will not be updated until you send the first command to the device.Returns: True if the device indicated an error, False otherwise. Return type: bool
-
slave_address
¶ Get the slave address (not read from the device!).
Returns: The slave address. Return type: byte
-
Response Data Types¶
Air Quality VOC¶
-
class
sensirion_shdlc_svm41.response_types.
AirQualityVoc
(ticks)[source]¶ Represents a measurement response for the VOC air quality.
With the
ticks
you can access the raw data as received from the device. For the converted value thevoc_index
attribute is available.-
__init__
(ticks)[source]¶ Creates an instance from the received raw data.
Parameters: ticks (int) – The read ticks as received from the device.
-
ticks
¶ The ticks (int) as received from the device.
-
voc_index
¶ The converted VOC index.
-
Air Quality NOx¶
-
class
sensirion_shdlc_svm41.response_types.
AirQualityNox
(ticks)[source]¶ Represents a measurement response for the NOx air quality.
With the
ticks
you can access the raw data as received from the device. For the converted value thenox_index
attribute is available.-
__init__
(ticks)[source]¶ Creates an instance from the received raw data.
Parameters: ticks (int) – The read ticks as received from the device.
-
ticks
¶ The ticks (int) as received from the device.
-
nox_index
¶ The converted NOx index.
-
Humidity¶
-
class
sensirion_shdlc_svm41.response_types.
Humidity
(ticks)[source]¶ Represents a measurement response for the humidity.
With the
ticks
you can access the raw data as received from the device. For the converted value thepercent_rh
attribute is available.-
__init__
(ticks)[source]¶ Creates an instance from the received raw data.
Parameters: ticks (int) – The read ticks as received from the device.
-
ticks
¶ The ticks (int) as received from the device.
-
percent_rh
¶ The converted humidity in %RH.
-
Temperature¶
-
class
sensirion_shdlc_svm41.response_types.
Temperature
(ticks)[source]¶ Represents a measurement response for the temperature.
With the
ticks
you can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsius
anddegrees_fahrenheit
.-
__init__
(ticks)[source]¶ Creates an instance from the received raw data.
Parameters: ticks (int) – The read ticks as received from the device.
-
ticks
¶ The ticks (int) as received from the device.
-
degrees_celsius
¶ The converted temperature in °C.
-
degrees_fahrenheit
¶ The converted temperature in °F.
-
Svm41FirmwareImage¶
-
class
sensirion_shdlc_svm41.firmware_image.
Svm41FirmwareImage
(hexfile)[source]¶ SVM41 firmware image.
This class represents a firmware image for the SVM41 device. It is used to load and verify Intel-Hex files for performing firmware updates over SHDLC.
-
__init__
(hexfile)[source]¶ Constructor which loads and parses the firmware from a hex file.
Parameters: hexfile (str/file) – The filename or file-like object containing the firmware in Intel-Hex format (*.hex). Raises: ShdlcFirmwareImageSignatureError – If the signature of the image is invalid.
-
application_version
¶ Get the application firmware version which is contained in the loaded image.
Returns: Application firmware version (note: debug flag is not supported, it’s always False). Return type: FirmwareVersion
-
available_bytes
¶ Get the count of available bytes left.
Returns: Count of available bytes. Return type: int
-
bootloader_version
¶ Get the bootloader version which is contained in the loaded image.
Returns: Bootloader version (note: debug flag is not supported, it’s always False). Return type: FirmwareVersion
-
checksum
¶ Get the checksum over the application firmware part of the loaded image. This is the checksum which needs to be sent to the product bootloader.
Returns: Checksum as a byte. Return type: byte
-
product_type
¶ Get the product type for which the loaded firmware is made.
Returns: Product type as an integer. Return type: int
-
read
(size=-1)¶ Read the next bytes of the application firmware.
Parameters: size (int) – Maximum count of bytes to read (-1 reads all available) Returns: Firmware data block. Return type: bytes
-
size
¶ Get the size of the application firmware.
Returns: Size in bytes. Return type: int
-
Device Errors¶
Command Not Allowed In Current State¶
-
class
sensirion_shdlc_svm41.device_errors.
Svm41CommandNotAllowedInCurrentState
[source]¶ Command is not allowed in the current state.
-
__init__
()[source]¶ Constructor.
Parameters: - code (byte) – The error code received from the device.
- message (string) – The error description for the given error code.
-
error_code
¶ Get the error code received from the device.
Returns: Received error code. Return type: byte
-
error_message
¶ Get the description of the received error code.
Returns: Error message. Return type: string
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
Fatal Error¶
-
class
sensirion_shdlc_svm41.device_errors.
Svm41FatalError
[source]¶ An error without specific error code occurred.
-
__init__
()[source]¶ Constructor.
Parameters: - code (byte) – The error code received from the device.
- message (string) – The error description for the given error code.
-
error_code
¶ Get the error code received from the device.
Returns: Received error code. Return type: byte
-
error_message
¶ Get the description of the received error code.
Returns: Error message. Return type: string
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
Commands¶
Start Measurement¶
-
class
sensirion_shdlc_svm41.commands.start_measurement.
Svm41CmdStartMeasurementBase
(*args, **kwargs)[source]¶ SHDLC command 0x00: “Start Measurement”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.start_measurement.
Svm41CmdStartMeasurement
[source]¶ Start Measurement Command
Starts measurement in polling mode.
Note
This command is only available in idle mode.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
Stop Measurement¶
-
class
sensirion_shdlc_svm41.commands.stop_measurement.
Svm41CmdStopMeasurementBase
(*args, **kwargs)[source]¶ SHDLC command 0x01: “Stop Measurement”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.stop_measurement.
Svm41CmdStopMeasurement
[source]¶ Stop Measurement Command
Leaves the measurement mode and returns to the idle mode.
Note
This command is only available in measurement mode.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
Read Measured Values¶
-
class
sensirion_shdlc_svm41.commands.read_measured_values.
Svm41CmdReadMeasuredValuesBase
(*args, **kwargs)[source]¶ SHDLC command 0x03: “Read Measured Values”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.read_measured_values.
Svm41CmdReadMeasuredValuesAsIntegers
[source]¶ Read Measured Values As Integers Command
Returns the new measurement results as integers.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
-
static
interpret_response
(data)[source]¶ Returns: - humidity (int) - Compensated ambient humidity in % RH with a scaling factor of 100.
- temperature (int) - Compensated ambient temperature in degrees celsius with a scaling of 200.
- voc_index (int) - VOC index with a scaling value of 10.
- nox_index (int) - NOx index with a scaling value of 10.
Return type: tuple
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.read_measured_values.
Svm41CmdReadMeasuredRawValues
[source]¶ Read Measured Raw Values Command
Returns the measured raw values.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
-
static
interpret_response
(data)[source]¶ Returns: - raw_humidity (int) - Uncompensated raw humidity in % RH as read from the SHT40 with a scaling factor of 100.
- raw_temperature (int) - Uncompensated raw temperature in degrees celsius as read from the SHT40 with a scaling of 200.
- raw_voc_ticks (int) - Raw VOC output ticks as read from the SGP sensor.
- raw_nox_ticks (int) - Raw NOx output ticks as read from the SGP sensor.
Return type: tuple
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
Algorithm Parameters¶
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdAlgorithmParametersBase
(*args, **kwargs)[source]¶ SHDLC command 0x60: “Algorithm Parameters”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdGetTemperatureOffsetForRhtMeasurements
[source]¶ Get Temperature Offset For Rht Measurements Command
Gets the T-Offset for the temperature compensation of the RHT algorithm.
-
static
interpret_response
(data)[source]¶ Returns: Temperature offset which is used for the RHT measurements. Values are in degrees celsius with a scaling of 200. Thus the received value must be divided by 200. Return type: int
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdGetVocTuningParameters
[source]¶ Get Voc Tuning Parameters Command
Gets the currently set parameters for customizing the VOC algorithm.
-
static
interpret_response
(data)[source]¶ Returns: - voc_index_offset (int) - VOC index representing typical (average) conditions.
- learning_time_offset_hours (int) - Time constant to estimate the VOC algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time.
- learning_time_gain_hours (int) - Time constant to estimate the VOC algorithm gain from the history in hours. Past events will be forgotten after about twice the learning time.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating.
- std_initial (int) - Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations.
- gain_factor (int) - Gain factor to amplify or to attenuate the VOC index output.
Return type: tuple
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdGetNoxTuningParameters
[source]¶ Get Nox Tuning Parameters Command
Gets the currently set parameters for customizing the NOx algorithm.
-
static
interpret_response
(data)[source]¶ Returns: - nox_index_offset (int) - NOx index representing typical (average) conditions.
- learning_time_offset_hours (int) - Time constant to estimate the NOx algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time.
- learning_time_gain_hours (int) - The time constant to estimate the NOx algorithm gain from the history has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This getter will always return the default value.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high NOx index signal). Set to zero to disable the gating.
- std_initial (int) - The initial estimate for standard deviation has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This getter will always return the default value.
- gain_factor (int) - Gain factor to amplify or to attenuate the NOx index output.
Return type: tuple
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdStoreNvData
[source]¶ Store Nv Data Command
Stores all algorithm parameters to the non-volatile memory.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdSetTemperatureOffsetForRhtMeasurements
(t_offset)[source]¶ Set Temperature Offset For Rht Measurements Command
Sets the T-Offset for the temperature compensation of the RHT algorithm.
Note
Execute the store command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.
-
__init__
(t_offset)[source]¶ Constructor.
Parameters: t_offset (int) – Temperature offset in degrees celsius. Accepted data formats is a int16 value (2 bytes). Values are in degrees celsius with a scaling of 200. Thus the provided value must be multiplied by 200.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdSetVocTuningParameters
(voc_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Set Voc Tuning Parameters Command
Sets parameters to customize the VOC algorithm. This command is only available in idle mode.
Note
Execute the store command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.
-
__init__
(voc_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Constructor.
Parameters: - voc_index_offset (int) – VOC index representing typical (average) conditions. Allowed values are in range 1..250. The default value is 100.
- learning_time_offset_hours (int) – Time constant to estimate the VOC algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- learning_time_gain_hours (int) – Time constant to estimate the VOC algorithm gain from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating. Allowed values are in range 0..3000. The default value is 180 minutes.
- std_initial (int) – Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. Allowed values are in range 10..5000. The default value is 50.
- gain_factor (int) – Gain factor to amplify or to attenuate the VOC index output. Allowed values are in range 1..1000. The default value is 230.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_parameters.
Svm41CmdSetNoxTuningParameters
(nox_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Set Nox Tuning Parameters Command
Sets parameters to customize the NOx algorithm. This command is only available in idle mode.
Note
Execute the store command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.
-
__init__
(nox_index_offset, learning_time_offset_hours, learning_time_gain_hours, gating_max_duration_minutes, std_initial, gain_factor)[source]¶ Constructor.
Parameters: - nox_index_offset (int) – NOx index representing typical (average) conditions. Allowed values are in range 1..250. The default value is 1.
- learning_time_offset_hours (int) – Time constant to estimate the NOx algorithm offset from the history in hours. Past events will be forgotten after about twice the learning time. Allowed values are in range 1..1000. The default value is 12 hours.
- learning_time_gain_hours (int) – The time constant to estimate the NOx algorithm gain from the history has no impact for the NOx algorithm. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high NOx index signal). Set to zero to disable the gating. Allowed values are in range 0..3000. The default value is 720 minutes.
- std_initial (int) – The initial estimate for standard deviation parameter has no impact for the NOx algorithm. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 50.
- gain_factor (int) – Gain factor to amplify or to attenuate the NOx index output. Allowed values are in range 1..1000. The default value is 230.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
Algorithm States¶
-
class
sensirion_shdlc_svm41.commands.algorithm_states.
Svm41CmdAlgorithmStatesBase
(*args, **kwargs)[source]¶ SHDLC command 0x61: “Algorithm States”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_states.
Svm41CmdGetVocState
[source]¶ Get Voc State Command
Gets the current VOC algorithm state. Retrieved values can be used to set the VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available during measurement mode.
Note
This feature can only be used after at least 3 hours of continuous operation.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.algorithm_states.
Svm41CmdSetVocState
(state)[source]¶ Set Voc State Command
Set previously retrieved VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available in idle mode.
Note
This feature should not be used after interruptions of more than 10 minutes.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
Device Information¶
-
class
sensirion_shdlc_svm41.commands.device_information.
Svm41CmdDeviceInformationBase
(*args, **kwargs)[source]¶ SHDLC command 0xD0: “Device Information”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.device_information.
Svm41CmdGetProductType
[source]¶ Get Product Type Command
Gets the product type from the device.
-
static
interpret_response
(data)[source]¶ Returns: String containing the product type. Return type: str
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.device_information.
Svm41CmdGetProductName
[source]¶ Get Product Name Command
Gets the product name from the device.
-
static
interpret_response
(data)[source]¶ Returns: String containing the product name. Return type: str
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
-
class
sensirion_shdlc_svm41.commands.device_information.
Svm41CmdGetSerialNumber
[source]¶ Get Serial Number Command
Gets the serial number from the device.
-
static
interpret_response
(data)[source]¶ Returns: String containing the serial number. Return type: str
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
Get Version¶
-
class
sensirion_shdlc_svm41.commands.get_version.
Svm41CmdGetVersionBase
(*args, **kwargs)[source]¶ SHDLC command 0xD1: “Get Version”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.get_version.
Svm41CmdGetVersion
[source]¶ Get Version Command
Gets the version information for the hardware, firmware and SHDLC protocol.
-
static
interpret_response
(data)[source]¶ Returns: - firmware_major (int) - Firmware major version number.
- firmware_minor (int) - Firmware minor version number.
- firmware_debug (bool) - Firmware debug state. If the debug state is set, the firmware is in development.
- hardware_major (int) - Hardware major version number.
- hardware_minor (int) - Hardware minor version number.
- protocol_major (int) - Protocol major version number.
- protocol_minor (int) - Protocol minor version number.
Return type: tuple
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
Device Reset¶
-
class
sensirion_shdlc_svm41.commands.device_reset.
Svm41CmdDeviceResetBase
(*args, **kwargs)[source]¶ SHDLC command 0xD3: “Device Reset”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.device_reset.
Svm41CmdDeviceReset
[source]¶ Device Reset Command
Executs a reset on the device.
Note
The device will reply before executing the reset. If the command is send with broadcast, the reset is done directly after the reception of the command.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
Get System Up Time¶
-
class
sensirion_shdlc_svm41.commands.get_system_up_time.
Svm41CmdGetSystemUpTimeBase
(*args, **kwargs)[source]¶ SHDLC command 0x93: “Get System Up Time”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.get_system_up_time.
Svm41CmdGetSystemUpTime
[source]¶ Get System Up Time Command
Get the system up time of the device.
-
static
interpret_response
(data)[source]¶ Returns: The time since the last power-on or device reset in seconds. Return type: int
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
static
Firmware Update¶
-
class
sensirion_shdlc_svm41.commands.firmware_update.
Svm41CmdFirmwareUpdateBase
(*args, **kwargs)[source]¶ SHDLC command 0xF3: “Firmware Update”.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.firmware_update.
Svm41CmdEnterBootloader
[source]¶ Enter Bootloader Command
Command to enter into the bootloader mode. The device will reboot into bootloader mode and wait until the new Firmware is received (start update command expected). Even after a power reset, the device returns into bootloader mode. The response frame is sent before the reset.
Note
After the response frame is received, the device will not accept new commands until fully booted (wait at least 1 s).
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.firmware_update.
Svm41CmdStartUpdate
[source]¶ Start Update Command
Command to start the firmware update. The devices flash will be erased (except bootloader) and the internal pointers resetted. The device is then ready to receive the new firmware with the update data command.
Note
Only supported when in bootloader mode.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.firmware_update.
Svm41CmdUpdateData
(data)[source]¶ Update Data Command
Command to send the new firmware data as hex code in binary format.
Note
Only supported when in bootloader mode after receiving the start update command. Send even number of bytes except for the last frame.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-
-
class
sensirion_shdlc_svm41.commands.firmware_update.
Svm41CmdStopUpdate
(checksum)[source]¶ Stop Update Command
After all update data frames are sent, the stop update marks the end of the update sequence. The checksum is sent to the device and verification is done. The device state represents the success of the update sequence. If successfully, the device writes the signature and reboots into the application.
Note
The checksum is calculated the same way as the SHDLC checksum. First sum all firmware update data bytes and then take the LSB of the result and invert it. This will be the checksum.
-
check_response_length
(data)¶ Check if the response length is correct.
Parameters: data (bytes) – Raw data (payload) received from the device. Raises: ShdlcResponseError – If length is wrong.
-
data
¶ Get the command data (payload).
Returns: Command data (length 0..255). Return type: bytes
-
id
¶ Get the command ID.
Returns: Command ID (0..255). Return type: byte
-
interpret_response
(data)¶ Interpret the response to this command received from the device. This converts the raw byte array to the actual data type(s) depending on the sent command.
Parameters: data (bytes) – Raw data (payload) received from the device. Returns: Interpreted response. Data type and meaning depends on the sent command. None for commands without response data. See the actual command implementation for details.
-
max_response_time
¶ Get the maximum response time for this command.
Returns: Maximum response time in seconds. Return type: float
-
post_processing_time
¶ Get the post processing time for this command. The post processing time defines how long a device needs to execute a command after responding to the SHDLC command. Most devices don’t need post processing (command is executed before the response is sent). Only special commands (e.g. a device reset) are executed after the response is sent.
Returns: Maximum response time in seconds. Return type: float
-