Skip to content

Commit 8e49600

Browse files
committed
Move file allocations outside of beginSD(), where they are used.
1 parent 0a8b0e3 commit 8e49600

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -431,28 +431,6 @@ void beginSD()
431431
sdCardSize = 0;
432432
outOfSDSpace = true;
433433

434-
//Allocate the ubxFile
435-
if (!ubxFile)
436-
{
437-
ubxFile = new FileSdFatMMC;
438-
if (!ubxFile)
439-
{
440-
systemPrintln("Failed to allocate ubxFile!");
441-
break;
442-
}
443-
}
444-
445-
//Allocate the managerTempFile
446-
if (!managerTempFile)
447-
{
448-
managerTempFile = new FileSdFatMMC;
449-
if (!managerTempFile)
450-
{
451-
systemPrintln("Failed to allocate managerTempFile!");
452-
break;
453-
}
454-
}
455-
456434
systemPrintln("microSD: Online");
457435
online.microSD = true;
458436
break;

Firmware/RTK_Surveyor/Form.ino

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,17 @@ static void handleFirmwareFileDownload(AsyncWebServerRequest *request)
241241

242242
if (managerFileOpen == false)
243243
{
244+
//Allocate the managerTempFile
245+
if (!managerTempFile)
246+
{
247+
managerTempFile = new FileSdFatMMC;
248+
if (!managerTempFile)
249+
{
250+
systemPrintln("Failed to allocate managerTempFile!");
251+
break;
252+
}
253+
}
254+
244255
if (managerTempFile->open(fileName, O_READ) == true)
245256
managerFileOpen = true;
246257
else
@@ -1359,6 +1370,17 @@ void handleUpload(AsyncWebServerRequest * request, String filename, size_t index
13591370
char tempFileName[50];
13601371
filename.toCharArray(tempFileName, sizeof(tempFileName));
13611372

1373+
//Allocate the managerTempFile
1374+
if (!managerTempFile)
1375+
{
1376+
managerTempFile = new FileSdFatMMC;
1377+
if (!managerTempFile)
1378+
{
1379+
systemPrintln("Failed to allocate managerTempFile!");
1380+
break;
1381+
}
1382+
}
1383+
13621384
//Attempt to gain access to the SD card
13631385
if (xSemaphoreTake(sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
13641386
{

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,17 @@ void beginLogging(const char *customFileName)
368368
strncpy(logFileName, customFileName, sizeof(fileName) - 1);
369369
}
370370

371+
//Allocate the ubxFile
372+
if (!ubxFile)
373+
{
374+
ubxFile = new FileSdFatMMC;
375+
if (!ubxFile)
376+
{
377+
systemPrintln("Failed to allocate ubxFile!");
378+
break;
379+
}
380+
}
381+
371382
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
372383
if (xSemaphoreTake(sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
373384
{

0 commit comments

Comments
 (0)