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

filtering devices by serial number #60

Open
carlodri opened this issue Mar 2, 2020 · 1 comment
Open

filtering devices by serial number #60

carlodri opened this issue Mar 2, 2020 · 1 comment

Comments

@carlodri
Copy link

carlodri commented Mar 2, 2020

Hello, and thanks for the great package!

I am trying to filter HID devices by serial number, using the following code:

filter = hid.HidDeviceFilter(vendor_id=0x2047, product_id=0x0965, serial_number = '123456')
devices_found = filter.get_devices()

The problem I'm facing is that the filter seems to ignore the serial_number = '123456' constraint, i.e. whatever string I put in the serial_number argument the list of devices is always the same. Is this a bug or am I missing something?

I can obviously filter the list manually, but I would have preferred to use the built-in filter...

@carlodri carlodri changed the title filtering by serial number filtering devices by serial number Mar 2, 2020
@carlodri
Copy link
Author

carlodri commented Mar 2, 2020

ok I think I answered myself about this, the problem is here:

filter_attributes = ["vendor_id", "product_id", "version_number",
"product_name", "vendor_name"]

and here:

elif item not in HidDevice.filter_attributes:
continue # field does not exist sys.error.write(...)

It seems like the filtering capability is restricted to the fields listed above in filter_attributes. Il will try and see if that list can be extended.

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

No branches or pull requests

1 participant