1

I'm trying to run a Node.js script that connects to a HID device (HTC Vive tracker) and sends feature reports to it, to run from boot.

I've tried using rc.local, a systemd file but none of it works if I power on the Raspberry Pi, however running it from rc.local works if I manually reboot the Raspberry Pi.

The script uses Node-hid to initialise the connection and is invoked by simply using node /path/to/script.

Aurora0001
  • 6,357
  • 3
  • 25
  • 39
SophieOH
  • 11
  • 4

2 Answers2

0

Basically, you have to call the correct path to find node, so correct your script on crontab like that:

@reboot /path/to/node /path/to/script

to find path/to/node/ simply run that command: which node and the result is what you are looking for.

in your specific case is: /home/pi/bin/node

0

Kind of a hacky way of doing this but while testing I found out it was that the raspberry pi was 'distracting' the tracker if booted but not rebooted so I added an if statement to rc.local which would reboot it once.

if  [ -e '/home/pi/bootorreboot.txt' ]
then
    rm -rf /home/pi/bootorreboot.txt
    sleep 10 && reboot
else
    echo 'exists' > /home/pi/bootorreboot.txt
    node /home/pi/node_modules/node-hid/src/simple-tracker.js &
fi
SophieOH
  • 11
  • 4