I'm debugging a situation where the remaining battery percentage report is not accurate for my newly installed battery.
Regarding the answer of my previous question, various tools query the battery information directly from the battery itself. However, output of battery voltage differs between /sys/class/power_supply/BAT1/voltage_now
and upower
:
# upower
voltage: 10.974 V
# /sys/...
10500000
Moreover, upower
updates its statistics every 2 minutes, where /sys/class/power_supply/BAT1/voltage_now
seems to be updated live. This also indicates that the sources of those two data-sources are probably different.
So, what are the data sources of those two data sources?
.../voltage_now
file actually creates a telegram, asks battery voltage from the battery pack via SMBUS and returns the answer (but not cache it forupower
or like) under the hood? – ceremcem Feb 17 '20 at 08:42upowerd
. I added more info to the answer to explain this. Hope it's clear now – Munzir Taha Feb 17 '20 at 09:56voltage_now
file. That is still a mystery. – ceremcem Feb 17 '20 at 13:59voltage_now
file viacat
(or anything that reads the file) triggers a function in the kernel, kernel connects to the battery pack via SMBUS, read the data and write it tovoltage_now
file and let us read the file. It would be pointless otherwise. How could I read thevoltage_now
file in every second and get the "correct" voltage value then? – ceremcem Feb 17 '20 at 17:41cat voltage_now
, the kernel would run some magic code and connect to the battery via SMBus, read the data and make it available viavoltage_now
. – Munzir Taha Feb 17 '20 at 19:15