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
Get battery data from statefs #237
Conversation
Add helpers for getting state names and use them in diagnostic logging.
Performs similar task as existing battery_bme and battery_upower plugins, but gets the battery data from files maintained by the statefs service. Checks presense of required propery files in /run/state/namespaces/Battery directory on mce startup. If files are not present, or become not available later on due to stopping and/or restarting of statefs service, periodic checks are made to detect when they come available again. While the files available, the battery level, status and charging activity state changes are tracked and pushed to datapipes in the form existing mce logic is expecting. [mce] Add plugin for tracking battery state via statefs. Contributes to JB#6273
By default load statefs battery plugin instead of the upower one. [mce] Get battery data from statefs. Fixes JB#6273
It is more or less expected that end of notification can occur later than expected and there is no harm in ending notification state even though one is not even started. Hence there is no need to spam the journal with these messages on default logging verbosity.
| sfsbat_state_t state; | ||
| } state_lut[] = | ||
| { | ||
| { "charging", STATEFS_BATTERY_STATE_CHARGING }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend you to add also "unknown" state tracking, adding it instead of separate IsValid (or similar) property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kind of built into startup defaults, but handling it explicitly is clearer (and works if battery should for some reason go to unknown state after initial probing too). Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand you are right: maybe "unknown" should be anything except known values. Also empty string is suitable for this state.
The logic assumed that battery is in unknown state until statefs reports transition to [charging, discharging, full, empty] is seen. However transitions to unknown state are ignored and the previous state is kept. Add "unknown" to set of expected Battery.State values. Treat empty string as an alias for "unknown". Unrecognized string values are treated similarly as "unknown", but a warning is emitted to journal.
Get battery data from statefs
No description provided.