Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading 2 files from $DISK at the program start
#3
Hi Technomaker, and thanks for your quick reply.
You have perfectly understood.
Of course, these files are opened again for writing (and closed) along the sketch when the values have to be changed (Temp and /or Time).
As you can see in my first post, I have opened temp.txt for reading, read, and close in the setup.
If I add the same for the file time.txt , like this :

Serial2.println("$FILE0:OPEN:temp.txt:r");
Serial2.println("$FILE0:RA");
Serial2.println("$FILE0:CLOSE");

Serial2.println("$FILE1:OPEN:time.txt:r");
Serial2.println("$FILE1:RA");
Serial2.println("$FILE1:CLOSE");

the Serial2.read in the loop being written like this :

int c;
 while ((c = Serial2.read()) > '\n') Msg += (char) c;
 if (c == '\n')
 {  
   delay(1000);
   Serial.println(Msg);
   Msg = "";   }

the response is only the content of the first file (temp.txt) as shown hereunder :

$OK-PING
$FILE0:OPEN: 29 bytes
$FILE0:>A:Temp135150170110180150180190

note : the characters "Temp" are also stored in head of values, in order to check if we read the right file.

Questions : why the content of the time.txt is not returned as a second line or something like ??
Must I append both files in one ? Ihave tried that, but with 57 bytes, the file does not be written (also strange...)

uupppsss... I have not noticed that you ask for writing also the "...while ((c = Serial2.read()) > '\n') Msg += (char) c;... in the setup.

I did not that, because i thought that the setup is read only once, and the "while" loop needs as many loops as amount of characters to read... no ????
Reply


Messages In This Thread
RE: Reading 2 files from $DISK at the program start - by jackjean - 07-04-2017, 04:04 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)