Skip to content

Commit 62e08b8

Browse files
committed
Add isPresent test functions for LG290P and mosaic
1 parent 2dd0247 commit 62e08b8

File tree

5 files changed

+242
-86
lines changed

5 files changed

+242
-86
lines changed

Firmware/RTK_Everywhere/GNSS.ino

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ float GNSS::getSurveyInStartingAccuracy()
4646
//----------------------------------------
4747
// Returns true if the antenna is shorted
4848
//----------------------------------------
49-
bool GNSS::isAntennaShorted() { return false; }
49+
bool GNSS::isAntennaShorted()
50+
{
51+
return false;
52+
}
5053

5154
//----------------------------------------
5255
// Returns true if the antenna is shorted
5356
//----------------------------------------
54-
bool GNSS::isAntennaOpen() { return false; }
57+
bool GNSS::isAntennaOpen()
58+
{
59+
return false;
60+
}
5561

5662
//----------------------------------------
5763
// Set the minimum satellite signal level for navigation.
@@ -98,3 +104,106 @@ void pushGPGGA(char *ggaData)
98104
}
99105
#endif // COMPILE_NETWORK
100106
}
107+
108+
// Detect what type of GNSS receiver module is installed
109+
// using serial or other begin() methods
110+
// To reduce potential false ID's, record the ID to NVM
111+
// If we have a previous ID, use it
112+
void gnssDetectReceiverType()
113+
{
114+
// Currently only the Flex requires GNSS receiver detection
115+
if (productVariant != RTK_FLEX)
116+
return;
117+
118+
// settings.detectedGnssReceiver = GNSS_RECEIVER_LG290P;
119+
// gnss = (GNSS *)new GNSS_LG290P();
120+
// systemPrintln("Starting GNSS receiver: LG290P");
121+
// return;
122+
123+
gnssBoot(); // Tell GNSS to run
124+
125+
// TODO remove after testing, force retest on each boot
126+
settings.detectedGnssReceiver = GNSS_RECEIVER_UNKNOWN;
127+
128+
// Start auto-detect if NVM is not yet set
129+
if (settings.detectedGnssReceiver == GNSS_RECEIVER_UNKNOWN)
130+
{
131+
#ifdef COMPILE_LG290P
132+
if (lg290pIsPresent() == true)
133+
{
134+
settings.detectedGnssReceiver = GNSS_RECEIVER_LG290P;
135+
recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
136+
}
137+
#else // COMPILE_LGP290P
138+
systemPrintln("<<<<<<<<<< !!!!!!!!!! LG290P NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
139+
#endif // COMPILE_LGP290P
140+
141+
#ifdef COMPILE_MOSAICX5
142+
// TODO - this uses UART2, but Flex is UART1. We need to make the mosaic send routines flexible to use
143+
// whichever UART we specify.
144+
// if (mosaicIsPresent() == true)
145+
// settings.detectedGnssReceiver = GNSS_RECEIVER_MOSAIC_X5;
146+
// recordSystemSettings(); // Record the detected GNSS receiver and avoid this test in the future
147+
#else // COMPILE_MOSAICX5
148+
systemPrintln("<<<<<<<<<< !!!!!!!!!! MOSAICX5 NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
149+
#endif // COMPILE_MOSAICX5
150+
}
151+
152+
// Start the detected receiver
153+
if (settings.detectedGnssReceiver == GNSS_RECEIVER_LG290P)
154+
{
155+
#ifdef COMPILE_LG290P
156+
gnss = (GNSS *)new GNSS_LG290P();
157+
present.gnss_lg290p = true;
158+
systemPrintln("Starting GNSS receiver: LG290P");
159+
#endif // COMPILE_LGP290P
160+
}
161+
else if (settings.detectedGnssReceiver == GNSS_RECEIVER_MOSAIC_X5)
162+
{
163+
#ifdef COMPILE_MOSAICX5
164+
gnss = (GNSS *)new GNSS_MOSAIC();
165+
present.gnss_mosaicX5 = true;
166+
systemPrintln("Starting GNSS receiver: mosaic-X5");
167+
#endif // COMPILE_MOSAICX5
168+
}
169+
170+
// Auto ID failed, mark everything as unknown
171+
else if (settings.detectedGnssReceiver == GNSS_RECEIVER_UNKNOWN)
172+
{
173+
gnss = (GNSS *)new GNSS_None();
174+
}
175+
}
176+
177+
// Based on the platform, put the GNSS receiver into run mode
178+
void gnssBoot()
179+
{
180+
if (productVariant == RTK_TORCH)
181+
{
182+
digitalWrite(pin_GNSS_DR_Reset, HIGH); // Tell UM980 and DR to boot
183+
}
184+
else if (productVariant == RTK_FLEX)
185+
{
186+
gpioExpanderGnssBoot(); // Drive the GNSS reset pin high
187+
}
188+
else if (productVariant == RTK_POSTCARD)
189+
{
190+
digitalWrite(pin_GNSS_Reset, HIGH); // Tell LG290P to boot
191+
}
192+
}
193+
194+
// Based on the platform, put the GNSS receiver into reset
195+
void gnssReset()
196+
{
197+
if (productVariant == RTK_TORCH)
198+
{
199+
digitalWrite(pin_GNSS_DR_Reset, LOW); // Tell UM980 and DR to reset
200+
}
201+
else if (productVariant == RTK_FLEX)
202+
{
203+
gpioExpanderGnssReset(); // Drive the GNSS reset pin low
204+
}
205+
else if (productVariant == RTK_POSTCARD)
206+
{
207+
digitalWrite(pin_GNSS_Reset, LOW); // Tell LG290P to reset
208+
}
209+
}

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ bool GNSS_LG290P::configureGNSS()
192192
// If we fail, reset LG290P
193193
systemPrintln("Resetting LG290P to complete configuration");
194194

195-
lg290pReset();
195+
gnssReset();
196196
delay(500);
197-
lg290pBoot();
197+
gnssBoot();
198198
}
199199

200200
systemPrintln("LG290P failed to configure");
@@ -2329,15 +2329,6 @@ uint32_t GNSS_LG290P::baudGetMaximum()
23292329
}
23302330

23312331
//----------------------------------------
2332-
void lg290pBoot()
2333-
{
2334-
digitalWrite(pin_GNSS_Reset, HIGH); // Tell LG290P to boot
2335-
}
2336-
2337-
void lg290pReset()
2338-
{
2339-
digitalWrite(pin_GNSS_Reset, LOW);
2340-
}
23412332

23422333
// Given a NMEA or PQTM sentence, determine if it is enabled in settings
23432334
// This is used to signal to the processUart1Message() task to remove messages that are needed
@@ -2392,4 +2383,36 @@ bool lg290pMessageEnabled(char *nmeaSentence, int sentenceLength)
23922383
return (true);
23932384
}
23942385

2386+
// Return true if we detect this receiver type
2387+
bool lg290pIsPresent()
2388+
{
2389+
// Locally instantiate the hardware and library so it will release on exit
2390+
2391+
HardwareSerial serialTestGNSS(2);
2392+
2393+
// LG290P communicates at 460800bps.
2394+
uint32_t platformGnssCommunicationRate = 115200 * 4;
2395+
2396+
// systemPrintf("Starting GNSS primary UART at %d on pins RX: %d TX: %d\r\n", platformGnssCommunicationRate,
2397+
// pin_GnssUart_RX, pin_GnssUart_TX);
2398+
2399+
serialTestGNSS.begin(platformGnssCommunicationRate, SERIAL_8N1, pin_GnssUart_RX, pin_GnssUart_TX);
2400+
2401+
LG290P lg290p;
2402+
2403+
if (lg290p.begin(serialTestGNSS) == true) // Give the serial port over to the library
2404+
{
2405+
// if (settings.debugGnss)
2406+
systemPrintln("LG290P detected");
2407+
serialTestGNSS.end();
2408+
return true;
2409+
}
2410+
2411+
if (settings.debugGnss)
2412+
systemPrintln("LG290P not detected. Moving on.");
2413+
2414+
serialTestGNSS.end();
2415+
return false;
2416+
}
2417+
23952418
#endif // COMPILE_LG290P

Firmware/RTK_Everywhere/GNSS_Mosaic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,9 @@ class GNSS_MOSAIC : GNSS
858858

859859
bool isPppConverging();
860860

861+
// Send commands out the UART to see if a mosaic module is present
862+
bool isPresent();
863+
861864
// Some functions (L-Band area frequency determination) merely need
862865
// to know if we have an RTK Fix. This function checks to see if the
863866
// given platform has reached sufficient fix type to be considered valid

0 commit comments

Comments
 (0)