20130111

Arduino + Canbus shield + GPS Receiver - update 1

A quick update on my Arduino + Canbus shield + GPS Receiver post from last year.

I had this plan to put the files in a sub folder in order to make sure that i would hit the limit to the number of files in the root of the file system, added a bit of code that would create up to a thousand files. Somehow it didn't work: didn't want to write in the sub folder...

But why use separate files anyway? The files will be evaluated on my main machine, it's easy enough for it to split the file. That simplifies the code a lot:


void start_new_file(void) 
{
 digitalWrite(LED2, HIGH);

 // we want to add to the end of the file file and flush manually for performance and to be nice to the sd card
 file = SD.open("DATA.TXT", O_READ | O_APPEND | O_WRITE);
 digitalWrite(LED2, LOW);
}

Also spotted the post Why is the SD library slow? and decided to flush the file manually. Performance isn't really an issue but fewer writes to the SD won't hurt! I flush before checking for the click.