我正在尝试从Node JS的条形码扫描器中检索扫描到的数据。我不确定这是不是正确的问题。如果问题是错的,很抱歉。
条形码扫描仪型号为Honeywell MS 9540。我不知道如何实现它。Node JS发现它是一个USB设备。有没有办法实现它?
我正在为Windows在Electron中构建一个应用程序,并考虑使用本地Node JS服务器来从设备中检索数据。
我在Node中使用过usb-barcode-scanner包。它还可以在其他USB设备中找到条形码扫描仪。但是我得到了一个错误:
Error: cannot open device with vendor id 0xc2e and product id 0x200下面是我的代码:
const express = require('express')
const app = express()
const { getDevices, UsbScanner } = require('usb-barcode-scanner')
console.log(getDevices())
let scanner = new UsbScanner({
vendorId: 3118,
productId: 512,
path: '\\\\?\\hid#vid_0c2e&pid_0200#6&24268576&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\\kbd'
/** You could also initialize the scanner by giving entering the path variable:
* path: 'IOService:/AppleACPI etc...'
**/
});
scanner.on('data', (data) => {
console.log(data);
});
app.listen(8000, function () {
console.log(`Express listening on port ` + 8000)
});发布于 2020-10-10 15:35:30
我意识到条形码扫描仪就像键盘一样工作。只需要聚焦一个输入,扫描的结果就是聚焦输入的值。
https://stackoverflow.com/questions/64279991
复制相似问题