hal not reading information about sysfs batteries correctly

Bug #194052 reported by Khashayar Naderehvandi
40
Affects Status Importance Assigned to Milestone
gnome-power-manager (Ubuntu)
Invalid
Undecided
Unassigned
hal (Debian)
Fix Released
Unknown
hal (Ubuntu)
Fix Released
Medium
Martin Pitt

Bug Description

Binary package hint: gnome-power-manager

After the latest fixes to hal (see Bug 177570), gpm now correctly reports two batteries instead of four on my laptop. However, I now have at least one new problem. The files created by gpm to keep track of the profiling of the battery charging and discharging are wrong.

The files in .gnome2/gnome-power-manager are:
profile-generic_id-charging.csv
profile-generic_id-generic_id-charging.csv
profile-generic_id-discharging.csv
profile-generic_id-generic_id-discharging.csv

Before the hal patch from bug 177570 was applied, I had those files (for two of the four batteries reported, I guess), and then I had four other files with file names including the name of my battery models. My guess is, hal reports the "wrong two" of the four batteries previously reported, resulting in inaccurate charge/discharge times inevitably.

I'll attach the output of gnome-power-manager --verbose --no-daemon and lshal.

Regards,
K.

Revision history for this message
Khashayar Naderehvandi (khashayar) wrote :
Revision history for this message
Khashayar Naderehvandi (khashayar) wrote :
Revision history for this message
Chris Jones (cmsj) wrote :

I'm not sure if this is g-p-m or not, but I agree that this seems to be showing the wrong battery from before.
I suggest this because if I click on the systray battery icon and then on the name of the battery, the popup with information about charge levels and vendors and so-on contains about half as much information as it did previously.

Revision history for this message
Stéphane Graber (stgraber) wrote :

I can confirm what Chris sees.
The only information which doesn't seem to be a default value is the vendor.
I attach a screenshot of gpm's battery information.

Revision history for this message
Stéphane Graber (stgraber) wrote :
Changed in gnome-power-manager:
status: New → Confirmed
Revision history for this message
Islam Badrel-Dein (islambadreldein) wrote :

Hello,

I have something similar on my laptop. The g-p-m shows the battery as charging whenever I plug my wall adapter. But the battery status freezes there after then. The attachment shows two snapshots, one of them showing the mistaken battery reading (it shows 43% while actually the battery was near to be charged). The second attachment shows the correct reading. I forced the correct reading to appear by unplugging then immediately plugging the wall adapter.

Some info:
islam@islam-laptop:~$ cat /proc/version
Linux version 2.6.24-8-generic (buildd@yellow) (gcc version 4.2.3 (Ubuntu 4.2.3-1ubuntu2)) #1 SMP Thu Feb 14 20:13:27 UTC 2008
islam@islam-laptop:~$ dpkg -s gnome-power-manager | grep Version
Version: 2.21.1-0ubuntu1
islam@islam-laptop:~$ dpkg -s hal | grep Version
Version: 0.5.10-5ubuntu7

I want to add that the same thing happens at discharging. The reading never gets updated until some major event occurs such as Suspend or Shutdown. Even if the battery is near to empty, it still shows as 99% charged!!!

Revision history for this message
Islam Badrel-Dein (islambadreldein) wrote :

The correct reading, forced by triggering an event.

Revision history for this message
Islam Badrel-Dein (islambadreldein) wrote :

Also, notice how the Battery Charge Monitor Applet is affected by buggy readings as well. This suggests that the bug resides in HAL!

Some more info:
islam@islam-laptop:~$ cat /proc/acpi/battery/BAT0/info
present: yes
design capacity: 4000 mAh
last full capacity: 4000 mAh
battery technology: rechargeable
design voltage: 11100 mV
design capacity warning: 200 mAh
design capacity low: 140 mAh
capacity granularity 1: 60 mAh
capacity granularity 2: 3800 mAh
model number: GRAPE32
serial number: 38330
battery type: LION
OEM info: SANYO
islam@islam-laptop:~$ hal-find-by-capability --capability "battery"
/org/freedesktop/Hal/devices/computer_power_supply_0
islam@islam-laptop:~$ cat /proc/acpi/battery/BAT0/
alarm info state
islam@islam-laptop:~$ cat /proc/acpi/battery/BAT0/state
present: yes
capacity state: ok
charging state: charged
present rate: 0 mA
remaining capacity: 4000 mAh
present voltage: 12576 mV

(PS: the battery is really charged 100% now. The shown data is not a bug :)

Revision history for this message
Lukas Hejtmanek (xhejtman) wrote :

I think this is a bug in hal.

lshal | grep -i bat
  [...]
  linux.sysfs_path = '/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0' (string)

hal reports different values than in linux.sysfs_path/* It seems that hal reloads values *only* on an acpi event, e.g., unplugging power. Values in the directory are getting changed while lshal reports still the same values unless I generate an acpi event using power cord (plug/unplug). Maybe other acpi events work as well.

Revision history for this message
sv2dgi (sv2dgi) wrote :

Same happens on me. Notebook Vye S37B. If I issue a:
/etc/init.d/hal restart
I get the current reading but again, nothing gets updated.
/sys/devices/LNXST... shows the correct values.
/proc/acpi/... also shows the correct values.

Revision history for this message
Brian Murray (brian-murray) wrote :

gnome-power-manager is just using the information that it finds out from hal. It is actually hal that is not getting the sysfs information properly.

Changed in hal:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

The related upstream Debian bug report points to a couple of patches at freedesktop.org that may resolve this bug.

Changed in hal:
status: Unknown → Confirmed
Revision history for this message
Daniel T Chen (crimsun) wrote :

I've posted test packages at http://www.trilug.org/~crimsun/hal/. Please leave feedback here.

Revision history for this message
Siegie (siegie) wrote :

I would like to test, but i have a 64 bit environment.
Can i compile from te hal_0.5.10.orig.tar.gz?

Revision history for this message
Bruce Cowan (bruce89-deactivatedaccount) wrote :

pbuilder is your friend.

Revision history for this message
Bruce Cowan (bruce89-deactivatedaccount) wrote :

Sorry for the spam, but I'll upload the package to my PPA.

Revision history for this message
Lukas Hejtmanek (xhejtman) wrote :

Bruce, I tried your latest hal (ubuntu8), I built it for AMD64 architecture. It does refresh battery content almost correctly. Remaining capacity seems to be OK. But it seems that it does not report current rate at all:
lshal | grep -i bat
  battery.charge_level.current = 65080 (0xfe38) (int)
  battery.charge_level.last_full = 81980 (0x1403c) (int)
  battery.charge_level.percentage = 79 (0x4f) (int)
  battery.charge_level.rate = 0 (0x0) (int)
  battery.model = '42T4511' (string)
  battery.present = true (bool)
  battery.rechargeable.is_charging = false (bool)
  battery.rechargeable.is_discharging = true (bool)
  battery.remaining_time = 16270 (0x3f8e) (int)
  battery.reporting.current = 65080 (0xfe38) (int)
  battery.reporting.design = 84240 (0x14910) (int)
  battery.reporting.last_full = 81980 (0x1403c) (int)
  battery.reporting.rate = 0 (0x0) (int)
  battery.reporting.technology = 'Li-ion' (string)
  battery.reporting.unit = 'mWh' (string)
  battery.technology = 'lithium-ion' (string)
  battery.type = 'primary' (string)
  battery.vendor = 'SANYO' (string)
  battery.voltage.current = 12031 (0x2eff) (int)
  battery.voltage.design = 10800 (0x2a30) (int)
  battery.voltage.unit = 'mV' (string)
  info.capabilities = {'battery'} (string list)
  info.category = 'battery' (string)
  linux.sysfs_path = '/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0' (string)

Revision history for this message
Siegie (siegie) wrote :

Your patch has corrected the battery loading. Now i have 80Wh instead of 7.2Wh. I can also read a correct discharge time.
Thanks for this fix.

But gnome-power-manager still thinks that the laptop is working on battery. When it's not.
After i unplug/plug the power cable, the problem is solved.

Revision history for this message
Bruce Cowan (bruce89-deactivatedaccount) wrote : Re: [Bug 194052] Re: hal not reading information about sysfs batteries correctly

On Sat, 2008-03-01 at 18:36 +0000, Lukas Hejtmanek wrote:
> Bruce, I tried your latest hal (ubuntu8), I built it for AMD64 architecture.

Sorry, but it's not mine. It's Daniel T Chen's work, I just uploaded it
to my PPA.

Revision history for this message
Lukas Hejtmanek (xhejtman) wrote :

OK, there is a typo in sources. hald/linux/device.c line 3181, if(!hal...) should be if(hal..). After it, lshal reports correctly rate. But gnome-power-manager is still wrong about the rate, more precisely, g-p-m updates the rate only on power plug/unplug. Battery capacity (%) is updated on the fly correctly. Also, after desktop startup g-p-m reports battery is discharging even if running on power.

Revision history for this message
Khashayar Naderehvandi (khashayar) wrote :
Revision history for this message
Daniel T Chen (crimsun) wrote :

@Lucas: thanks, that's fixed in ~2.

@Khashayar: How does the addition of a battery serial number field resolve this issue?

Revision history for this message
Chris Halse Rogers (raof) wrote :

The ~3 packages seem to work for me (amd64). g-p-m provides a (seemingly) accurate power history graph, the battery charge % is correctly reported, and it notices when I change from battery to AC and back again.

If anyone else on AMD64 wants to test these packages, they're available at http://cooperteam.net/hal

Revision history for this message
Khashayar Naderehvandi (khashayar) wrote :

@Daniel: I'm sorry, I momentarily forgot that the summary of this bug had changed since I first filed it. When I filed it the summary was something like "incorrect profiling files created", and indeed the profiling files created in ~/.gnome2/gnome-power-manager are called 'profile-generic_id-generic..." and so on. With that patch (at least I _think_ it's that patch), the files are named 'profile-CP194245-XX....' and so on. This might be relevant when having two batteries, I don't know..

Revision history for this message
Siegie (siegie) wrote :

Thanks for those packages they fixed it.

Revision history for this message
Martin Pitt (pitti) wrote :

I merged Daniel's branch, thank you! Will upload today.

Changed in gnome-power-manager:
status: Confirmed → Invalid
Changed in hal:
assignee: nobody → pitti
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package hal - 0.5.10-5ubuntu8

---------------
hal (0.5.10-5ubuntu8) hardy; urgency=low

  [ Scott James Remnant ]
  * Add debian/patches/96_uinput_device_support.patch: This creates a HAL
    device for the uinput device, allowing us to set ACLs for it using
    PolicyKit/ConsoleKit.

  [ Daniel T Chen ]
  * Add debian/patches/97_fix_power_info_via_sysfs.patch: Fix battery status
    reading from /sys. Patches taken from upstream GIT head.
    (LP: #194052, #194719)

  [ Martin Pitt ]
  * Add debian/patches/02_sysfs_battery_serial.patch: Get battery serial
    number from sysfs. Patch taken fro upstream GIT head.

 -- Martin Pitt <email address hidden> Mon, 03 Mar 2008 15:02:40 +0100

Changed in hal:
status: Fix Committed → Fix Released
Changed in hal:
status: Confirmed → Fix Released
Revision history for this message
sv2dgi (sv2dgi) wrote :

Fix confirmed on my machine. Everything, battery, status-update, remaining-time, power works.
Thanks! Keep-up the good work!

Revision history for this message
sharninder (sharninder) wrote :

Works for me too on a dell latitude d630. Although has anyone noticed that the g-p-m display doesn't change as fast as the power settings display changes in windows. In windows its almost instantaneous.

Revision history for this message
Andrew Conkling (andrewski) wrote : Re: [Bug 194052] Re: hal not reading information about sysfs batteries correctly

On Tue, Mar 4, 2008 at 6:28 AM, sharninder <email address hidden> wrote:

> Although has anyone noticed
> that the g-p-m display doesn't change as fast as the power settings
> display changes in windows.

Well, I've had a different experience with Windows' power management, and
that's certainly not Ubuntu's measure of quality. More to the point though,
it certainly does appear slower for me than it did on Gutsy or with the
previous Hardy packages. I just filed bug #198335 to that affect.

Revision history for this message
sharninder (sharninder) wrote :

The windows comparison was just for reference. The gutsy comparison would have certainly been more relevant but I didn't have a gutsy notebook handy at the time. Anyway, thanks for the filing the bug.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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