Hi guys, I have got a problem while using nodejs serial-port library. I can receive some datas, but the serial communication hangs up after 4 or 5 messages ... After that, my arduino code seems to be freezed (my code just light 3 different leds based on an input duration), the only to get it works correctly is to press the RST button ... I have noticed sometimes that the arduino seems to slow down, and when I connect to /dev/ttyMCC (using "screen /dev/ttyMCC 9600") it go back normally ... I can post my sketch here if it could help to debug, and my nodejs code, they are both ultra basic (just print data to serial, and get it with nodejs should reproduce this bug). Thanks, Nico Edit : I have found this, I don't understand all, but it seems to be related to this bug, I don't know if the commit added on December 22th is on Udubuntu 2 RC1 (released on December 23th)
I have just tested same code on an UDOO Quad, and it is working well ... I can't freeze the Arduino by reading serial through nodejs
Hi there! We've just uploaded the solution in "troubleshooting" in the docs: http://www.udoo.org/docs-neo/Debugging_&_Troubleshooting/USB_stops_working_after_programming_M4.html Please, let me know if it works
I have checked out your solution, and it does not seem to resolve the problem ... Here is my simple arduino code (I have added a delay to slow down serial printing, but it does not change the problem) Code: #define BUTTON_PIN 2 int buttonState = 0; int i = 0; void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT); } void loop() { buttonState = digitalRead(BUTTON_PIN); if(buttonState == HIGH){ Serial.print("Test : "); Serial.println(i++); delay(100); } } And here is my nodejs code : Code: var SerialPort = require("serialport").SerialPort var serialPort = new SerialPort("/dev/ttyMCC", { baudrate: 115200 }); serialPort.on("open", function(){ console.log("open"); serialPort.on("data", function(data){ if(!data){ return; } console.log("data received : " + data); }); }); There is no problem using this command "screen /dev/ttyMCC 115200", all output a printed without any error. But while using nodejs after some ouptut reading the serial port seems to hang up ... Here is the output I get using my nodejs code : Edit : Here is the output I get using the same code on a UDOO Quad :
@Nico Try to add a Serial.flush(); at the end of your loop(). I faced a similar problem in my Neo while exchanging messages with a C program in the Linux side. I found out that by using flush and avoiding the use of Serial.println() my code stabilized. Sent from my SAMSUNG-SM-G920A using Tapatalk
@jrullan Thanks for this hack! It works like a charm!! Edit : Here is the working arduino code : Code: #define BUTTON_PIN 2 int buttonState = 0; int i = 0; void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT); } void loop() { buttonState = digitalRead(BUTTON_PIN); if(buttonState == HIGH){ Serial.print("Test : "); Serial.print(i++); delay(100); } Serial.flush(); }
@Nico, Great! It feels good to be able to help a fellow Neo user after struggling myself for over two weeks with this problem. I imagine, the problem lies in the implementation of the Serial object that the Neo uses. @Andrea, Maybe the Udoo team could fix it in the near future. Sent from my SAMSUNG-SM-G920A using Tapatalk