Hi, I'm working on getting the arduino in the UDOO to talk to a python script. I have successfully loaded the example serial library script to the Arduino on ACM0: // Attach a LED to Pin 13 int led = 13; char inChar; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output and turn off pinMode(led, OUTPUT); digitalWrite(led, HIGH); // initialize serial port at a baud rate of 115200 bps Serial.begin(115200); delay(100); Serial.println("start"); } void loop() { inChar = '\0'; while (Serial.available()) { // get the new byte: inChar = (char)Serial.read(); } //Serial.print("inChar= ");Serial.println(inChar); //char byteParsed = parseResponse(inChar); if (inChar == '1') { // compare received data digitalWrite(led, HIGH); // turn on light } else if (inChar == '0') { digitalWrite(led, LOW); // turn off light } //delay(10); } // the characters sent to Arduino as String are interpreted as ASCII, // we decrease 48 to return to ASCII range char parseResponse(char received) { return received - 48; } And I lightly modified the python serial script example to run indefinitely (added a while1: ). import serial import time ser = serial.Serial('/dev/ttyACM0',115200,timeout=1) ser.flushOutput() print 'Serial connected' while 1: ser.write("1") # write to Arduino to turn ON the LED print("LED On") time.sleep(1) # delay for 1 second ser.write("0") # write to Arduino to turn OFF the LED print("LED Off") time.sleep(1) # delay for 1 second This setup works fine and communicates to the Arduino well for all of about 10 seconds. Then the python script fails out with the following message: Traceback (most recent call last): File "python_serial_example.py", line 12, in <module> ser.write("1") # write to Arduino to turn ON the LED File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 547, in write raise SerialException('write failed: %s' % (v,)) serial.serialutil.SerialException: write failed: [Errno 5] Input/output error I see it says the write failed but why? Is the Arduino running out of available memory to store the incoming serial data? I am trying to get this to work so I can adapt it to another script which will just toggle one pin for a few hours. I would really like this code to work for long periods of time. Thanks!
Upon further investigation: I wrote a script that just blinks the LED. This script should run forever, but the LED blinks ~15 times then the arduino freezes, reboots itself, and starts over. This seems to indicate to me that it's running out of memory. But I do not know why. This is my first time using the 101 instead of an Uno. int led = 13; char inChar; void setup() { pinMode(led, OUTPUT); //Flash the LED to indicate setup complete digitalWrite(led, HIGH); delay(100); digitalWrite(led, LOW); delay(50); digitalWrite(led, HIGH); delay(100); digitalWrite(led, LOW); delay(50); digitalWrite(led, HIGH); delay(100); digitalWrite(led, LOW); delay(50); } void loop() { digitalWrite(led, HIGH); delay(500); digitalWrite(led, LOW); delay(500); }
Your last sketch should run forever. It does not looks to be an issue of the Curie. Check your python program again? Was that running? If you look at the examples in my signature you have some more information about exchange information between Linux and Arduino. I did not check the Udoo x86 but the Neo has issues with sending data to Linux while it was not ready yet for receiving (due to slower startup).