Skip to content

laptop_battery_monitor: breaks when discharging #9

@kdhansen

Description

@kdhansen

I am running Ubuntu Xenial 16.04 with Kinetic in a VirtualBox on a MacBook Pro, so I don't know if this is a general problem to Xenial/Kinetic or some artifact of the VirtualBox.

The laptop_battery_monitor works while the laptop is plugged in to the mains, but when the adapter is disconnected, the node dies. Resulting in:

[WARN] [WallTime: 1472477308.423277] Battery : unable to check laptop battery state [[Errno 19] No such device]
[laptop_battery-2] process has finished cleanly

I tracked it down to what I think is a kernel module problem. Running grep "" * in /sys/class/power_supply/BAT0/ when plugged in gives:

alarm:0
capacity:100
capacity_level:Full
cycle_count:0
grep: device: Is a directory
energy_full:50000000
energy_full_design:50000000
energy_now:50000000
manufacturer:innotek
model_name:1
grep: power: Is a directory
power_now:0
present:1
serial_number:0
status:Full
grep: subsystem: Is a directory
technology:Unknown
type:Battery
uevent:POWER_SUPPLY_NAME=BAT0
uevent:POWER_SUPPLY_STATUS=Full
uevent:POWER_SUPPLY_PRESENT=1
uevent:POWER_SUPPLY_TECHNOLOGY=Unknown
uevent:POWER_SUPPLY_CYCLE_COUNT=0
uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10000000
uevent:POWER_SUPPLY_VOLTAGE_NOW=10000000
uevent:POWER_SUPPLY_POWER_NOW=0
uevent:POWER_SUPPLY_ENERGY_FULL_DESIGN=50000000
uevent:POWER_SUPPLY_ENERGY_FULL=50000000
uevent:POWER_SUPPLY_ENERGY_NOW=50000000
uevent:POWER_SUPPLY_CAPACITY=100
uevent:POWER_SUPPLY_CAPACITY_LEVEL=Full
uevent:POWER_SUPPLY_MODEL_NAME=1
uevent:POWER_SUPPLY_MANUFACTURER=innotek
uevent:POWER_SUPPLY_SERIAL_NUMBER=0
voltage_min_design:10000000
voltage_now:10000000

Whereas when the power is unplugged we get:

alarm:0
capacity:100
capacity_level:Normal
cycle_count:0
grep: device: Is a directory
energy_full:50000000
energy_full_design:50000000
energy_now:50000000
manufacturer:innotek
model_name:1
grep: power: Is a directory
grep: power_now: No such device
present:1
serial_number:0
status:Discharging
grep: subsystem: Is a directory
technology:Unknown
type:Battery
uevent:POWER_SUPPLY_NAME=BAT0
uevent:POWER_SUPPLY_STATUS=Discharging
uevent:POWER_SUPPLY_PRESENT=1
uevent:POWER_SUPPLY_TECHNOLOGY=Unknown
uevent:POWER_SUPPLY_CYCLE_COUNT=0
uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10000000
uevent:POWER_SUPPLY_VOLTAGE_NOW=10000000
uevent:POWER_SUPPLY_ENERGY_FULL_DESIGN=50000000
uevent:POWER_SUPPLY_ENERGY_FULL=50000000
uevent:POWER_SUPPLY_ENERGY_NOW=50000000
uevent:POWER_SUPPLY_CAPACITY=100
uevent:POWER_SUPPLY_CAPACITY_LEVEL=Normal
uevent:POWER_SUPPLY_MODEL_NAME=1
uevent:POWER_SUPPLY_MANUFACTURER=innotek
uevent:POWER_SUPPLY_SERIAL_NUMBER=0
voltage_min_design:10000000
voltage_now:10000000

As you can see power_now is present but there is no device.

A fix may be to change line 181 and 182 to

try:
    rv.current = _read_number(_battery_acpi_path + '/power_now')/10e5 / \
        _read_number(_battery_acpi_path + '/voltage_now')
    except IOError:
        rv.current = 0

But then the node would report 0 even though the current may be something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions