From f977f3659d159b0617adfcea1c74f0c5bc590980 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 23 May 2024 13:51:01 -0600 Subject: [PATCH] Avoid defaulting arrays that do not apply to current platform --- Firmware/RTK_Everywhere/menuMessages.ino | 97 +++++++++++++----------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/Firmware/RTK_Everywhere/menuMessages.ino b/Firmware/RTK_Everywhere/menuMessages.ino index e2ffb4dab..b8d564c84 100644 --- a/Firmware/RTK_Everywhere/menuMessages.ino +++ b/Firmware/RTK_Everywhere/menuMessages.ino @@ -211,7 +211,7 @@ void zedMenuMessagesSubtype(uint8_t *localMessageRate, const char *messageType) } else zedSetMessageOffsets(&ubxMessages[0], messageType, startOfBlock, - endOfBlock); // Find start and stop of given messageType in message array + endOfBlock); // Find start and stop of given messageType in message array for (int x = 0; x < (endOfBlock - startOfBlock); x++) { @@ -599,65 +599,72 @@ void checkGNSSArrayDefaults() { bool defaultsApplied = false; - if (settings.ubxMessageRates[0] == 254) + if (present.gnss_zedf9p) { - defaultsApplied = true; - // Reset rates to defaults - for (int x = 0; x < MAX_UBX_MSG; x++) + if (settings.ubxMessageRates[0] == 254) { - if (ubxMessages[x].msgClass == UBX_RTCM_MSB) - settings.ubxMessageRates[x] = 0; // For general rover messages, RTCM should be zero by default. - // ubxMessageRatesBase will have the proper defaults. - else - settings.ubxMessageRates[x] = ubxMessages[x].msgDefaultRate; + defaultsApplied = true; + + // Reset rates to defaults + for (int x = 0; x < MAX_UBX_MSG; x++) + { + if (ubxMessages[x].msgClass == UBX_RTCM_MSB) + settings.ubxMessageRates[x] = 0; // For general rover messages, RTCM should be zero by default. + // ubxMessageRatesBase will have the proper defaults. + else + settings.ubxMessageRates[x] = ubxMessages[x].msgDefaultRate; + } } - } - if (settings.ubxMessageRatesBase[0] == 254) - { - defaultsApplied = true; + if (settings.ubxMessageRatesBase[0] == 254) + { + defaultsApplied = true; - // Reset Base rates to defaults - int firstRTCMRecord = zedGetMessageNumberByName("UBX_RTCM_1005"); - for (int x = 0; x < MAX_UBX_MSG_RTCM; x++) - settings.ubxMessageRatesBase[x] = ubxMessages[firstRTCMRecord + x].msgDefaultRate; + // Reset Base rates to defaults + int firstRTCMRecord = zedGetMessageNumberByName("UBX_RTCM_1005"); + for (int x = 0; x < MAX_UBX_MSG_RTCM; x++) + settings.ubxMessageRatesBase[x] = ubxMessages[firstRTCMRecord + x].msgDefaultRate; + } } - - if (settings.um980Constellations[0] == 254) + else if (present.gnss_um980) { - defaultsApplied = true; - // Reset constellations to defaults - for (int x = 0; x < MAX_UM980_CONSTELLATIONS; x++) - settings.um980Constellations[x] = 1; - } + if (settings.um980Constellations[0] == 254) + { + defaultsApplied = true; - if (settings.um980MessageRatesNMEA[0] == 254) - { - defaultsApplied = true; + // Reset constellations to defaults + for (int x = 0; x < MAX_UM980_CONSTELLATIONS; x++) + settings.um980Constellations[x] = 1; + } - // Reset rates to defaults - for (int x = 0; x < MAX_UM980_NMEA_MSG; x++) - settings.um980MessageRatesNMEA[x] = umMessagesNMEA[x].msgDefaultRate; - } + if (settings.um980MessageRatesNMEA[0] == 254) + { + defaultsApplied = true; - if (settings.um980MessageRatesRTCMRover[0] == 254) - { - defaultsApplied = true; + // Reset rates to defaults + for (int x = 0; x < MAX_UM980_NMEA_MSG; x++) + settings.um980MessageRatesNMEA[x] = umMessagesNMEA[x].msgDefaultRate; + } - // For rovers, RTCM should be zero by default. - for (int x = 0; x < MAX_UM980_RTCM_MSG; x++) - settings.um980MessageRatesRTCMRover[x] = 0; - } + if (settings.um980MessageRatesRTCMRover[0] == 254) + { + defaultsApplied = true; - if (settings.um980MessageRatesRTCMBase[0] == 254) - { - defaultsApplied = true; + // For rovers, RTCM should be zero by default. + for (int x = 0; x < MAX_UM980_RTCM_MSG; x++) + settings.um980MessageRatesRTCMRover[x] = 0; + } - // Reset RTCM rates to defaults - for (int x = 0; x < MAX_UM980_RTCM_MSG; x++) - settings.um980MessageRatesRTCMBase[x] = umMessagesRTCM[x].msgDefaultRate; + if (settings.um980MessageRatesRTCMBase[0] == 254) + { + defaultsApplied = true; + + // Reset RTCM rates to defaults + for (int x = 0; x < MAX_UM980_RTCM_MSG; x++) + settings.um980MessageRatesRTCMBase[x] = umMessagesRTCM[x].msgDefaultRate; + } } // If defaults were applied, also default the non-array settings for this particular GNSS receiver