gpt4 book ai didi

google-chrome - Webusb 扫描文件

转载 作者:行者123 更新时间:2023-12-01 15:03:33 26 4
gpt4 key购买 nike

有人成功配置了 webusb 来扫描文档吗?我能够连接到 USB 扫描仪,但找不到有关扫描文档的命令的任何文档:

$lsusb -v

Bus 001 Device 007: ID 1083:163e Canon Electronics, Inc. 
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x1083 Canon Electronics, Inc.
idProduct 0x163e
bcdDevice 2.02
iManufacturer 1 CANON
iProduct 2 CANON DR-M160
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 98mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 0 (Defined at Interface level)
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 6
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 1
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0001
Self Powered

下面的代码测试低级别传输,但是即使 PromiseStatus 被标记为已解决,状态为停顿,并且 device.transferIn 状态保持挂起。我无法更进一步,因为我没有找到任何适用于我的扫描仪或任何其他扫描仪的文档。
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: 'vendor',
recipient: 'device',
request: 0x22,
value: 0x01,
index: 0x01}))
.then(() => device.transferIn(1, 64)) // Waiting for 64 bytes of data from endpoint #1.
.then(result => {
let decoder = new TextDecoder();
console.log('Received: ' + decoder.decode(result.data));
})
.catch(error => { console.log(error); });

谢谢 !

最佳答案

我怀疑您是否设法与设备连接。
阅读specification为了安全起见,您可以看到设备应该进行一些更改才能通过 webusb 访问,而您的扫描仪没有类似的东西。

我尝试使用 WebUSB,导致我购买了一个 arduino 微 Controller 进行简单测试。更多信息,您可以read this article关于 Google Developer 网站上的 WebUSB。
这个微 Controller 的目的是将它用作 PC 和扫描仪之间的代理/中介,因为我可以完全控制微 Controller 并且可以正确地检测它以与 WebUSB 一起使用。

关于google-chrome - Webusb 扫描文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48136414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com