thegecko / webusb

Node.js implementation of the WebUSB Specification
https://thegecko.github.io/webusb/
MIT License
183 stars 27 forks source link

Remove iface.claimed check on control transfers #33

Closed dsanders11 closed 5 years ago

dsanders11 commented 5 years ago

These checks aren't necessary (aren't mentioned in the latest version of the spec). I have a use-case of adjusting camera settings on a UVC (USB Video Class) device, and have confirmed it works fine without claiming the interface (in addition to verifying in other libraries which don't claim the interface before the control transfers).

thegecko commented 5 years ago

Do you have a problem with these checks in place?

dsanders11 commented 5 years ago

@thegecko, yes, claiming the interface isn't necessary for the control transfers and they may already be claimed by other applications or drivers, so it may not be possible to claim the interface.

thegecko commented 5 years ago

Ok, thanks

thegecko commented 5 years ago

@dsanders11 Hmm, I can see these checks in the spec:

https://wicg.github.io/webusb/#check-the-validity-of-the-control-transfer-parameters

Step 3 if the recipient is interface, step 4 if the recipient is endpoint.

dsanders11 commented 5 years ago

@thegecko, hmm, you're right, I missed that section. Let me look into it some more, it may be another thing that's in the spec that doesn't need to be.

dsanders11 commented 5 years ago

@thegecko, I'm not sure here, I don't have a deep enough understanding of the USB spec to know if it's required or not.

I thought that perhaps libusb was auto-claiming the interface, giving me the illusion of not needing to claim it. There's an auto_claim function in the Windows code, but I'm using Mac and I don't see one in there. I've also cranked up the debug output for libusb and don't see any mention of claiming the interface. I've tested with claiming first and that also works. ¯\_(ツ)_/¯

Since I can remove the check myself if it becomes a problem, and I'm not clear on the correctness of this PR, I'm going to go ahead and close it.

thegecko commented 5 years ago

Ok, let me know if anything changes :)