Repository: pwr-Solaar/Solaar

Issue:
solaar show crashes for M705
**Information**
<!-- Do not bother opening an issue for version 0.9.2 or older, it is extremely outdated. Please update to the latest one and see if your issue persists. -->
- Solaar version (`git describe --tags` if cloned from Solaar repository): 1.0.2.r12.g8999565-1 (clone from repository)
- Distribution: Arch Linux
- Kernel version (ex. `uname -srmo`): `Linux 5.7.2-arch1-1 x86_64 GNU/Linux`
- Output of `solaar show`:
```
Unifying Receiver
  Device path  : /dev/hidraw0
  USB id       : 046d:c52b
  Serial       : 28B295ED
    Firmware   : 24.11.B0036
    Bootloader : 02.09
    Other      : AA.AC
  Has 4 paired device(s) out of a maximum of 6.
  Notifications: wireless, software present (0x000900)
  Device activity counters: 1=177, 2=222, 4=24

  1: Wireless Mouse MX Master 2S
     Codename     : MX Master 2S
     Kind         : mouse
     Wireless PID : 4069
     Protocol     : HID++ 4.5
     Polling rate : 8 ms (125Hz)
     Serial number: 493D1134
        Bootloader: BOT 56.01.B0006
          Firmware: MPM 12.01.B0006
          Firmware: MPM 12.01.B0006
             Other: 
     The power switch is located on the base.
     Supports 32 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
         3: DEVICE NAME            {0005}   
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: CRYPTO ID              {0021}   
         7: BATTERY STATUS         {1000}   
         8: CONFIG DEVICE PROPS    {1806}   internal, hidden
         9: CHANGE HOST            {1814}   
        10: REPROG CONTROLS V4     {1B04}   
        11: ADJUSTABLE DPI         {2201}   
            Sensitivity (DPI): 3000
        12: VERTICAL SCROLLING     {2100}   
            Roller type: 3G
            Ratchet per turn: 24
            Scroll lines: 0
        13: SMART SHIFT            {2110}   
            Smart Shift: 12
        14: HIRES WHEEL            {2121}   
            Multiplier: 8
            Has invert
              Normal wheel motion
            Has ratchet switch
              Normal wheel mode
            High resolution mode
            HID notification
            High Resolution Wheel Invert: False
            Wheel Resolution: True
        15: GESTURE 2              {6501}   
        16: DFUCONTROL SIGNED      {00C2}   
        17: unknown:1813           {1813}   internal, hidden
        18: unknown:1830           {1830}   internal, hidden
        19: unknown:1890           {1890}   internal, hidden
        20: unknown:1891           {1891}   internal, hidden
        21: unknown:18A1           {18A1}   internal, hidden
        22: unknown:18C0           {18C0}   internal, hidden
        23: unknown:1DF3           {1DF3}   internal, hidden
        24: unknown:1E00           {1E00}   hidden
        25: unknown:1EB0           {1EB0}   internal, hidden
        26: unknown:1803           {1803}   internal, hidden
        27: unknown:1861           {1861}   internal, hidden
        28: unknown:9001           {9001}   internal, hidden
        29: unknown:9200           {9200}   internal, hidden
        30: unknown:9202           {9202}   internal, hidden
        31: OOBSTATE               {1805}   internal, hidden
     Has 8 reprogrammable keys:
         0: LEFT CLICK                , default: LeftClick                   => LEFT CLICK                
             mse, pos:0, group:1, gmask:1
         1: RIGHT CLICK               , default: RightClick                  => RIGHT CLICK               
             mse, pos:0, group:1, gmask:1
         2: MIDDLE BUTTON             , default: MiddleMouseButton           => MIDDLE BUTTON             
             mse, reprogrammable, divertable, pos:0, group:3, gmask:7
         3: BACK AS BUTTON 4          , default: BackEx                      => BACK AS BUTTON 4          
             mse, reprogrammable, divertable, pos:0, group:2, gmask:3
         4: FORWARD AS BUTTON 5       , default: BrowserForwardEx            => FORWARD AS BUTTON 5       
             mse, reprogrammable, divertable, pos:0, group:2, gmask:3
         5: unknown:00C3              , default: unknown:00A9                => unknown:00C3              
             mse, reprogrammable, divertable, pos:0, group:3, gmask:7
         6: unknown:00C4              , default: unknown:009D                => unknown:00C4              
             mse, reprogrammable, divertable, pos:0, group:3, gmask:7
         7: unknown:00D7              , default: unknown:00B4                => unknown:00D7              
             divertable, virtual, pos:0, group:4, gmask:0
     Battery: 90%, discharging, next level 50%.

  2: Wireless Mobile Mouse MX Anywhere 2
     Codename     : MX Anywhere 2
     Kind         : mouse
     Wireless PID : 4072
     Protocol     : HID++ 4.5
     Polling rate : 8 ms (125Hz)
     Serial number: DDAE1933
        Bootloader: BOT 57.10.B0003
          Firmware: MPM 13.10.B0003
          Firmware: MPM 13.10.B0003
             Other: 
     The power switch is located on the base.
     Supports 28 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
         3: DEVICE NAME            {0005}   
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: CRYPTO ID              {0021}   
         7: BATTERY STATUS         {1000}   
         8: CONFIG DEVICE PROPS    {1806}   internal, hidden
         9: CHANGE HOST            {1814}   
        10: REPROG CONTROLS V4     {1B04}   
        11: ADJUSTABLE DPI         {2201}   
            Sensitivity (DPI): 1600
        12: VERTICAL SCROLLING     {2100}   
            Roller type: 3G
            Ratchet per turn: 24
            Scroll lines: 0
        13: HIRES WHEEL            {2121}   
            Multiplier: 8
            Has invert
              Normal wheel motion
            Has ratchet switch
              Normal wheel mode
            Low resolution mode
            HID notification
            High Resolution Wheel Invert: False
            Wheel Resolution: False
        14: DFUCONTROL SIGNED      {00C2}   
        15: unknown:1813           {1813}   internal, hidden
        16: unknown:1830           {1830}   internal, hidden
        17: unknown:1890           {1890}   internal, hidden
        18: unknown:1891           {1891}   internal, hidden
        19: unknown:18A1           {18A1}   internal, hidden
        20: unknown:18C0           {18C0}   internal, hidden
        21: unknown:1DF3           {1DF3}   internal, hidden
        22: unknown:1E00           {1E00}   hidden
        23: unknown:1EB0           {1EB0}   internal, hidden
        24: unknown:1803           {1803}   internal, hidden
        25: unknown:1861           {1861}   internal, hidden
        26: unknown:9001           {9001}   internal, hidden
        27: OOBSTATE               {1805}   internal, hidden
     Has 8 reprogrammable keys:
         0: LEFT CLICK                , default: LeftClick                   => LEFT CLICK                
             mse, pos:0, group:1, gmask:1
         1: RIGHT CLICK               , default: RightClick                  => RIGHT CLICK               
             mse, pos:0, group:1, gmask:1
         2: MIDDLE BUTTON             , default: unknown:00A9                => MIDDLE BUTTON             
             mse, reprogrammable, divertable, pos:0, group:2, gmask:11
         3: BACK AS BUTTON 4          , default: BackEx                      => BACK AS BUTTON 4          
             mse, reprogrammable, divertable, pos:0, group:3, gmask:15
         4: FORWARD AS BUTTON 5       , default: BrowserForwardEx            => FORWARD AS BUTTON 5       
             mse, reprogrammable, divertable, pos:0, group:3, gmask:15
         5: LEFT SCROLL AS AC PAN     , default: HorzScrollLeftSet           => LEFT SCROLL AS AC PAN     
             mse, reprogrammable, divertable, pos:0, group:3, gmask:15
         6: RIGHT SCROLL AS AC PAN    , default: HorzScrollRightSet          => RIGHT SCROLL AS AC PAN    
             mse, reprogrammable, divertable, pos:0, group:3, gmask:15
         7: unknown:00D7              , default: unknown:00B4                => unknown:00D7              
             divertable, virtual, pos:0, group:4, gmask:0
     Battery: 90%, discharging, next level 50%.

  3: Wireless Touch Keyboard K400
     Codename     : K400
     Kind         : keyboard
     Wireless PID : 4024
     Protocol     : HID++ 2.0
     Polling rate : 8 ms (125Hz)
     Serial number: 25CF31D9
     The power switch is located on the edge of top right corner.
     Battery: unknown (device is offline).

  4: Marathon Mouse M705 (M-R0009)
     Codename     : M705 (M-R0009)
     Kind         : mouse
     Wireless PID : 101B
     Protocol     : HID++ 1.0
     Polling rate : 8 ms (125Hz)
     Serial number: 41629AAD
          Firmware: 17.01.B0017
        Bootloader: 02.06
             Other: 00.04
     The power switch is located on the base.
     Notifications: battery status (0x100000).
solaar: error: not enough values to unpack (expected 3, got 2)

```

**Describe the bug**
`solaar show` crashes with the error `solaar: error: not enough values to unpack (expected 3, got 2)` when trying to output information about the battery status for the Marathon Mouse M705.

**To Reproduce**
Steps to reproduce the behavior:
1. run `solaar show`


**Additional context**
As far as I can tell, d41c35b1c616853a8e337ba22974b088441cb21d is the last commit that does not throw this error. 79947dca6c8bd63ca4824d93a63d447bf7f38bbb is the first commit with this error. Output of `solaar show M705` for commit d41c35b1c616853a8e337ba22974b088441cb21d:
```
  4: Marathon Mouse M705 (M-R0009)
     Codename     : M705 (M-R0009)
     Kind         : mouse
     Wireless PID : 101B
     Protocol     : HID++ 1.0
     Polling rate : 8 ms (125Hz)
     Serial number: 41629AAD
          Firmware: 17.01.B0017
        Bootloader: 02.06
             Other: 00.04
     The power switch is located on the base.
     Notifications: battery status (0x100000).
     Battery: 65%, discharging.
```



Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/hidpp10.py b/lib/logitech_receiver/hidpp10.py
--- a/lib/logitech_receiver/hidpp10.py
+++ b/lib/logitech_receiver/hidpp10.py
@@ -189,7 +189,7 @@ def parse_battery_status(register, reply):
 				else BATTERY_STATUS.recharging if status_byte == 0x50
 				else BATTERY_STATUS.full if status_byte == 0x90
 				else None)
-		return charge, status_text
+		return charge, status_text, None
 
 	if register == REGISTERS.battery_status:
 		status_byte = ord(reply[:1])
diff --git a/lib/solaar/cli/__init__.py b/lib/solaar/cli/__init__.py
--- a/lib/solaar/cli/__init__.py
+++ b/lib/solaar/cli/__init__.py
@@ -165,4 +165,5 @@ def run(cli_args=None, hidraw_path=None):
 		tb_last = extract_tb(_sys.exc_info()[2])[-1]
 		_sys.exit('%s: assertion failed: %s line %d' % (NAME.lower(), tb_last[0], tb_last[1]))
 	except Exception as e:
-		_sys.exit('%s: error: %s' % (NAME.lower(), e))
+		from traceback import format_exc
+		_sys.exit('%s: error: %s' % (NAME.lower(), format_exc()))
diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py
--- a/lib/solaar/gtk.py
+++ b/lib/solaar/gtk.py
@@ -118,7 +118,8 @@ def main():
 		ui.run_loop(listener.start_all, listener.stop_all, args.window!='only', args.window!='hide')
 	except Exception as e:
 		import sys
-		sys.exit('%s: error: %s' % (NAME.lower(), e))
+		from traceback import format_exc
+		sys.exit('%s: error: %s' % (NAME.lower(), format_exc()))
 
 
 if __name__ == '__main__':


Test patch: