Arduino YUN strange behaviour

Hi everyone, i'm programming a YUN to make a data logger. It worked for a couple of days, never perfectly but worked. Then it stopped working and i'm trying to understand adding some debug lines where the problem is. I detected it is somewhere in this piece of code (which worked in other sketches i used on the same board) which suddenly stopped working from one day to another.

WriteSysLog("Updating system datetime...");   
  String result;
  Process time;
  // date is a command line utility to get the date and the time 
  // in different formats depending on the additional parameter 
  time.begin("date");
  time.addParameter("+%D");  // parameters: D for the complete date mm/dd/yy
                                                                  //01234567
  WriteSysLog("starting date process...");                                                                   
  time.run();  // run the command
  WriteSysLog("Process ended"); 
  
  // read the output of the command
  while(time.available()>0) {
    char c = time.read();    
    WriteSysLog(String(c));
    if(c != '\n')
      result += c;
  }

The result in the Serial monitor is the following. Please note the long delays between serial outputs, which usually take milliseconds:

Updating system datetime...

about 30 seconds

starting date process...

about 23 seconds

Process ended

and then the time.read() function starts giving those results without any sense every 10 secs

ƒ



>

>

E

i do not understand what happened to my YUN, can somebody help me pls? :'(

Why round trip?

Utilize database TIMESTAMP is far more efficient than application layer.

Storing Data in Mysql/SQLITE3 with TIMESTAMP:

http://forum.arduino.cc/index.php?topic=318295.msg2202176#msg2202176

If you do file system log, you still could use Openwrt (Linux) application layer to TIMESTAMP.

Sounds cool and of course more clean. I'll give it a try. I haven't used a database before because I thought it could take more resources than file system and it could make the arduino more instable than now.

niddu: ::::SNIP::::

i do not understand what happened to my YUN, can somebody help me pls? :'(

@niddu,

Where is the rest of your code? This makes no sense.

Jesse

jessemonroy650: @niddu,

Where is the rest of your code? This makes no sense.

Jesse

The test of the code is working fine and I detected the critic part was in the section of code I posted. The full sketch was about 400 lines of code.

@sonnyyu You were right, I'm trying to follow your suggestions and it seems it is working much better now!

sonnyyu: Why round trip?

Utilize database TIMESTAMP is far more efficient than application layer.

Storing Data in Mysql/SQLITE3 with TIMESTAMP:

http://forum.arduino.cc/index.php?topic=318295.msg2202176#msg2202176

If you do file system log, you still could use Openwrt (Linux) application layer to TIMESTAMP.

It works great!! now i can make a lot of reports/query to display data on PHP. Thanks!

I've got a question, how do you pass a string with spaces and maybe special chars in it as a parameter from the arduino sketch to a PHP?

EG:

void WriteLog(String text) 
{
 Process p;              
 p.begin("/mnt/sda1/insertLog.php");      
 p.addParameter(String(text)); 
 p.run();
}

where text = "some log from my sketch!!!"

niddu: where text = "some log from my sketch!!!"

I'm not at my Yun and can't try it, but my first thought is to enclose the string in double quotes:

text = "\"some log from my sketch!!!\""

To put a double quote inside a double quoted string, you need to prefix it with a backslash escape character.