Skip to content

Commit b6103cb

Browse files
committed
Mosaic logging improvements
Remove redundant gnss-> pointers Remove redundant comments Correct getLoggingType() - bad use of loggingType Perform a soft reset when SD card is inserted or removed (probably needs a "displayCardChange" on the OLED)
1 parent af81f62 commit b6103cb

File tree

1 file changed

+53
-15
lines changed

1 file changed

+53
-15
lines changed

Firmware/RTK_Everywhere/GNSS_Mosaic.ino

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ void GNSS_MOSAIC::begin()
266266
}
267267

268268
// Set COM2 (Radio) and COM3 (Data) baud rates
269-
gnss->setRadioBaudRate(settings.radioPortBaud);
270-
gnss->setDataBaudRate(settings.dataPortBaud);
269+
setRadioBaudRate(settings.radioPortBaud);
270+
setDataBaudRate(settings.dataPortBaud);
271271

272272
// Set COM2 (Radio) protocol(s)
273-
gnss->setCorrRadioExtPort(settings.enableExtCorrRadio, true); // Force the setting
273+
setCorrRadioExtPort(settings.enableExtCorrRadio, true); // Force the setting
274274

275275
updateSD(); // Check card size and free space
276276

@@ -454,8 +454,6 @@ bool GNSS_MOSAIC::configureLogging()
454454
bool response = true;
455455
String setting;
456456

457-
// TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is present...
458-
459457
// Configure logging
460458
if ((settings.enableLogging == true) || (settings.enableLoggingRINEX == true))
461459
{
@@ -480,8 +478,6 @@ bool GNSS_MOSAIC::configureLogging()
480478
response &= sendWithResponse(setting, "RINEXLogging");
481479
}
482480

483-
// TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is present...
484-
485481
if (settings.enableExternalHardwareEventLogging)
486482
{
487483
setting = String("sso,Stream" + String(MOSAIC_SBF_EXTEVENT_STREAM) +
@@ -819,9 +815,6 @@ bool GNSS_MOSAIC::enableNMEA()
819815
response &= sendWithResponse(setting, "NMEAOutput");
820816
}
821817

822-
// TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is
823-
// present...
824-
825818
if (settings.enableLogging)
826819
{
827820
setting =
@@ -1267,10 +1260,10 @@ uint8_t GNSS_MOSAIC::getLoggingType()
12671260
{
12681261
if (checkNMEARates())
12691262
{
1270-
loggingType = LOGGING_STANDARD;
1263+
logType = LOGGING_STANDARD;
12711264

12721265
if (checkPPPRates())
1273-
loggingType = LOGGING_PPP;
1266+
logType = LOGGING_PPP;
12741267
}
12751268
}
12761269

@@ -1652,7 +1645,7 @@ void GNSS_MOSAIC::menuConstellations()
16521645
}
16531646

16541647
// Apply current settings to module
1655-
gnss->setConstellations();
1648+
setConstellations();
16561649

16571650
clearBuffer(); // Empty buffer of any newline chars
16581651
}
@@ -1814,7 +1807,7 @@ void GNSS_MOSAIC::menuMessages()
18141807
systemPrintln();
18151808
systemPrintln("Menu: GNSS Messages");
18161809

1817-
systemPrintf("Active messages: %d\r\n", gnss->getActiveMessageCount());
1810+
systemPrintf("Active messages: %d\r\n", getActiveMessageCount());
18181811

18191812
systemPrintln("1) Set NMEA Messages");
18201813
systemPrintln("2) Set Rover RTCM Messages");
@@ -2474,6 +2467,12 @@ bool GNSS_MOSAIC::surveyInStart()
24742467
//----------------------------------------
24752468
void GNSS_MOSAIC::update()
24762469
{
2470+
// The mosaic-X5 supports microSD logging. But the microSD is connected directly to the X5, not the ESP32.
2471+
// present.microSd is false, but present.microSdCardDetectLow is true.
2472+
// If the microSD card is not inserted at power-on, the X5 does not recognise it if it is inserted later.
2473+
// The only way to get the X5 to recognise the card seems to be to perform a soft reset.
2474+
// Where should we perform the soft reset? updateSD seems the best place...
2475+
24772476
// Update the SD card size, free space and logIncreasing
24782477
static unsigned long sdCardSizeLastCheck = 0;
24792478
const unsigned long sdCardSizeCheckInterval = 5000; // Matches the interval in logUpdate
@@ -2482,6 +2481,7 @@ void GNSS_MOSAIC::update()
24822481
if (millis() > (sdCardSizeLastCheck + sdCardSizeCheckInterval))
24832482
{
24842483
updateSD();
2484+
24852485
if (previousFreeSpace == 0)
24862486
previousFreeSpace = sdFreeSpace;
24872487
if (sdFreeSpace < previousFreeSpace)
@@ -2512,7 +2512,45 @@ void GNSS_MOSAIC::update()
25122512
//----------------------------------------
25132513
bool GNSS_MOSAIC::updateSD()
25142514
{
2515-
// TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is present...
2515+
// See comments in update() above
2516+
// updateSD() is probably the best place to check if an SD card has been inserted / removed
2517+
static bool previousCardPresent = sdCardPresent(); // This only gets called once
2518+
2519+
// Check if card has been inserted / removed
2520+
// In both cases, perform a soft reset
2521+
// The X5 is not good at recognizing if a card is inserted after power-on, or was present but has been removed
2522+
if (previousCardPresent != sdCardPresent())
2523+
{
2524+
previousCardPresent = sdCardPresent();
2525+
2526+
systemPrint("microSD card has been ");
2527+
systemPrint(previousCardPresent ? "inserted" : "removed");
2528+
systemPrintln(". Performing a soft reset...");
2529+
2530+
sendWithResponse("erst,soft,none\n\r", "ResetReceiver");
2531+
2532+
// Allow many retries
2533+
int retries = 0;
2534+
int retryLimit = 20;
2535+
2536+
// Set COM4 to: CMD input (only), SBF output (only)
2537+
while (!sendWithResponse("sdio,COM4,CMD,SBF\n\r", "DataInOut"))
2538+
{
2539+
if (retries == retryLimit)
2540+
break;
2541+
retries++;
2542+
sendWithResponse("SSSSSSSSSSSSSSSSSSSS\n\r", "COM4>"); // Send escape sequence
2543+
}
2544+
2545+
if (retries == retryLimit)
2546+
{
2547+
systemPrintln("Soft reset failed!");
2548+
return false;
2549+
}
2550+
}
2551+
2552+
if (!previousCardPresent) // If the card is not present, skip the list disk info
2553+
return false;
25162554

25172555
char diskInfo[200];
25182556
bool response =

0 commit comments

Comments
 (0)