Skip to content
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

receiver: gather host names from HOSTS_INFO feature and show them #842

Merged
merged 1 commit into from
Jul 9, 2020

Conversation

pfps
Copy link
Collaborator

@pfps pfps commented Jul 9, 2020

Addresses #806

@pfps
Copy link
Collaborator Author

pfps commented Jul 9, 2020

Test with device that has HOSTS_INFO feature.

Changing hosts would be better if the hosts had names. This PR attempts to gather these names.

To test, run bin/solaar show and look for output under the HOSTS_INFO line. Report back results.

@barolo
Copy link

barolo commented Jul 9, 2020

getting this on solar show:

         9: HOSTS INFO             {1815}   
solaar: error: Traceback (most recent call last):
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/__init__.py", line 175, in run
    m.run(c, args, _find_receiver, _find_device)
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/show.py", line 227, in run
    _print_device(dev)
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/show.py", line 176, in _print_device
    host_names = _hidpp20.get_host_names(dev)
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/logitech_receiver/hidpp20.py", line 673, in get_host_names
    name += name_piece[2:2 + min(remaining, 14)]
TypeError: can only concatenate str (not "bytes") to str

@pfps
Copy link
Collaborator Author

pfps commented Jul 9, 2020

Grr. Python. Grr.

This bug should be fixed now.

@barolo
Copy link

barolo commented Jul 9, 2020

It works, but solaar show is quite slow now, gets stuck in few places

 2: Craft Advanced Keyboard
     Codename     : Craft
     Kind         : keyboard
...
         8: CHANGE HOST            {1814}   
         9: HOSTS INFO             {1815}   
            Host: %s (%s) %s 0 paired DESKTOP-SL4D3O2
            Host: %s (%s) %s 1 paired 
            Host: %s (%s) %s 2 paired MacBook
...
     Has 24 reprogrammable keys:
         0: Host Switch channel 1     , default: HostSwitch Channel 1        => Host Switch channel 1     
             nonstandard, divertable, persistently divertable, pos:0, group:0, gmask:0
         1: Host Switch channel 2     , default: HostSwitch Channel 2        => Host Switch channel 2     
             nonstandard, divertable, persistently divertable, pos:0, group:0, gmask:0
         2: Host Switch channel 3     , default: HostSwitch Channel 3        => Host Switch channel 3     
             nonstandard, divertable, persistently divertable, pos:0, group:0, gmask:0
...

@pfps
Copy link
Collaborator Author

pfps commented Jul 9, 2020

OK, aside from the silly formatting bug this should be ready to go.
I'm assuming that your device has three active connections, #0 to a Windows (?) PC, #2 to a Mac, and #1 to a Linux PC. It would be nice to put a name in for connection #1, maybe something like the hostname of the computer.

@barolo
Copy link

barolo commented Jul 9, 2020

I'm not sure what 0 is currently ( checked, it's windows 10 ), usually it's android, 1 is main which is Linux, and 2 is Mac, enduser facing numbering needs to be changed to correspond with keys otherwise it can be confusing. LO detects #1 as just windows.

In LO it's written exactly as:
"Windows 10.0 > DESKTOP-SLD302" #0
"Windows" #1
"OS X 10.15.6 > MacBook" for #2

@pfps pfps force-pushed the hostinfo branch 3 times, most recently from f2d6ae2 to cbee537 Compare July 9, 2020 14:56
@pfps
Copy link
Collaborator Author

pfps commented Jul 9, 2020

@barolo I expect that LO is defaulting to Windows when it doesn't have any other information.
The OS information comes from the same feature, but I don't know if it is worth adding that in Solaar.
I fiddled a bit with the code, so it is worth another check.

@saue0 The function get_host_names(device) can be used to get this information. (Currently it's only in this PR.) The function will return a dictionary from host numbers to a pair of a boolean (whether this host is paired) and the host name.

@barolo
Copy link

barolo commented Jul 9, 2020

@pfps erros out with:

 9: HOSTS INFO             {1815}   
solaar: error: Traceback (most recent call last):
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/__init__.py", line 175, in run
    m.run(c, args, _find_receiver, _find_device)
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/show.py", line 227, in run
    _print_device(dev)
  File "/run/media/gregory/ZINE/DEVP/Solaar/lib/solaar/cli/show.py", line 177, in _print_device
    for host, (paired, name) in host_names.iter():
AttributeError: 'dict' object has no attribute 'iter'

@pfps
Copy link
Collaborator Author

pfps commented Jul 9, 2020

Argh. It's items. OK fixed. hopefully.

@barolo
Copy link

barolo commented Jul 9, 2020

Argh. It's items. OK fixed. hopefully.

Yup, works now, and is cleaned up

            9: HOSTS INFO             {1815}   
            Host: 0 (paired) DESKTOP-SL4D3O2
            Host: 1 (paired) 
            Host: 2 (paired) MacBook

@pfps pfps merged commit c38d10a into pwr-Solaar:master Jul 9, 2020
@pfps pfps deleted the hostinfo branch July 15, 2020 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants