Skip to content

Commit 8f4864d

Browse files
authored
Merge pull request #711 from sparkfun/AddFlex_pcUpdates
AddFlex with pcUpdates - adds support for the X5
2 parents 2316f10 + 85709da commit 8f4864d

File tree

15 files changed

+1108
-602
lines changed

15 files changed

+1108
-602
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ void beginBoard()
334334
gnss = (GNSS *)new GNSS_ZED();
335335
#else // COMPILE_ZED
336336
gnss = (GNSS *)new GNSS_None();
337+
systemPrintln("<<<<<<<<<< !!!!!!!!!! ZED NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
337338
#endif // COMPILE_ZED
338339

339340
present.brand = BRAND_SPARKFUN;
@@ -464,6 +465,7 @@ void beginBoard()
464465
gnss = (GNSS *)new GNSS_ZED();
465466
#else // COMPILE_ZED
466467
gnss = (GNSS *)new GNSS_None();
468+
systemPrintln("<<<<<<<<<< !!!!!!!!!! ZED NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
467469
#endif // COMPILE_ZED
468470

469471
present.brand = BRAND_SPARKPNT;
@@ -546,6 +548,7 @@ void beginBoard()
546548
gnss = (GNSS *)new GNSS_ZED();
547549
#else // COMPILE_ZED
548550
gnss = (GNSS *)new GNSS_None();
551+
systemPrintln("<<<<<<<<<< !!!!!!!!!! ZED NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
549552
#endif // COMPILE_ZED
550553

551554
present.brand = BRAND_SPARKPNT;
@@ -635,6 +638,8 @@ void beginBoard()
635638
// mosaic COM3 is connected to the Data connector - via the multiplexer
636639
// mosaic COM3 is available as a generic COM port. The firmware configures the baud. Nothing else.
637640

641+
// NOTE: Facet Flex with mosaic-X5 is VERY different!
642+
638643
// Specify the GNSS radio
639644
#ifdef COMPILE_MOSAICX5
640645
gnss = (GNSS *)new GNSS_MOSAIC();
@@ -659,10 +664,11 @@ void beginBoard()
659664
present.invertedFastPowerOff = true;
660665
present.gnss_to_uart = true;
661666
present.gnss_to_uart2 = true;
662-
present.needsExternalPpl = true; // Uses the PointPerfect Library
663667
present.microSdCardDetectLow = true; // Except microSD is connected to mosaic... present.microSd is false
668+
664669
present.minCno = true;
665670
present.minElevation = true;
671+
present.needsExternalPpl = true; // Uses the PointPerfect Library for L-Band
666672
present.dynamicModel = true;
667673

668674
pin_muxA = 2;
@@ -1166,6 +1172,11 @@ void pinGnssUartTask(void *pvParameters)
11661172
// LG290P communicates at 460800bps.
11671173
platformGnssCommunicationRate = 115200 * 4;
11681174
}
1175+
else if (settings.detectedGnssReceiver == GNSS_RECEIVER_MOSAIC_X5)
1176+
{
1177+
// Mosaic defaults to 115200, but mosaicIsPresentOnFlex() increases COM1 to 460800bps
1178+
platformGnssCommunicationRate = 115200 * 4;
1179+
}
11691180
else
11701181
{
11711182
// If we don't know the GNSS receiver, default to 115200

Firmware/RTK_Everywhere/GNSS.ino

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,65 +118,65 @@ void gnssDetectReceiverType()
118118
gnssBoot(); // Tell GNSS to run
119119

120120
// TODO remove after testing, force retest on each boot
121+
// Note: with this in place, the X5 detection will take a lot longer due to the baud rate change
121122
settings.detectedGnssReceiver = GNSS_RECEIVER_UNKNOWN;
122123

123124
// Start auto-detect if NVM is not yet set
124125
if (settings.detectedGnssReceiver == GNSS_RECEIVER_UNKNOWN)
125126
{
127+
// The COMPILE guards prevent else if
128+
// Use a do while (0) so we can break when GNSS is detected
129+
do {
126130
#ifdef COMPILE_LG290P
127-
if (lg290pIsPresent() == true)
128-
{
129-
systemPrintln("Auto-detected GNSS receiver: LG290P");
130-
131-
present.gnss_lg290p = true;
132-
present.minCno = true;
133-
present.minElevation = true;
134-
present.needsExternalPpl = true; // Uses the PointPerfect Library
135-
136-
settings.detectedGnssReceiver = GNSS_RECEIVER_LG290P;
137-
recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
138-
}
131+
if (lg290pIsPresent() == true)
132+
{
133+
systemPrintln("Auto-detected GNSS receiver: LG290P");
134+
settings.detectedGnssReceiver = GNSS_RECEIVER_LG290P;
135+
recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
136+
break;
137+
}
139138
#else // COMPILE_LGP290P
140-
systemPrintln("<<<<<<<<<< !!!!!!!!!! LG290P NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
139+
systemPrintln("<<<<<<<<<< !!!!!!!!!! LG290P NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
141140
#endif // COMPILE_LGP290P
142141

143142
#ifdef COMPILE_MOSAICX5
144-
// TODO - this uses UART2, but Flex is UART1. We need to make the mosaic send routines flexible to use
145-
// whichever UART we specify.
146-
// else if (mosaicIsPresent() == true)
147-
// {
148-
// systemPrintln("Auto-detected GNSS receiver: mosaic-X5");
149-
150-
// present.gnss_mosaicX5 = true;
151-
// present.minCno = true;
152-
// present.minElevation = true;
153-
// present.dynamicModel = true;
154-
// present.needsExternalPpl = true; // Uses the PointPerfect Library
155-
156-
// settings.detectedGnssReceiver = GNSS_RECEIVER_MOSAIC_X5;
157-
// recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
158-
// }
143+
if (mosaicIsPresentOnFlex() == true) // Note: this changes the COM1 baud from 115200 to 460800
144+
{
145+
systemPrintln("Auto-detected GNSS receiver: mosaic-X5");
146+
settings.detectedGnssReceiver = GNSS_RECEIVER_MOSAIC_X5;
147+
recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
148+
break;
149+
}
159150
#else // COMPILE_MOSAICX5
160-
else
161-
{
162-
systemPrintln("<<<<<<<<<< !!!!!!!!!! MOSAICX5 NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
163-
}
151+
systemPrintln("<<<<<<<<<< !!!!!!!!!! MOSAICX5 NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
164152
#endif // COMPILE_MOSAICX5
153+
} while (0);
165154
}
166155

167156
// Start the detected receiver
168157
if (settings.detectedGnssReceiver == GNSS_RECEIVER_LG290P)
169158
{
170159
#ifdef COMPILE_LG290P
171160
gnss = (GNSS *)new GNSS_LG290P();
161+
172162
present.gnss_lg290p = true;
163+
present.minCno = true;
164+
present.minElevation = true;
165+
present.needsExternalPpl = true; // Uses the PointPerfect Library
166+
173167
#endif // COMPILE_LGP290P
174168
}
175169
else if (settings.detectedGnssReceiver == GNSS_RECEIVER_MOSAIC_X5)
176170
{
177171
#ifdef COMPILE_MOSAICX5
178172
gnss = (GNSS *)new GNSS_MOSAIC();
173+
179174
present.gnss_mosaicX5 = true;
175+
present.minCno = true;
176+
present.minElevation = true;
177+
present.dynamicModel = true;
178+
// present.needsExternalPpl = true; // Nope. No L-Band support...
179+
180180
#endif // COMPILE_MOSAICX5
181181
}
182182

Firmware/RTK_Everywhere/GNSS_Mosaic.h

Lines changed: 22 additions & 2 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)
@@ -860,6 +862,8 @@ class GNSS_MOSAIC : GNSS
860862

861863
// Send commands out the UART to see if a mosaic module is present
862864
bool isPresent();
865+
bool isPresentOnSerial(HardwareSerial *serialPort, const char *command, const char *response, const char *console, int retryLimit = 20);
866+
bool mosaicIsPresentOnFlex();
863867

864868
// Some functions (L-Band area frequency determination) merely need
865869
// to know if we have an RTK Fix. This function checks to see if the
@@ -943,6 +947,14 @@ class GNSS_MOSAIC : GNSS
943947
char *response = nullptr,
944948
size_t responseSize = 0,
945949
bool debug = true);
950+
bool sendAndWaitForIdle(HardwareSerial *serialPort,
951+
const char *message,
952+
const char *reply,
953+
unsigned long timeout = 1000,
954+
unsigned long idle = 25,
955+
char *response = nullptr,
956+
size_t responseSize = 0,
957+
bool debug = true);
946958

947959
// Send message. Wait for up to timeout millis for reply to arrive
948960
// If the reply is received, keep reading bytes until the serial port has
@@ -985,6 +997,13 @@ class GNSS_MOSAIC : GNSS
985997
unsigned long wait = 25,
986998
char *response = nullptr,
987999
size_t responseSize = 0);
1000+
bool sendWithResponse(HardwareSerial *serialPort,
1001+
const char *message,
1002+
const char *reply,
1003+
unsigned long timeout = 1000,
1004+
unsigned long wait = 25,
1005+
char *response = nullptr,
1006+
size_t responseSize = 0);
9881007

9891008
// Send message. Wait for up to timeout millis for reply to arrive
9901009
// If the reply has started to be received when timeout is reached, wait for a further wait millis
@@ -1013,7 +1032,8 @@ class GNSS_MOSAIC : GNSS
10131032
// baudRate: New baud rate for the COM port
10141033
// Outputs:
10151034
// Returns true if the baud rate was set and false upon failure
1016-
bool setBaudRateCOM(uint8_t port, uint32_t baudRate);
1035+
bool setBaudRate(uint8_t uartNumber, uint32_t baudRate); // From the super class
1036+
bool setBaudRateCOM(uint8_t port, uint32_t baudRate); // Original X5 implementation
10171037

10181038
// Enable all the valid constellations and bands for this platform
10191039
bool setConstellations();
@@ -1094,7 +1114,7 @@ class GNSS_MOSAIC : GNSS
10941114

10951115
void updateSD();
10961116

1097-
void waitSBFReceiverSetup(unsigned long timeout);
1117+
void waitSBFReceiverSetup(HardwareSerial *serialPort, unsigned long timeout);
10981118
};
10991119

11001120
#endif // __GNSS_MOSAIC_H__

0 commit comments

Comments
 (0)