fw/services/battery: add optional fuel gauge diagnostic logging - #1850
Draft
adipascu wants to merge 1 commit into
Draft
fw/services/battery: add optional fuel gauge diagnostic logging#1850adipascu wants to merge 1 commit into
adipascu wants to merge 1 commit into
Conversation
Add a Kconfig-gated periodic log line with the raw fuel gauge inputs and outputs: SOC, voltage, current, temperature, TTE/TTF, and charger state. Unlike the existing INFO log it fires on a fixed interval regardless of charge activity, giving development devices a uniform time series for validating state-of-charge estimation, for example under charge regimes that never reach full. Off by default, so production builds are unchanged. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Adrian Pascu <adrian@pascu.be>
adipascu
force-pushed
the
gauge-diag-log
branch
from
August 11, 2026 05:51
773cf1d to
b31c4a3
Compare
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.
Validating state-of-charge estimation needs a uniform record of what the fuel gauge was told and what it concluded. The existing battery log fires on percent changes and while charging, so it is dense during a charge and silent for hours otherwise. This adds an evenly spaced one, off unless a build asks for it.
BATTERY_GAUGE_DIAG_LOGgates a single structured line carrying the raw inputs and outputs together: SOC in centi-percent, voltage, current, temperature, time-to-empty and time-to-full, and whether the charger is unplugged, plugged or charging.BATTERY_GAUGE_DIAG_LOG_INTERVAL_Ssets the cadence, 60 to 3600 seconds, default 900. Everything logged is already in hand at that point inprv_update_state, so nothing new is measured and no driver changes are needed.The flag defaults to off and the block compiles out with it, so production builds are byte-identical to today.
Motivated by the review discussion on #1841. Answering whether reported SOC drifts when a battery never reaches full needs voltage sampled alongside SOC on a fixed interval, from a watch actually living under a charge limit, which is what this produces. Running on my Pebble Time 2 since 2026-08-11 with the charge limit at 55%.
Written with AI assistance (Claude).
Aside: I am currently available for firmware contracting or full-time work. Contact: adrian@pascu.be.