我使用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,接收者:'endpoint',请求: 1,索引: 0x00,值:129
这里的“value”非常棘手,因为根据文档,所有其他参数都应该是正确的,但是发送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是一个无符号短整型,最大为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 ...etc)。
设备描述和端点描述符可在here中使用
谢谢
发布于 2018-01-18 17:51:47
刚找到,请求应该是:
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 Co:1:075:00 0
这正是我需要的。
https://stackoverflow.com/questions/48314830
复制相似问题