Raspberry pi - USB HID node error

Hello,
been trying to install node/node-red-contrib-usbhid by following all the steps with no success.

Through the Palette-Management i get the errors below (truncated)

/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../../../../nan/nan_object_wrap.h:65:61:   required from here
/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h:10004:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
make: *** [HID.target.mk:118: Release/obj.target/HID/src/HID.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.19.75-v7l+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/node-red-contrib-usbhid/node_modules/node-hid
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-hid@0.5.7 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-hid@0.5.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-12-20T21_12_14_469Z-debug.log

20 Dec 21:12:14 - [warn] ------------------------------------------

Through the shell by running the command npm install node-hid --build-from-source --unsafe-perm
I get the results below:

make: Leaving directory '/home/pi/node_modules/node-hid/build'
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

+ node-hid@1.1.0
added 61 packages from 43 contributors and audited 97 packages in 27.056s
found 0 vulnerabilities

but still, no nodes are added, and the package shows as uninstalled in the palette management.

my target is to use a usb scanner that reads using a python script successfully and is an HID device.

Thank you.

That's because you installed it in the pi home directory rather than in the .node-red directory.

Hello Colin,

This time i tried to install it with the error below.

pi@raspberrypi:~/.node-red $ sudo npm install node-red-contrib-usbhid --build-from-source --unsafe-perm
npm WARN checkPermissions Missing write access to /home/pi/.node-red/node_modules/node-hid
npm ERR! code ELOOP
npm ERR! syscall access
npm ERR! path /home/pi/.node-red/node_modules/node-hid
npm ERR! errno -40
npm ERR! ELOOP: too many symbolic links encountered, access '/home/pi/.node-red/node_modules/node-hid'

as with the ls -alt i get the below

pi@raspberrypi:~/.node-red/node_modules $ ls -alt
total 312
drwxr-xr-x 78 pi pi 4096 Dec 21 08:05 .
lrwxrwxrwx  1 pi pi    8 Dec 21 08:05 node-hid -> node-hid

so, is the node-hid the same as node-red-contrib-usbhid?
if not, how can i solve the linking issue above please?

Thank u.

You should not use sudo for installing local nodes. Now you may have files owned by root in your home directory which is likely to cause problems later. Probably best to delete that node and try again. Try

cd ~/.node-red/node_modules
sudo rm -rf node-hid
cd ~/.node-red

and try the install again. Take care with the sudo rm command as you can use that to delete your operating system if you get it wrong.
I don't know why you are using build-from-source or unsafe-perm, but I assume you have a reason for that.

Hello Colin,

i'm if i don't use unsafe-perm and build-from-source it ends with the error below

/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../../../../nan/nan_object_wrap.h:65:61:   required from here
/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h:10004:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
make: *** [HID.target.mk:118: Release/obj.target/HID/src/HID.o] Error 1
make: Leaving directory '/home/pi/.node-red/node_modules/node-red-contrib-usbhid/node_modules/node-hid/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.19.75-v7l+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/node-red-contrib-usbhid/node_modules/node-hid
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-hid@0.5.7 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-hid@0.5.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-12-21T09_11_46_646Z-debug.log

When installing from the palette manager i get the error below

/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../../../../nan/nan_object_wrap.h:65:61:   required from here
/home/pi/.cache/node-gyp/12.14.0/include/node/v8.h:10004:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
make: *** [HID.target.mk:118: Release/obj.target/HID/src/HID.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.19.75-v7l+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/node-red-contrib-usbhid/node_modules/node-hid
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-hid@0.5.7 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-hid@0.5.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-12-21T10_27_11_458Z-debug.log

21 Dec 10:27:11 - [warn] ------------------------------------------


If you look at GitHub, it would seem the author has lost interest and several people have had install issues (https://github.com/somebuddy87/node-red-contrib-usbhid/issues/1) but some have had some success (https://github.com/somebuddy87/node-red-contrib-usbhid/issues/3) with a 'bit' of extra work.

@zenofmud
Yes i can see that, the point is i cannot find any other way to read input from an HID Zebra (Symbol) QR Code scanner to nodered.
do you think there is another way to do this?

If you read the second thread I pointed to, it looks like some people have abeen successful installing the node - with some extra work.

I know of no way to use that scanner, but I don't have one, never used one so there has been no need for me to look for a solution. Maybe someone else has and will give you an answer, but till then, if I needed to use it, I'd look at those threads...

Some HID devices do just look like keyboards etc - so may just send strings into an input field in the dashboard, or use the keyboard node on Pi... but then again - many do not...

Hello,
Just found a configuration utitlity for the scanner.
i may change the behavior of the scanner to one of the below, do u recommend any that works with Node-red!

image

In terminal run
tail -f /var/log/syslog
Then hit return a couple of times so you get a gap in the output.
Now plug the device in and copy/paste the resulting syslog output here. Copy/paste if possible please rather than a screenshot.

Here's the output

Dec 21 15:13:23 raspberrypi kernel: [  413.641597] usb 1-1.1: USB disconnect, device number 3
Dec 21 15:13:26 raspberrypi kernel: [  416.759939] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
Dec 21 15:13:26 raspberrypi kernel: [  416.899465] usb 1-1.3: New USB device found, idVendor=05e0, idProduct=1200, bcdDevice= 0.01
Dec 21 15:13:26 raspberrypi kernel: [  416.899481] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec 21 15:13:26 raspberrypi kernel: [  416.899494] usb 1-1.3: Product: Symbol Bar Code Scanner::EA
Dec 21 15:13:26 raspberrypi kernel: [  416.899506] usb 1-1.3: Manufacturer: Symbol Technologies, Inc, 2008
Dec 21 15:13:26 raspberrypi kernel: [  416.899517] usb 1-1.3: SerialNumber: 19099520100079
Dec 21 15:13:26 raspberrypi kernel: [  416.910399] input: Symbol Technologies, Inc, 2008 Symbol Bar Code Scanner::EA as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/0003:05E0:1200.0002/input/input1
Dec 21 15:13:26 raspberrypi kernel: [  416.980897] hid-generic 0003:05E0:1200.0002: input,hidraw0: USB HID v1.10 Keyboard [Symbol Technologies, Inc, 2008 Symbol Bar Code Scanner::EA] on usb-0000:01:00.0-1.3/input0
Dec 21 15:13:26 raspberrypi mtp-probe: checking bus 1, device 4: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Dec 21 15:13:26 raspberrypi mtp-probe: bus: 1, device: 4 was not an MTP device
Dec 21 15:13:27 raspberrypi systemd-udevd[740]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Dec 21 15:13:27 raspberrypi mtp-probe: checking bus 1, device 4: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Dec 21 15:13:27 raspberrypi mtp-probe: bus: 1, device: 4 was not an MTP device

i believe i can make some changes to the default settings as per the screenshot in the reply before this one.
Thank u.

That suggests it might just appear to be a keyboard. If you open a terminal and scan something does anything appear?

Hi, Did you ever get this working? I am having the same problem on a Pi4 running Dietpi