Skip to content

Commit 8784601

Browse files
committed
Merge branch 'svm4x_2.0.3_20231114_0935' into 'master'
Update SVM4x driver from SVM4X model version 2.0.3 See merge request Sensirion/Python/python-uart-svm4x!4
2 parents b124bd9 + aa66122 commit 8784601

11 files changed

Lines changed: 147 additions & 139 deletions

CHANGELOG.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ CHANGELOG
33

44
unreleased
55
::::::::::
6-
- Update driver to the latest sensor model
6+
7+
2.0.3
8+
:::::
9+
10+
- class Svm41Device was renamed to Svm4xDevice
11+
- get_product_type has no longer a parameter as_int, was replaced with separate function get_product_type_as_int
712

813
0.1.0
914
:::::

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The SVM4x evaluation kit covers evaluation of the SGP40 and SGP41 sensors.
1313

1414

1515

16+
1617
## Connect the sensor
1718

1819
You can connect your sensor over the provided USB cable.

docs/execute-measurements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Execute measurements
22
====================
33

4-
The following steps shows how to use this driver to execute a simple measurement on a Windows system.
4+
The following steps show how to use this driver to execute a simple measurement on a Windows system.
55

66
1. Install the SVM4X sensor driver and all required packages as described in :ref:`Installation`.
77
2. Connect the SVM4X sensor to your system with the serial USB cable.

examples/algorithm_tuning_example_uart_svm4x.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
# THIS FILE IS AUTOMATICALLY GENERATED!
77
#
8-
# Generator: sensirion-driver-generator 0.32.0
8+
# Generator: sensirion-driver-generator 0.33.0
99
# Product: svm4x
10-
# Model-Version: 2.0.0
10+
# Model-Version: 2.0.3
1111
#
1212

1313
import time
@@ -48,7 +48,7 @@
4848
sensor.set_voc_tuning_parameters(100, 12, 12, 180, 50, 230)
4949
sensor.set_nox_tuning_parameters(1, 12, 12, 720, 50, 230)
5050
sensor.start_measurement()
51-
for i in range(50):
51+
for i in range(100):
5252
try:
5353
time.sleep(1.0)
5454
(a_humidity, a_temperature, a_voc_index, a_nox_index

examples/example_usage_uart_svm4x.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
# THIS FILE IS AUTOMATICALLY GENERATED!
77
#
8-
# Generator: sensirion-driver-generator 0.32.0
8+
# Generator: sensirion-driver-generator 0.33.0
99
# Product: svm4x
10-
# Model-Version: 2.0.0
10+
# Model-Version: 2.0.3
1111
#
1212

1313
import time
@@ -28,8 +28,28 @@
2828
serial_number = sensor.get_serial_number()
2929
print(f"serial_number: {serial_number}; "
3030
)
31+
product_type = sensor.get_product_type()
32+
print(f"product_type: {product_type}; "
33+
)
34+
product_name = sensor.get_product_name()
35+
print(f"product_name: {product_name}; "
36+
)
37+
(firmware_major, firmware_minor, firmware_debug, hardware_major, hardware_minor, protocol_major, protocol_minor
38+
) = sensor.get_version()
39+
print(f"firmware_major: {firmware_major}; "
40+
f"firmware_minor: {firmware_minor}; "
41+
f"firmware_debug: {firmware_debug}; "
42+
f"hardware_major: {hardware_major}; "
43+
f"hardware_minor: {hardware_minor}; "
44+
f"protocol_major: {protocol_major}; "
45+
f"protocol_minor: {protocol_minor}; "
46+
)
47+
t_offset = sensor.get_temperature_offset_for_rht_measurements()
48+
print(f"t_offset: {t_offset}; "
49+
)
50+
sensor.set_temperature_offset_for_rht_measurements(0)
3151
sensor.start_measurement()
32-
for i in range(50):
52+
for i in range(100):
3353
try:
3454
time.sleep(1.0)
3555
(a_humidity, a_temperature, a_voc_index, a_nox_index

metadata.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
generator_version: 0.32.0
2-
model_version: 2.0.0
1+
generator_version: 0.33.0
2+
model_version: 2.0.3
33
dg_status:
44
- released
55
is_manually_modified: true
66
first_generated: '2022-09-27 17:04'
7-
last_generated: '2023-10-19 10:12'
7+
last_generated: '2023-11-14 09:35'

sensirion_uart_svm4x/commands.py

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
# THIS FILE IS AUTOMATICALLY GENERATED!
77
#
8-
# Generator: sensirion-driver-generator 0.32.0
8+
# Generator: sensirion-driver-generator 0.33.0
99
# Product: svm4x
10-
# Model-Version: 2.0.0
10+
# Model-Version: 2.0.3
1111
#
1212
"""
1313
The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes
@@ -113,7 +113,10 @@ def pack(self):
113113

114114

115115
class ReadMeasuredValuesAsIntegers(Transfer):
116-
"""Returns the new measurement results as integers."""
116+
"""
117+
Read measurement data as integers.
118+
This command is named get_signals in the datasheet.
119+
"""
117120

118121
CMD_ID = 0x3
119122

@@ -125,7 +128,10 @@ def pack(self):
125128

126129

127130
class ReadMeasuredRawValues(Transfer):
128-
"""Returns the measured raw values."""
131+
"""
132+
Read measuremed raw values.
133+
This command is named get_signals_raw in the datasheet.
134+
"""
129135

130136
CMD_ID = 0x3
131137

@@ -137,7 +143,10 @@ def pack(self):
137143

138144

139145
class GetTemperatureOffsetForRhtMeasurements(Transfer):
140-
"""Gets the T-Offset for the temperature compensation of the RHT algorithm."""
146+
"""
147+
Gets the T-Offset for the temperature compensation of the RHT algorithm.
148+
This command is named get_temperature_offset in the datasheet.
149+
"""
141150

142151
CMD_ID = 0x60
143152

@@ -149,7 +158,10 @@ def pack(self):
149158

150159

151160
class GetVocTuningParameters(Transfer):
152-
"""Gets the currently set parameters for customizing the VOC algorithm."""
161+
"""
162+
Gets the currently set parameters for customizing the VOC algorithm.
163+
This command is named get_voc_parameters in the datasheet.
164+
"""
153165

154166
CMD_ID = 0x60
155167

@@ -161,7 +173,10 @@ def pack(self):
161173

162174

163175
class GetNoxTuningParameters(Transfer):
164-
"""Gets the currently set parameters for customizing the NOx algorithm."""
176+
"""
177+
Gets the currently set parameters for customizing the NOx algorithm.
178+
This command is named get_nox_parameters in the datasheet.
179+
"""
165180

166181
CMD_ID = 0x60
167182

@@ -173,7 +188,17 @@ def pack(self):
173188

174189

175190
class StoreNvData(Transfer):
176-
"""Stores all algorithm parameters to the non-volatile memory."""
191+
"""
192+
This command stores all parameters previously set with the commands
193+
set_temperature_offset_for_rht_measurements, set_voc_tuning_parameters and
194+
set_nox_tuning_parameters to the non-volatile
195+
memory of SVM4x. These parameters will not be erased
196+
during reset and will be used by the corresponding algorithms
197+
after start-up. To reset the storage to factory settings the
198+
master has to set all parameters to the default values followed
199+
by a subsequent call of the store_nv_data command.
200+
This command is named store_input_parameters in the datasheet.
201+
"""
177202

178203
CMD_ID = 0x60
179204

@@ -201,6 +226,7 @@ class SetVocTuningParameters(Transfer):
201226
"""
202227
Sets parameters to customize the VOC algorithm. This command is only available
203228
in idle mode.
229+
This command is named set_voc_parameters in the datasheet.
204230
"""
205231

206232
CMD_ID = 0x60
@@ -226,6 +252,7 @@ class SetNoxTuningParameters(Transfer):
226252
"""
227253
Sets parameters to customize the NOx algorithm. This command is only available
228254
in idle mode.
255+
This command is named set_nox_parameters in the datasheet.
229256
"""
230257

231258
CMD_ID = 0x60
@@ -263,22 +290,6 @@ def pack(self):
263290
rx = RxData('>8B')
264291

265292

266-
class GetNoxState(Transfer):
267-
"""
268-
Gets the current NOx algorithm state. Retrieved values can be used to set the
269-
NOx algorithm state to resume operation after a short interruption, skipping
270-
initial learning phase. This command is only available during measurement mode.
271-
"""
272-
273-
CMD_ID = 0x61
274-
275-
def pack(self):
276-
return self.tx_data.pack([0x9])
277-
278-
tx = TxData(CMD_ID, '>BB', device_busy_delay=0.05, slave_address=None, ignore_ack=False)
279-
rx = RxData('>8B')
280-
281-
282293
class SetVocState(Transfer):
283294
"""
284295
Set previously retrieved VOC algorithm state to resume operation after a short
@@ -295,37 +306,3 @@ def pack(self):
295306
return self.tx_data.pack([0x88, self._state])
296307

297308
tx = TxData(CMD_ID, '>BB8B', device_busy_delay=0.05, slave_address=None, ignore_ack=False)
298-
299-
300-
class SetNoxState(Transfer):
301-
"""
302-
Set previously retrieved NOx algorithm state to resume operation after a short
303-
interruption, skipping initial learning phase. This command is only available in
304-
idle mode.
305-
"""
306-
307-
CMD_ID = 0x61
308-
309-
def __init__(self, state):
310-
self._state = state
311-
312-
def pack(self):
313-
return self.tx_data.pack([0x89, self._state])
314-
315-
tx = TxData(CMD_ID, '>BB8B', device_busy_delay=0.05, slave_address=None, ignore_ack=False)
316-
317-
318-
class EnterBootloader(Transfer):
319-
"""
320-
Command to enter into the bootloader mode. The device will reboot into
321-
bootloader mode and wait until the new Firmware is received (start update
322-
command expected). Even after a power reset, the device returns into bootloader
323-
mode. The response frame is sent before the reset.
324-
"""
325-
326-
CMD_ID = 0xf3
327-
328-
def pack(self):
329-
return self.tx_data.pack([])
330-
331-
tx = TxData(CMD_ID, '>B')

0 commit comments

Comments
 (0)