FileIO explanations

Hello to all,

i am using an Arduino Yun in conjunction with a custom board based on a PIC18F25K80. The two boards are serial connected (software serial on the 32u4 side).

I have an hex file on th uSD card annd i want to read byte per byte from the 32u4 and send data to the PIC via serial.

I have done some trial but it stopped after some chars read.
I have prepared this code now (and i will try it tomorrow!):

File hex = FileSystem.open("/mnt/sda1/pic.hex", FILE_READ);
                     fSize = hex.size();
                     for (nn=0;nn < fSize; nn++) {
                                 while (hex.available()<1){
                                         delay(1);
                                         wdt_reset();
                                 }
                                 fr[0] = hex.read();
				 while (hex.available()<1){
                                         delay(1);
                                         wdt_reset();
                                 }
                                 fr[1] = hex.read();
                                 unsigned long nReadHex= strtoul(fr, NULL, 16);
                                 sr = 0;
                                 to = 0;
                                 while (sr != 120 && sr != 121) {
                                       if (mySerial.available()>0) {
                                           sr = mySerial.read();
                                           wdt_reset();
                                           delay(1);
                                       }
                                 }   
                                 mySerial.write(nReadHex);
                                 delay(1);         
                     }
                     hex.close();

May you please explain me a little bit more about file.available() ?
As i want to read 2 bytes, i thought doing:

 while (hex.available()<2) {
       delay(1);
}

would help me to wait for 2 bytes available but i was waiting forever.....

Any help will be appreciated :slight_smile:

Regards,
Ettore

have you already upgraded the yun? can you paste the output of this command?

cat /etc/arduino/openwrt-yun-release

tomorrow i will post the exact version, anyway i upgraded it few days after openwrt-yun release.

Is there an updated version on openwrt-yun ?
Where may i find a changelog ?

Thanks
Ettore

here is my version:

 cat /etc/arduino/openwrt-yun-release
built=Fri Apr 11 04:46:31 CEST 2014