@@ -183,6 +183,18 @@ void resetArtemis(void)
183183 }
184184 if (online.serialLogging == true )
185185 {
186+ if (incomingBufferSpot > 0 )
187+ {
188+ // Write the remainder of the buffer
189+ digitalWrite (PIN_STAT_LED, HIGH); // Toggle stat LED to indicating log recording
190+ serialDataFile.write (incomingBuffer, incomingBufferSpot); // Record the buffer to the card
191+ digitalWrite (PIN_STAT_LED, LOW);
192+
193+ incomingBufferSpot = 0 ;
194+
195+ lastSeriaLogSyncTime = rtcMillis (); // Reset the last sync time to now
196+ }
197+
186198 serialDataFile.sync ();
187199 updateDataFileAccess (&serialDataFile); // Update the file access time & date
188200 serialDataFile.close ();
@@ -281,6 +293,18 @@ void goToSleep(uint32_t sysTicksToSleep)
281293 }
282294 if (online.serialLogging == true )
283295 {
296+ if (incomingBufferSpot > 0 )
297+ {
298+ // Write the remainder of the buffer
299+ digitalWrite (PIN_STAT_LED, HIGH); // Toggle stat LED to indicating log recording
300+ serialDataFile.write (incomingBuffer, incomingBufferSpot); // Record the buffer to the card
301+ digitalWrite (PIN_STAT_LED, LOW);
302+
303+ incomingBufferSpot = 0 ;
304+
305+ lastSeriaLogSyncTime = rtcMillis (); // Reset the last sync time to now
306+ }
307+
284308 serialDataFile.sync ();
285309 updateDataFileAccess (&serialDataFile); // Update the file access time & date
286310 serialDataFile.close ();
@@ -589,6 +613,18 @@ void stopLogging(void)
589613 }
590614 if (online.serialLogging == true )
591615 {
616+ if (incomingBufferSpot > 0 )
617+ {
618+ // Write the remainder of the buffer
619+ digitalWrite (PIN_STAT_LED, HIGH); // Toggle stat LED to indicating log recording
620+ serialDataFile.write (incomingBuffer, incomingBufferSpot); // Record the buffer to the card
621+ digitalWrite (PIN_STAT_LED, LOW);
622+
623+ incomingBufferSpot = 0 ;
624+
625+ lastSeriaLogSyncTime = rtcMillis (); // Reset the last sync time to now
626+ }
627+
592628 serialDataFile.sync ();
593629 updateDataFileAccess (&serialDataFile); // Update the file access time & date
594630 serialDataFile.close ();
0 commit comments