Bug 60827 - Logitech K520 Keyboard & Mouse wireless battery shown as 0%
Summary: Logitech K520 Keyboard & Mouse wireless battery shown as 0%
Status: RESOLVED FIXED
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Richard Hughes
QA Contact:
URL: https://launchpad.net/bugs/1103064
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-14 08:55 UTC by Martin Pitt
Modified: 2013-10-28 23:09 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Martin Pitt 2013-02-14 08:55:54 UTC
http://cgit.freedesktop.org/upower/commit/?id=95184593504bca5240ecd29 introduced support for Logitech unifying devices. However, with 0.9.19 their charge is shown as 0%:

Device: /org/freedesktop/UPower/devices/mouse_input5
  native-path:          /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input5
  vendor:               Logitech
  power supply:         no
  updated:              Thu Feb 14 03:54:12 2013 (34 seconds ago)
  has history:          yes
  has statistics:       no
  mouse
    present:             yes
    rechargeable:        yes
    state:               discharging
    percentage:          0%

Device: /org/freedesktop/UPower/devices/keyboard_input6
  native-path:          /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input6
  vendor:               Logitech
  power supply:         no
  updated:              Thu Feb 14 03:54:12 2013 (34 seconds ago)
  has history:          yes
  has statistics:       no
  keyboard
    present:             no
    rechargeable:        yes
    state:               unknown
    percentage:          0%


This leads to confusing output in both gnome-power-statistics (https://launchpadlibrarian.net/129122895/power-settings-window.png) as well as indicators (https://launchpadlibrarian.net/129122931/indicators.png).

I think as a defensive action we should not add a "percentage" property if we are unable to read the actual charge, i. e. if it is 0.

Ideally we'd fix reading the charge, of course.
Comment 1 Julien Danjou 2013-02-14 09:02:34 UTC
That doesn't sound complicated to fix, though I'm not sure what's the best strategy in term of UPower handling of that case. Richard, do you have any hint, or you're comfortable enough to fix it?
I can test a patch if you don't have the hardware.
Comment 2 Martin Pitt 2013-02-14 09:16:13 UTC
I'm now at a machine which has these devices attached. I can reproduce the bug with 0.9.19, but interestingly with git head I don't see the devices at all any more. There might be some regression in http://cgit.freedesktop.org/upower/commit/?id=b1f12feb1fd45, did you or Julien happen to try current master with such a device?

The udev rule seems to work somewhat; it attaches the property to the USB HID device (not the input device); I assume that's intended?

P: /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C52B.0005
E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C5
2B.0005
E: DRIVER=logitech-djdevice
E: HID_ID=0003:0000046D:0000C52B
E: HID_NAME=Logitech Unifying Device. Wireless PID:1024
E: HID_PHYS=usb-0000:00:1a.0-1.5.1:1
E: MODALIAS=hid:b0003g0000v0000046Dp0000C52B
E: SUBSYSTEM=hid
E: UDEV_LOG=3
E: UPOWER_BATTERY_TYPE=unifying
E: USEC_INITIALIZED=47249781752

P: /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C52B.0006
E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C5
2B.0006
E: DRIVER=logitech-djdevice
E: HID_ID=0003:0000046D:0000C52B
E: HID_NAME=Logitech Unifying Device. Wireless PID:2011
E: HID_PHYS=usb-0000:00:1a.0-1.5.1:2
E: MODALIAS=hid:b0003g0000v0000046Dp0000C52B
E: SUBSYSTEM=hid
E: UDEV_LOG=3
E: UPOWER_BATTERY_TYPE=unifying
E: USEC_INITIALIZED=47249782421


With that, the debugging output is

TI:04:15:59     registering subsystem : hid
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.3/0003:046D:0A29.0001
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.0/0003:046D:C52B.0002
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.1/0003:046D:C52B.0003
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004
TI:04:15:59     Using Unifying receiver hidraw device file: /dev/hidraw1
TI:04:15:59     Getting idx for feature GetDeviceNameType [05]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     Getting idx for feature BatteryLevelStatus [1000]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     Getting idx for feature SolarDashboard [4301]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     failed to coldplug unifying device: device is unreachable
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C52B.0005
TI:04:15:59     Using Unifying receiver hidraw device file: /dev/hidraw1
TI:04:15:59     Getting idx for feature GetDeviceNameType [05]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     Getting idx for feature BatteryLevelStatus [1000]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     Getting idx for feature SolarDashboard [4301]
TI:04:15:59     Failed to get feature idx: invalid response from device: 7
TI:04:15:59     failed to coldplug unifying device: device is unreachable
TI:04:15:59     failed to coldplug /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/0003:046D:C52B.0006
Comment 3 Martin Pitt 2013-02-14 09:17:17 UTC
Julien, FTR, I'm "pitti" on Freenode (hanging out in e. g. #udev) if you want to discuss/debug on IRC.
Comment 4 Martin Pitt 2013-02-14 09:21:54 UTC
On 0.9.19, the debug output is

TI:04:19:37        invalid bitmask entry for /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/
1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input5
TI:04:19:37        Using Unifying receiver hidraw device file: /dev/hidraw1
TI:04:19:37        object path = /org/freedesktop/UPower/devices/mouse_input5
TI:04:19:37        Unifying device 1 is offline
TI:04:19:37        added native-path: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input5
TI:04:19:37        using id: Logitech
[...]
TI:04:19:37        invalid bitmask entry for /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input6
TI:04:19:37        Using Unifying receiver hidraw device file: /dev/hidraw1
TI:04:19:37        object path = /org/freedesktop/UPower/devices/keyboard_input6
TI:04:19:37        Unifying device 2 is offline
TI:04:19:37        added native-path: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.2/0003:046D:C52B.0004/input/input6

TI:04:19:37        using id: Logitech

The "invalid bitmask" might be related to http://cgit.freedesktop.org/upower/commit/?id=35b0d25 ?
Comment 5 Martin Pitt 2013-02-14 09:24:58 UTC
With git reset to commit 35b0d25 I basically get the same output as with 0.9.19, so the "invalid bitmask" still remains with 35b0d25.
Comment 6 Martin Pitt 2013-02-14 11:09:06 UTC
Julien was talking to me on IRC, and got me some clarifications:

 - The "invalid bit mask" thing is something else, and nothing to worry about.

 - In the original bug report, both devices were "present", whereas in my remote ssh testing they are both "offline". That's because these devices power down after some minutes of inactivity, which is plausible because the person owning this device is asleep right now, and I only have ssh access.

 - You can't read charge levels or much else from powered down devices. However, that's not the bug here as even in the original report, where both devices are online, the percentage is 0%

 - Julien only wrote support for the HID 1.0 protocol, but on that machine they are using HID++ 2.0.

So we are back to the original problem that upower should not claim a 0% percentage if its actually unable to read the percentage.

Also, it seems that the refactoring patch broke these devices entirely, but that might also just be fallout from the powered down devices somehow, and thus I'd rather let Julien test it again on master.

Thanks!
Comment 7 Lionel Landwerlin 2013-08-21 14:34:34 UTC
Hi all, 

Anyone having a beginning of a fix to test for this bug?
I'm having kind of a similar problem with my wireless logitech mouse.
From time to time upower shows the mouse at 100% and other times at 1%. So I get notification all the time in gnome-shell.
If you have any code path to look at I would be happy to try some things out.

Thanks.
Comment 8 Peter Wu 2013-08-25 09:50:44 UTC
Lionel, a mouse you say? I guess that is an issue which occurs when older (non-related!) reports from hidraw are seen as a response to the battery query.

Please try https://git.lekensteyn.nl/upower/log/?h=hidpp-rework, that should resolve your issue. At least get the commits up to https://git.lekensteyn.nl/upower/commit/?h=hidpp-rework&id=a375524c52e75079236127f9a89bd335cd37b3c9
Comment 9 Martin Pitt 2013-09-03 06:42:33 UTC
This should be fixed with the set of Peter Wu's "hidpp" rewrite patches which landed in upstream master now.
Comment 10 Peter Wu 2013-09-03 09:02:16 UTC
Thanks for merging. Martin, note that the battery percentage may still show as 0% if a device was unavailable when UPower starts, but in that case the state is "unknown". Applications should check the state before using "percentage".
Comment 11 Peter Wu 2013-09-03 19:51:18 UTC
Heads-up: I noticed that the K800 reports 0% while charging (0 means "unknown level"). I think this is unfixable in UPower and that applications should not warn when a device is charging and the percentage is 0.

This also messes up history, if you expected a nice history with a climbing percentage, you will be disappointed. I wonder what happens when the battery is fully charged.
Comment 12 saintger 2013-10-28 22:23:32 UTC
Using upower 0.9.23-2 on Debian, I still have this issue:

Device: /org/freedesktop/UPower/devices/mouse_0003o046DoC52Bx0004
  native-path:          /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.2/0003:046D:C52B.0003/0003:046D:C52B.0004
  vendor:               Logitech, Inc.
  model:                Performance MX
  serial:               CC1238BC
  power supply:         no
  updated:              lun. 28 oct. 2013 23:24:33 CET (58 seconds ago)
  has history:          yes
  has statistics:       no
  mouse
    present:             yes
    rechargeable:        yes
    state:               discharging
    percentage:          20%

The battery level is wrong and sometimes fluctuate (between 1%; 20% and 55%).
Currently the battery is almost full (thanks to the LEDs on the mouse) and the battery level only indicates 20%.
Comment 13 Peter Wu 2013-10-28 23:09:58 UTC
(In reply to comment #12)
> Using upower 0.9.23-2 on Debian, I still have this issue:
> [..]
> The battery level is wrong and sometimes fluctuate (between 1%; 20% and 55%).
> Currently the battery is almost full (thanks to the LEDs on the mouse) and
> the battery level only indicates 20%.

The Performance MX uses the HID++ 1.0 protocol for reading the battery level from a register. Is the displayed battery percentage always from a fixed set of numbers? Does the number jump upwards and downwards all the time, or is it decreasing over time?

Can you verify the battery level with Solaar?


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.