Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Firmware/RTK_Everywhere/AP-Config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@
</div>
</div>

<div id="useMSM7Setting">
<div class="form-check mt-3">
<label class="form-check-label" for="useMSM7">MSM7 RTCM Selection</label>
<input class="form-check-input" type="checkbox" value="" id="useMSM7">
<span class="tt" data-bs-placement="right"
title="Use MSM7 format RTCM mesages. Default: Disabled (MSM4).">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
</div>

<div class="form-check mt-3">
<label class="form-check-label" for="enableNtripClient">Enable NTRIP Client</label>
<input class="form-check-input" type="checkbox" value="" id="enableNtripClient">
Expand Down
5 changes: 5 additions & 0 deletions Firmware/RTK_Everywhere/AP-Config/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function parseIncoming(msg) {
hide("externalPortOptions");
show("logToSDCard");
hide("galileoHasSetting");
hide("useMSM7Setting");
hide("tiltConfig");
hide("beeperControl");
show("measurementRateInput");
Expand Down Expand Up @@ -145,6 +146,7 @@ function parseIncoming(msg) {
show("externalPortOptions");
show("logToSDCard");
hide("galileoHasSetting");
hide("useMSM7Setting");
hide("tiltConfig");
hide("beeperControl");
show("measurementRateInput");
Expand All @@ -165,6 +167,7 @@ function parseIncoming(msg) {
show("externalPortOptions");
show("logToSDCard");
hide("galileoHasSetting");
hide("useMSM7Setting");
hide("tiltConfig");
hide("beeperControl");
hide("measurementRateInput");
Expand Down Expand Up @@ -255,6 +258,7 @@ function parseIncoming(msg) {
show("logToSDCard");

hide("galileoHasSetting");
show("useMSM7Setting");
hide("tiltConfig");
hide("beeperControl");

Expand Down Expand Up @@ -324,6 +328,7 @@ function parseIncoming(msg) {
hide("constellationSbas"); //Not supported on LG290P
show("constellationNavic");
hide("galileoHasSetting"); //Not supported on LG290P
show("useMSM7Setting");
hide("tiltConfig"); //Not supported on Torch X2

show("measurementRateInput");
Expand Down
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1955,10 +1955,10 @@ void tpISR()
{
if (timTpUpdated) // Only sync if timTpUpdated is true - set by storeTIMTPdata on ZED platforms only
{
if (millisNow - lastRTCSync >
if ((millisNow - lastRTCSync) >
syncRTCInterval) // Only sync if it is more than syncRTCInterval since the last sync
{
if (millisNow < (timTpArrivalMillis + 999)) // Only sync if the GNSS time is not stale
if ((millisNow - timTpArrivalMillis) < 999) // Only sync if the GNSS time is not stale
{
if (gnss->isFullyResolved()) // Only sync if GNSS time is fully resolved
{
Expand Down
2 changes: 1 addition & 1 deletion Firmware/RTK_Everywhere/Bluetooth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void bluetoothUpdate()
{
#ifdef COMPILE_BT
static uint32_t lastCheck = millis(); // Check if connected every 100ms
if (millis() > (lastCheck + 100))
if ((millis() - lastCheck) > 100)
{
lastCheck = millis();

Expand Down
6 changes: 3 additions & 3 deletions Firmware/RTK_Everywhere/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void displayUpdate()
if (online.display == true)
{
static unsigned long lastDisplayUpdate = 0;
if (millis() - lastDisplayUpdate > 500 || forceDisplayUpdate == true) // Update display at 2Hz
if (((millis() - lastDisplayUpdate) > 500) || (forceDisplayUpdate == true)) // Update display at 2Hz
{
lastDisplayUpdate = millis();
forceDisplayUpdate = false;
Expand Down Expand Up @@ -2493,7 +2493,7 @@ void paintSystemTest()
if (online.display == true)
{
// Toggle between two displays
if (millis() - systemTestDisplayTime > 3000)
if ((millis() - systemTestDisplayTime) > 3000)
{
systemTestDisplayTime = millis();
systemTestDisplayNumber++;
Expand Down Expand Up @@ -3206,7 +3206,7 @@ void displayWebConfig(std::vector<iconPropertyBlinking> &iconPropertyList)

// Toggle display back and forth for long SSIDs and IPs
// Run the timer no matter what, but load firstHalf/lastHalf with the same thing if strlen < maxWidth
if (millis() - ssidDisplayTimer > 2000)
if ((millis() - ssidDisplayTimer) > 2000)
{
ssidDisplayTimer = millis();
ssidDisplayFirstHalf = !ssidDisplayFirstHalf;
Expand Down
6 changes: 3 additions & 3 deletions Firmware/RTK_Everywhere/ESPNOW.ino
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void espNowUpdate()

// If it's been longer than 50ms since we last added a byte to the buffer
// then we've reached the end of the RTCM stream. Send partial buffer.
if (espNowOutgoingSpot > 0 && (millis() - espNowLastAdd) > 50)
if ((espNowOutgoingSpot > 0) && ((millis() - espNowLastAdd) > 50))
{
if (espNowState == ESPNOW_PAIRED)
esp_now_send(0, (uint8_t *)&espNowOutgoing, espNowOutgoingSpot); // Send partial packet to all peers
Expand All @@ -654,7 +654,7 @@ void espNowUpdate()

// If we don't receive an ESP NOW packet after some time, set RSSI to very negative
// This removes the ESPNOW icon from the display when the link goes down
if (millis() - espNowLastRssiUpdate > 5000 && espNowRSSI > -255)
if (((millis() - espNowLastRssiUpdate) > 5000) && (espNowRSSI > -255))
espNowRSSI = -255;

// The display menu, serial menu, or CLI may request pairing be started
Expand Down Expand Up @@ -682,7 +682,7 @@ void espNowUpdate()
randomSeed(millis());
static unsigned long lastMacSend = millis();
static int timeout = 1000 + random(0, 100); // Pick a random number between 1000 to 1100ms
if (millis() - lastMacSend > timeout)
if ((millis() - lastMacSend) > timeout)
{
lastMacSend = millis();
espNowSendPairMessage(
Expand Down
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/GNSS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void pushGPGGA(char *ggaData)
// Provide the caster with our current position as needed
if (ntripClient->connected() && settings.ntripClient_TransmitGGA == true)
{
if (millis() - lastGGAPush > NTRIPCLIENT_MS_BETWEEN_GGA)
if ((millis() - lastGGAPush) > NTRIPCLIENT_MS_BETWEEN_GGA)
{
lastGGAPush = millis();

Expand Down Expand Up @@ -359,7 +359,7 @@ void gnssFirmwareBeginUpdate()
// Button task will gnssFirmwareRemoveUpdate and restart

// Temporary fix for buttonless Flex. TODO - remove
if ((productVariant == RTK_FLEX) && (millis() > (lastSerial + 30000)))
if ((productVariant == RTK_FLEX) && ((millis() - lastSerial) > 30000))
{
// Beep to indicate exit
beepOn();
Expand Down
36 changes: 28 additions & 8 deletions Firmware/RTK_Everywhere/GNSS_LG290P.ino
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,16 @@ bool GNSS_LG290P::enterConfigMode(unsigned long waitForSemaphoreTimeout_millis)
do
{ // Wait for up to waitForSemaphoreTimeout for library to stop blocking
isBlocking = _lg290p->isBlocking();
} while (isBlocking && (millis() < (start + waitForSemaphoreTimeout_millis)));
} while (isBlocking && ((millis() - start) < waitForSemaphoreTimeout_millis));

// This will fail if the library is still blocking, but it is worth a punt...
return (_lg290p->sendOkCommand("$PQTMCFGPROT",
",W,1,2,00000000,00000000")); // Disable NMEA and RTCM on the LG290P UART2

if (lg290pFirmwareVersion >= 6) // See #747
// Disable NMEA and RTCM on the LG290P UART2, but leave the undocumented Bit 1 enabled
return (_lg290p->sendOkCommand("$PQTMCFGPROT", ",W,1,2,00000007,00000002"));

// Disable NMEA and RTCM on the LG290P UART2
return (_lg290p->sendOkCommand("$PQTMCFGPROT", ",W,1,2,00000000,00000000"));
}
return (false);
}
Expand All @@ -613,8 +618,14 @@ bool GNSS_LG290P::enterConfigMode(unsigned long waitForSemaphoreTimeout_millis)
bool GNSS_LG290P::exitConfigMode()
{
if (online.gnss)
return (_lg290p->sendOkCommand("$PQTMCFGPROT",
",W,1,2,00000005,00000005")); // Enable NMEA and RTCM on the LG290P UART2
{
if (lg290pFirmwareVersion >= 6) // See #747
// Enable NMEA and RTCM on the LG290P UART2, plus the undocumented Bit 1
return (_lg290p->sendOkCommand("$PQTMCFGPROT", ",W,1,2,00000007,00000007"));

// Enable NMEA and RTCM on the LG290P UART2
return (_lg290p->sendOkCommand("$PQTMCFGPROT", ",W,1,2,00000005,00000005"));
}
return (false);
}

Expand Down Expand Up @@ -849,8 +860,10 @@ bool GNSS_LG290P::enableRTCMBase()
systemPrintln("Enabling Base RTCM output");

// PQTMCFGRTCM fails to respond with OK over UART2 of LG290P, so don't look for it
char cfgRtcm[40];
snprintf(cfgRtcm, sizeof(cfgRtcm), "PQTMCFGRTCM,W,%c,0,-90,07,06,2,1", settings.useMSM7 ? '7' : '4');
_lg290p->sendOkCommand(
"PQTMCFGRTCM,W,4,0,-90,07,06,2,1"); // Enable MSM4, output regular intervals, interval (seconds)
cfgRtcm); // Enable MSM4/7, output regular intervals, interval (seconds)
}

return (response);
Expand Down Expand Up @@ -1005,12 +1018,13 @@ bool GNSS_LG290P::enableRTCMRover()
if (settings.debugCorrections)
systemPrintf("Enabling Rover RTCM MSM output with rate of %d\r\n", minimumRtcmRate);

// Enable MSM7 (for faster PPP CSRS results), output at a rate equal to the minimum RTCM rate (EPH Mode = 2)
// Enable MSM4/7 (for faster PPP CSRS results), output at a rate equal to the minimum RTCM rate (EPH Mode = 2)
// PQTMCFGRTCM, W, <MSM_Type>, <MSM_Mode>, <MSM_ElevThd>, <Reserved>, <Reserved>, <EPH_Mode>, <EPH_Interval>
// Set MSM_ElevThd to 15 degrees from rftop suggestion

char msmCommand[40] = {0};
snprintf(msmCommand, sizeof(msmCommand), "PQTMCFGRTCM,W,7,0,15,07,06,2,%d", minimumRtcmRate);
snprintf(msmCommand, sizeof(msmCommand), "PQTMCFGRTCM,W,%c,0,15,07,06,2,%d",
settings.useMSM7 ? '7' : '4', minimumRtcmRate);

// PQTMCFGRTCM fails to respond with OK over UART2 of LG290P, so don't look for it
_lg290p->sendOkCommand(msmCommand);
Expand Down Expand Up @@ -1904,6 +1918,10 @@ void GNSS_LG290P::menuMessages()
systemPrintln("11) Reset to PPP Logging (NMEAx7 / RTCMx4 - 30 second decimation)");
systemPrintln("12) Reset to High-rate PPP Logging (NMEAx7 / RTCMx4 - 1Hz)");


if (namedSettingAvailableOnPlatform("useMSM7")) // Redundant - but good practice for code reuse
systemPrintf("13) MSM Selection: MSM%c\r\n", settings.useMSM7 ? '7' : '4');

systemPrintln("x) Exit");

int incoming = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
Expand Down Expand Up @@ -1977,6 +1995,8 @@ void GNSS_LG290P::menuMessages()
systemPrintln("Reset to PPP Logging Defaults (NMEAx7 / RTCMx4 - 30 second decimation)");
}
}
else if ((incoming == 13) && (namedSettingAvailableOnPlatform("useMSM7"))) // Redundant - but good practice for code reuse)
settings.useMSM7 ^= 1;

else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
break;
Expand Down
24 changes: 13 additions & 11 deletions Firmware/RTK_Everywhere/GNSS_Mosaic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
unsigned long startTime = millis();
size_t replySeen = 0;

while ((millis() < (startTime + timeout)) && (replySeen < strlen(reply))) // While not timed out and reply not seen
while (((millis() - startTime) < timeout) && (replySeen < strlen(reply))) // While not timed out and reply not seen
{
if (serialPort->available()) // If a char is available
{
Expand All @@ -2145,7 +2145,7 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
if (replySeen == strlen(reply)) // If the reply was seen
{
startTime = millis();
while (millis() < (startTime + idle))
while ((millis() - startTime) < idle)
{
if (serialPort->available())
{
Expand Down Expand Up @@ -2256,18 +2256,18 @@ bool GNSS_MOSAIC::sendWithResponse(HardwareSerial *serialPort, const char *messa
}

// If the reply has started to arrive at the timeout, allow extra time
if (millis() > (startTime + timeout)) // Have we timed out?
if ((millis() - startTime) > timeout) // Have we timed out?
if (replySeen == 0) // If replySeen is zero, don't keepGoing
keepGoing = false;

if (millis() > (startTime + timeout + wait)) // Have we really timed out?
if ((millis() - startTime) > (timeout + wait)) // Have we really timed out?
keepGoing = false; // Don't keepGoing
}

if (replySeen == strlen(reply)) // If the reply was seen
{
startTime = millis();
while (millis() < (startTime + wait))
while ((millis() - startTime) < wait)
{
if (serialPort->available())
{
Expand Down Expand Up @@ -2433,6 +2433,8 @@ bool GNSS_MOSAIC::setDataBaudRate(uint32_t baud)
// Set the elevation in degrees
// Inputs:
// elevationDegrees: The elevation value in degrees
// Notes:
// mosaic supports negative elevations, but our firmware only support 0-90
//----------------------------------------
bool GNSS_MOSAIC::setElevation(uint8_t elevationDegrees)
{
Expand Down Expand Up @@ -2795,7 +2797,7 @@ void GNSS_MOSAIC::update()
const unsigned long sdCardSizeCheckInterval = 5000; // Matches the interval in logUpdate
static unsigned long sdCardLastFreeChange = millis(); // X5 is slow to update free. Seems to be about every ~20s?
static uint64_t previousFreeSpace = 0;
if (millis() > (sdCardSizeLastCheck + sdCardSizeCheckInterval))
if ((millis() - sdCardSizeLastCheck) > sdCardSizeCheckInterval)
{
updateSD(); // Check if the card has been removed / inserted

Expand All @@ -2817,7 +2819,7 @@ void GNSS_MOSAIC::update()
// The free space has not changed
// X5 is slow to update free. Seems to be about every ~20s?
// So only set logIncreasing to false after 30s
if (millis() > (sdCardLastFreeChange + 30000))
if ((millis() - sdCardLastFreeChange) > 30000)
logIncreasing = false;
}
else // if (sdFreeSpace > previousFreeSpace)
Expand All @@ -2839,7 +2841,7 @@ void GNSS_MOSAIC::update()

// Update spartnCorrectionsReceived
// Does this need if(online.lband_gnss) ? Not sure... TODO
if (millis() > (lastSpartnReception + (settings.correctionsSourcesLifetime_s * 1000))) // Timeout
if ((millis() - lastSpartnReception) > (settings.correctionsSourcesLifetime_s * 1000)) // Timeout
{
if (spartnCorrectionsReceived) // If corrections were being received
{
Expand Down Expand Up @@ -2920,7 +2922,7 @@ void GNSS_MOSAIC::waitSBFReceiverSetup(HardwareSerial *serialPort, unsigned long
reportFatalError("Failed to initialize the SBF parser");

unsigned long startTime = millis();
while ((millis() < (startTime + timeout)) && (_receiverSetupSeen == false))
while (((millis() - startTime) < timeout) && (_receiverSetupSeen == false))
{
if (serialPort->available())
{
Expand Down Expand Up @@ -3223,7 +3225,7 @@ void mosaicX5flushRX(unsigned long timeout)
if (timeout > 0)
{
unsigned long startTime = millis();
while (millis() < (startTime + timeout))
while ((millis() - startTime) < timeout)
{
if (serial2GNSS->available())
{
Expand All @@ -3247,7 +3249,7 @@ void mosaicX5flushRX(unsigned long timeout)
bool mosaicX5waitCR(unsigned long timeout)
{
unsigned long startTime = millis();
while (millis() < (startTime + timeout))
while ((millis() - startTime) < timeout)
{
if (serial2GNSS->available())
{
Expand Down
12 changes: 7 additions & 5 deletions Firmware/RTK_Everywhere/GNSS_ZED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ bool GNSS_ZED::configureBase()
settings.ubxMessageRatesBase[x]); // UBLOX_CFG UART1 + 2 = USB
}

response &= _zed->addCfgValset(UBLOX_CFG_NAVSPG_INFIL_MINELEV, settings.minElev); // Set minimum elevation
// Set minimum elevation
// Note: ZED supports negative elevations, but our firmware only allows 0-90
response &= _zed->addCfgValset(UBLOX_CFG_NAVSPG_INFIL_MINELEV, settings.minElev);

response &= _zed->sendCfgValset(); // Closing value

Expand Down Expand Up @@ -1375,7 +1377,7 @@ float GNSS_ZED::getSurveyInMeanAccuracy()

// Use a local static so we don't have to request these values multiple times (ZED takes many ms to respond
// to this command)
if (millis() - lastCheck > 1000)
if ((millis() - lastCheck) > 1000)
{
lastCheck = millis();
svinMeanAccuracy = _zed->getSurveyInMeanAccuracy(50);
Expand All @@ -1396,7 +1398,7 @@ int GNSS_ZED::getSurveyInObservationTime()

// Use a local static so we don't have to request these values multiple times (ZED takes many ms to respond
// to this command)
if (millis() - lastCheck > 1000)
if ((millis() - lastCheck) > 1000)
{
lastCheck = millis();
svinObservationTime = _zed->getSurveyInObservationTime(50);
Expand Down Expand Up @@ -2668,7 +2670,7 @@ bool GNSS_ZED::surveyInReset()
while (_zed->getSurveyInActive(100) || _zed->getSurveyInValid(100))
{
delay(100);
if (millis() - startTime > maxTime)
if ((millis() - startTime) > maxTime)
return (false); // Reset of survey failed
}

Expand Down Expand Up @@ -2732,7 +2734,7 @@ bool GNSS_ZED::surveyInStart()
while (_zed->getSurveyInActive(100) == false)
{
delay(100);
if (millis() - startTime > maxTime)
if ((millis() - startTime) > maxTime)
return (false); // Reset of survey failed
}

Expand Down
Loading