@@ -26,30 +26,46 @@ GNSS_Mosaic.ino
26
26
// File type "1" is NMEA
27
27
// ==============================================================================
28
28
29
- // ----------------------------------------
30
- // Control the messages that get logged to SD
31
- // ----------------------------------------
32
- void menuLogMosaic ()
29
+ void printMosaicCardSpace ()
33
30
{
34
- bool applyChanges = false ;
35
-
36
- while (1 )
31
+ // mosaicSdCardSize and mosaicSdFreeSpace are updated via the SBF 4059 (storeBlock4059)
32
+ if (present.mosaicMicroSd )
37
33
{
38
- systemPrintln ();
39
- systemPrintln (" Menu: Logging" );
40
-
41
34
char sdCardSizeChar[20 ];
42
35
String cardSize;
43
- stringHumanReadableSize (cardSize, sdCardSize );
36
+ stringHumanReadableSize (cardSize, mosaicSdCardSize );
44
37
cardSize.toCharArray (sdCardSizeChar, sizeof (sdCardSizeChar));
45
38
char sdFreeSpaceChar[20 ];
46
39
String freeSpace;
47
- stringHumanReadableSize (freeSpace, sdFreeSpace );
40
+ stringHumanReadableSize (freeSpace, mosaicSdFreeSpace );
48
41
freeSpace.toCharArray (sdFreeSpaceChar, sizeof (sdFreeSpaceChar));
49
42
43
+ // On Facet mosaic, the SD is connected directly to the X5 and is accessible
44
+ // On Facet Flex X5, the internal mosaic SD card is not accessible
50
45
char myString[70 ];
51
46
snprintf (myString, sizeof (myString), " SD card size: %s / Free space: %s" , sdCardSizeChar, sdFreeSpaceChar);
52
47
systemPrintln (myString);
48
+ }
49
+ }
50
+
51
+ // ----------------------------------------
52
+ // Control the messages that get logged to SD
53
+ // ----------------------------------------
54
+ void menuLogMosaic ()
55
+ {
56
+ if (!present.mosaicMicroSd ) // This may be needed for the G5 P3 ?
57
+ return ;
58
+
59
+ bool applyChanges = false ;
60
+
61
+ while (1 )
62
+ {
63
+ systemPrintln ();
64
+ systemPrintln (" Menu: Mosaic Logging" );
65
+ systemPrintln ();
66
+
67
+ printMosaicCardSpace ();
68
+ systemPrintln ();
53
69
54
70
systemPrint (" 1) Log NMEA to microSD: " );
55
71
if (settings.enableLogging == true )
@@ -2576,58 +2592,44 @@ void GNSS_MOSAIC::storeBlock4013(SEMP_PARSE_STATE *parse)
2576
2592
2577
2593
if (Tracking)
2578
2594
{
2579
- // SV is being tracked. If it is not in svInTracking, add it
2580
- std::vector<uint8_t >::iterator pos = std::find (svInTracking.begin (), svInTracking.end (), SVID);
2581
- if (pos == svInTracking.end ())
2582
- svInTracking.push_back (SVID);
2595
+ // SV is being tracked
2596
+ std::vector<svTracking_t>::iterator pos = std::find_if (svInTracking.begin (), svInTracking.end (), find_sv (SVID));
2597
+ if (pos == svInTracking.end ()) // If it is not in svInTracking, add it
2598
+ svInTracking.push_back ({SVID, millis ()});
2599
+ else // Update lastSeen
2600
+ {
2601
+ svTracking_t sv = *pos;
2602
+ sv.lastSeen = millis ();
2603
+ *pos = sv;
2604
+ }
2583
2605
}
2584
2606
else
2585
2607
{
2586
2608
// SV is not being tracked. If it is in svInTracking, remove it
2587
- std::vector<uint8_t >::iterator pos = std::find (svInTracking.begin (), svInTracking.end (), SVID);
2609
+ std::vector<svTracking_t >::iterator pos = std::find_if (svInTracking.begin (), svInTracking.end (), find_sv ( SVID) );
2588
2610
if (pos != svInTracking.end ())
2589
2611
svInTracking.erase (pos);
2590
2612
}
2591
-
2592
- // uint16_t PVTStatus = sempSbfGetU2(parse, 20 + ChannelInfoBytes + SB1Length + (j * SB2Length) + 4);
2593
-
2594
- // bool Used = false;
2595
- // for (uint16_t shift = 0; shift < 16; shift += 2) // Step through each 2-bit status field
2596
- // {
2597
- // if ((PVTStatus & (0x0003 << shift)) == (0x0002 << shift)) // 2 : Used
2598
- // {
2599
- // Used = true;
2600
- // }
2601
- // }
2602
-
2603
- // if (Used)
2604
- // {
2605
- // // SV is being used for PVT. If it is not in svInPVT, add it
2606
- // std::vector<uint8_t>::iterator pos =
2607
- // std::find(svInPVT.begin(), svInPVT.end(), SVID);
2608
- // if (pos == svInPVT.end())
2609
- // svInPVT.push_back(SVID);
2610
- // }
2611
- // else
2612
- // {
2613
- // // SV is not being used for PVT. If it is in svInPVT, remove it
2614
- // std::vector<uint8_t>::iterator pos =
2615
- // std::find(svInPVT.begin(), svInPVT.end(), SVID);
2616
- // if (pos != svInPVT.end())
2617
- // svInPVT.erase(pos);
2618
- // }
2619
2613
}
2620
2614
2621
2615
ChannelInfoBytes += SB1Length + (N2 * SB2Length);
2622
2616
}
2623
2617
2618
+ // Erase stale SVs
2619
+ bool keepGoing = true ;
2620
+ while (keepGoing)
2621
+ {
2622
+ std::vector<svTracking_t>::iterator pos = std::find_if (svInTracking.begin (), svInTracking.end (), find_stale_sv (millis ()));
2623
+ if (pos != svInTracking.end ())
2624
+ svInTracking.erase (pos);
2625
+ else
2626
+ keepGoing = false ;
2627
+ }
2628
+
2624
2629
_satellitesInView = (uint8_t )std::distance (svInTracking.begin (), svInTracking.end ());
2625
2630
2626
2631
// if (settings.debugGnss && !inMainMenu)
2627
- // {
2628
- // uint8_t _inPVT = (uint8_t)std::distance(svInPVT.begin(), svInPVT.end());
2629
- // systemPrintf("ChannelStatus: InTracking %d, InPVT %d\r\n", _satellitesInView, _inPVT);
2630
- // }
2632
+ // systemPrintf("ChannelStatus: InTracking %d\r\n", _satellitesInView);
2631
2633
}
2632
2634
2633
2635
// ----------------------------------------
@@ -2651,6 +2653,9 @@ void GNSS_MOSAIC::storeBlock4014(SEMP_PARSE_STATE *parse)
2651
2653
// ----------------------------------------
2652
2654
void GNSS_MOSAIC::storeBlock4059 (SEMP_PARSE_STATE *parse)
2653
2655
{
2656
+ if (!present.mosaicMicroSd )
2657
+ return ;
2658
+
2654
2659
if (sempSbfGetU1 (parse, 14 ) < 1 ) // Check N is at least 1
2655
2660
return ;
2656
2661
@@ -2670,9 +2675,15 @@ void GNSS_MOSAIC::storeBlock4059(SEMP_PARSE_STATE *parse)
2670
2675
2671
2676
uint64_t diskUsage = (diskUsageMSB * 4294967296 ) + diskUsageLSB;
2672
2677
2673
- sdCardSize = diskSizeMB * 1048576 ; // Convert to bytes
2678
+ mosaicSdCardSize = diskSizeMB * 1048576 ; // Convert to bytes
2679
+
2680
+ mosaicSdFreeSpace = mosaicSdCardSize - diskUsage;
2674
2681
2675
- sdFreeSpace = sdCardSize - diskUsage;
2682
+ if (!present.microSd ) // Overwrite - if this is the only SD card
2683
+ {
2684
+ sdCardSize = mosaicSdCardSize;
2685
+ sdFreeSpace = mosaicSdFreeSpace;
2686
+ }
2676
2687
2677
2688
_diskStatusSeen = true ;
2678
2689
}
@@ -2975,7 +2986,7 @@ bool GNSS_MOSAIC::isPresentOnSerial(HardwareSerial *serialPort, const char *comm
2975
2986
2976
2987
if (retries == retryLimit)
2977
2988
{
2978
- systemPrintln (" Could not communicate with mosaic-X5! Attempting a soft reset..." );
2989
+ systemPrintln (" Could not communicate with mosaic-X5 at selected baud rate. Attempting a soft reset..." );
2979
2990
2980
2991
sendWithResponse (serialPort, " erst,soft,none\n\r " , " ResetReceiver" );
2981
2992
@@ -2991,7 +3002,7 @@ bool GNSS_MOSAIC::isPresentOnSerial(HardwareSerial *serialPort, const char *comm
2991
3002
2992
3003
if (retries == retryLimit)
2993
3004
{
2994
- systemPrintln (" Could not communicate with mosaic-X5! " );
3005
+ systemPrintln (" Could not communicate with mosaic-X5 at selected baud rate " );
2995
3006
return (false );
2996
3007
}
2997
3008
}
0 commit comments