WICG / webusb

Connecting hardware to the web.
https://wicg.github.io/webusb/
Other
1.31k stars 131 forks source link

Control Transfer Length Limit #155

Closed dsanders11 closed 5 years ago

dsanders11 commented 5 years ago

Is there a rationale I'm missing in the spec regarding why control transfers are limited to length <= bMaxPacketSize0?

From the steps for controlTransferIn:

  1. If length is greater than the bMaxPacketSize0 field of the device’s device descriptor, reject promise with a TypeError and abort these steps.

I have a use-case of using many of the descriptors defined in the USB Video Class spec. In light of the limitation covered in #60, the best way to get access to those descriptors appears to be to send a GET_DESCRIPTOR control transfer for the configuration descriptor, which returns all descriptors for that configuration, allowing me to parse them and get the ones I need. The length needed for the control transfer to get all this data is 3,000+ bytes.

I've commented out the size check in the Node.js port and everything works as expected. The limitation in the spec seems unexpected, as bMaxPacketSize0 is always going to be 64 bytes or less.

reillyeon commented 5 years ago

That step is wrong. A control transfer length greater than bMaxPacketSize0 is completely valid and will result in multiple DATA packets in response to the SETUP packet.

Chrome does not implement this check. I will remove it from the specification.

dsanders11 commented 5 years ago

@reillyeon, thanks for the quick response and action!