Skip to content

Commit 8c62df0

Browse files
authored
Merge pull request #212 from sparkfun/release_candidate
v2.10
2 parents 1b1d9f4 + facd024 commit 8c62df0

File tree

7 files changed

+188
-52
lines changed

7 files changed

+188
-52
lines changed

.github/workflows/build-for-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@master
22+
uses: actions/checkout@main
2323

2424
- name: Extract branch name
2525
run: echo "BRANCH=${{github.ref_name}}" >> $GITHUB_ENV

.github/workflows/non-release-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@master
22+
uses: actions/checkout@main
2323

2424
- name: Get firmware version 1
2525
run: |
@@ -108,7 +108,7 @@ jobs:
108108
echo "targetBinary=./Firmware/${{ env.FILENAME_PREFIX }}/build/SparkFun.apollo3.sfe_artemis_atp/${{ env.FILENAME_PREFIX }}${{ env.firmwareMajorMinor }}.bin" >> "$GITHUB_ENV"
109109
110110
- name: Upload binary to action
111-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
112112
with:
113113
name: ${{ env.FILENAME_PREFIX }}${{ env.firmwareMajorMinor }}.bin
114114
path: ${{ env.targetBinary }}

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,14 @@
163163
164164
v2.9
165165
Adds support for TMP102 low(er) cost temperature sensor
166+
167+
v2.10
168+
Restructure the serial logging code in loop()
169+
Where possible, write residual serial data to file before closing
166170
*/
167171

168172
const int FIRMWARE_VERSION_MAJOR = 2;
169-
const int FIRMWARE_VERSION_MINOR = 9;
173+
const int FIRMWARE_VERSION_MINOR = 10;
170174

171175
//Define the OLA board identifier:
172176
// This is an int which is unique to this variant of the OLA and which allows us
@@ -176,7 +180,7 @@ const int FIRMWARE_VERSION_MINOR = 9;
176180
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
177181
// the major firmware version * 0x10
178182
// the minor firmware version
179-
#define OLA_IDENTIFIER 0x128 // Stored as 296 decimal in OLA_settings.txt
183+
#define OLA_IDENTIFIER 0x12A // Stored as 298 decimal in OLA_settings.txt
180184

181185
//#define noPowerLossProtection // Uncomment this line to disable the sleep-on-power-loss functionality
182186

@@ -291,7 +295,6 @@ Apollo3RTC myRTC; //Create instance of RTC class
291295
uint64_t lastSeriaLogSyncTime = 0;
292296
uint64_t lastAwakeTimeMillis;
293297
const int MAX_IDLE_TIME_MSEC = 500;
294-
bool newSerialData = false;
295298
char incomingBuffer[256 * 2]; //This size of this buffer is sensitive. Do not change without analysis using OpenLog_Serial.
296299
int incomingBufferSpot = 0;
297300
int charsReceived = 0; //Used for verifying/debugging serial reception
@@ -611,39 +614,19 @@ void loop() {
611614

612615
if (settings.logSerial == true && online.serialLogging == true && settings.useTxRxPinsForTerminal == false)
613616
{
614-
size_t timestampCharsLeftToWrite = strlen(serialTimestamp);
615-
//SerialPrintf2("timestampCharsLeftToWrite is %d\r\n", timestampCharsLeftToWrite);
616-
//SerialFlush();
617+
// v2.10 - this code has been restructured....
617618

618-
if (Serial1.available() || (timestampCharsLeftToWrite > 0))
619+
// The writing of the timestamp has the highest priority
620+
if (strlen(serialTimestamp) > 0)
619621
{
620-
while (Serial1.available() || (timestampCharsLeftToWrite > 0))
622+
while (strlen(serialTimestamp) > 0) // Copy all timestamp chars into incomingBuffer
621623
{
622-
if (timestampCharsLeftToWrite > 0) // Based on code written by @DennisMelamed in PR #70
623-
{
624-
incomingBuffer[incomingBufferSpot++] = serialTimestamp[0]; // Add a timestamp character to incomingBuffer
625-
626-
for (size_t i = 0; i < timestampCharsLeftToWrite; i++)
627-
{
628-
serialTimestamp[i] = serialTimestamp[i+1]; // Shuffle the remaining chars along by one, including the NULL terminator
629-
}
624+
incomingBuffer[incomingBufferSpot++] = serialTimestamp[0]; // Add a timestamp character to incomingBuffer
630625

631-
timestampCharsLeftToWrite -= 1; // Now decrement timestampCharsLeftToWrite
632-
}
633-
else
626+
size_t timestampCharsLeftToWrite = strlen(serialTimestamp);
627+
for (size_t i = 0; i < timestampCharsLeftToWrite; i++)
634628
{
635-
incomingBuffer[incomingBufferSpot++] = Serial1.read();
636-
charsReceived++;
637-
638-
//Get the RTC timestamp if we just received the timestamp token
639-
if (settings.timestampSerial && (incomingBuffer[incomingBufferSpot-1] == settings.timeStampToken))
640-
{
641-
getTimeString(&serialTimestamp[2]);
642-
serialTimestamp[0] = 0x0A; // Add Line Feed at the start of the timestamp
643-
serialTimestamp[1] = '^'; // Add an up-arrow to indicate the timestamp relates to the preceeding data
644-
serialTimestamp[strlen(serialTimestamp) - 1] = 0x0A; // Change the final comma of the timestamp to a Line Feed
645-
timestampCharsLeftToWrite = strlen(serialTimestamp); // Update timestampCharsLeftToWrite now, so timestamp is printed immediately (#192)
646-
}
629+
serialTimestamp[i] = serialTimestamp[i+1]; // Shuffle the remaining chars along by one, including the NULL terminator
647630
}
648631

649632
if (incomingBufferSpot == sizeof(incomingBuffer))
@@ -652,35 +635,68 @@ void loop() {
652635
serialDataFile.write(incomingBuffer, sizeof(incomingBuffer)); //Record the buffer to the card
653636
digitalWrite(PIN_STAT_LED, LOW);
654637
incomingBufferSpot = 0;
638+
639+
//If we are sleeping between readings then we cannot rely on millis() as it is powered down
640+
//Use RTC instead
641+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
642+
643+
checkBattery();
655644
}
656-
checkBattery();
657645
}
658-
659-
//If we are sleeping between readings then we cannot rely on millis() as it is powered down
660-
//Use RTC instead
661-
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
662-
newSerialData = true;
663646
}
664-
else if (newSerialData == true)
647+
648+
// Now check for incoming serial data. Process bytes until a timestamp token is detected
649+
if (Serial1.available())
665650
{
666-
if ((rtcMillis() - lastSeriaLogSyncTime) > MAX_IDLE_TIME_MSEC) //If we haven't received any characters recently then sync log file
651+
while ((Serial1.available()) && (strlen(serialTimestamp) == 0))
667652
{
668-
if (incomingBufferSpot > 0)
653+
incomingBuffer[incomingBufferSpot++] = Serial1.read();
654+
charsReceived++;
655+
656+
//Get the RTC timestamp if we just received the timestamp token
657+
if (settings.timestampSerial && (incomingBuffer[incomingBufferSpot-1] == settings.timeStampToken))
658+
{
659+
getTimeString(&serialTimestamp[2]);
660+
serialTimestamp[0] = 0x0A; // Add Line Feed at the start of the timestamp
661+
serialTimestamp[1] = '^'; // Add an up-arrow to indicate the timestamp relates to the preceeding data
662+
serialTimestamp[strlen(serialTimestamp) - 1] = 0x0A; // Change the final comma of the timestamp to a Line Feed
663+
}
664+
665+
if (incomingBufferSpot == sizeof(incomingBuffer))
669666
{
670-
//Write the remainder of the buffer
671667
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
672-
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
673-
serialDataFile.sync();
674-
if (settings.frequentFileAccessTimestamps == true)
675-
updateDataFileAccess(&serialDataFile); // Update the file access time & date
668+
serialDataFile.write(incomingBuffer, sizeof(incomingBuffer)); //Record the buffer to the card
676669
digitalWrite(PIN_STAT_LED, LOW);
677-
678670
incomingBufferSpot = 0;
671+
672+
//If we are sleeping between readings then we cannot rely on millis() as it is powered down
673+
//Use RTC instead
674+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
675+
676+
checkBattery();
679677
}
678+
}
679+
}
680+
681+
// Periodically sync data to SD
682+
if ((rtcMillis() - lastSeriaLogSyncTime) > MAX_IDLE_TIME_MSEC) //If we haven't logged any characters recently then sync log file
683+
{
684+
if (incomingBufferSpot > 0)
685+
{
686+
//Write the remainder of the buffer
687+
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
688+
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
689+
serialDataFile.sync();
690+
if (settings.frequentFileAccessTimestamps == true)
691+
updateDataFileAccess(&serialDataFile); // Update the file access time & date
692+
digitalWrite(PIN_STAT_LED, LOW);
693+
694+
incomingBufferSpot = 0;
680695

681-
newSerialData = false;
682696
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
683697
printDebug("Total chars received: " + (String)charsReceived + "\r\n");
698+
699+
checkBattery();
684700
}
685701
}
686702
}
@@ -797,6 +813,18 @@ void loop() {
797813
}
798814
if (online.serialLogging == true)
799815
{
816+
if (incomingBufferSpot > 0)
817+
{
818+
//Write the remainder of the buffer
819+
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
820+
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
821+
digitalWrite(PIN_STAT_LED, LOW);
822+
823+
incomingBufferSpot = 0;
824+
825+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
826+
}
827+
800828
serialDataFile.sync();
801829
updateDataFileAccess(&serialDataFile); // Update the file access time & date
802830
serialDataFile.close();

Firmware/OpenLog_Artemis/lowerPower.ino

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

Firmware/OpenLog_Artemis/menuMain.ino

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ void menuMain(bool alwaysOpen)
9898
}
9999
if (online.serialLogging == true)
100100
{
101+
if (incomingBufferSpot > 0)
102+
{
103+
//Write the remainder of the buffer
104+
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
105+
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
106+
digitalWrite(PIN_STAT_LED, LOW);
107+
108+
incomingBufferSpot = 0;
109+
110+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
111+
}
112+
101113
serialDataFile.sync();
102114
updateDataFileAccess(&serialDataFile); // Update the file access time & date
103115
serialDataFile.close();
@@ -164,6 +176,18 @@ void menuMain(bool alwaysOpen)
164176
}
165177
if (online.serialLogging == true)
166178
{
179+
if (incomingBufferSpot > 0)
180+
{
181+
//Write the remainder of the buffer
182+
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
183+
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
184+
digitalWrite(PIN_STAT_LED, LOW);
185+
186+
incomingBufferSpot = 0;
187+
188+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
189+
}
190+
167191
serialDataFile.sync();
168192
updateDataFileAccess(&serialDataFile); // Update the file access time & date
169193
serialDataFile.close();

Firmware/OpenLog_Artemis/menuSerialLogging.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ void menuSerialLogging()
8181
{
8282
if (online.serialLogging)
8383
{
84+
if (incomingBufferSpot > 0)
85+
{
86+
//Write the remainder of the buffer
87+
digitalWrite(PIN_STAT_LED, HIGH); //Toggle stat LED to indicating log recording
88+
serialDataFile.write(incomingBuffer, incomingBufferSpot); //Record the buffer to the card
89+
digitalWrite(PIN_STAT_LED, LOW);
90+
91+
incomingBufferSpot = 0;
92+
93+
lastSeriaLogSyncTime = rtcMillis(); //Reset the last sync time to now
94+
}
95+
8496
//Shut it all down
8597
updateDataFileAccess(&serialDataFile); // Update the file access time & date
8698
serialDataFile.close();

Firmware/OpenLog_Artemis/zmodem.ino

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void sdCardHelp(void)
171171
DSERIALprintln(F("Available Commands:")); DSERIAL->flush();
172172
DSERIALprintln(F("HELP - Print this list of commands")); DSERIAL->flush();
173173
DSERIALprintln(F("DIR - List files in current working directory - alternate LS")); DSERIAL->flush();
174-
DSERIALprintln(F("DEL file - Delete file - alternate RM")); DSERIAL->flush();
174+
DSERIALprintln(F("DEL file - Delete file - alternate RM (\"DEL *\" will delete all files)")); DSERIAL->flush();
175175
DSERIALprintln(F("SZ file - Send file from OLA to terminal using ZModem (\"SZ *\" will send all files)")); DSERIAL->flush();
176176
DSERIALprintln(F("SS file - Send file from OLA using serial TX pin")); DSERIAL->flush();
177177
DSERIALprintln(F("CAT file - Type file to this terminal - alternate TYPE")); DSERIAL->flush();
@@ -300,7 +300,43 @@ void sdCardMenu(int numberOfSeconds)
300300

301301
else if (!strcmp_P(cmd, PSTR("DEL")) || !strcmp_P(cmd, PSTR("RM"))) // ReMove / DELete file
302302
{
303-
if (!sd.remove(param))
303+
if (!strcmp_P(param, PSTR("*")))
304+
{
305+
306+
count_files(&Filesleft, &Totalleft);
307+
DSERIALprint(F("\r\nDeleting at most ")); DSERIAL->print(Filesleft); DSERIALprint(F(" files (")); DSERIAL->print(Totalleft); DSERIALprintln(F(" bytes)"));
308+
309+
root.open("/"); // (re)open the root directory
310+
root.rewind(); // rewind
311+
312+
if (Filesleft > 0)
313+
{
314+
while (fout.openNext(&root, O_RDONLY))
315+
{
316+
// read next directory entry in current working directory
317+
if (!fout.isDir()) {
318+
char fname[30];
319+
size_t fsize = 30;
320+
fout.getName(fname, fsize);
321+
fout.close();
322+
if ((strcmp_P(fname, PSTR("OLA_settings.txt"))) && (strcmp_P(fname, PSTR("OLA_deviceSettings.txt"))))
323+
sd.remove(fname);
324+
}
325+
else
326+
{
327+
fout.close();
328+
}
329+
}
330+
DSERIALprintln(F("\r\nFiles deleted!\r\n"));
331+
}
332+
else
333+
{
334+
DSERIALprintln(F("\r\nNo files to delete\r\n"));
335+
}
336+
337+
root.close();
338+
}
339+
else if (!sd.remove(param))
304340
{
305341
DSERIALprint(F("\r\nFailed to delete file "));
306342
DSERIAL->flush(); DSERIAL->println(param); DSERIAL->flush();

0 commit comments

Comments
 (0)