Ubuntu

[Master] hal/acpi incorrectly reports AC adapter state

Reported by Luis Alberto Pabón on 2008-04-06
96
This bug affects 5 people
Affects Status Importance Assigned to Milestone
acpi
Fix Released
Medium
acpi (Ubuntu)
Undecided
Unassigned
hal (Ubuntu)
Low
Unassigned

Bug Description

hal properly reports battery charging/discharging state but incorrectly reports whether the AC adapter is unplugged.

lshal output when unplugged or plugged in both indicates:
ac_adapter.present = true (bool)

present on several laptops in Hardy, Intrepid, and Jaunty.

in Jaunty:
acpi -V (plugged in)
     Battery 0: Charging, 81%, 04:06:26 until charged
     Battery 0: design capacity 53280 mAh, last full capacity 50890 mAh = 95%
  AC Adapter 0: on-line
     Thermal 0: ok, 47.0 degrees C
     Cooling 0: LCD 0 of 8
     Cooling 1: Processor 0 of 10
     Cooling 2: Processor 0 of 10

acpi -V (unplugged)
     Battery 0: Discharging, 81%, 02:16:47 remaining
     Battery 0: design capacity 53280 mAh, last full capacity 50890 mAh = 95%
  AC Adapter 0: on-line
     Thermal 0: ok, 47.0 degrees C
     Cooling 0: LCD 0 of 8
     Cooling 1: Processor 0 of 10
     Cooling 2: Processor 0 of 10

Original report:
Binary package hint: kde-guidance

Not sure for how long this has been going on, perhaps a couple of weeks. The kde applet for the power manager doesn't seem to know when the battery is unplugged or not, resulting in no CPU governor change and no screen backlight dimming.

When unplugged, changes on the "mains connected" settings will reflect immediately, same as when it is plugged.

This is a Sony VAIO FS285M laptop (centrino chipset, Pentium M 1.73). It used to work just fine for many a month in this regard.

Hardy was installed fresh in January due to a bigger HDD coming in. It worked fine then.

Hardy fully updated as of yesterday, Kubuntu, running the KDE3 applet under KDE 4.0.3 (no change if I run the KDE3 desktop).

uname -a
Linux ordenata 2.6.24-12-generic #1 SMP Wed Mar 12 23:01:54 UTC 2008 i686 GNU/Linux

Please let me know what else is needed for diagnosis.

Luis Alberto Pabón (copong) wrote :

"The kde applet for the power manager doesn't seem to know when the battery is unplugged or not"

Sorry, what I meant is "when the laptop is connected to the mains or not"

Luka Renko (lure) wrote :

Can you provide "lshal" when plugged and when unplugged, to see if HAL has proper information?

You can also run "lshal -m" and plug/unplug power supply to see if anything is printed to console output.

Changed in kde-guidance:
assignee: nobody → lure
status: New → Incomplete
Luis Alberto Pabón (copong) wrote :

Luka, this is lshal plugged

Luis Alberto Pabón (copong) wrote :

And lshal unplugged.

This is the diff of them both, it seems that HAL knows when the status changes:

luis@ordenata:~$ diff lshal.plugged lshal.unplugged
297,299c297,299
< battery.rechargeable.is_charging = true (bool)
< battery.rechargeable.is_discharging = false (bool)
< battery.remaining_time = 780 (0x30c) (int)
---
> battery.rechargeable.is_charging = false (bool)
> battery.rechargeable.is_discharging = true (bool)
> battery.remaining_time = 122464 (0x1de60) (int)

Luis Alberto Pabón (copong) wrote :

lshal -m (exec when connected, then disconnect, then connect again)

luis@ordenata:~$ lshal -m

Start monitoring devicelist:
-------------------------------------------------
23:00:54.235: computer_power_supply_battery_BAT0 property battery.remaining_time = 3778 (0xec2)
23:00:54.243: computer_power_supply_battery_BAT0 property battery.charge_level.current = 43991 (0xabd7)
23:00:54.245: computer_power_supply_battery_BAT0 property battery.reporting.current = 3514 (0xdba)

23:01:02.052: computer_power_supply_battery_BAT0 property battery.remaining_time = 6284 (0x188c)
23:01:02.058: computer_power_supply_battery_BAT0 property battery.charge_level.current = 43979 (0xabcb)
23:01:02.061: computer_power_supply_battery_BAT0 property battery.reporting.current = 3513 (0xdb9)
23:01:02.064: computer_power_supply_battery_BAT0 property battery.rechargeable.is_discharging = false
23:01:02.066: computer_power_supply_battery_BAT0 property battery.rechargeable.is_charging = true

Luis Alberto Pabón (copong) wrote :

Sorry, forgot to add that last night a new kernel was installed with no change regarding this problem:

luis@ordenata:~$ uname -a
Linux ordenata 2.6.24-15-generic #1 SMP Fri Apr 4 03:48:31 UTC 2008 i686 GNU/Linux

@Luis
Can I please have you provide the output (if any) of the following command:
"hal-find-by-capability --capability ac_adapter"
Does the above output change whether you are on AC or on battery?

If it exists, please provide the output of the following command when plugged to AC and when on battery:
"hal-get-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present"

Found the problem myself; discard the previous message. Tried to do the diff thing too, and that didn't really show what expected.

From the lshal.unplugged file:
ac_adapter.present = true (bool)

The problem is, that your AC adapter is reported as present (eg. plugged in) by HAL even when it is not.

  • unnamed Edit (1.1 KiB, text/html; charset=ISO-8859-1)

Glad you found out where the problem lies :) Is there anything else I can
do? try out a patch, anything?

On 07/04/2008, awen <email address hidden> wrote:
>
> Found the problem myself; discard the previous message. Tried to do the
> diff thing too, and that didn't really show what expected.
>
> >From the lshal.unplugged file:
> ac_adapter.present = true (bool)
>
> The problem is, that your AC adapter is reported as present (eg. plugged
> in) by HAL even when it is not.
>
>
> --
> [Hardy] Guidance-power-manager doesn't know when laptop is mains unplugged
> https://bugs.launchpad.net/bugs/213128
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
Luis Pabón

I think it's a hal issue that has to be solved there.

Louimama (louismjacquelin) wrote :

I've got the same problem on a VAIO FZ160E. Seems to be a common problem on Vaios : see bug #216345 .

Hal reports if battery is charging or discharging as well as the remaining power. Maybe guidance-power-manager should rely on those info to switch between power management policies.

Any chance it'll get resolved for Hardy?

Olivier (olivier-lacroix) wrote :

Luka, this bug is marked as incomplete, but the output you asked has been provided. Do you need anything else ?

Louimama (louismjacquelin) wrote :

Ok. I did a quick and dirty hack. Now that works on my machine. Of course this issue should be resolved in hal, but at least it works. Edit /usr/share/python-support/kde-guidance-powermanager/powermanage.py and change the function onBattery to look that way

def onBattery(self):
        """ Find out if we're on AC or on battery using HAL. """
        if not self.hasAC:
            print "No AC adapter found - assume that we are on batteries."
            return False

 properties = self.batteries[0].GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
 return properties["battery.rechargeable.is_discharging"]

Luka, maybe it is possible to combine the two tests, both on the ac_adapter and the battery state ?

  • unnamed Edit (1.7 KiB, text/html; charset=ISO-8859-1)

Luimama, your hack works for me.

2008/4/24 Louimama <email address hidden>:

> Ok. I did a quick and dirty hack. Now that works on my machine. Of
> course this issue should be resolved in hal, but at least it works. Edit
> /usr/share/python-support/kde-guidance-powermanager/powermanage.py and
> change the function onBattery to look that way
>
> def onBattery(self):
> """ Find out if we're on AC or on battery using HAL. """
> if not self.hasAC:
> print "No AC adapter found - assume that we are on batteries."
> return False
>
> properties =
> self.batteries[0].GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
> return properties["battery.rechargeable.is_discharging"]
>
>
> Luka, maybe it is possible to combine the two tests, both on the ac_adapter
> and the battery state ?
>
> --
> [Hardy] Guidance-power-manager doesn't know when laptop is mains unplugged
> https://bugs.launchpad.net/bugs/213128
> You received this bug notification because you are a direct subscriber
> of the bug.
>

--
Luis Pabón

Luis Alberto Pabón (copong) wrote :
  • unnamed Edit (189 bytes, text/html; charset=ISO-8859-1)

Well, sort of :) unplugging from mains has got the effect of changing the
screen brightness straight away, however the CPU governor takes a long while
to switch, if it actually does :)

Same Problems on Acer TravelMate C300

HAL does detect when power is unplugged. lshal -m shows correct output but the command
hal-get-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present
returns true in both cases (plugged or unplugged)

FriedChicken (domlyons) wrote :

Guidance-Power-Manger doesn't recognize if mains is plugged out and battery put in (to save battery lifetime I always plug the battery of if it isn't needed) in hibernate/suspend-to-disc mode. I have to restart the power manager that the battery is detected and the battery profile gets enabled.

Is this the same problem or should I open a new bug?

MarcS (marc-schmitzer) wrote :

Same problem here on a Dell Inspiron 5160 and Hardy.
lshal reports
  ac_adapter.present = true
even when unplugged. Battery charging/discharging state is reported correctly, though.

maho (maho) wrote :

I have almost identical problem (even made duplicate in #243243 ;) ).

I'm attaching lshal and lshal -m outputs.

maho (maho) wrote :
dBera (dbera-web) wrote :

Same on inspiron 1100 w/ Hardy. Identical lshal/lshal -m outputs so not attaching anything. I can do some tests if needed. Thanks.

eddiewould (eddie-eddiewould) wrote :

I've the following issues on a SONY VAIO VGN-CR323 Notebook:

- guidance-power-manager doesn't appear to be able to tell when the AC adaptor is plugged in.

When plugged:
> cat /proc/acpi/ac_adapter/ACAD/state
 state: on-line
> hal-find-by-capability --capability ac_adapter
 /org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_ACAD
> hal-get-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present
 false

When unplugged:
> cat /proc/acpi/ac_adapter/ACAD/state
 state: off-line
> hal-find-by-capability --capability ac_adapter
 /org/freedesktop/Hal/devices/computer_power_supply_ac_adapter_ACAD
> hal-get-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present
 false

I've attached output from lshal when both plugged and unplugged.

Hopefully this helps in resolving the bug...

Moebius (louiscyphre) wrote :

I've posted a workaround in a similar bug report...

https://bugs.launchpad.net/ubuntu/+source/hal/+bug/254603/comments/1

Hope it helps.

I don't understand why this hasn't been fixed yet. The worst part is that it
used to work fine until a change in hal happened, and I reported the bug
like a week after.

Thanks Moebius, your workaround worked like a charm.

:)

Moebius, your workaround works lovely :) However there's one thing it
doesn't change: the cpu freq scaling governor.

So I was trying this out on the command line:
sudo echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

but I get a "permission denied" error (using sudo wtf)... any ideas? Got
powersave as one of the listed available governors

Luis,
for me hal changes the CPU freq scaling governor too.

However, you cannot edit the file /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor until you are in a root environment (sudo will not work). So, to edit the file, just type:
sudo -i
echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Remember that you have to do this for all your cores.

To automate the process you can append that lines to your power-switch scripts. So we have:

/etc/acpi/ac.d/power-switch.sh containing:
hal-set-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present --bool true
echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

/etc/acpi/battery.d/power-switch.sh containing:
hal-set-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present --bool false
echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo "powersave" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

Anyway, probably the best way to configure your CPU freq scaling policy is through the guidance-power-manager so you can easily change it later. To do that, just click with the left mouse button on the guidance-power-manager icon in you system tray: a configuration panel will pop up.
(I configure my policies through the guidance-power-manager and it works well with hal)

Hope it helps.

Thanks Moebius, I put those on the sh files and the circle is now complete.

Yeah, got guidance configured that way already, the problem is well, if HAL
doesn't know the laptop is unplugged guidance obviously can't do anything at
all, not even change the governor. At least on my laptop! So nothing would
change - the battery icon would still appear as charging, the screen
brightness wouldn't dim and the cpu would still be running on the ondemand
governor. It would even report the battery as being 100% charged all the way
until forced shutdown due to battery being flat.

Changed in hal:
status: Incomplete → New
Daniel T Chen (crimsun) on 2008-12-09
Changed in hal:
importance: Undecided → Low

HP Pavilion dv6000t with same problem. For me this is really difficult because I never get a low-battery warning and my auto-suspend never happens... I've lost significant work and time due to this bug.

Workaround seems to work for me, however. Thanks!

Changed in hal:
status: New → Confirmed

On a Sony Vaio CS11S if i unplug power i don't see any "ac_adapter" messages in the lshal output, just this line:

computer_power_supply_battery_BAT1 property battery.rechargeable.is_discharging = true

But "ac_adapter.present" changed from true to false (without notify in the "-m" output). Also if i plug in the power cord again, the status remains "false".

So HAL isn't recognizing the ac adapter change.

Luka Renko (lure) on 2009-05-01
Changed in hal (Ubuntu):
assignee: Luka Renko (lure) → nobody
Scott Howard (showard314) wrote :

Another duplicate has shown up, I'm posting here comments from there:

 Alex Midgley (alex-tapdancinggoats: 14) wrote on 2009-05-04: (permalink)

This bug seems to have moved into acpi in Jaunty. I have a Sony Vaio VGN-CR520E, and the above fix (https://bugs.launchpad.net/ubuntu/+source/hal/+bug/254603/comments/1) corrected the hal problem in Intrepid. However, now even acpi is always reporting that the AC adapter is plugged in.

acpi -V (plugged in)
     Battery 0: Charging, 81%, 04:06:26 until charged
     Battery 0: design capacity 53280 mAh, last full capacity 50890 mAh = 95%
  AC Adapter 0: on-line
     Thermal 0: ok, 47.0 degrees C
     Cooling 0: LCD 0 of 8
     Cooling 1: Processor 0 of 10
     Cooling 2: Processor 0 of 10

acpi -V (unplugged)
     Battery 0: Discharging, 81%, 02:16:47 remaining
     Battery 0: design capacity 53280 mAh, last full capacity 50890 mAh = 95%
  AC Adapter 0: on-line
     Thermal 0: ok, 47.0 degrees C
     Cooling 0: LCD 0 of 8
     Cooling 1: Processor 0 of 10
     Cooling 2: Processor 0 of 10

It detects that the battery is discharging, but not that the AC adapter is off-line.

Same thing from:
https://bugs.launchpad.net/ubuntu/+source/hal/+bug/375260
Nick B. shows that the battery is reported as charging and discharging, but the AC adapter is not reported plugged in/out.

Moving the dupes over and will investigate. This is a problem with HAL, I'll be updating the title and description with the updated information we've collected.

summary: - [Hardy] Guidance-power-manager doesn't know when laptop is mains
- unplugged
+ [Master] hal/acpi incorrectly reports AC adapter state
description: updated
Scott Howard (showard314) wrote :

There is a very similar bug upstream: http://bugzilla.kernel.org/show_bug.cgi?id=12641

The bug apparently appears around kernel 2.6.29

Changed in acpi (Ubuntu):
status: New → Confirmed
Changed in acpi:
status: Unknown → Incomplete
ex-oficio (wilkinson-luke) wrote :

i experience this issue INTERMITTENTLY on my HP dv6599ea (dv6000 series basically). when it decides to exhibit the behaviour i have discovered that issuing the command

cat /proc/acpi/ac_adapter/ACAD/state

gives the response:

state: off-line

or:

state: on-line

depending on what the case may be, but the act of issuing the command causes gnome or hal or guidance-power-manager (or whatever the source of the issue is) is become aware of the proper state, and make all the proper display, and power adjustments.

i find this strange (and certainly beyond my understanding of the OS), and just thought i would let you know in case it helps; apologies if it doesn't.

when the problem is there, it is precisely as described in the initial description of the bug at the top of this report.

only deviation is that i am not using kde, i am using gnome(ubuntu jaunty):

uname -a
Linux orion 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:58:03 UTC 2009 x86_64 GNU/Linux

gnome version as per the attached .png.

many thanks for all efforts.

Gemu (g3mu) wrote :

hi

I have a little hack for this problem

cat /proc/acpi/ac_adapter/ACAD/state

this command to force update the status of AC_Adapter correctly, this will be used for the hack.

sudo vim /etc/acpi/events/battery_event
(copy/paste)
event=battery.*
action=cat /proc/acpi/ac_adapter/AC/state > /dev/null

then restarting the daemon acpid or reboot.
service acpid restart

now plugged in/out should work out correctly.

g3mu,

I'm happy to report your suggested hack works for me, many thanks. i
wouldn't have thought of that as it required a bit more insight into the
system than i have!

did you post it on the bug page?

much appreciated, thanks again,

L Wilkinson

On Mon, 2009-08-10 at 05:40 +0000, Gemu wrote:
> hi
>
> I have a little hack for this problem
>
> cat /proc/acpi/ac_adapter/ACAD/state
>
> this command to force update the status of AC_Adapter correctly, this
> will be used for the hack.
>
> sudo vim /etc/acpi/events/battery_event
> (copy/paste)
> event=battery.*
> action=cat /proc/acpi/ac_adapter/AC/state > /dev/null
>
> then restarting the daemon acpid or reboot.
> service acpid restart
>
> now plugged in/out should work out correctly.
>

linuxrules (linuxrules) wrote :

here is a good fix to put in /etc/acpi/battery.sh ( I had the same problem and fixed it by adding this to the top)

#########################################
AC_state=/proc/acpi/ac_adapter/AC/state

if grep -q "on-line" ${AC_state} ; then

    hal-set-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present --bool true

else

    hal-set-property --udi `hal-find-by-capability --capability ac_adapter` --key ac_adapter.present --bool false

fi
#########################################

Changed in acpi:
status: Incomplete → Fix Released
Changed in acpi:
importance: Unknown → Medium
dino99 (9d9) wrote :
Changed in acpi (Ubuntu):
status: Confirmed → Invalid
Changed in hal (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.