Instead of trying to read my MicroSD direct with the computer, I've set up a "logswitch" button, whereby when HIGH, openlog will log data to test.log. When it is LOW, I want to readFile, and dump the data to the serial port (where I can capture the whole log with gobetweeno).
Is this practical or possible? If so, could someone help me with the readFile(x, y, z)? I would really just like a better explanation of how readFile works- as in, x is filename, y is start record (zero- I want the whole log) and z? can I determine the end of the record on the SD, then set it as a variable in place of z- in order to save the entire log to variable fullog?
ps, I know there is a problem with this part of the sketch, since openlog is not dropping into command mode (and therefore printing 13 to serial monitor). The logging part works fine though
void logserial(){
logger.begin(9600);
if(digitalRead(logswitchpin) == HIGH){
//logger.print(26, BYTE);
//logger.print(26, BYTE);
//logger.print(26, BYTE);
//logger.print(13, BYTE);
//delay(wait);
//logger.print("append ");
//logger.print("test.log");
//logger.print(13, BYTE);
//delay(wait);
DateTime now = RTC.now();
if(now.hour() < 10) {
logger.print("0");
}
logger.print(now.hour(), DEC);
logger.print(':');
if(now.minute() < 10) {
logger.print("0");
}
logger.print(now.minute(), DEC);
logger.print(':');
if(now.second() < 10) {
logger.print("0");
}
logger.print(now.second(), DEC);
logger.print(" ");
logger.print(temp);
logger.print(13, BYTE);
logger.print(10, BYTE);
}
if(digitalRead(logswitchpin) != HIGH){// if we aren't loggin', were printin'!
logger.print("sync");
logger.print(13, BYTE);
readFile("test.log",0, 8);
String fulllog;
fulllog = logger.read();
Serial.begin(9600);
delay(wait);
Serial.print(fulllog);
}
}
void readFile(char fname[40], int start, int length)
{
int wait = 200;
//Send escape command
logger.print(26, BYTE);
#ifdef OPENLOG_VERSION NEW
logger.print(26, BYTE);
logger.print(26, BYTE);
#endif
//We don't know where we are without checking. Either we just dropped to command prompt, or we were already sitting at the command prompt.
//If we were already at the command prompt, then we've got a bunch of command characters sitting there.
//Press enter to dump them
logger.print(13, BYTE);
delay(wait);
logger.print("read ");
logger.print(fname);
logger.print(" ");
logger.print(start);
logger.print(" ");
logger.print(length);
//OpenLog is echoing all the commands up to this point including 'read test.log 0 100', etc. We don't want this stuff in the buffer
logger.flush(); //Remove all the trash in the current buffer
//Now send the enter command to OpenLog to actually initiate the read command
logger.print(13, BYTE);
delay(wait);
}