diff --git a/speeduino/SD_logger.h b/speeduino/SD_logger.h index 9c244617..e7bcc488 100644 --- a/speeduino/SD_logger.h +++ b/speeduino/SD_logger.h @@ -70,6 +70,7 @@ void writeSDLogEntry(); void writetSDLogHeader(); void beginSDLogging(); void endSDLogging(); +void syncSDLog(); void setTS_SD_status(); void formatExFat(); void deleteLogFile(char, char, char, char); diff --git a/speeduino/SD_logger.ino b/speeduino/SD_logger.ino index 21fc382a..e38cc1a2 100644 --- a/speeduino/SD_logger.ino +++ b/speeduino/SD_logger.ino @@ -445,6 +445,14 @@ void checkForSDStop() } +void syncSDLog() +{ + if( (SD_status == SD_STATUS_ACTIVE) && (!logFile.isBusy()) ) + { + logFile.sync(); + } +} + /** * Will perform a complete format of the SD card to ExFAT. * This will delete all files and create a new empty file system. diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index e9065fef..d719cbd5 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -308,6 +308,7 @@ void loop(void) #ifdef SD_LOGGING if(configPage13.onboard_log_file_rate == LOGGER_RATE_4HZ) { writeSDLogEntry(); } + syncSDLog(); //Sync the SD log file to the card 4 times per second. #endif currentStatus.fuelPressure = getFuelPressure();