【问题标题】:WebUSB limitation controlTransferOut?WebUSB 限制控制TransferOut?
【发布时间】:2018-01-18 06:06:40
【问题描述】:

我使用 usbmon 来分析 usb 数据包,并在 webusb 中实现它,但是我无法找到解决方案。这是 Sane 发送到 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

类似于 controlTransferOut() 命令,requestType=Standard,receiver: 'endpoint', request: 1, index: 0x00, value:129

这里的“值”非常棘手,因为根据文档,所有其他参数都应该是正确的,但是发送 value:129 应该发送类似:

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

然而我得到的是:

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

虽然 value 是一个无符号的 short,它是 max 0xffff !所以显然值应该是0,下一个半字节0x0081。我的问题是如何在第二个半字节中触发具有值的控制输出(Co)?

代码是这样的:

 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})) 

所有其他组合都与响应“Stall”一起发送,例如(类、接口:21 - 供应商、设备:40 ...等)。

设备描述和端点描述符可用here

谢谢

【问题讨论】:

    标签: google-chrome endpoint webusb


    【解决方案1】:

    刚刚找到,请求应该是:

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

    这个给:

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

    这正是我需要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 2010-12-02
      • 2011-10-07
      相关资源
      最近更新 更多