Dear All,
I am facing a boring issue.
I am using OpenLog and I am trying to read a file.
To read a file, you have to enter the following code
( My issue is on the following code
_openlog.print(F("read "));
_openlog.print(fileName);
//_openlog.print(F(" 0"));
//_openlog.flush();
_openlog.print(F("\r"));
// _openlog.print(13,BYTE);
/*
_openlog.print(start);
if(end > 0)
{
_openlog.print(F(" "));
_openlog.print(end);
}
*/
//sprintf(buffer2, "read %s\r", fileName);
//Serial.print(buffer2);
//Wait for OpenLog to respond with 'r'
while(1) {
if(_openlog.available())
{
if(_openlog.read() == '\r')
{
isCommandMode = false;
break;
}
}
}
// Code to code 2
Just after the above code, it start reading the file while _openlog is available.
(The output is ASCII)
//code 2
int charactersRead = 0;
for(int timeOut = 0 ; timeOut < 1000 ; timeOut++)
{
while(_openlog.available() > 0)
{
char r = (_openlog.read());
Serial.write(r); //Take the character from OpenLog and push it to software serial TX
charactersRead++;//= charsToRead;
timeOut = 0;
}
delay(1);
}
answer = 1;
Serial.write() should print this
{0,228,03,1771,2d6f,12,55&ti=150811231018}{0,228,03,1771,2d6f,12,55&ti=150811231409}{0,228,03,1771,2d6f,12,60&ti=150811233950}{0,228,03,1771,2d6f,12,57&ti=150811235133}{0,228,03,1771,2d6f,12,58&ti=150811235318}{0,228,03,1771,2d6f,12,61&ti=150811235646}{0,228,03,1771,2d6f,12,61&ti=150812000855}{0,228,03,1771,2d6f,12,62&ti=150812001456}{0,228,03,1771,2d6f,12,59&ti=150812001727}{0,228,03,1771,2d6f,12,59&ti=150812002009}{0,228,03,1771,2d6f,12,63&ti=150812021312}{0,228,03,1771,2d6f,12,63&ti=150812021614}{0,228,03,1771,2d6f,12,54&ti=150812022653}{0,228,03,1771,2d6f,12,56&ti=150812022817}{0,228,03,1771,2d6f,12,59&ti=150812023815}{0,228,03,1771,2d6f,12,62&ti=150812024332}{0,228,03,1771,2d6f,12,63&ti=150812025805}{0,228,03,1771,2d6f,12,62&ti=150812030627}
but it print this
{0,228,03,1771,2d6f,12,55&ti=150811231018}{0,228,03,1771,2d6f,12,55&ti=1508140,76,=252,22i05037f853{21d,i142,2,&000,7f2526215122&0,11,2&13,8031f6=2}2,22i11001f252{,7d,=002,22i00.
>
The '>' is normal. It means that file is read.
If you look at the the seond display, the print should fine until the 75th caracter.
This why I am tring to understand.
I think it's because Serial.available() hold 64 byte, and then it crash. My code run at 9600 baud.
How an I make the _openlog.read() "remove" the red caracter from the Serial, when it's read???
Do you see my problem?
//code 2
int charactersRead = 0;
for(int timeOut = 0 ; timeOut < 1000 ; timeOut++)
{
while(_openlog.available() > 0)
{
char r = (_openlog.read());
Serial.write(r); //Take the character from OpenLog and push it to software serial TX
charactersRead++;//= charsToRead;
timeOut = 0;
}
delay(1);
}
answer = 1;
Thank a lot