#[SOLVED] Suddenly unable to get estimation to when battery will be discharged

43 messages · Page 1 of 1 (latest)

radiant silo
#

Hello, I tried today to get an estimation of when my battery will be discharged using acpi. Yesterday I got a X hours, X minutes and X seconds estimation; But today, I get instead "discharging at zero rate - will never fully discharge".
Opened battop to see if it was only acpi but it's also unable to estimate
So, I went on a quest on Internet and all the results are for thinkpads that when not plugged, drop to 0% and/or the messaged is displayed when the laptop is plugged, that is not my case, (when I'm plugged I get the estimation of when my laptop will be charged).
Tried a TLP recalibration but (that was prior to this) it states that I don't have the hardware driver to do this. Once again, no internet research helped me.

I don't remember what I did exactly yesterday/before the problem appeared (except that I did an update of the whole system and fiddled with bios but I don't rembember acpi being broken after) and please note I can easily be confused, I'm way out of my domain of knowledge

Anyway, would really like (even tho it is not important) to get back battery estimation...

Thanks to anyone who will try to help me. Anyway, if you need more infos, I'll try to provide it.

harsh gulch
#

grep . /sys/class/power_supply/BAT*/uevent

radiant silo
#

DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=283
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7700000
POWER_SUPPLY_VOLTAGE_NOW=7177000
POWER_SUPPLY_CURRENT_NOW=-1834000
POWER_SUPPLY_CHARGE_FULL_DESIGN=7013000
POWER_SUPPLY_CHARGE_FULL=5816000
POWER_SUPPLY_CHARGE_NOW=998000
POWER_SUPPLY_CAPACITY=17
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_MODEL_NAME=Primary
POWER_SUPPLY_MANUFACTURER=Hewlett-Packard
POWER_SUPPLY_SERIAL_NUMBER=15533 2020/10/17

harsh gulch
#

The problem is whatever tool you used to get that info from

radiant silo
#

I mean, else I didn't express myself correctly or I don't understand quite well what you mean, but the problem was not the battery itself but to get the time remaining before my battery is discharged. Like I said, acpi return a "discharging at zero rate" message and battop tool is also unbale to determine how much time is left before battery hits 0%

#

Here, battop is supposed to give me a time value to the "time to empty" and even give me the value for "discharging with"

#

And yesterday both tools, acpi and battop were working fine. Like I 'm describing

harsh gulch
#

(POWER_SUPPLY_CHARGE_NOW / POWER_SUPPLY_CURRENT_NOW) * 60 minutes

radiant silo
#

Yeah, never said it was the battery, I'm just looking for a way to fix the tools because they are supposed to be working?

harsh gulch
#

Can you apply this patch to acpi 1.7 source?

diff --git a/acpi.c b/acpi.c
index 7967828..14d1743 100644
--- a/acpi.c
+++ b/acpi.c
@@ -272,6 +272,7 @@ void print_battery_information(struct list *batteries, int show_empty_slots, int
     fields = battery->data;
     while (fields) {
         value = fields->data;
+        printf("d: %s\n", value->attr);
         if (!strcasecmp(value->attr, "remaining capacity")) {
         remaining_capacity = get_unit_value(value->value);
         if (!state)
radiant silo
harsh gulch
radiant silo
harsh gulch
radiant silo
harsh gulch
#

download the attached file, don't copy it

radiant silo
#

Except having more infos displayed, still the sameproblem ("discharging at zero rate")

harsh gulch
#

Well, we are debugging now. Please apply this patch. Save as /tmp/patch2

patch -Np1 -r - < /tmp/patch2
radiant silo
harsh gulch
#

run grep . /sys/class/power_supply/BAT*/uevent again

#

quickly

radiant silo
#

Uh? OKay reupload picture

harsh gulch
#

Uh. discord is displaying a little poop lol

radiant silo
#

Should I continue?

harsh gulch
#

Okay, just copy this acpi.c file to the source directory, overwriting the existing one.

radiant silo
#

Okay and then? Configure,patch or just run ./acpi ?

harsh gulch
#

no, just make and run

radiant silo
harsh gulch
#

Yeah, your program has bugs.

radiant silo
#

Can confirm, and I suspect battop to just read acpi output for "time to empty"

harsh gulch
#

In short, if the acpi.c file has a check:

if (present_rate > MIN_PRESENT_RATE) {
    seconds = 3600 * (last_capacity - remaining_capacity) / present_rate;
    poststr = " until charged";
} else {
    poststr = "charging at zero rate - will never fully charge.";
    seconds = -1;
}

which states that if current_now is negative, then it's not discharging, this is not how the Linux kernel's power_supply_class works. It can be either negative or positive to indicate discharging or charging.
https://www.kernel.org/doc/html/latest/power/power_supply_class.html

#

So, file a bug report to the upstream.

#

Can confirm, and I suspect battop to just read acpi output for "time to empty"
No, it doesn't use the acpi program directly; it uses the same power_supply_class, though. It probably reads current_now incorrectly in the same way as acpi

radiant silo
harsh gulch
radiant silo
#

Yeah just noticed, thanks