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

Duplicate filtering functions don't agreee #74

Closed
pelikhan opened this issue Nov 13, 2020 · 4 comments
Closed

Duplicate filtering functions don't agreee #74

pelikhan opened this issue Nov 13, 2020 · 4 comments
Assignees
Labels

Comments

@pelikhan
Copy link

pelikhan commented Nov 13, 2020

We have a device that requires this code path to match.

if (filter.classCode) {

But the device pre-filter does not have this code path.

if (filter.classCode && filter.classCode !== device.deviceDescriptor.bDeviceClass) return false;

Should both filter be merged?

@thegecko
Copy link
Owner

Hmm, the usb.ts case follows the WebUSB specification correctly AFAICT.

The filter in the adapter is different and was used to find allowedDevices already selected. This bit is quite difficult as recognising a device as the same between plugs is hard (the unique address on the bus can change and other IDs such as SerialNumber and vid/pid are either optional or not unique).

My approach was to use a filter, but it's far from ideal, perhaps it should be swapped to storing a hash of known data.

This aside, I can see the same filter is being used here:

return adapter.listUSBDevices(options.filters)

And it probably shouldn't, hence the issue you are seeing!

@thegecko thegecko self-assigned this Nov 13, 2020
@thegecko thegecko added the bug label Nov 13, 2020
@thegecko
Copy link
Owner

@pelikhan Does deleting these lines fix your issue?

webusb/src/adapter.ts

Lines 255 to 262 in 0a3f331

// Class
if (filter.classCode && filter.classCode !== device.deviceDescriptor.bDeviceClass) return false;
// Subclass
if (filter.subclassCode && filter.subclassCode !== device.deviceDescriptor.bDeviceSubClass) return false;
// Protocol
if (filter.protocolCode && filter.protocolCode !== device.deviceDescriptor.bDeviceProtocol) return false;

@pelikhan
Copy link
Author

pelikhan commented Nov 13, 2020

it goes through but then i get LIBUSB_ERROR_NOT_FOUND so my setup does not seem to be ok :( :( :(, but at least it finds a device.

@pelikhan
Copy link
Author

Thanks’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants