pywinusb
pywinusb copied to clipboard
filtering devices by serial number
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...
ok I think I answered myself about this, the problem is here:
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L259-L260
and here:
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L220-L221
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.