Skip to content

v1.6 - Fix Stability Issues #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 20, 2021
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
29 changes: 21 additions & 8 deletions Firmware/RTK_Surveyor/Base.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ bool configureUbloxModuleBase()
}
}

#define OUTPUT_SETTING 14

//Turn on RTCM so that we can harvest RTCM over I2C and send out over WiFi
//This is easier than parsing over UART because the library handles the frame detection
getPortSettings(COM_PORT_I2C); //Load the settingPayload with this port's settings
if (settingPayload[OUTPUT_SETTING] != (COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3))
response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); //Set the I2C port to output UBX (config), and RTCM3 (casting)
//response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_RTCM3); //Not a valid state. Goes to UBX+NMEA+RTCM3 -

//In base mode the Surveyor should output RTCM over UART2 and I2C ports:
//(Primary) UART2 in case the Surveyor is connected via radio to rover
//(Optional) I2C in case user wants base to connect to WiFi and NTRIP Serve to Caster
Expand Down Expand Up @@ -90,10 +99,10 @@ bool beginSurveyIn()
//Wait until active becomes true
long maxTime = 5000;
long startTime = millis();
while(i2cGNSS.getSurveyInActive(100) == false)
while (i2cGNSS.getSurveyInActive(100) == false)
{
delay(100);
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
if (millis() - startTime > maxTime) return (false); //Reset of survey failed
}

return (true);
Expand All @@ -110,19 +119,19 @@ bool resetSurvey()
delay(1000);
response &= i2cGNSS.disableSurveyMode(maxWait); //Disable survey

if(response == false)
return(response);
if (response == false)
return (response);

//Wait until active and valid becomes false
long maxTime = 5000;
long startTime = millis();
while(i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
while (i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
{
delay(100);
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
if (millis() - startTime > maxTime) return (false); //Reset of survey failed
}

return(true);
return (true);
}

//Start the base using fixed coordinates
Expand Down Expand Up @@ -203,7 +212,11 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
}

//Check for too many digits
if (logIncreasing == true)
if (settings.enableResetDisplay == true)
{
if (rtcmPacketsSent > 99) rtcmPacketsSent = 1; //Trim to two digits to avoid overlap
}
else if (logIncreasing == true)
{
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid log icon
}
Expand Down
31 changes: 23 additions & 8 deletions Firmware/RTK_Surveyor/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void beginBoard()

//Bug in ZED-F9P v1.13 firmware causes RTK LED to not light when RTK Floating with SBAS on.
//The following changes the POR default but will be overwritten by settings in NVM or settings file
ubxConstellations[1].enabled = false;
settings.ubxConstellations[1].enabled = false;

strcpy(platformFilePrefix, "SFE_Surveyor");
strcpy(platformPrefix, "Surveyor");
Expand Down Expand Up @@ -112,14 +112,25 @@ void beginBoard()
if (esp_reset_reason() == ESP_RST_POWERON)
{
reuseLastLog = false; //Start new log
settings.resetCount = 0;
recordSystemSettings(); //Record to NVM

loadSettingsPartial();
if (settings.enableResetDisplay == true)
{
settings.resetCount = 0;
recordSystemSettings(); //Record to NVM
}
}
else
{
reuseLastLog = true; //Attempt to reuse previous log
settings.resetCount++;
recordSystemSettings(); //Record to NVM

loadSettingsPartial();
if (settings.enableResetDisplay == true)
{
settings.resetCount++;
recordSystemSettings(); //Record to NVM
Serial.printf("resetCount: %d\n\r", settings.resetCount);
}

Serial.print("Reset reason: ");
switch (esp_reset_reason())
Expand Down Expand Up @@ -196,6 +207,9 @@ void beginSD()
}

online.microSD = true;

Serial.println(F("microSD online"));
scanForFirmware(); //See if SD card contains new firmware that should be loaded at startup
}
else
{
Expand All @@ -214,7 +228,7 @@ void beginUART2()
"UARTStart", //Just for humans
2000, //Stack Size
NULL, //Task input parameter
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
&pinUART2TaskHandle, //Task handle
0); //Core where task should run, 0=core, 1=Arduino

Expand All @@ -225,9 +239,9 @@ void beginUART2()
//Assign UART2 interrupts to the core 0. See: https://github.com/espressif/arduino-esp32/issues/3386
void pinUART2Task( void *pvParameters )
{
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
serialGNSS.setRxBufferSize(SERIAL_SIZE_RX);
serialGNSS.setTimeout(50);
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.

uart2pinned = true;

Expand Down Expand Up @@ -336,6 +350,7 @@ void beginGNSS()

printModuleInfo(); //Print module type and firmware version
}

online.gnss = true;
}

Expand Down Expand Up @@ -460,6 +475,6 @@ void beginSystemState()
"BtnCheck", //Just for humans
buttonTaskStackSize, //Stack Size
NULL, //Task input parameter
ButtonCheckTaskPriority, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
ButtonCheckTaskPriority,
&ButtonCheckTaskHandle); //Task handle
}
38 changes: 31 additions & 7 deletions Firmware/RTK_Surveyor/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void updateDisplay()
displayWiFiConfig(); //Display SSID and IP
break;
case (STATE_TEST):
//Do nothing
paintSystemTest();
break;
case (STATE_TESTING):
paintSystemTest();
Expand Down Expand Up @@ -445,12 +445,7 @@ void paintSIV()
oled.print(i2cGNSS.getSIV());
}

if (settings.enableResetDisplay == true)
{
oled.setFontType(0); //Small font
oled.setCursor(16 + (8 * 3) + 6, 38); //x, y
oled.print(settings.resetCount);
}
paintResets();
}
}

Expand Down Expand Up @@ -646,6 +641,8 @@ void paintBaseTempTransmitting()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -680,6 +677,8 @@ void paintBaseTempWiFiStarted()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -715,6 +714,8 @@ void paintBaseTempWiFiConnected()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -776,6 +777,8 @@ void paintBaseTempCasterConnected()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -822,6 +825,8 @@ void paintBaseFixedTransmitting()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -856,6 +861,8 @@ void paintBaseFixedWiFiStarted()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -891,6 +898,8 @@ void paintBaseFixedWiFiConnected()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -952,6 +961,8 @@ void paintBaseFixedCasterConnected()
oled.setFontType(1); //Set font to type 1: 8x16
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()

paintResets();

paintLogging();
}
}
Expand Down Expand Up @@ -1558,3 +1569,16 @@ void displayMessage(const char* message, uint16_t displayTime)
delay(displayTime);
}
}

void paintResets()
{
if (online.display == true)
{
if (settings.enableResetDisplay == true)
{
oled.setFontType(0); //Small font
oled.setCursor(16 + (8 * 3) + 6, 38); //x, y
oled.print(settings.resetCount);
}
}
}
26 changes: 16 additions & 10 deletions Firmware/RTK_Surveyor/Form.ino
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ void startConfigAP()
#ifdef COMPILE_WIFI
static void handleFirmwareFileUpload(AsyncWebServerRequest *request, String fileName, size_t index, uint8_t *data, size_t len, bool final)
{
if(online.microSD == false)
{
Serial.println(F("No SD card available"));
return;
}

//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_longWait_ms) != pdPASS) {
Serial.println(F("Failed to get file system lock on firmware file"));
Expand Down Expand Up @@ -243,13 +249,13 @@ void createSettingsString(char* settingsCSV)
//GNSS Config
stringRecord(settingsCSV, "measurementRateHz", 1000.0 / settings.measurementRate, 2); //2 = decimals to print
stringRecord(settingsCSV, "dynamicModel", settings.dynamicModel);
stringRecord(settingsCSV, "ubxConstellationsGPS", ubxConstellations[0].enabled); //GPS
stringRecord(settingsCSV, "ubxConstellationsSBAS", ubxConstellations[1].enabled); //SBAS
stringRecord(settingsCSV, "ubxConstellationsGalileo", ubxConstellations[2].enabled); //Galileo
stringRecord(settingsCSV, "ubxConstellationsBeiDou", ubxConstellations[3].enabled); //BeiDou
stringRecord(settingsCSV, "ubxConstellationsGLONASS", ubxConstellations[5].enabled); //GLONASS
stringRecord(settingsCSV, "ubxConstellationsGPS", settings.ubxConstellations[0].enabled); //GPS
stringRecord(settingsCSV, "ubxConstellationsSBAS", settings.ubxConstellations[1].enabled); //SBAS
stringRecord(settingsCSV, "ubxConstellationsGalileo", settings.ubxConstellations[2].enabled); //Galileo
stringRecord(settingsCSV, "ubxConstellationsBeiDou", settings.ubxConstellations[3].enabled); //BeiDou
stringRecord(settingsCSV, "ubxConstellationsGLONASS", settings.ubxConstellations[5].enabled); //GLONASS
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
stringRecord(settingsCSV, ubxMessages[x].msgTextName, ubxMessages[x].msgRate);
stringRecord(settingsCSV, settings.ubxMessages[x].msgTextName, settings.ubxMessages[x].msgRate);

//Base Config
stringRecord(settingsCSV, "baseTypeSurveyIn", !settings.fixedBase);
Expand Down Expand Up @@ -394,11 +400,11 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
{
char tempString[50]; //ubxConstellationsSBAS
sprintf(tempString, "ubxConstellations%s", ubxConstellations[x].textName);
sprintf(tempString, "ubxConstellations%s", settings.ubxConstellations[x].textName);

if (strcmp(settingName, tempString) == 0)
{
ubxConstellations[x].enabled = settingValueBool;
settings.ubxConstellations[x].enabled = settingValueBool;
knownSetting = true;
break;
}
Expand All @@ -410,9 +416,9 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
{
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
{
if (strcmp(settingName, ubxMessages[x].msgTextName) == 0)
if (strcmp(settingName, settings.ubxMessages[x].msgTextName) == 0)
{
ubxMessages[x].msgRate = settingValue;
settings.ubxMessages[x].msgRate = settingValue;
knownSetting = true;
break;
}
Expand Down
Loading