pwr-Solaar / Solaar

Linux device manager for Logitech devices
https://pwr-solaar.github.io/Solaar
GNU General Public License v2.0
5.38k stars 401 forks source link

Logitech g703 battery not detected/ unknown in GUI (feature BATTERY_VOLTAGE) #570

Closed maxdraki closed 4 years ago

maxdraki commented 4 years ago

Hello - I have a Logitech g703 mouse using the lightspeed receiver. Solaar detects the mouse but the battery is not detected.

I'm running Ubuntu 19.10 - kernel - 5.3.0-18-generic

$ solaar -d
06:29:15,579     INFO [MainThread] root: language en_GB (UTF-8), translations path None
06:29:15,670     INFO [MainThread] solaar.upower: connected to system dbus, watching for suspend/resume events
06:29:15,740     INFO [MainThread] solaar.listener: starting receiver listening threads
06:29:15,820     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path=u'/dev/hidraw8', vendor_id=u'046d', product_id=u'c539', serial=u'', release='3904', manufacturer='Logitech', product='USB Receiver', interface=2, driver=u'logitech-djreceiver')
06:29:16,734  WARNING [MainThread] logitech_receiver.base: timeout (0.90/0.90) on device 255 request {80B2} params []
06:29:16,735     INFO [ReceiverListener:hidraw8] logitech_receiver.listener: started with <LightspeedReceiver(/dev/hidraw8,15)> (15)
06:29:16,735     INFO [ReceiverListener:hidraw8] solaar.listener: <LightspeedReceiver(/dev/hidraw8,15)>: notifications listener has started (15)
06:29:16,739     INFO [ReceiverListener:hidraw8] logitech_receiver.receiver: <LightspeedReceiver(/dev/hidraw8,15)>: receiver notifications enabled => ('wireless', 'software present')
06:29:16,742     INFO [ReceiverListener:hidraw8] solaar.listener: status_changed <LightspeedReceiver(/dev/hidraw8,15)>: present, No paired devices. (0) 
06:29:16,755     INFO [ReceiverListener:hidraw8] logitech_receiver.receiver: <LightspeedReceiver(/dev/hidraw8,15)>: found new device 1 (4070)
06:29:16,755     INFO [ReceiverListener:hidraw8] solaar.listener: Notification(1,41,0C,B27040) triggered new device <PairedDevice(1,4070,G703)> (mouse)
06:29:16,883     INFO [ReceiverListener:hidraw8] solaar.listener: status_changed <LightspeedReceiver(/dev/hidraw8,15)>: present, 1 paired device. (0) 
06:29:16,946     INFO [ReceiverListener:hidraw8] solaar.configuration: saved {u'4070:AFE674F7': {u'dpi': 1600, u'_name': u'G703 Wired/Wireless Gaming Mouse'}, u'_version': u'1.0.1'} to /home/max/.config/solaar/config.json
06:29:16,966     INFO [ReceiverListener:hidraw8] solaar.listener: status_changed <PairedDevice(1,4070,G703)>: paired online, {'LINK ENCRYPTED': True} (1) 
$ solaar show
Unifying Receiver
  Device path  : /dev/hidraw8
  USB id       : 046d:c539
  Serial       : 4CA99F7C
    Firmware   : 39.04.B0036
    Bootloader : 02.09
    Other      : AA.BE
  Has 1 paired device(s) out of a maximum of 1.
  Notifications: wireless, software present (0x000900)
  Device activity counters: (empty)

  1: G703 Wired/Wireless Gaming Mouse
     Codename     : G703
     Kind         : mouse
     Wireless PID : 4070
     Protocol     : HID++ 4.2
     Polling rate : 8 ms (125Hz)
     Serial number: AFE674F7
          Firmware: MPM 14.02.B0007
        Bootloader: BOT 64.02.B0007
             Other: 
     The power switch is located on the base.
     Supports 29 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
         3: DEVICE NAME            {0005}   
         4: unknown:1001           {1001}   
         5: unknown:1863           {1863}   internal, hidden
         6: unknown:18A1           {18A1}   internal, hidden
         7: unknown:1E00           {1E00}   hidden
         8: unknown:1E20           {1E20}   
         9: unknown:1EB0           {1EB0}   internal, hidden
        10: ADJUSTABLE DPI         {2201}   
        11: ANGLE SNAPPING         {2230}   
        12: SURFACE TUNING         {2240}   
        13: REPORT RATE            {8060}   
        14: ONBOARD PROFILES       {8100}   
        15: MOUSE BUTTON SPY       {8110}   
        16: unknown:1850           {1850}   internal, hidden
        17: unknown:00C2           {00C2}   
        18: unknown:1801           {1801}   internal, hidden
        19: unknown:1802           {1802}   internal, hidden
        20: unknown:1803           {1803}   internal, hidden
        21: unknown:1890           {1890}   internal, hidden
        22: unknown:1811           {1811}   internal, hidden
        23: unknown:8111           {8111}   
        24: COLOR LED EFECTS       {8070}   
        25: unknown:1809           {1809}   
        26: unknown:1830           {1830}   internal, hidden
        27: unknown:1805           {1805}   internal, hidden
        28: unknown:1806           {1806}   internal, hidden
     Battery status unavailable.

Any suggestions? Thanks very much

pfps commented 4 years ago

@FFY00 There is code in Solaar to process battery voltage notifications so that part of the solution should be working. The problem might be that there is no code that checks battery status or voltage when devices connect.

pfps commented 4 years ago

@FFY00 Yes indeed, Solaar does not update battery status when a device reconnects unless there is no previous battery status. It should probably update battery status whenever a device comes online.

maxdraki commented 4 years ago

Hi @pfps - unfortunately I had to plug the mouse in while working as it was down to 3% (according to logitech's software - I have to use Windows for work :( ) But.. I have been collecting the battery level from solaar show for a while and I've attached the log - the first col is timestamp. The gaps are either when I've been working and so plugged into my laptop, or while I guess it's hibernating.. Should be some info you can use

Max battery-volt.txt

pfps commented 4 years ago

solaar show should output three fields (voltage, status, and level). Please paste output for me to check. What I was interested in seeing was whether the level changed (from average to critical, or something like that).

maxdraki commented 4 years ago

Unfortunately I wasn't collecting everything..

> solaar show
Lightspeed Receiver
  Device path  : /dev/hidraw9
  USB id       : 046d:c539
  Serial       : 4CA99F7C
    Firmware   : 39.06.B0040
    Bootloader : 02.09
    Other      : AA.BE
  Has 1 paired device(s) out of a maximum of 1.
  Notifications: wireless, software present (0x000900)
  Device activity counters: (empty)

 > 1: G703 Wired/Wireless Gaming Mouse
     Codename     : G703
     Kind         : mouse
     Wireless PID : 4070
     Protocol     : HID++ 4.2
     Polling rate : 1 ms (1000Hz)
     Serial number: AFE674F7
          Firmware: MPM 14.02.B0007
        Bootloader: BOT 64.02.B0007
             Other: 
     The power switch is located on the base.
     Supports 29 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
         3: DEVICE NAME            {0005}   
         4: BATTERY VOLTAGE        {1001}   
         5: unknown:1863           {1863}   internal, hidden
         6: unknown:18A1           {18A1}   internal, hidden
         7: unknown:1E00           {1E00}   hidden
         8: unknown:1E20           {1E20}   
         9: unknown:1EB0           {1EB0}   internal, hidden
        10: ADJUSTABLE DPI         {2201}   
            Sensitivity (DPI): 1000
        11: ANGLE SNAPPING         {2230}   
        12: SURFACE TUNING         {2240}   
        13: REPORT RATE            {8060}   
        14: ONBOARD PROFILES       {8100}   
        15: MOUSE BUTTON SPY       {8110}   
        16: unknown:1850           {1850}   internal, hidden
        17: DFUCONTROL SIGNED      {00C2}   
        18: unknown:1801           {1801}   internal, hidden
        19: DEVICE RESET           {1802}   internal, hidden
        20: unknown:1803           {1803}   internal, hidden
        21: unknown:1890           {1890}   internal, hidden
        22: unknown:1811           {1811}   internal, hidden
        23: LATENCY MONITORING     {8111}   
        24: COLOR LED EFFECTS      {8070}   
        25: unknown:1809           {1809}   
        26: unknown:1830           {1830}   internal, hidden
        27: OOBSTATE               {1805}   internal, hidden
        28: CONFIG DEVICE PROPS    {1806}   internal, hidden
     Battery: 4162mV, discharging, average.
pfps commented 4 years ago

If you are collecting the output, please also collect that last value - that's the one the is used to change the battery icon.
Solaar might also be changing the voltage displayed in the GUI, but I'm not completely sure that this is the case. Please let me know whether the voltage being displayed in the GUI follows the voltage from solaar show.

maxdraki commented 4 years ago

Will do - will send more info tomorrow, or when I have some more data

maxdraki commented 4 years ago

Here's a file with voltage, status and level - missing data is either when it was sleeping or it was plugged into my laptop. It looks like the GUI is displaying the correct voltage, but not all the time as far as I've noticed - if not the voltage, then "average". I've not noticed the icon change

battery-volt.txt

Still not seeing anything in upower -d, although as mentioned, /sys/class/power_supply/hidpp_battery_* is being updated :man_shrugging:

pfps commented 4 years ago

Solaar wasn't keeping good track of the battery voltage in the GUI. I've put in a pull request (#906) to do a better job of this. Can you try running this PR? Let me know if the battery voltage changes in the Solaar main window while the window is visible.

To run PR #906, first clone Solaar if you have not already done so and cd to the clone directory. The first time you download the pull request, fetch it into a new branch and checkout that branch, as in:

git fetch origin pull/906/head:pull_906
git checkout pull_906

To download a new version of the pull request, pull it into your branch for the request, as in:

git checkout pull_906
git pull origin pull/906/head:pull_906

Then, from that directory, run

bin/solaar
maxdraki commented 4 years ago

Seems to be working - I haven't closed the solaar window, although the display did sleep for a while.. 2020-08-08_19-50

2020-08-08_20-58

maxdraki commented 4 years ago

Maybe spoke too soon - is it meant to update at every voltage change? Battery: 3926mV, discharging, average. image

pfps commented 4 years ago

I expect that your mouse is not notifying the GUI every time the voltage changes so the GUI is displaying the last value it was told about. To check for sure you can run Solaar with debugging on, as bin/solaar -dd. This will produce a lot of output. What you are looking for are lines that look something like:

... DEBUG [...:hidraw9] logitech_receiver.... => r[11 01 040? ......]

These are reports of the battery voltage (feature 04) for your mouse (device 01). If the ? is non-zero then this is a response to a request from Solaar. If the ? is zero then this is a spontaneous notification from the device about voltage change. The last part is the actual voltage data with the voltage in the first two bytes and some status flags in the next byte.

As your battery's voltage decreases these reports should show up from time to time and Solaar (with PR #906) should update the GUI with the reported voltage.

maxdraki commented 4 years ago

Thanks again @pfps - I've piped the debug info to a file in case it's useful battery-debug.txt

pfps commented 4 years ago

Yes, very useful. There is a stupid bug in the PR. I've fixed the bug so can you download the new version of the PR and provide output of solaar -dd again?

maxdraki commented 4 years ago

Here we go again - hope I managed to update the PR properly (not really used git cli before!) battery-debug.txt

pfps commented 4 years ago

Oops, my fault. The instructions I provided don't work because of the way I changed the PR. I'll send new instructions shortly.

pfps commented 4 years ago

What you need to do is:

git checkout pull_906
git fetch origin pull/906/head
git reset --hard FETCH_HEAD

Sorry for the incorrect instructions.

maxdraki commented 4 years ago

Thanks @pfps Let's try again - lmk if there's a problem battery-debug.txt

pfps commented 4 years ago

It looks as if the processing of battery voltage notifications is working correctly, but of course I can't see whether the voltage changes in the GUI. Is that happening? I see a voltage change in your logs so the device is reporting voltage changes quite regularly.

But you did uncover another issue. This issue shouldn't have changed how Solaar reports the battery voltage, but can you test out the newest version of PR #906?

maxdraki commented 4 years ago

Definitely seems to be working :) the GUI is updating the voltage.. debug info attached

battery-debug.txt

pfps commented 4 years ago

OK, I'll merge into the master branch.

effective-light commented 3 years ago

If anyone is still interested, UPower support will probably make it's way into the mainline in the 5.15 kernel.

See: https://lore.kernel.org/lkml/nycvar.YFH.7.76.2108201433050.15313@cbobk.fhfr.pm/