Skip to content

Commit 6209722

Browse files
committed
wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.
1 parent 1d31bd0 commit 6209722

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

lib/wsen-hids/wsen_hids/device.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def _write_reg(self, reg, value):
9090

9191
def _read_regs(self, reg, length):
9292
try:
93+
if length > 1:
94+
reg |= AUTO_INCREMENT
9395
return self.i2c.readfrom_mem(self.address, reg, length)
9496
except OSError as exc:
9597
raise WSENHIDSCommunicationError(
@@ -220,7 +222,7 @@ def data_ready(self):
220222

221223
def _read_raw_humidity_temperature(self):
222224
# Multi-byte read with auto-increment bit set.
223-
data = self._read_regs(REG_H_OUT_L | AUTO_INCREMENT, 4)
225+
data = self._read_regs(REG_H_OUT_L, 4)
224226

225227
h_raw = data[0] | (data[1] << 8)
226228
t_raw = data[2] | (data[3] << 8)

tests/scenarios/wsen_hids.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ mock_registers:
3232
0x33: 0x18
3333
# T1_T0_MSB: bits[1:0]=T0 msb=0, bits[3:2]=T1 msb=1 -> 0x04
3434
0x35: 0x04
35-
# H0_T0_OUT (signed16 = 3000 = 0x0BB8)
36-
0x36: [0xB8, 0x0B]
37-
# H1_T0_OUT (signed16 = 9000 = 0x2328)
38-
0x3A: [0x28, 0x23]
39-
# T0_OUT (signed16 = 2000 = 0x07D0)
40-
0x3C: [0xD0, 0x07]
41-
# T1_OUT (signed16 = 5000 = 0x1388)
42-
0x3E: [0x88, 0x13]
35+
# H0_T0_OUT (signed16 = 3000 = 0x0BB8) — auto-increment read
36+
0xB6: [0xB8, 0x0B]
37+
# H1_T0_OUT (signed16 = 9000 = 0x2328) — auto-increment read
38+
0xBA: [0x28, 0x23]
39+
# T0_OUT (signed16 = 2000 = 0x07D0) — auto-increment read
40+
0xBC: [0xD0, 0x07]
41+
# T1_OUT (signed16 = 5000 = 0x1388) — auto-increment read
42+
0xBE: [0x88, 0x13]
4343

4444
# Raw data via auto-increment read at 0xA8 (0x28 | 0x80)
4545
# H_OUT_L, H_OUT_H, T_OUT_L, T_OUT_H

0 commit comments

Comments
 (0)