I need my raspberry to connect to an Arduino via the USB serialport. I have managed to do this smoothly in a traditional RPi environment (with Raspbian) with nodejs (using johhny-five or plain firmata/serialport npm modules) BUT I have not been able to connect to the serialport from a Resin container.
For example with this basic node program
var five = require("johnny-five"),
board = new fiveBoard();
board = new five.Board();
board.on("ready", function() {
(new five.Led(13)).strobe();
});
I just get the message:
root@raspberrypi:/home/test# node server.js
1425982101921 Looking for connected device
(And I have an Arduino with Firmata in one of the USB ports … even tried with 2 Arduinos on each of the USB ports and cannot get the serialport to work).
It seems that the container “sees” the usb ports
root@raspberrypi:/dev# ls ttyACM*
ttyACM0 ttyACM1
But it is not able to connect/open them
Do you know if there is any restriction for connection to USB serial ports from a Resin container? Is there any way around this issue?
I have found that the serial ports (/dev/ttyACM0 & /dev/ttyACM1) are active and work if I connect to them from the container using a serialport terminal such as minicom.
The problem is that the npm package serialport.js expects to get the list of available ports reading the dirs:
/dev/serial/by-path
or
/dev/serial/by-id
BUT the containers does not have those dirs (no /dev/serial in the container).
Other packages that work on top of serialport,js (such as johnny-five) expect the serialport.list() method to work properly in order to identify available ports, but it is failing to find the ports.
Not sure about how resin works … but could it be that when the resin software creates the container, it should map the /dev/serial dirs from the host into the container and it is not doing so?
After discussing this with my colleagues I realise I’ve missed an important step - you need to start udevd first before triggering the udev update. At this point it makes sense to use a separate start script, e.g.:-