Crash by reading out a file from sd card

Hi guys,

i try to read out a file located on the sd card containing this sample text:
10
12;1;12;1;2;3;4;5;6;7:148;142;238:0,96;112
12;1;12;1;2;3;4;5;6;7:128;64;0:0,96;142
12;1;12;1;2;3;4;5;6;7:128;64;0:1,74;142
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;142
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;142
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;142
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;142
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;189
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;215
12;1;12;1;2;3;4;5;6;7:255;128;255:1,74;245

over the function:

void loadProgramm(String filename){
  String searchdirectory = "/mnt/sd/sequ/";
  searchdirectory += filename;
  char buf[searchdirectory.length()+1];
  searchdirectory.toCharArray(buf,searchdirectory.length()+1);
  Console.print("open:");
  Console.print(buf);
  Console.print("\n");
  FileSystem.begin();
  File Readin = FileSystem.open(buf,FILE_READ);
  
  if(Readin){
    Console.print("File open success\n"); 
    char letter =0;
    String number ;
    int debugcouter =0;
    while(Readin.available()){
      Console.print(debugcouter++);
      Console.print(":");
      letter=Readin.read();
      Console.print(letter);
      Console.print("\n");
      Readin.flush();
    }
    Readin.close();
    Console.print("finish");
    }
}

i can read the file until step 188 ,the first occurrence of 255 (bold on the sample text). After the print of the last 5. The console is only blinking and no other command, which is send over the rest api, will be proceeded. I tried if this one is caused by the 255, but even if i set it on the middle it reads only until step 188. Is there any limitation for reading? Or has somebody a idea why i can not read out the whole file?

thanks for you help

Hi,

i found a workaround for this topic. I use process class to run the "cat" command on the file and read out the output of this process.

void getFileOverProcess() {
  Process p;       
  p.begin("cat");  
  p.addParameter("/mnt/sd/sequ/sequence1"); 
  p.run();   
  while (p.available()>0) {
    char c = p.read();
    Console.print(c);
  }
}

But this can't be the solution, so if anybody has a solution for the file.read() error please give me a feedback.
thanks

Hi Korkra, I agree it should just work. Before going deep into debugging, can you give a spin to the yet-to-be-released version of the IDE (so called "nightly builds")? http://arduino.cc/en/Main/Software#toc4
They contain some fixes made to the Bridge that had a similar symptom

Hi Federico ,
thanks for your reply.
i tested the nightly build of today, same behavior. Can i test something more to help you?

regards
korkra

PS: it would be nice to have a revision number in the "help"->"over arduino" window. i would help you to determine in which version the error occur.

Hi all,
I have the same problem.

I added a note here:
http://forum.arduino.cc/index.php?topic=206494.msg1544904#msg1544904

hope it helps.

Vjncenzo

Hi All,
I opened Problems with FileIO.Read() for some file dimension/content · Issue #12 · arduino/YunBridge · GitHub and it has been solved.

Thanks!
Vjncenzo


the answer I had is:
may you look the content of the file /usr/bin/run-bridge and check if the exec line contains the flag -u ? The whole file should look to something like:

#!/bin/sh

cd /usr/lib/python2.7/bridge

exec python -u bridge.py 2> /tmp/bridge.py-stderr.log

anyone knows what this -u option does (seems like google was not my best friend for this)
Best regards
Jantje

From the "man"

-u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop.

Thanks Federico
Karma ++
Jan