Took a little digging, but I have Node.js 0.10.24 and Node-Hid successfully installed and talking to my Delcom USB indicator. I wanted to take a minute to document the steps I took. Before following the steps in this article, make sure you have your Raspberry Pi hooked up to the network.
Getting the OS Ready
Start by updating all your packages:
sudo apt-get update sudo apt-get dist-upgrade
You will need a couple of additional packages required by node-hid, a node library used to communicate with USB HID devices like the Delcom USB Indicator:
sudo apt-get install libudev-dev libusb-1.0-0-dev
Node.js Install
As least as I write this you cannot get Node.js 0.10.x using apt-get. Instead, you have to install it yourself. Here’s the steps I used for node 0.10.24:
sudo mkdir /opt/node wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz tar xvzf node-v0.10.24-linux-arm-pi.tar.gz sudo cp -r node-v0.10.24-linux-arm-pi/* /opt/node
You’ll also have to put node into your path and set NODE_JS_HOME by editing your profile. Open up the profile:
sudo nano /etc/profile
Put the following right before you see “export PATH”:
NODE_JS_HOME="/opt/node" PATH="$PATH:$NODE_JS_HOME/bin"
Once you reboot, you can verify the node installation by issuing the following command:
node -v
It should print out v0.10.24 on your console.
Node-Hid and Test Project
Now it’s time to create a little node project to test things out. This example will set things up in a directory called ~/nodetest:
mkdir ~/nodetest cd ~/nodetest npm install node-hid
You can then use nano to create a js file to execute with node:
nano test.js
Here’s the code:
var hid = require('node-hid'); var devices = hid.devices(); console.log('Devices:') console.log(devices);
Once you plug in the Delcom device, you can run the app to find it as follows:
node test.js
You should see output like this:
[ { vendorId: 4037, productId: 45184, path: '0001:0005:00', release: 32, interface: 0 } ]
If you have multiple USB HID devices attached, they will appear in the list as well. The one with the vendorId given above is the Delcom device.
One More Thing
I prefer to write code on my Mac using Webstorm. I get access to my Raspberry Pi console using ssh and transfer files with help from the netatalk AFP client installed as follows:
sudo apt-get install netatalk