Repository navigation
Clamp negative ADC limits before unsigned conversion - #140
Open
Solarboaters wants to merge 1 commit into
Open
Solarboaters wants to merge 1 commit into
Solarboaters wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
adc_raw_clamp checks the upper ADC bound but converts negative scaled limits directly to uint16_t. In a local host test, adc_raw_clamp(1.0F, -1.0F) returned 65535. This out-of-range floating-to-unsigned conversion should be avoided.
Clamp negative scaled values to zero before converting. Added boundary cases to the existing DAQ tests. An isolated C++ harness running the production helper reproduced the failure and passed after the change for negative, zero, in-range and above-maximum inputs.
This verifies the helper behavior. A negative threshold arriving through the live firmware configuration has not been reproduced. Full Zephyr and hardware testing remain pending.
Evidence audit — 17 November 2026
Individually rebuilt and ran the production Zephyr native test image from public revision
4b1c9275f: 96 tests, zero failures. This is separate from the combined run of #135–#145, which passes all 103 tests. Replacing the relevant production implementations with the original code reproduces the new regression failures.Reproduction in the west workspace, from the firmware directory:
Environment: Linux x86-64, GCC host toolchain, Zephyr 4.4.2, manifest dependencies. These tests use the project's native simulated interfaces; no ARM board or charging hardware was operated.