Skip to content

Commit 1cbe718

Browse files
authored
Merge pull request #553 from sparkfun/pcUpdates
pcUpdates
2 parents 14161b6 + cd0c7c3 commit 1cbe718

29 files changed

+965
-555
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void updatePPL() {}
266266
bool sendGnssToPpl(uint8_t *buffer, int numDataBytes) {return false;}
267267
bool sendSpartnToPpl(uint8_t *buffer, int numDataBytes) {return false;}
268268
bool sendAuxSpartnToPpl(uint8_t *buffer, int numDataBytes) {return false;}
269-
void pointperfectPrintKeyInformation() {systemPrintln("**PPL Not Compiled**");}
269+
void pointperfectPrintKeyInformation(const char *requestedBy) {systemPrintln("**PPL Not Compiled**");}
270270

271271
#endif // COMPILE_POINTPERFECT_LIBRARY
272272

Firmware/RTK_Everywhere/Display.ino

Lines changed: 194 additions & 89 deletions
Large diffs are not rendered by default.

Firmware/RTK_Everywhere/GNSS_LG290P.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class GNSS_LG290P : GNSS
176176
// Returns true if successfully started and false upon failure
177177
bool enableRTCMTest();
178178

179-
bool enterConfigMode();
179+
bool enterConfigMode(unsigned long waitForSemaphoreTimeout_millis);
180180

181181
bool exitConfigMode();
182182

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 86 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,6 @@ bool GNSS_LG290P::checkPPPRates()
165165
//----------------------------------------
166166
bool GNSS_LG290P::configureGNSS()
167167
{
168-
// Skip configuring the GNSS receiver if no new changes are necessary
169-
if (settings.updateGNSSSettings == false)
170-
{
171-
systemPrintln("LG290P configuration maintained");
172-
return (true);
173-
}
174-
175168
for (int x = 0; x < 3; x++)
176169
{
177170
// Wait up to 5 seconds for device to come online
@@ -218,31 +211,45 @@ bool GNSS_LG290P::configureOnce()
218211
Enable selected RTCM messages on COM2
219212
*/
220213

214+
if (settings.gnssConfiguredOnce)
215+
{
216+
systemPrintln("LG290P configuration maintained");
217+
return (true);
218+
}
219+
221220
if (settings.debugGnss)
222221
debuggingEnable(); // Print all debug to Serial
223222

224223
serialGNSS->flush(); // Remove any incoming characters
225224

226225
bool response = true;
227226

228-
response &= enterConfigMode();
227+
uint8_t retries = 4;
228+
229+
while ((retries > 0) && (!enterConfigMode(500)))
230+
{
231+
retries--;
232+
systemPrintf("configureOnce: Enter config mode failed. %d retries remaining\r\n", retries);
233+
}
234+
235+
response &= (retries > 0);
229236
if (settings.debugGnss && response == false)
230-
systemPrintln("ConfigureOnce: Enter config mode failed");
237+
systemPrintln("configureOnce: Enter config mode failed");
231238

232239
response &= setDataBaudRate(settings.dataPortBaud); // LG290P UART1 is connected to CH342 (Port B)
233240
response &= _lg290p->setPortBaudrate(2, 115200 * 4); // LG290P UART2 is connected to the ESP32 UART1
234241
response &= setRadioBaudRate(settings.radioPortBaud); // LG290P UART3 is connected to the locking JST connector
235242
if (settings.debugGnss && response == false)
236-
systemPrintln("ConfigureOnce: setBauds failed");
243+
systemPrintln("configureOnce: setBauds failed");
237244

238245
// Enable PPS signal with a width of 200ms
239246
response &= _lg290p->setPPS(200, false, true); // duration time ms, alwaysOutput, polarity
240247
if (settings.debugGnss && response == false)
241-
systemPrintln("ConfigureOnce: setPPS failed");
248+
systemPrintln("configureOnce: setPPS failed");
242249

243250
response &= setConstellations();
244251
if (settings.debugGnss && response == false)
245-
systemPrintln("ConfigureOnce: setConstellations failed");
252+
systemPrintln("configureOnce: setConstellations failed");
246253

247254
// We do not set Rover or fix rate here because fix rate only applies in rover mode.
248255

@@ -255,14 +262,13 @@ bool GNSS_LG290P::configureOnce()
255262
systemPrintln("LG290P configuration updated");
256263

257264
// Save the current configuration into non-volatile memory (NVM)
258-
// We don't need to re-configure the LG290P at next boot
259-
bool settingsWereSaved = saveConfiguration();
260-
if (settingsWereSaved)
261-
settings.updateGNSSSettings = false;
265+
response &= saveConfiguration();
262266
}
263267
else
264268
online.gnss = false; // Take it offline
265269

270+
settings.gnssConfiguredOnce = response;
271+
266272
return (response);
267273
}
268274

@@ -282,13 +288,28 @@ bool GNSS_LG290P::configureRover()
282288
return (false);
283289
}
284290

291+
// If our settings haven't changed, trust GNSS's settings
292+
if (settings.gnssConfiguredRover)
293+
{
294+
systemPrintln("Skipping LG290P Rover configuration");
295+
return (true);
296+
}
297+
285298
bool response = true;
286299

287300
serialGNSS->flush(); // Remove any incoming characters
288301

289-
response &= enterConfigMode();
302+
uint8_t retries = 4;
303+
304+
while ((retries > 0) && (!enterConfigMode(500)))
305+
{
306+
retries--;
307+
systemPrintf("configureRover: Enter config mode failed. %d retries remaining\r\n", retries);
308+
}
309+
310+
response &= (retries > 0);
290311
if (settings.debugGnss && response == false)
291-
systemPrintln("Rover: Enter config mode failed");
312+
systemPrintln("configureRover: Enter config mode failed");
292313

293314
// We must force receiver into Rover mode so that we can set fix rate
294315
int currentMode = getMode();
@@ -299,21 +320,21 @@ bool GNSS_LG290P::configureRover()
299320
// fail because NMEA is not present.
300321
_lg290p->setModeRover(); // Wait for save and reset
301322
if (settings.debugGnss && response == false)
302-
systemPrintln("Rover: Set mode rover failed");
323+
systemPrintln("configureRover: Set mode rover failed");
303324
}
304325

305326
// Set the fix rate. Default on LG290P is 10Hz so set accordingly.
306327
response &= setRate(settings.measurementRateMs / 1000.0); // May require save/reset
307328
if (settings.debugGnss && response == false)
308-
systemPrintln("Rover: Set rate failed");
329+
systemPrintln("configureRover: Set rate failed");
309330

310331
response &= enableRTCMRover();
311332
if (settings.debugGnss && response == false)
312-
systemPrintln("Rover: Enable RTCM failed");
333+
systemPrintln("configureRover: Enable RTCM failed");
313334

314335
response &= enableNMEA();
315336
if (settings.debugGnss && response == false)
316-
systemPrintln("Rover: Enable NMEA failed");
337+
systemPrintln("configureRover: Enable NMEA failed");
317338

318339
response &= exitConfigMode(); // We must exit config before we save otherwise we will save with NMEA/RTCM off
319340

@@ -324,18 +345,17 @@ bool GNSS_LG290P::configureRover()
324345
else
325346
{
326347
// Save the current configuration into non-volatile memory (NVM)
327-
// We don't need to re-configure the LG290P at next boot
328-
bool settingsWereSaved = saveConfiguration();
329-
if (settingsWereSaved)
330-
settings.updateGNSSSettings = false;
348+
response &= saveConfiguration();
331349

332350
// For RTCM and MSM messages to take effect (ie, PointPerfect is active) we must save/reset
333351
softwareReset();
334352

335-
if (settings.debugGnss)
353+
if (settings.debugGnss && response)
336354
systemPrintln("LG290P Rover configured");
337355
}
338356

357+
settings.gnssConfiguredRover = response;
358+
339359
return (response);
340360
}
341361

@@ -356,13 +376,28 @@ bool GNSS_LG290P::configureBase()
356376
return (false);
357377
}
358378

379+
if (settings.gnssConfiguredBase)
380+
{
381+
if (settings.debugGnss)
382+
systemPrintln("Skipping LG290P Base configuration");
383+
return true;
384+
}
385+
359386
bool response = true;
360387

361388
serialGNSS->flush(); // Remove any incoming characters
362389

363-
response &= enterConfigMode();
390+
uint8_t retries = 4;
391+
392+
while ((retries > 0) && (!enterConfigMode(500)))
393+
{
394+
retries--;
395+
systemPrintf("configureBase: Enter config mode failed. %d retries remaining\r\n", retries);
396+
}
397+
398+
response &= (retries > 0);
364399
if (settings.debugGnss && response == false)
365-
systemPrintln("Base: Enter config mode failed");
400+
systemPrintln("configureBase: Enter config mode failed");
366401

367402
// "When set to Base Station mode, the receiver will automatically disable NMEA message output and enable RTCM MSM4
368403
// and RTCM3-1005 message output."
@@ -380,7 +415,7 @@ bool GNSS_LG290P::configureBase()
380415
// fail because NMEA is not present.
381416
_lg290p->setModeBase(false); // Don't save and reset
382417
if (settings.debugGnss && response == false)
383-
systemPrintln("Base: Set mode base failed");
418+
systemPrintln("configureBase: Set mode base failed");
384419

385420
// Device should now have survey mode disabled
386421
}
@@ -394,16 +429,16 @@ bool GNSS_LG290P::configureBase()
394429
// fail because NMEA is not present.
395430
disableSurveyIn(false); // Don't save and reset
396431
if (settings.debugGnss && response == false)
397-
systemPrintln("Base: disable survey in failed");
432+
systemPrintln("configureBase: disable survey in failed");
398433
}
399434

400435
response &= enableRTCMBase(); // Set RTCM messages
401436
if (settings.debugGnss && response == false)
402-
systemPrintln("Base: Enable RTCM failed");
437+
systemPrintln("configureBase: Enable RTCM failed");
403438

404439
response &= enableNMEA(); // Set NMEA messages
405440
if (settings.debugGnss && response == false)
406-
systemPrintln("Base: Enable NMEA failed");
441+
systemPrintln("configureBase: Enable NMEA failed");
407442

408443
response &= exitConfigMode(); // We must exit config before we save otherwise we will save with NMEA/RTCM off
409444

@@ -414,21 +449,20 @@ bool GNSS_LG290P::configureBase()
414449
else
415450
{
416451
// Save the current configuration into non-volatile memory (NVM)
417-
// We don't need to re-configure the LG290P at next boot
418-
bool settingsWereSaved = saveConfiguration();
419-
if (settingsWereSaved)
420-
settings.updateGNSSSettings = false;
452+
response &= saveConfiguration();
421453

422454
softwareReset();
423455

424456
// When a device is changed from Rover to Base, NMEA messages settings do not survive PQTMSAVEPAR
425457
// Re-enable NMEA post reset
426-
enableNMEA(); // Set NMEA messages
458+
response &= enableNMEA(); // Set NMEA messages
427459

428-
if (settings.debugGnss)
460+
if (settings.debugGnss && response)
429461
systemPrintln("LG290P Base configured");
430462
}
431463

464+
settings.gnssConfiguredBase = response;
465+
432466
return (response);
433467
}
434468

@@ -454,11 +488,20 @@ bool GNSS_LG290P::configureNtpMode()
454488
//----------------------------------------
455489
// Disable NMEA and RTCM on UART2 to reduce the serial traffic
456490
//----------------------------------------
457-
bool GNSS_LG290P::enterConfigMode()
491+
bool GNSS_LG290P::enterConfigMode(unsigned long waitForSemaphoreTimeout_millis)
458492
{
459493
if (online.gnss)
494+
{
495+
unsigned long start = millis();
496+
bool isBlocking;
497+
do { // Wait for up to waitForSemaphoreTimeout for library to stop blocking
498+
isBlocking = _lg290p->isBlocking();
499+
} while (isBlocking && (millis() < (start + waitForSemaphoreTimeout_millis)));
500+
501+
// This will fail if the library is still blocking, but it is worth a punt...
460502
return (_lg290p->sendOkCommand("$PQTMCFGPROT",
461503
",W,1,2,00000000,00000000")); // Disable NMEA and RTCM on the LG290P UART2
504+
}
462505
return (false);
463506
}
464507

@@ -1757,7 +1800,9 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
17571800
printUnknown(incoming);
17581801
}
17591802

1760-
settings.updateGNSSSettings = true; // Update the GNSS config at the next boot
1803+
settings.gnssConfiguredOnce = false; // Update the GNSS config at the next boot
1804+
settings.gnssConfiguredBase = false;
1805+
settings.gnssConfiguredRover = false;
17611806

17621807
clearBuffer(); // Empty buffer of any newline chars
17631808
}

Firmware/RTK_Everywhere/GNSS_Mosaic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ bool mosaicX5waitCR(unsigned long timeout = 25); // Header
549549

550550
class GNSS_MOSAIC : GNSS
551551
{
552+
// The mosaic-X5 does not have self-contained interface library.
553+
// But the ZED-F9P, UM980 and LG290P all do.
554+
// On the X5, we communicate manually over serial2GNSS using functions like
555+
// sendWithResponse and sendAndWaitForIdle.
556+
// In essence, the interface library is wholly contained in this class.
557+
// TODO: consider breaking the mosaic comms functions out into their own library
558+
// and add a private library class instance here.
559+
552560
protected:
553561

554562
// These globals are updated regularly via the SBF parser

0 commit comments

Comments
 (0)