从Node JS中的条形码扫描仪Honeywell MS 9540获取数据

问题描述

我正在尝试从Node JS中的条形码扫描仪检索扫描的数据。我不确定这是否是正确的问题。抱歉,如果问题有误。

条形码扫描仪型号为honeywell MS9540。我不知道如何实现它。 Node JS发现它为USB设备。有什么办法可以实现吗?

我正在Electron中为Windows构建一个应用程序,并考虑使用本地Node JS服务器从设备中检索数据。

我在Node JS中使用了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)
});

解决方法

我已经意识到条形码扫描仪可以用作键盘。只需关注输入即可,扫描结果将成为关注输入的值。