Bug 5752 - HAL reports is_charging as TRUE while charge_rate =0 and battery is fully loaded
Summary: HAL reports is_charging as TRUE while charge_rate =0 and battery is fully loaded
Status: RESOLVED WONTFIX
Alias: None
Product: hal
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: David Zeuthen (not reading bugmail)
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-29 06:31 UTC by Jaap Haitsma
Modified: 2008-10-20 01:19 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
acpi output (2.43 KB, text/plain)
2006-02-20 08:55 UTC, Jaap Haitsma
Details
lshal output (58.94 KB, text/plain)
2006-02-20 08:57 UTC, Jaap Haitsma
Details
patch which cleansup acpi.c and util.c so we can code a suitable fix (21.63 KB, patch)
2006-02-21 00:56 UTC, Richard Hughes
Details | Splinter Review

Description Jaap Haitsma 2006-01-29 06:31:55 UTC
HAL reports is_charging as TRUE while charge_rate =0 and battery is fully loaded
I.e. 100% charge and current_charge == last_full_charge.
Comment 1 Jaap Haitsma 2006-01-29 07:22:23 UTC
Some system info: my laptop is Dell Latitude C600 with Debian Unstable
Comment 2 Danny Kukawka 2006-02-04 06:35:11 UTC
please attach output of 'grep . /proc/acpi/battery/*/*' and the output for the 
battery from lshal
Comment 3 Jaap Haitsma 2006-02-20 08:55:07 UTC
Created attachment 4675 [details]
acpi output
Comment 4 Jaap Haitsma 2006-02-20 08:57:06 UTC
Created attachment 4676 [details]
lshal output

You see here with BAT0 that current_charge equals the last_full_charge but
charging still equals true
Comment 5 Jaap Haitsma 2006-02-20 08:57:41 UTC
Sorry I meant with BAT1 you see it
Comment 6 Richard Hughes 2006-02-20 09:03:01 UTC
>You see here with BAT0 that current_charge equals the last_full_charge
> but charging still equals true

So we can add a condition in the battery refresh handler:

if (current_charge >= last_full_charge) {
        is_charging = FALSE;
}

and that would fix the problem, right?
Comment 7 Jaap Haitsma 2006-02-20 09:10:52 UTC
(In reply to comment #6)
> >You see here with BAT0 that current_charge equals the last_full_charge
> > but charging still equals true
> 
> So we can add a condition in the battery refresh handler:
> 
> if (current_charge >= last_full_charge) {
>         is_charging = FALSE;
> }
> 
> and that would fix the problem, right?

I think so. Make sure you add a comment and a reference to this bug in the code
otherwise somebody else might rip it out again

Comment 8 Richard Hughes 2006-02-20 09:13:48 UTC
Okay, I'll knock a patch up. It'll need some infrastructure work first, but
you'll see what I mean in a minute. I'll post to hal-devel list, and I'll cc you
Jaap.
Comment 9 Richard Hughes 2006-02-21 00:56:02 UTC
Created attachment 4685 [details] [review]
patch which cleansup acpi.c and util.c so we can code a suitable fix

Jaap, can you try the attached patch please? It's against CVS, but should apply
against the last release.
Comment 10 Danny Kukawka 2006-02-21 06:46:03 UTC
The idea to do this:

if (current_charge >= last_full_charge) {
        is_charging = FALSE;
}

is not correct. This maybe fix this machine, but this is wrong for other acpi 
machines. 

If e.g. last_full_charge is not correct set and the machine really charge the 
battery this presumption is complete wrong. This maybe also fails on machines 
which not set the last full capacity. 

You need to accept, that there are some machines which reports this in this 
way. There is maybe a reason why the battery report this. You can workaround 
this in your application, but not in HAL because you can't presume this in 
every case.
Comment 11 Richard Hughes 2006-02-21 06:51:43 UTC
Valid point, but wouldn't:

if (last_full_charge > 0 && current_charge >= last_full_charge) {
        is_charging = FALSE;
}

cover the not setting of last_full_charge?

I would argue that this *does* belong in HAL for exactly the oppose reason, that
the user-programs should not have to indervidually handle errata and hardware
bugs, but the solution is in one place, properly documented.

Richard.
Comment 12 Danny Kukawka 2006-02-21 07:07:52 UTC
No, IMO not. I also have here machines which definitely charing if they already 
arrived the last_full_charge. They are not full and they charge. 

One example is a DELL D600 which has as last full 44810 mWh and as current 
53000 mWh. This battery is over the last full but is charging. In the best case 
your code would only be some seconds wrong, but in the worst case a couple of 
minutes. IMO not the best idea. 

Btw. an other example would be a machine which reports a too low last full 
(maybe the battery is broken, maybe the ACPI implementation or the value is 
never correct set and never changed). In this case the battery maybe charge the 
next 30-60 and hal already reports the machine as full loaded.

Btw. In this special case the battery looks a littlebit old. Unlike to battery 
0 this battery has a lower last full value than the designed value. This is 
maybe the reason why the battery reports as charging. What say cat /proc/acpi/
battery/BAT0/* and what happens if you switch the both batteries?
Comment 13 Richard Hughes 2006-02-21 20:46:18 UTC
>One example is a DELL D600 which has as last full 44810 mWh and as current
>53000 mWh. This battery is over the last full but is charging. In the best case 
>your code would only be some seconds wrong, but in the worst case a couple of 
>minutes. IMO not the best idea. 

Then this is a broken battery in itself.

Current charge should never be greater than the last full capacity, logically.

To fix this battery we can correct for the value by saying:

If (current_charge > last_full)
  last_full = current_charge;

The permutations of broken stuff mean all this should be worked around in *one
place* rather than dozens of programs that trust the values from HAL.

Richard.
Comment 14 Benjamin Close 2008-01-11 02:36:31 UTC
Bugzilla Upgrade Mass Bug Change

NEEDSINFO state was removed in Bugzilla 3.x, reopening any bugs previously listed as NEEDSINFO.

  - benjsc
    fd.o Wrangler
Comment 15 Danny Kukawka 2008-10-20 01:19:59 UTC
Close really old bug, no activity since more than 2 years. Feel free to reopen if the problem is still present in latest HAL release or git master.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.