GNOME Bugzilla – Bug 314182
vaio fs215M: battery doesn't shows up
Last modified: 2009-08-15 18:40:50 UTC
battstat doesn't shows my battery. However hal and acpi seems to know about it... alarm: unsupported present: yes design capacity: 4400 mAh last full capacity: 4400 mAh battery technology: non-rechargeable design voltage: 12588 mV design capacity warning: 1000 mAh design capacity low: 400 mAh capacity granularity 1: 100 mAh capacity granularity 2: 100 mAh model number: serial number: battery type: LiOn OEM info: Sony Corp. present: yes capacity state: ok charging state: charging present rate: unknown remaining capacity: 4400 mAh present voltage: unknown udi = '/org/freedesktop/Hal/devices/acpi_BAT0' info.udi = '/org/freedesktop/Hal/devices/acpi_BAT0' (string) linux.hotplug_type = 4 (0x4) (int) battery.charge_level.percentage = 0 (0x0) (int) battery.remaining_time = 0 (0x0) (int) battery.charge_level.rate = 0 (0x0) (int) battery.charge_level.last_full = -4400 (0xffffeed0) (int) battery.charge_level.current = -4400 (0xffffeed0) (int) battery.reporting.rate = 0 (0x0) (int) battery.reporting.current = 4400 (0x1130) (int) battery.rechargeable.is_discharging = false (bool) battery.rechargeable.is_charging = true (bool) battery.is_rechargeable = true (bool) battery.charge_level.granularity_2 = 1259500 (0x1337ec) (int) battery.charge_level.granularity_1 = 1259500 (0x1337ec) (int) battery.charge_level.low = 5038000 (0x4cdfb0) (int) battery.charge_level.warning = 12595000 (0xc02f38) (int) battery.charge_level.design = 55418000 (0x34d9c90) (int) battery.voltage.design = 12595 (0x3133) (int) battery.voltage.unit = 'mV' (string) battery.reporting.granularity_2 = 100 (0x64) (int) battery.reporting.granularity_1 = 100 (0x64) (int) battery.reporting.low = 400 (0x190) (int) battery.reporting.warning = 1000 (0x3e8) (int) battery.reporting.design = 4400 (0x1130) (int) battery.reporting.last_full = 4400 (0x1130) (int) battery.reporting.unit = 'mAh' (string) battery.technology = 'LiOn' (string) battery.vendor = 'Sony' (string) battery.present = true (bool) info.capabilities = {'battery'} (string list) info.category = 'battery' (string) battery.type = 'primary' (string) info.product = 'Battery Bay' (string) info.parent = '/org/freedesktop/Hal/devices/computer' (string) linux.acpi_type = 0 (0x0) (int) linux.acpi_path = '/proc/acpi/battery/BAT0' (string)
hald bug: Present voltage is unknown. Attempting to read current voltage will get you a -1 inside HAL. Current charge (in mA) is multiplied by current voltage (4400 * -1 = -4400) battstat sees negative charge and gets angry. cc:ing Richard Hughes on this one.
Richard: basically, you should check to see if the return value of the 'present voltage' is -1 and if so then fallback to the design voltage.
Created attachment 51134 [details] [review] fix. Richard: this is what a fix might look like. Completely untested. pbor: please try applying this to your HAL and see if it fixes the problem for you.
Created attachment 51136 [details] [review] new fix. hahah. I should have at least tried to compile it first :)
The patch seems to work good for me. Thanks for the quick fix Ryan! Who says filing bugs is useless... :)
Created attachment 51140 [details] [review] fix to hal Shall I push the attached upstream? I've changed a few lines in your patch, adding a warning and changed voltage_current to just voltage (as it's misleading otherwise) - I think I was working on the patch simultanous to you!
HAL_WARNING (("battery.voltage.current invalid, using battery.voltage.design")); I don't think this is appropriate since there are real-world situations where this occurs and it's not a bug. The other warning might be appropriate, though. I guess we'll find out if that code is ever used for anyone....... Push this into HAL. I'll notify the Ubuntu guys. I'm closing this bug now since it doesn't really have anything to do with battstat :)
Thanks for notifying me. However, this part is bogus: + if (voltage <= 0) { + HAL_WARNING (("battery.voltage.current invalid, using battery.voltage.design")); + voltage = hal_device_property_get_int (d, "battery.voltage.current"); In the last line you need to s/current/design/ to make it do what you want. :-) I did that fix in the Ubuntu version.
Yes, sorry, I already noticed this, and fixed the patch before I committed it to hal. I committed the patch to fix this issue this morning, so if you try HAL cvs, the issue should be fixed. Richard.