OK, I have this working, sorta. However, I get multiple iterations of the same line, ie. 10 line 1s followed by 10 line 2s followed by 10 line 3s, etc. It is as if an EOL never occurs so the code keeps asking for the same line 10 times then moves on to the next line for some reason that I do not understand.
The file being read is a .wav file.
// Test reading a file using the Betwino RFLIN command //
int a=1; //for incrementing line number
int incomingLine = 0; //for incoming data
void setup() {
Serial.begin(9600);
}
int GETLINE (){
Serial.print("#S|DOGRFLIN|[");
Serial.print(a);
Serial.println("]#"); //send Betwino command
if (Serial.available() > 0){
incomingLine = Serial.read(); //Get line of data
a++;
return (incomingLine);
}
}
void loop () {
while (incomingLine> -1){ /* -1 = file does not exist
-2 = linenr > highest linenr
-3 = some other error */
GETLINE ();
}
}