Skip to content

Commit d66aa26

Browse files
committed
More WIP. Signs of life...
1 parent cc8b71c commit d66aa26

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

Firmware/RTK_Everywhere/GNSS_Mosaic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ class GNSS_MOSAIC : GNSS
559559
// and add a private library class instance here.
560560

561561
protected:
562+
// Flag which indicates GNSS is blocking (needs exclusive access to the UART)
563+
bool _isBlocking = false;
562564

563565
// These globals are updated regularly via the SBF parser
564566
double _clkBias_ms; // PVTGeodetic RxClkBias (will be sawtooth unless clock steering is enabled)

Firmware/RTK_Everywhere/GNSS_Mosaic.ino

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,17 @@ void GNSS_MOSAIC::begin()
310310

311311
_receiverSetupSeen = false;
312312

313+
_isBlocking = true;
314+
313315
// Request the ReceiverSetup SBF block using a esoc (exeSBFOnce) command on COM1
314316
String request = "esoc,COM1,ReceiverSetup\n\r";
315317
serialGNSS->write(request.c_str(), request.length());
316318

317319
// Wait for up to 5 seconds for the Receiver Setup
318320
waitSBFReceiverSetup(serialGNSS, 5000);
319321

322+
_isBlocking = false;
323+
320324
if (_receiverSetupSeen) // Check 5902 ReceiverSetup was seen
321325
{
322326
systemPrintln("GNSS mosaic-X5 online");
@@ -1571,7 +1575,9 @@ bool GNSS_MOSAIC::isAntennaOpen()
15711575
//----------------------------------------
15721576
bool GNSS_MOSAIC::isBlocking()
15731577
{
1574-
return false;
1578+
// Facet mosaic is non-blocking. It has exclusive access to COM4
1579+
// Facet Flex (mosaic) is blocking. Suspend the GNSS read task only if needed
1580+
return _isBlocking && (productVariant == RTK_FLEX);
15751581
}
15761582

15771583
//----------------------------------------
@@ -2092,6 +2098,8 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
20922098
if (strlen(reply) == 0) // Reply can't be zero-length
20932099
return false;
20942100

2101+
_isBlocking = true;
2102+
20952103
if (debug && (settings.debugGnss == true) && (!inMainMenu))
20962104
systemPrintf("sendAndWaitForIdle: sending %s\r\n", message);
20972105

@@ -2142,9 +2150,13 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
21422150
}
21432151
}
21442152

2153+
_isBlocking = false;
2154+
21452155
return true;
21462156
}
21472157

2158+
_isBlocking = false;
2159+
21482160
return false;
21492161
}
21502162

@@ -2199,6 +2211,8 @@ bool GNSS_MOSAIC::sendWithResponse(HardwareSerial *serialPort, const char *messa
21992211
if (strlen(reply) == 0) // Reply can't be zero-length
22002212
return false;
22012213

2214+
_isBlocking = true;
2215+
22022216
if ((settings.debugGnss == true) && (!inMainMenu))
22032217
systemPrintf("sendWithResponse: sending %s\r\n", message);
22042218

@@ -2257,9 +2271,13 @@ bool GNSS_MOSAIC::sendWithResponse(HardwareSerial *serialPort, const char *messa
22572271
}
22582272
}
22592273

2274+
_isBlocking = false;
2275+
22602276
return true;
22612277
}
22622278

2279+
_isBlocking = false;
2280+
22632281
return false;
22642282
}
22652283

@@ -3349,8 +3367,10 @@ bool mosaicIsPresentOnFlex()
33493367
millis() - start);
33503368
if (settings.debugGnss)
33513369
systemPrintf("mosaic-X5 baud rate %supdated\r\n", result ? "" : "NOT ");
3370+
serialTestGNSS.end();
33523371
return result;
33533372
}
33543373

3374+
serialTestGNSS.end();
33553375
return false;
33563376
}

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const int ringBufferConsumerEntries = sizeof(ringBufferConsumer) / sizeof(ringBu
7878
#define RTK_RTCM_PARSER_INDEX 2
7979
#define RTK_UBLOX_PARSER_INDEX 3
8080
#define RTK_UNICORE_BINARY_PARSER_INDEX 4
81+
#define RTK_SBF_PARSER_INDEX 5
8182

8283
// List the parsers to be included
8384
SEMP_PARSE_ROUTINE const parserTable[] = {
@@ -86,6 +87,7 @@ SEMP_PARSE_ROUTINE const parserTable[] = {
8687
sempRtcmPreamble,
8788
sempUbloxPreamble,
8889
sempUnicoreBinaryPreamble,
90+
sempSbfPreamble,
8991
};
9092
const int parserCount = sizeof(parserTable) / sizeof(parserTable[0]);
9193

@@ -96,6 +98,7 @@ const char *const parserNames[] = {
9698
"RTCM",
9799
"u-Blox",
98100
"Unicore Binary",
101+
"SBF",
99102
};
100103
const int parserNameCount = sizeof(parserNames) / sizeof(parserNames[0]);
101104

@@ -391,7 +394,9 @@ void gnssReadTask(void *e)
391394
if (settings.debugGnss)
392395
sempEnableDebugOutput(rtkParse);
393396

394-
if (present.gnss_mosaicX5 && (productVariant != RTK_FLEX))
397+
bool sbfParserNeeded = present.gnss_mosaicX5 && (productVariant != RTK_FLEX);
398+
399+
if (sbfParserNeeded)
395400
{
396401
// Initialize the SBF parser for the mosaic-X5
397402
sbfParse = sempBeginParser(sbfParserTable, sbfParserCount, sbfParserNames, sbfParserNameCount,
@@ -481,11 +486,11 @@ void gnssReadTask(void *e)
481486
{
482487
// Update the parser state based on the incoming byte
483488
// On mosaic-X5, pass the byte to sbfParse. On all other platforms, pass it straight to rtkParse
484-
sempParseNextByte(present.gnss_mosaicX5 ? sbfParse : rtkParse, incomingData[x]);
489+
sempParseNextByte(sbfParserNeeded ? sbfParse : rtkParse, incomingData[x]);
485490

486491
// See notes above. On the mosaic-X5, check that the incoming SBF blocks have expected IDs and
487492
// lengths to help prevent raw L-Band data being misidentified as SBF
488-
if (present.gnss_mosaicX5)
493+
if (sbfParserNeeded)
489494
{
490495
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)sbfParse->scratchPad;
491496

@@ -633,6 +638,12 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
633638
systemPrintf("%s %s, 0x%04x (%d) bytes\r\n", parse->parserName, parserNames[type], parse->length,
634639
parse->length);
635640
break;
641+
642+
case RTK_SBF_PARSER_INDEX:
643+
message = sempSbfGetBlockNumber(parse);
644+
systemPrintf("%s %s %d, 0x%04x (%d) bytes\r\n", parse->parserName, parserNames[type], message,
645+
parse->length, parse->length);
646+
break;
636647
}
637648
}
638649

@@ -678,6 +689,12 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
678689
nmeaExtractStdDeviations((char *)parse->buffer, parse->length);
679690
}
680691

692+
// Facet Flex mosaic - pass the SBF to processUart1SBF
693+
if ((present.gnss_mosaicX5) && (productVariant == RTK_FLEX) && (type == RTK_SBF_PARSER_INDEX))
694+
{
695+
processUart1SBF(parse, type);
696+
}
697+
681698
// Determine where to send RTCM data
682699
if (inBaseMode() && type == RTK_RTCM_PARSER_INDEX)
683700
{
@@ -694,7 +711,7 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
694711
if ((present.gnss_lg290p) && (pointPerfectIsEnabled()) && (mqttClientIsConnected() == true))
695712
usingPPL = true;
696713
// mosaic-X5 : Determine if we want to use corrections
697-
if ((present.gnss_mosaicX5) && (pointPerfectIsEnabled()))
714+
if ((present.gnss_mosaicX5) && (pointPerfectLbandNeeded()))
698715
usingPPL = true;
699716

700717
if (usingPPL)
@@ -792,6 +809,14 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
792809
parse->length = 0;
793810
}
794811

812+
// Suppress SBF messages from mosaic. Not needed by end GIS apps.
813+
if (type == RTK_SBF_PARSER_INDEX)
814+
{
815+
// Erase buffer
816+
parse->buffer[0] = 0;
817+
parse->length = 0;
818+
}
819+
795820
// Determine if this message will fit into the ring buffer
796821
bytesToCopy = parse->length;
797822
space = availableHandlerSpace;

0 commit comments

Comments
 (0)