Node-red-contrib-usbhid not building on Raspberry Pi v1

#1

Hi

I'm working on a project using an old Raspberry Pi (Model B v1.2) connected to a Magtek usb swipe card reader. Currently, I have a python script to send the data from the card reader via HTTP post to my Node Red flow. This works well enough, but I'd like to do everything in Node Red if possible. However, due to the age of my Pi, node-red-contrib-usbhid is not available as a binary and I have to build it from source. This is where the problem lies. I've built node-hid from source successfully, but when I try to install node-red-contrib-usbhid I get the following errors:

HID.target.mk:110: recipe for target 'Release/obj.target/HID/src/HID.o' failed
make: *** [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:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.14.98+
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 v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

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-03-18T15_29_47_613Z-debug.log
0 Likes

#2

I couldn't get this approach to work, so I gave up and went back to the Python script which I wanted to avoid as it needed sudo access. This would not work running within the daemon node as I wanted it to automatically restart on an error. Eventually I found out how to change the permissions of the Python script so that the daemon node could control it, and now everything works satisfactorily.

0 Likes