Get data from barcode scanner (Honeywell MS 9540) in Node JS

3.1k views Asked by At

I'm trying to retrieve scanned data from barcode scanner in Node JS. I'm not sure whether this is correct question. Sorry if the question is wrong.

The barcode scanner model is Honeywell MS 9540. I don't have an idea how to implement it. Node JS found it as a USB device. Is there any way of implementing it?

I'm building an app for Windows in Electron and thinking about using local Node JS server for for retrieving data from devices.

I've used usb-barcode-scanner package in Node JS. And it could find barcode scanner among other USB devices. But I'm getting an error:

Error: cannot open device with vendor id 0xc2e and product id 0x200

Here is my code:

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

There are 1 answers

0
Bakhrom On BEST ANSWER

I've realized that barcode scanners work as a keyboard. Just an input should be focused and scanned result will be the value of the focused input.