I am using an arduino Mega with an external SD card module. I have a large file on the SD card (7 840 KB, or 4 values logged at 10Hz for about 8 hours) that needs to be processed using a predetermined algorithm.
The algorithm works for almost 5 of the 8 hours but then exits the algorithm. The processing function is run in the main loop when the user enters a value in to the serial monitor. The start of the processing function is as follows:
void processNight(String FileName){
processFile = SD.open(FileName);
if(processFile){
startTime = millis();
while (processNightFile.available()){
currentTime = processNightFile.parseFloat();
currentSPO2 = processNightFile.parseFloat();
currentFlow = processNightFile.parseFloat();
currentBE = processNightFile.parseFloat();
currentHR = processNightFile.parseFloat();
//The processing is done here
}
//Some print function that shows how long the function ran for.
}
}
The function runs for almost 1028 seconds and then exits. Is there any way to extend this cutoff time, or do I need to break the file up and process it in chunks?
IF the problem was mine, I would count the number of loops in your "while" loop and display that count to see if the while stopped at the same count every time.
could you attach the file here or does it include confidential information?
you could record both in ASCII and binary and use the binary version for the processing
this code
checks if 1 byte is available and reads lots of bytes without any error detection. if for whatever reason the recording was incorrect, you have no way to recover.
if you don't want to go binary, I would make sure that the records are separated by an identifiable marker and terminate the record with a new line. I would read the line in (read until '\n') and then parse the line performing some error detection.
What does file.available() return? The docs say it's not a bool, but an integer. So is it 32767 until the the remaining file is less than that, or is it the just the least significant 15 bits of the available size (which could be zero when there's more file actually available?