Go Down

Topic: Yun Bridge Flakiness (Read 1 time) previous topic - next topic


Arduino community--

I'm looking to use my Yun as a data logging platform for data being emitted by a serial source. I keep having hangs and other unexpected lost characters at a rate of 50 bytes/second, and my suspicion is that the bridge library is getting saturated somehow.  At extremely slow transmission speeds this does not appear to happen.

What is the preferred way to stream data from the serial port to a file on the SD card? Are the file libraries considered stable?

My current code:

Code: [Select]
* Logs everything it hears on pin 10 to a file

#include <FileIO.h>
#include <SoftwareSerial.h>

// SoftwareSerial mySerial(10, 11); // RX, TX
SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
  // put your setup code here, to run once:
  // Setup Bridge (needed every time we communicate with the Arduino Yún)
  while(!Serial);  // wait for Serial port to connect.
  Serial.println("File Write Script example\n\n");
  mySerial.println("Listening on pin 10");

char buff[1000];

void loop()
  int cycleStart = millis();

  Serial.println( "Opening file...");
  File thefile = FileSystem.open("/mnt/sd/log4.csv", FILE_APPEND);

  Serial.println( "Entering loop...");
  while( millis() - cycleStart < 10000 )
      // thefile.write(mySerial.read() );
      int l = mySerial.readBytes( buff, 999 );

      Serial.write((uint8_t *)buff, l);
      thefile.write((uint8_t *)buff, l );

  cycleStart = millis();
  Serial.println( "Closing file...");





Don't know if this is related, but there's a bug (buffer overflow) on the bridge library code that handles the file io on SD card.
This bug affects ide version <= 1.5.4
A fix is already on git but non released yet (planned for 1.5.5)
Try using the git version of the ide (branch ide-1.5.x) and check if that fixes your problems


FYI: you don't need git and/or a development environment to have the latest and greatest of the IDE
Just download a nightly build http://arduino.cc/en/Main/Software#toc4 (remember that it's not signed, so you'll receive some notifications from your operating system)

Go Up