wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.#110
Merged
wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.#110
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect multi-byte I2C register reads in the wsen-hids driver by ensuring the sensor’s required AUTO_INCREMENT bit is applied whenever reading more than one byte, which restores correct calibration parsing and accurate temperature/humidity measurements.
Changes:
- Update
WSEN_HIDS._read_regs()to OR inAUTO_INCREMENTfor multi-byte reads. - Remove redundant AUTO_INCREMENT OR-ing at the call site in
_read_raw_humidity_temperature(). - Update the WSEN-HIDS mock scenario register map to use auto-incremented register keys for multi-byte calibration reads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/wsen-hids/wsen_hids/device.py | Centralizes AUTO_INCREMENT behavior in _read_regs() and simplifies raw read call sites. |
| tests/scenarios/wsen_hids.yaml | Adjusts mock register keys to validate the new multi-byte auto-increment behavior in mock tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #109
Summary
_read_regs()to setAUTO_INCREMENT(bit 7) when reading more than 1 byte, as required by the WSEN-HIDS (HTS221-based) I2C protocol| AUTO_INCREMENTin_read_raw_humidity_temperature()(now handled centrally)0xB6,0xBA,0xBC,0xBE)Bug
Without the auto-increment bit, multi-byte reads return the same byte repeated. This corrupted all 16-bit calibration values (T0_OUT, T1_OUT, H0_T0_OUT, H1_T0_OUT), causing temperature to read ~6°C too low and humidity to be inaccurate.
Hardware validation
Before fix:
After fix:
Test plan
ruff checkpassespytest tests/ -k mock— 44/44 passed (no regressions)