@@ -266,11 +266,11 @@ void GNSS_MOSAIC::begin()
266
266
}
267
267
268
268
// 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 );
271
271
272
272
// Set COM2 (Radio) protocol(s)
273
- gnss-> setCorrRadioExtPort (settings.enableExtCorrRadio , true ); // Force the setting
273
+ setCorrRadioExtPort (settings.enableExtCorrRadio , true ); // Force the setting
274
274
275
275
updateSD (); // Check card size and free space
276
276
@@ -454,8 +454,6 @@ bool GNSS_MOSAIC::configureLogging()
454
454
bool response = true ;
455
455
String setting;
456
456
457
- // TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is present...
458
-
459
457
// Configure logging
460
458
if ((settings.enableLogging == true ) || (settings.enableLoggingRINEX == true ))
461
459
{
@@ -480,8 +478,6 @@ bool GNSS_MOSAIC::configureLogging()
480
478
response &= sendWithResponse (setting, " RINEXLogging" );
481
479
}
482
480
483
- // TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is present...
484
-
485
481
if (settings.enableExternalHardwareEventLogging )
486
482
{
487
483
setting = String (" sso,Stream" + String (MOSAIC_SBF_EXTEVENT_STREAM) +
@@ -819,9 +815,6 @@ bool GNSS_MOSAIC::enableNMEA()
819
815
response &= sendWithResponse (setting, " NMEAOutput" );
820
816
}
821
817
822
- // TODO: use sdCardPresent() here? Except the mosaic seems pretty good at figuring out if the microSD is
823
- // present...
824
-
825
818
if (settings.enableLogging )
826
819
{
827
820
setting =
@@ -1267,10 +1260,10 @@ uint8_t GNSS_MOSAIC::getLoggingType()
1267
1260
{
1268
1261
if (checkNMEARates ())
1269
1262
{
1270
- loggingType = LOGGING_STANDARD;
1263
+ logType = LOGGING_STANDARD;
1271
1264
1272
1265
if (checkPPPRates ())
1273
- loggingType = LOGGING_PPP;
1266
+ logType = LOGGING_PPP;
1274
1267
}
1275
1268
}
1276
1269
@@ -1652,7 +1645,7 @@ void GNSS_MOSAIC::menuConstellations()
1652
1645
}
1653
1646
1654
1647
// Apply current settings to module
1655
- gnss-> setConstellations ();
1648
+ setConstellations ();
1656
1649
1657
1650
clearBuffer (); // Empty buffer of any newline chars
1658
1651
}
@@ -1814,7 +1807,7 @@ void GNSS_MOSAIC::menuMessages()
1814
1807
systemPrintln ();
1815
1808
systemPrintln (" Menu: GNSS Messages" );
1816
1809
1817
- systemPrintf (" Active messages: %d\r\n " , gnss-> getActiveMessageCount ());
1810
+ systemPrintf (" Active messages: %d\r\n " , getActiveMessageCount ());
1818
1811
1819
1812
systemPrintln (" 1) Set NMEA Messages" );
1820
1813
systemPrintln (" 2) Set Rover RTCM Messages" );
@@ -2474,6 +2467,12 @@ bool GNSS_MOSAIC::surveyInStart()
2474
2467
// ----------------------------------------
2475
2468
void GNSS_MOSAIC::update ()
2476
2469
{
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
+
2477
2476
// Update the SD card size, free space and logIncreasing
2478
2477
static unsigned long sdCardSizeLastCheck = 0 ;
2479
2478
const unsigned long sdCardSizeCheckInterval = 5000 ; // Matches the interval in logUpdate
@@ -2482,6 +2481,7 @@ void GNSS_MOSAIC::update()
2482
2481
if (millis () > (sdCardSizeLastCheck + sdCardSizeCheckInterval))
2483
2482
{
2484
2483
updateSD ();
2484
+
2485
2485
if (previousFreeSpace == 0 )
2486
2486
previousFreeSpace = sdFreeSpace;
2487
2487
if (sdFreeSpace < previousFreeSpace)
@@ -2512,7 +2512,45 @@ void GNSS_MOSAIC::update()
2512
2512
// ----------------------------------------
2513
2513
bool GNSS_MOSAIC::updateSD ()
2514
2514
{
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 ;
2516
2554
2517
2555
char diskInfo[200 ];
2518
2556
bool response =
0 commit comments