mikerovers / usb-barcode-scanner

A typed library for using USB barcode scanners in Node.js with support for Typescript
https://www.npmjs.com/package/usb-barcode-scanner
MIT License
26 stars 26 forks source link

Can't open device #3

Open devyaz opened 5 years ago

devyaz commented 5 years ago

i used to run the same code in an Electron App without problems, now after 2 system upgrades am getting the below error

Uncaught Exception: Error: cannot open device with vendor id 0x4b4 and product id 0xbca1 at new HID (/home/martin/Electron/electron-api-demos/node_modules/node-hid/nodehid.js:54:17) at new UsbScanner (/home/martin/Electron/electron-api-demos/node_modules/usb-barcode-scanner/dist/usb-barcode-scanner.js:31:25) i tried removing node-modules and yarn to re-install but still cant open device if i either use deviceId or path! EDIT Node HID reports a different devID vendID from what i get with const getDevices= require('usb-barcode-scanner').getDevices console.log(getDevices()); the above code gives { vendorId: 1204, productId: 48289, path: '/dev/hidraw0', serialNumber: '', manufacturer: 'Guest', product: 'Barcode Reader', release: 594, interface: 0 } and Node HID reports vendor id 0x46d and product id 0xc52f which is hexadecimal for 1133 and prodID 50479 which is my mouse BT dongle yet i provided my vendor Id and product id of 1204 and 48289 even if i remove the bluetoth dongle for wireless mouse

mikerovers commented 5 years ago

@devyaz I can not come up with a direct solutions at the moment. Have you made any progress with this issue in the past days?

devyaz commented 5 years ago

Nope I haven't

On Thu., 27 Dec. 2018, 15:56 Mike Rovers <notifications@github.com wrote:

@devyaz https://github.com/devyaz I can not come up with a direct solutions at the moment. Have you made any progress with this issue in the past days?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mikerovers/usb-barcode-scanner/issues/3#issuecomment-450155125, or mute the thread https://github.com/notifications/unsubscribe-auth/ATfQSTeyr6Q03HJQzlGMmUuSB38tEfY-ks5u9NGigaJpZM4ZJqsE .

dimitrisal commented 5 years ago

I have the same issue in windows, when I run the nodejs with sudo in ubuntu it works but i get the same value twice per scan.

devyaz commented 5 years ago

@dimitrisal can you show code! So we can help

dimitrisal commented 5 years ago

@devyaz I am using the example code. With the same code if i run the nodejs as sudo in the linux work but without sudo or in windows doesnt work i get the same error (with different vendor id and product id)

Error: cannot open device with vendor id 0x4b4 and product id 0xbca1

`let UsbScanner = require('usb-barcode-scanner').UsbScanner;

let scanner = new UsbScanner({ vendorId: 1155, productId: 22352 });

scanner.on('data', (data) => { console.log(data); });

scanner.startScanning();`

devyaz commented 5 years ago

It needs sudo to run in linux since it has to access devices on the pc which require permission i guess it might as well run in windows if CMD is run ad administrator

devyaz commented 5 years ago

It might be something in linux or Electron update thats breaking escpos. Perhaps @mikerovers you need to upgrade it?, Unfortunately i haven't tried using Node 8 i think it worked then

mikerovers commented 5 years ago

@devyaz @dimitrisal I am facing the same problems on Windows (node v11.12.0). I will try to look for differences in HID usage in Windows and Unix for a start.

mikerovers commented 5 years ago

I was unable to find a working solutions for this at the moment. I would suggest trying another package of making your application Unix only.

srmullaney commented 4 years ago

@mikerovers

I have just run into the same problem on windows and despite my best efforts to enable permissions extra, I have not been able to fix the problem. Have you been able to solve this problem?

Thanks in advance!

srmullaney commented 4 years ago

I think I might have found the answer. Please see this response to a similar issue.