1

I used usbmon to analyse usb packets, and implement it in webusb however I wasn't able to find a solution for this. This is what Sane send to usb :

 S Co:1:074:0 s 02 01 0000 0081 0000 0
 C Co:1:074:0 0 0
 S Co:1:074:0 s 02 01 0000 0002 0000 0
 C Co:1:074:0 0 0

Which is similar to a controlTransferOut() command, with requestType=Standard, recipient: 'endpoint', request: 1, index: 0x00, value:129

The 'value' here is very tricky since all other parameters should be correct according to documentation, however sending value:129 should send something like :

 S Co:1:074:0 s 02 01 0081 0000 0000 0

However what I got instead is :

Uncaught (in promise) DOMException: The specified endpoint number is out of range. 

While value is an unsigned short, which is max 0xffff ! So obviously value should be 0, and next nibble 0x0081. My question is how to trigger a Control Output (Co) with value in second nibble ?

The code is something like this :

 navigator.usb.requestDevice({ filters: [{ vendorId: 0x1083}] })
    .then(selectedDevice => {
       device = selectedDevice;
       return device.open(); // Begin a session.
     })
  .then(() => device.selectConfiguration(1))
    .then(() => device.claimInterface(0))
    .then(() => device.controlTransferOut({
    requestType: 'standard',
    recipient: 'endpoint',
    request: 0x00, 
    value: 129, 
    index: 0x00})) 

All other combinations are sent with response "Stall" for example (class, interface : 21 - vendor, device : 40 ...etc).

Device description and Endpoint descriptor are available here

Thank you

Hatem
  • 200
  • 1
  • 10

1 Answers1

3

Just found it, request should be :

device.controlTransferOut({
    requestType: 'standard',
    recipient: 'endpoint',
    request: 1, 
    value: 0, 
    index: 129})

This give :

S Co:1:075:0 s 02 01 0000 0081 0000 0 C Co:1:075:0 0 0

Which is exactly what I need.

Hatem
  • 200
  • 1
  • 10