Skip to content

Commit ab89374

Browse files
authored
Merge pull request #668 from sparkfun/pcUpdates
Add print profile option to menuUserProfiles
2 parents c19f1c9 + 95842c0 commit ab89374

File tree

11 files changed

+162
-19
lines changed

11 files changed

+162
-19
lines changed

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,16 @@
14711471
<span class="icon-info-circle text-primary ms-2"></span>
14721472
</span>
14731473
</div>
1474+
1475+
<div class="form-check mt-3">
1476+
<label class="form-check-label" for="enableNmeaOnRadio">Enable NMEA output on
1477+
Radio</label>
1478+
<input class="form-check-input" type="checkbox" value="" id="enableNmeaOnRadio">
1479+
<span class="tt" data-bs-placement="right" id="enableNmeaOnRadioInfoText"
1480+
title="Enable NMEA output on external radio. Default: True">
1481+
<span class="icon-info-circle text-primary ms-2"></span>
1482+
</span>
1483+
</div>
14741484
</div>
14751485
</div>
14761486

Firmware/RTK_Everywhere/AP-Config/src/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function parseIncoming(msg) {
121121
show("useLocalizedDistributionCheckbox");
122122
show("useEnableExtCorrRadio");
123123
show("extCorrRadioSPARTNSourceDropdown");
124+
hide("enableNmeaOnRadio");
124125
hide("shutdownNoChargeTimeoutMinutesCheckboxDetail");
125126

126127
hide("constellationNavic"); //Not supported on ZED
@@ -151,6 +152,7 @@ function parseIncoming(msg) {
151152
show("useLocalizedDistributionCheckbox");
152153
show("useEnableExtCorrRadio");
153154
show("extCorrRadioSPARTNSourceDropdown");
155+
hide("enableNmeaOnRadio");
154156

155157
hide("constellationNavic"); //Not supported on ZED
156158
}
@@ -172,6 +174,7 @@ function parseIncoming(msg) {
172174
hide("useLocalizedDistributionCheckbox");
173175
show("useEnableExtCorrRadio");
174176
hide("extCorrRadioSPARTNSourceDropdown");
177+
show("enableNmeaOnRadio");
175178

176179
select = ge("dynamicModel");
177180
let newOption = new Option('Static', '0');
@@ -256,7 +259,8 @@ function parseIncoming(msg) {
256259
show("surveyInSettings");
257260
show("useLocalizedDistributionCheckbox");
258261
show("useEnableExtCorrRadio");
259-
show("extCorrRadioSPARTNSourceDropdown");
262+
hide("extCorrRadioSPARTNSourceDropdown");
263+
show("enableNmeaOnRadio");
260264

261265
hide("constellationSbas"); //Not supported on LG290P
262266
show("constellationNavic");

Firmware/RTK_Everywhere/GNSS_LG290P.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ class GNSS_LG290P : GNSS
9999
// Given the name of an RTCM message, return the array number
100100
uint8_t getRtcmMessageNumberByName(const char *msgName);
101101

102-
// Returns true if the device is in Rover mode
103-
// Currently the only two modes are Rover or Base
104-
bool inRoverMode();
105-
106102
// Return true if the GPGGA message is active
107103
bool isGgaActive();
108104

@@ -304,6 +300,10 @@ class GNSS_LG290P : GNSS
304300
// Returns full year, ie 2023, not 23.
305301
uint16_t getYear();
306302

303+
// Returns true if the device is in Rover mode
304+
// Currently the only two modes are Rover or Base
305+
bool inRoverMode();
306+
307307
bool isBlocking();
308308

309309
// Date is confirmed once we have GNSS fix

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,21 @@ bool GNSS_LG290P::enableNMEA()
617617
// Check if this NMEA message is supported by the current LG290P firmware
618618
if (lg290pFirmwareVersion >= lgMessagesNMEA[messageNumber].firmwareVersionSupported)
619619
{
620+
// Disable NMEA output on UART3 RADIO
621+
int msgRate = settings.lg290pMessageRatesNMEA[messageNumber];
622+
if ((portNumber == 3) && (settings.enableNmeaOnRadio == false))
623+
msgRate = 0;
624+
620625
// If firmware is 4 or higher, use setMessageRateOnPort, otherwise setMessageRate
621626
if (lg290pFirmwareVersion >= 4)
622627
// Enable this message, at this rate, on this port
623628
response &=
624629
_lg290p->setMessageRateOnPort(lgMessagesNMEA[messageNumber].msgTextName,
625-
settings.lg290pMessageRatesNMEA[messageNumber], portNumber);
630+
msgRate, portNumber);
626631
else
627632
// Enable this message, at this rate
628633
response &= _lg290p->setMessageRate(lgMessagesNMEA[messageNumber].msgTextName,
629-
settings.lg290pMessageRatesNMEA[messageNumber]);
634+
msgRate);
630635
if (response == false && settings.debugGnss)
631636
systemPrintf("Enable NMEA failed at messageNumber %d %s.\r\n", messageNumber,
632637
lgMessagesNMEA[messageNumber].msgTextName);
@@ -659,11 +664,25 @@ bool GNSS_LG290P::enableNMEA()
659664
if (pointPerfectIsEnabled())
660665
{
661666
// Force on any messages that are needed for PPL
662-
if (gpggaEnabled == false)
663-
response &= _lg290p->setMessageRate("GGA", 1);
667+
// If firmware is 4 or higher, use setMessageRateOnPort, otherwise setMessageRate
668+
if (lg290pFirmwareVersion >= 4)
669+
{
670+
// Enable GGA / ZDA on port 2 (ESP32) only
671+
if (gpggaEnabled == false)
672+
response &= _lg290p->setMessageRateOnPort("GGA", 1, 2);
664673

665-
// if (gpzdaEnabled == false)
666-
// response &= _lg290p->setMessageRate("ZDA", 1);
674+
// if (gpggaEnabled == false)
675+
// response &= _lg290p->setMessageRateOnPort("GGA", 1, 1);
676+
}
677+
else
678+
{
679+
// Enable GGA / ZDA on all ports. It's the best we can do.
680+
if (gpggaEnabled == false)
681+
response &= _lg290p->setMessageRate("GGA", 1);
682+
683+
// if (gpzdaEnabled == false)
684+
// response &= _lg290p->setMessageRate("ZDA", 1);
685+
}
667686
}
668687

669688
return (response);

Firmware/RTK_Everywhere/GNSS_Mosaic.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,11 @@ bool GNSS_MOSAIC::enableNMEA()
853853
String(mosaicMsgRates[settings.mosaicStreamIntervalsNMEA[stream]].name) + "\n\r");
854854
response &= sendWithResponse(setting, "NMEAOutput");
855855

856-
setting = String("sno,Stream" + String(stream + MOSAIC_NUM_NMEA_STREAMS + 1) + ",COM2," + streams[stream] +
857-
"," + String(mosaicMsgRates[settings.mosaicStreamIntervalsNMEA[stream]].name) + "\n\r");
856+
if (settings.enableNmeaOnRadio)
857+
setting = String("sno,Stream" + String(stream + MOSAIC_NUM_NMEA_STREAMS + 1) + ",COM2," + streams[stream] +
858+
"," + String(mosaicMsgRates[settings.mosaicStreamIntervalsNMEA[stream]].name) + "\n\r");
859+
else
860+
setting = String("sno,Stream" + String(stream + MOSAIC_NUM_NMEA_STREAMS + 1) + ",COM2,none,off\n\r");
858861
response &= sendWithResponse(setting, "NMEAOutput");
859862

860863
if (settings.enableGnssToUsbSerial)

Firmware/RTK_Everywhere/GNSS_UM980.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ class GNSS_UM980 : GNSS
136136
// Given the name of an RTCM message, return the array number
137137
uint8_t getRtcmMessageNumberByName(const char *msgName);
138138

139-
// Returns true if the device is in Rover mode
140-
// Currently the only two modes are Rover or Base
141-
bool inRoverMode();
142-
143139
// Return true if the GPGGA message is active
144140
bool isGgaActive();
145141

@@ -339,6 +335,10 @@ class GNSS_UM980 : GNSS
339335
// Returns full year, ie 2023, not 23.
340336
uint16_t getYear();
341337

338+
// Returns true if the device is in Rover mode
339+
// Currently the only two modes are Rover or Base
340+
bool inRoverMode();
341+
342342
bool isBlocking();
343343

344344
// Date is confirmed once we have GNSS fix

Firmware/RTK_Everywhere/NVM.ino

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ bool loadSystemSettingsFromFileLFS(char *fileName, const char *findMe, char *fou
840840
{
841841
// If we can't read the first line of the settings file, give up
842842
systemPrintln("Giving up on settings file");
843-
return (false);
843+
break;
844844
}
845845
}
846846
else
@@ -875,7 +875,7 @@ bool loadSystemSettingsFromFileLFS(char *fileName, const char *findMe, char *fou
875875
}
876876
}
877877
strncpy(found, ptr, len);
878-
break;
878+
break; // We are done
879879
}
880880
}
881881
}
@@ -892,6 +892,69 @@ bool loadSystemSettingsFromFileLFS(char *fileName, const char *findMe, char *fou
892892
return (true);
893893
}
894894

895+
bool printSystemSettingsFromFileLFS(char *fileName)
896+
{
897+
// log_d("printing setting fileName: %s", fileName);
898+
899+
if (!LittleFS.exists(fileName))
900+
{
901+
// log_d("settingsFile not found in LittleFS\r\n");
902+
return (false);
903+
}
904+
905+
File settingsFile = LittleFS.open(fileName, FILE_READ);
906+
if (!settingsFile)
907+
{
908+
// log_d("settingsFile not found in LittleFS\r\n");
909+
return (false);
910+
}
911+
912+
char line[100];
913+
int lineNumber = 0;
914+
915+
systemPrintln();
916+
systemPrintln("--------------------------------------------------------------------------------");
917+
918+
while (settingsFile.available())
919+
{
920+
// Get the next line from the file
921+
int n;
922+
n = getLine(&settingsFile, line, sizeof(line));
923+
924+
if (n <= 0)
925+
{
926+
systemPrintf("Failed to read line %d from settings file\r\n", lineNumber);
927+
}
928+
else if (line[n - 1] != '\n' && n == (sizeof(line) - 1))
929+
{
930+
systemPrintf("Settings line %d too long\r\n", lineNumber);
931+
if (lineNumber == 0)
932+
{
933+
// If we can't read the first line of the settings file, give up
934+
systemPrintln("Giving up on settings file");
935+
break;
936+
}
937+
}
938+
else
939+
{
940+
systemPrintln(line);
941+
}
942+
943+
lineNumber++;
944+
if (lineNumber > 800) // Arbitrary limit. Catch corrupt files.
945+
{
946+
systemPrintf("Max line number exceeded. Giving up reading file: %s\r\n", fileName);
947+
break;
948+
}
949+
}
950+
951+
systemPrintln("--------------------------------------------------------------------------------");
952+
systemPrintln();
953+
954+
settingsFile.close();
955+
return (true);
956+
}
957+
895958
// Convert a given line from file into a settingName and value
896959
// Sets the setting if the name is known
897960
// The order of variables matches the order found in settings.h

Firmware/RTK_Everywhere/menuMain.ino

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ void menuUserProfiles()
350350

351351
systemPrintf("%d) Delete profile '%s'\r\n", MAX_PROFILE_COUNT + 3, profileNames[profileNumber]);
352352

353+
systemPrintf("%d) Print profile\r\n", MAX_PROFILE_COUNT + 4);
354+
353355
systemPrintln("x) Exit");
354356

355357
int incoming = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
@@ -424,6 +426,21 @@ void menuUserProfiles()
424426
else
425427
systemPrintln("Delete aborted");
426428
}
429+
else if (incoming == MAX_PROFILE_COUNT + 4)
430+
{
431+
// Print profile
432+
systemPrintf("Select the profile to be printed (1-%d): ",MAX_PROFILE_COUNT);
433+
434+
int printThis = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
435+
436+
if (printThis >= 1 && printThis <= MAX_PROFILE_COUNT)
437+
{
438+
char printFileName[60];
439+
snprintf(printFileName, sizeof(printFileName), "/%s_Settings_%d.txt", platformFilePrefix,
440+
printThis - 1);
441+
printSystemSettingsFromFileLFS(printFileName);
442+
}
443+
}
427444

428445
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
429446
break;

Firmware/RTK_Everywhere/menuPorts.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void menuPortsNoMux()
7979
{
8080
systemPrintf("4) Toggle use of external corrections radio on UART3: %s\r\n",
8181
settings.enableExtCorrRadio ? "Enabled" : "Disabled");
82+
systemPrintf("5) NMEA output on radio UART3: %s\r\n",
83+
settings.enableNmeaOnRadio ? "Enabled" : "Disabled");
8284
}
8385

8486
systemPrintln("x) Exit");
@@ -140,6 +142,10 @@ void menuPortsNoMux()
140142
// Toggle the SPARTN source for the external corrections radio
141143
settings.extCorrRadioSPARTNSource ^= 1;
142144
}
145+
else if ((incoming == 5) && (present.gnss_lg290p))
146+
{
147+
settings.enableNmeaOnRadio ^= 1;
148+
}
143149
else if (incoming == 'x')
144150
break;
145151
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
@@ -150,6 +156,18 @@ void menuPortsNoMux()
150156
printUnknown(incoming);
151157
}
152158

159+
#ifdef COMPILE_LG290P
160+
if (present.gnss_lg290p)
161+
{
162+
// Apply these changes at menu exit - to enable/disable NMEA on radio
163+
GNSS_LG290P *aLG290P = (GNSS_LG290P *)gnss;
164+
if (aLG290P->inRoverMode() == true)
165+
restartRover = true;
166+
else
167+
restartBase = true;
168+
}
169+
#endif // COMPILE_MOSAICX5
170+
153171
clearBuffer(); // Empty buffer of any newline chars
154172
}
155173

@@ -201,6 +219,8 @@ void menuPortsMultiplexed()
201219
settings.enableExtCorrRadio ? "Enabled" : "Disabled");
202220
systemPrintf("5) Output GNSS data to USB1 serial: %s\r\n",
203221
settings.enableGnssToUsbSerial ? "Enabled" : "Disabled");
222+
systemPrintf("6) NMEA output on radio COM2: %s\r\n",
223+
settings.enableNmeaOnRadio ? "Enabled" : "Disabled");
204224
}
205225

206226
systemPrintln("x) Exit");
@@ -283,6 +303,10 @@ void menuPortsMultiplexed()
283303
{
284304
settings.enableGnssToUsbSerial ^= 1;
285305
}
306+
else if ((incoming == 6) && (present.gnss_mosaicX5))
307+
{
308+
settings.enableNmeaOnRadio ^= 1;
309+
}
286310
else if (incoming == 'x')
287311
break;
288312
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
@@ -299,6 +323,7 @@ void menuPortsMultiplexed()
299323
if (present.gnss_mosaicX5)
300324
{
301325
// Apply these changes at menu exit - to enable message output on USB1
326+
// and/or enable/disable NMEA on radio
302327
GNSS_MOSAIC *mosaic = (GNSS_MOSAIC *)gnss;
303328
if (mosaic->inRoverMode() == true)
304329
restartRover = true;

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ struct Settings
904904
uint32_t radioPortBaud = 57600; // Default to 57600bps to support connection to SiK1000 type telemetry radios
905905
int16_t serialTimeoutGNSS = 1; // In ms - used during serialGNSS->begin. Number of ms to pass of no data before
906906
// hardware serial reports data available.
907+
bool enableNmeaOnRadio = true; // Postcard (LG290P) and Facet mosaic only
907908

908909
// Setup Button
909910
bool disableSetupButton = false; // By default, allow setup through the overlay button(s)
@@ -1517,6 +1518,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
15171518
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.enableGnssToUsbSerial, "enableGnssToUsbSerial", },
15181519
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, _uint32_t, 0, & settings.radioPortBaud, "radioPortBaud", },
15191520
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _int16_t, 0, & settings.serialTimeoutGNSS, "serialTimeoutGNSS", },
1521+
{ 1, 1, 0, 0, 0, 1, 0, 0, 1, _bool, 0, & settings.enableNmeaOnRadio, "enableNmeaOnRadio", },
15201522

15211523
// F
15221524
// a

0 commit comments

Comments
 (0)