Skip to content

Commit add0302

Browse files
committed
Make logFileName global and print in menuLog().
1 parent 8996f79 commit add0302

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const uint8_t sdSizeCheckTaskPriority = 0; //3 being the highest, and 0 being th
170170
const int sdSizeCheckStackSize = 2000;
171171
bool sdSizeCheckTaskComplete = false;
172172

173+
char logFileName[sizeof("SFE_Facet_L-Band_230101_120101.ubx_plusExtraSpace")] = "";
173174
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
174175

175176
//Connection settings to NTRIP Caster

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ void menuLog()
2222
sdFreeSpaceChar
2323
);
2424
systemPrintln(myString);
25+
26+
if (online.logging)
27+
{
28+
systemPrintf("Current log file name: %s\r\n", logFileName);
29+
}
2530
}
2631
else
2732
systemPrintln("No microSD card is detected");
2833

29-
if(bufferOverruns)
34+
if (bufferOverruns)
3035
systemPrintf("Buffer overruns: %d\r\n", bufferOverruns);
3136

3237
systemPrint("1) Log to microSD: ");
@@ -94,8 +99,8 @@ void menuLog()
9499
}
95100
else if (incoming == 4 && settings.enableLogging == true && online.logging == true)
96101
{
97-
endSD(false, true); //Close down file. A new one will be created at the next calling of updateLogs().
98-
beginLogging();
102+
endLogging(false, true); //(gotSemaphore, releaseSemaphore) Close file. Reset parser stats.
103+
beginLogging(); //Create new file based on current RTC.
99104
setLoggingType(); //Determine if we are standard, PPP, or custom. Changes logging icon accordingly.
100105
}
101106
else if (incoming == 5)
@@ -336,15 +341,22 @@ void beginLogging(const char *customFileName)
336341
//Generate a standard log file name
337342
if (reuseLastLog == true) //attempt to use previous log
338343
{
339-
if (findLastLog(fileName) == false)
344+
reuseLastLog = false;
345+
346+
if (findLastLog(logFileName) == false)
340347
log_d("Failed to find last log. Making new one.");
341348
else
342349
log_d("Using last log file.");
343350
}
351+
else
352+
{
353+
//We are not reusing the last log, so erase the global/original filename
354+
strcpy(logFileName, "");
355+
}
344356

345-
if (strlen(fileName) == 0)
357+
if (strlen(logFileName) == 0)
346358
{
347-
snprintf(fileName, sizeof(fileName), "/%s_%02d%02d%02d_%02d%02d%02d.ubx", //SdFat library
359+
snprintf(logFileName, sizeof(logFileName), "/%s_%02d%02d%02d_%02d%02d%02d.ubx", //SdFat library
348360
platformFilePrefix,
349361
rtc.getYear() - 2000, rtc.getMonth() + 1, rtc.getDay(), //ESP32Time returns month:0-11
350362
rtc.getHour(true), rtc.getMinute(), rtc.getSecond() //ESP32Time getHour(true) returns hour:0-23
@@ -353,7 +365,7 @@ void beginLogging(const char *customFileName)
353365
}
354366
else
355367
{
356-
strncpy(fileName, customFileName, sizeof(fileName) - 1);
368+
strncpy(logFileName, customFileName, sizeof(fileName) - 1);
357369
}
358370

359371
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
@@ -364,9 +376,9 @@ void beginLogging(const char *customFileName)
364376
// O_CREAT - create the file if it does not exist
365377
// O_APPEND - seek to the end of the file prior to each write
366378
// O_WRITE - open for write
367-
if (ubxFile->open(fileName, O_CREAT | O_APPEND | O_WRITE) == false)
379+
if (ubxFile->open(logFileName, O_CREAT | O_APPEND | O_WRITE) == false)
368380
{
369-
systemPrintf("Failed to create GNSS UBX data file: %s\r\n", fileName);
381+
systemPrintf("Failed to create GNSS UBX data file: %s\r\n", logFileName);
370382
online.logging = false;
371383
xSemaphoreGive(sdCardSemaphore);
372384
return;
@@ -439,7 +451,7 @@ void beginLogging(const char *customFileName)
439451
return;
440452
}
441453

442-
systemPrintf("Log file name: %s\r\n", fileName);
454+
systemPrintf("Log file name: %s\r\n", logFileName);
443455
online.logging = true;
444456
} //online.sd, enable.logging, online.rtc
445457
} //online.logging

0 commit comments

Comments
 (0)