-
Notifications
You must be signed in to change notification settings - Fork 1
bq27441: Harmonize driver and add test scenario. #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c78451d
bq27441: Harmonize driver with project conventions.
nedseb 20cda8f
bq27441: Add test scenario for battery fuel gauge driver.
nedseb 9706f1b
bq27441: Increase capacity range to 2000 mAh in tests.
nedseb 59b4b08
tests: Document bus_id parameter in FakeI2C docstring.
nedseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| driver: bq27441 | ||
| driver_class: BQ27441 | ||
| i2c_address: 0x55 | ||
|
|
||
| # I2C config for hardware tests (STeaMi board - STM32WB55) | ||
| i2c: | ||
| id: 1 | ||
|
|
||
| # Register values for mock tests | ||
| # BQ27441 uses 2-byte little-endian registers read via struct.unpack("<h") | ||
| # The constructor calls power_up() -> set_capacity() -> writeExtendedData() | ||
| # which enters config mode (needs CFGUPMODE flag in FLAGS register). | ||
| mock_registers: | ||
| # CONTROL (0x00): status word (unsealed, INITCOMP set) | ||
| 0x00: [0x80, 0x00] | ||
| # FLAGS (0x06): CFGUPMODE | BAT_DET | DSG — needed for enterConfig/exitConfig | ||
| 0x06: [0x19, 0x00] | ||
| # VOLTAGE (0x04): 3700 mV | ||
| 0x04: [0x74, 0x0E] | ||
| # REM_CAPACITY (0x0C): 600 mAh | ||
| 0x0C: [0x58, 0x02] | ||
| # FULL_CAPACITY (0x0E): 650 mAh | ||
| 0x0E: [0x8A, 0x02] | ||
| # AVG_CURRENT (0x10): 50 mA | ||
| 0x10: [0x32, 0x00] | ||
| # AVG_POWER (0x18): 185 mW | ||
| 0x18: [0xB9, 0x00] | ||
| # SOC (0x1C): 92% | ||
| 0x1C: [0x5C, 0x00] | ||
| # SOH (0x20): 99% (low byte = percent, high byte = status) | ||
| 0x20: [0x63, 0x00] | ||
|
|
||
| tests: | ||
| - name: "Read voltage" | ||
| action: call | ||
| method: voltage | ||
| expect: 3700 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read state of charge" | ||
| action: call | ||
| method: state_of_charge | ||
| expect: 92 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read remaining capacity" | ||
| action: call | ||
| method: capacity_remaining | ||
| expect: 600 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read full capacity" | ||
| action: call | ||
| method: capacity_full | ||
| expect: 650 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read average current" | ||
| action: call | ||
| method: current_average | ||
| expect: 50 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read average power" | ||
| action: call | ||
| method: power | ||
| expect: 185 | ||
| mode: [mock] | ||
|
|
||
| - name: "Read state of health" | ||
| action: call | ||
| method: state_of_health | ||
| expect: 99 | ||
| mode: [mock] | ||
|
|
||
| - name: "Battery connected check" | ||
| action: manual | ||
| prompt: "Une batterie est-elle connectée à la carte ?" | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Device type is BQ27441" | ||
| action: call | ||
| method: is_valid_device | ||
| expect: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Voltage in plausible range" | ||
| action: call | ||
| method: voltage | ||
| expect_range: [3000, 4300] | ||
| mode: [hardware] | ||
|
|
||
| - name: "State of charge in valid range" | ||
| action: call | ||
| method: state_of_charge | ||
| expect_range: [0, 100] | ||
| mode: [hardware] | ||
|
|
||
| - name: "Remaining capacity positive" | ||
| action: call | ||
| method: capacity_remaining | ||
| expect_range: [0, 2000] | ||
| mode: [hardware] | ||
|
|
||
| - name: "Full capacity positive" | ||
| action: call | ||
| method: capacity_full | ||
| expect_range: [100, 2000] | ||
| mode: [hardware] | ||
|
|
||
| - name: "Average current readable" | ||
| action: call | ||
| method: current_average | ||
| expect_not_none: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Average power readable" | ||
| action: call | ||
| method: power | ||
| expect_not_none: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "State of health in valid range" | ||
| action: call | ||
| method: state_of_health | ||
| expect_range: [0, 100] | ||
| mode: [hardware] | ||
|
|
||
| - name: "Battery info summary" | ||
| action: manual | ||
| display: | ||
| - method: voltage | ||
| label: "Tension" | ||
| unit: "mV" | ||
| - method: state_of_charge | ||
| label: "Charge" | ||
| unit: "%" | ||
| - method: capacity_remaining | ||
| label: "Capacité restante" | ||
| unit: "mAh" | ||
| - method: capacity_full | ||
| label: "Capacité totale" | ||
| unit: "mAh" | ||
| - method: current_average | ||
| label: "Courant moyen" | ||
| unit: "mA" | ||
| - method: state_of_health | ||
| label: "Santé batterie" | ||
| unit: "%" | ||
| prompt: "Ces valeurs sont-elles cohérentes avec l'état de la batterie ?" | ||
| expect_true: true | ||
| mode: [hardware] |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.