New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix solaar start issues #382

Merged
merged 8 commits into from Jan 12, 2018

Conversation

Projects
None yet
4 participants
@mchehab

mchehab commented Sep 11, 2017

Solaar initialization on Fedora has become problematic over time. With Fedora 25, sometimes, I had to start it a few times, until it gets everything right. On Fedora 26, things got a lot worse: most of the time, it just doesn't even report the Unified Receiver. When it reports, it takes a lot of time, as it waits for a timeout from g-io-error-quark.

This patch series contain the fixes needed to make it work. After that, Solaar is smoothly detecting both my mouse and Keyboard every time it starts.

On this series we have:

patch 1 - that's actually a minor fix for solaar CLI and Anywhere Mouse MX 2, in order to prevent an error when calling via command line;

patch 2 is actually a hack: efectively it disables the python Notify extension, with doesn't seem to be working here with Fedora 26. I've no idea about how to properly fix it, but Solaar works just fine without it.

patch 3 solves a race condition at the listener logic that registers a new device. It took me a lot of time to discover the root case, as, at least on my i7core machine, turning debug on is usually enough to solve the race issue.

patch 4 solves another race condition: if Solaar are receiving lots of notifications at the time it starts (for example, if the mouse is moving), it loses the registration events, as the queue size is only 16, and it takes several seconds to register the Anywhere Mouse MX 2 mouse.

mchehab added some commits Mar 21, 2017

Add support for CLI show to display High Res Wheel settings
Add support for the high resolution wheel found on MX Anywhere 2.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
MX Anywhere2: Correct feature Smooth Scrool
Set wrongly to HI_RES_SCROLLING. Correct it to HIRES_WHEEL as reported
by MX Anywhere2.

relates to #283

Signed-off-by: Josenivaldo Benito Jr <jrbenito@benito.qsl.br>
Add notification for high-resolution Wheel events
The event at address 0 is only produced while in HID++ mode.

The rachet event (address 0x10) happens on both HID and
HID++ modes.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Remove the hid++ high-res wheel notification
The best is to make the logitech-hidpp driver to switch to
hid++ notification mode when it starts. As we don't want users
to mangle with it, let's remove support from it.

PS.: I opted to keep this as a separate patch. This way, if
anyone needs to add support for it, in order to debug the
driver, it is just a matter of reverting this patch.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
hidpp20.py: handle gracefully errors at REPROG_CONTROLS_V4
At least with Anywhere Mouse MX 2, one reprogrammed key
fails to read:

    ERROR [MainThread] logitech_receiver.base: (3) device 3 error on feature request {0829}: 2 = invalid argument

That causes "solaar show" to crash.  Instead, let's handle
errors there gracefully, reporting it as:

         7: unknown:00C3              , default: unknown:009C                => unknown:00C3
             virtual, pos:0, group:4, gmask:0

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
ui: notify.py: disable python Notify extension
For whatever reason, this doesn't work on Fedora 26:

06:47:05,925    DEBUG [ReceiverListener:hidraw1] logitech_receiver.base: (13) => r[20 02 0100 0000000000000000000000]
06:47:05,925    DEBUG [ReceiverListener:hidraw1] logitech_receiver.notifications: <PairedDevice(2,2011,K520)> (1.0) custom notification Notification(2,01,00,000000000$
06:47:05,925  WARNING [ReceiverListener:hidraw1] logitech_receiver.notifications: <PairedDevice(2,2011,K520)>: unrecognized Notification(2,01,00,000000000000000000000$
06:47:08,806    ERROR [MainThread] solaar.ui.notify: showing <Notify.Notification object at 0x7f82c2484640 (NotifyNotification at 0x556fa0fc5a40)>
Traceback (most recent call last):
  File "./devel/solaar/lib/solaar/ui/notify.py", line 145, in show
    n.show()
Error: g-io-error-quark: Error calling StartServiceByName for org.freedesktop.Notifications: Timeout was reached (24)


So, disable it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
listener: fix device registration logic
The "already_known" var actually doesn't track if the device was
already registered or not.

That causes race issues at Solaar, causing it to sometimes not
detect a device.

Change the logic to always call register_new_device if the
corresponding events happen, and updating already_known
to reflect it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
listener: don't add elements if queue is full
When Solaar is loaded, if a large number of events happen,
it will lose the register events, as the queue size is too
small (16). So, check if the queue is full, in order to
avoid losing those important events.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
@Lekensteyn

Looks good, the hacks seem acceptable too. Just waiting a tiny bit, maybe @doctor64 can comment on the REPROG_CONTROLS_V4 patch.

I'll try to merge it in a week if there are no further comments.

@@ -328,13 +328,19 @@ def __getitem__(self, index):
if self.keyversion == 1:
self.keys[index] = _ReprogrammableKeyInfo(index, ctrl_id_text, ctrl_task_text, flags)
if self.keyversion == 4:
mapped_data = feature_request(self.device, FEATURE.REPROG_CONTROLS_V4, 0x20, key&0xff00, key&0xff)

This comment has been minimized.

@Lekensteyn

Lekensteyn Sep 20, 2017

Collaborator

@doctor64 introduced this functionality in PR #337 FWIW

@Lekensteyn

Lekensteyn Sep 20, 2017

Collaborator

@doctor64 introduced this functionality in PR #337 FWIW

This comment has been minimized.

@doctor64

doctor64 Sep 22, 2017

Hmm, never see error here, but I don't have MX Anywhere 2 mouse. Anyway, error checking looks Ok, i'm little old school, and never trust in try/catch :)
Out of curiosity, can you provide command trace of failed command?

@doctor64

doctor64 Sep 22, 2017

Hmm, never see error here, but I don't have MX Anywhere 2 mouse. Anyway, error checking looks Ok, i'm little old school, and never trust in try/catch :)
Out of curiosity, can you provide command trace of failed command?

This comment has been minimized.

@doctor64

doctor64 Sep 22, 2017

Looks like Logitech messed up with virtual buttons, to understand we need a traces

@doctor64

doctor64 Sep 22, 2017

Looks like Logitech messed up with virtual buttons, to understand we need a traces

This comment has been minimized.

@mchehab

mchehab Sep 26, 2017

That's the result of:
$ python -m trace --trackcalls bin/solaar show

https://pastebin.com/4NA3vEvr

PS.: when trace is on, it doesn't print the error message:
solaar: error: {'params': '\x00\xc3', 'request': 2092L, 'number': 3, 'error': 2}

@mchehab

mchehab Sep 26, 2017

That's the result of:
$ python -m trace --trackcalls bin/solaar show

https://pastebin.com/4NA3vEvr

PS.: when trace is on, it doesn't print the error message:
solaar: error: {'params': '\x00\xc3', 'request': 2092L, 'number': 3, 'error': 2}

This comment has been minimized.

@doctor64

doctor64 Sep 27, 2017

@mchehab I mean command trace, output of solaar -dd show
Sorry for misunderstanding

@doctor64

doctor64 Sep 27, 2017

@mchehab I mean command trace, output of solaar -dd show
Sorry for misunderstanding

This comment has been minimized.

@mchehab

mchehab Sep 28, 2017

@doctor64 OK, you likely want just the last parts of the trace, after getting the 7th programable key, right?

There it is:


         6: RIGHT SCROLL AS AC PAN    , default: HorzScrollRightSet          => RIGHT SCROLL AS AC PAN    
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,415    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 070000]
22:17:26,434    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 00C3009C800004000100000000000000]
22:17:26,435    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082D 00C300]
22:17:26,454    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 FF08 2D020000000000000000000000000000]
22:17:26,454    ERROR [MainThread] logitech_receiver.base: (3) device 3 error on feature request {082D}: 2 = invalid argument
solaar: error: {'params': '\x00\xc3', 'request': 2093L, 'number': 3, 'error': 2}
@mchehab

mchehab Sep 28, 2017

@doctor64 OK, you likely want just the last parts of the trace, after getting the 7th programable key, right?

There it is:


         6: RIGHT SCROLL AS AC PAN    , default: HorzScrollRightSet          => RIGHT SCROLL AS AC PAN    
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,415    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 070000]
22:17:26,434    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 00C3009C800004000100000000000000]
22:17:26,435    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082D 00C300]
22:17:26,454    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 FF08 2D020000000000000000000000000000]
22:17:26,454    ERROR [MainThread] logitech_receiver.base: (3) device 3 error on feature request {082D}: 2 = invalid argument
solaar: error: {'params': '\x00\xc3', 'request': 2093L, 'number': 3, 'error': 2}

This comment has been minimized.

@mchehab

mchehab Sep 28, 2017

If you want, that's the full trace for the programmable keys:

22:17:26,112    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 080F 000000]
22:17:26,132    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 080F 08000000000000000000000000000000]
     Has 8 reprogrammable keys:
22:17:26,132    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081F 000000]
22:17:26,152    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081F 00500038110001010000000000000000]
22:17:26,152    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082B 005000]
22:17:26,172    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082B 00500000000000000000000000000000]
         0: LEFT CLICK                , default: LeftClick                   => LEFT CLICK                
             mse, reprogrammable, pos:0, group:1, gmask:1
22:17:26,173    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081E 010000]
22:17:26,192    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081E 00510039110001010000000000000000]
22:17:26,192    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082A 005100]
22:17:26,212    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082A 00510000000000000000000000000000]
         1: RIGHT CLICK               , default: RightClick                  => RIGHT CLICK               
             mse, reprogrammable, pos:0, group:1, gmask:1
22:17:26,213    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081C 020000]
22:17:26,232    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081C 005200A93100020B0100000000000000]
22:17:26,232    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005200]
22:17:26,252    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 00520000000000000000000000000000]
         2: MIDDLE BUTTON             , default: unknown:00A9                => MIDDLE BUTTON             
             divertable, mse, reprogrammable, pos:0, group:2, gmask:11
22:17:26,253    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 030000]
22:17:26,274    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 0053003C3100030F0100000000000000]
22:17:26,274    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082E 005300]
22:17:26,292    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082E 00530000000000000000000000000000]
         3: BACK AS BUTTON 4          , default: BackEx                      => BACK AS BUTTON 4          
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,293    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081F 040000]
22:17:26,314    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081F 0056003E3100030F0100000000000000]
22:17:26,314    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005600]
22:17:26,334    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 00560000000000000000000000000000]
         4: FORWARD AS BUTTON 5       , default: BrowserForwardEx            => FORWARD AS BUTTON 5       
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,335    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 050000]
22:17:26,354    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 005B003F3100030F0100000000000000]
22:17:26,354    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082E 005B00]
22:17:26,374    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082E 005B0000000000000000000000000000]
         5: LEFT SCROLL AS AC PAN     , default: HorzScrollLeftSet           => LEFT SCROLL AS AC PAN     
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,375    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081A 060000]
22:17:26,394    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081A 005D00403100030F0100000000000000]
22:17:26,394    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005D00]
22:17:26,414    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 005D0000000000000000000000000000]
         6: RIGHT SCROLL AS AC PAN    , default: HorzScrollRightSet          => RIGHT SCROLL AS AC PAN    
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,415    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 070000]
22:17:26,434    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 00C3009C800004000100000000000000]
22:17:26,435    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082D 00C300]
22:17:26,454    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 FF08 2D020000000000000000000000000000]
22:17:26,454    ERROR [MainThread] logitech_receiver.base: (3) device 3 error on feature request {082D}: 2 = invalid argument
solaar: error: {'params': '\x00\xc3', 'request': 2093L, 'number': 3, 'error': 2}
@mchehab

mchehab Sep 28, 2017

If you want, that's the full trace for the programmable keys:

22:17:26,112    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 080F 000000]
22:17:26,132    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 080F 08000000000000000000000000000000]
     Has 8 reprogrammable keys:
22:17:26,132    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081F 000000]
22:17:26,152    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081F 00500038110001010000000000000000]
22:17:26,152    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082B 005000]
22:17:26,172    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082B 00500000000000000000000000000000]
         0: LEFT CLICK                , default: LeftClick                   => LEFT CLICK                
             mse, reprogrammable, pos:0, group:1, gmask:1
22:17:26,173    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081E 010000]
22:17:26,192    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081E 00510039110001010000000000000000]
22:17:26,192    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082A 005100]
22:17:26,212    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082A 00510000000000000000000000000000]
         1: RIGHT CLICK               , default: RightClick                  => RIGHT CLICK               
             mse, reprogrammable, pos:0, group:1, gmask:1
22:17:26,213    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081C 020000]
22:17:26,232    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081C 005200A93100020B0100000000000000]
22:17:26,232    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005200]
22:17:26,252    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 00520000000000000000000000000000]
         2: MIDDLE BUTTON             , default: unknown:00A9                => MIDDLE BUTTON             
             divertable, mse, reprogrammable, pos:0, group:2, gmask:11
22:17:26,253    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 030000]
22:17:26,274    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 0053003C3100030F0100000000000000]
22:17:26,274    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082E 005300]
22:17:26,292    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082E 00530000000000000000000000000000]
         3: BACK AS BUTTON 4          , default: BackEx                      => BACK AS BUTTON 4          
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,293    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081F 040000]
22:17:26,314    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081F 0056003E3100030F0100000000000000]
22:17:26,314    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005600]
22:17:26,334    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 00560000000000000000000000000000]
         4: FORWARD AS BUTTON 5       , default: BrowserForwardEx            => FORWARD AS BUTTON 5       
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,335    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 050000]
22:17:26,354    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 005B003F3100030F0100000000000000]
22:17:26,354    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082E 005B00]
22:17:26,374    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082E 005B0000000000000000000000000000]
         5: LEFT SCROLL AS AC PAN     , default: HorzScrollLeftSet           => LEFT SCROLL AS AC PAN     
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,375    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 081A 060000]
22:17:26,394    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 081A 005D00403100030F0100000000000000]
22:17:26,394    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082F 005D00]
22:17:26,414    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 082F 005D0000000000000000000000000000]
         6: RIGHT SCROLL AS AC PAN    , default: HorzScrollRightSet          => RIGHT SCROLL AS AC PAN    
             divertable, mse, reprogrammable, pos:0, group:3, gmask:15
22:17:26,415    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 0819 070000]
22:17:26,434    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 0819 00C3009C800004000100000000000000]
22:17:26,435    DEBUG [MainThread] logitech_receiver.base: (3) <= w[10 03 082D 00C300]
22:17:26,454    DEBUG [MainThread] logitech_receiver.base: (3) => r[11 03 FF08 2D020000000000000000000000000000]
22:17:26,454    ERROR [MainThread] logitech_receiver.base: (3) device 3 error on feature request {082D}: 2 = invalid argument
solaar: error: {'params': '\x00\xc3', 'request': 2093L, 'number': 3, 'error': 2}
# Error: g-io-error-quark: Error calling StartServiceByName for org.freedesktop.Notifications: Timeout was reached (24)
available = False

This comment has been minimized.

@Lekensteyn

Lekensteyn Sep 20, 2017

Collaborator

These APIs are very old, I guess that disabling them is OK especially if they cause issues like this

@Lekensteyn

Lekensteyn Sep 20, 2017

Collaborator

These APIs are very old, I guess that disabling them is OK especially if they cause issues like this

@jrbenito

This comment has been minimized.

Show comment
Hide comment
@jrbenito

jrbenito Sep 25, 2017

I did not experienced errors with Mint but tested this with MX2 and K270 - works ok.

jrbenito commented Sep 25, 2017

I did not experienced errors with Mint but tested this with MX2 and K270 - works ok.

@doctor64

Looks Ok for me

@Lekensteyn Lekensteyn merged commit 1a67b33 into pwr:master Jan 12, 2018

@Lekensteyn

This comment has been minimized.

Show comment
Hide comment
@Lekensteyn

Lekensteyn Jan 12, 2018

Collaborator

Thanks, sorry for the delay

Collaborator

Lekensteyn commented Jan 12, 2018

Thanks, sorry for the delay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment