I'm trying to bypass Bridge library and read serial directly from nodejs. I'm on the last sys upgrade (1.3) I have correctly installed nodes and serial module via opkg install. I have also commented out the line in the /etc/inittab
:
#ttyATH0::askfirst:/bin/ash --login
This is my arduino code:
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("dudee");
delay(100);
}
This is my node.js code:
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("/dev/ttyATH0", {
baudrate: 9600,
dataBits: 8,
parity: 'none',
stopBits: 1,
flowControl: false
}, false);
console.log("hello");
serialPort.on("open", function () {
console.log('open');
serialPort.on('data', function(data) {
console.log('data received: ' + data);
});
});
serialPort.on('error', function(err) {
console.log('error: '+err);
});
serialPort.open();
If I ssh to yun and run the script I don't see any "dudee":
~/test# node serial.js
hello
open
While if I open the serial monitor I see it.
If I run the node script on my computer (changing the right serial port name) everything works nice and I see the dude..
What can it be?