Skip to content

Commit

Permalink
Add soft and hard reset
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulZC committed Sep 24, 2024
1 parent c578b1d commit ac0a63b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Firmware/RTK_mosaic-T_Firmware/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void displayGNSSFail(uint16_t displayTime)

void displayBadBias(uint16_t displayTime)
{
displayMessage("Bad RxClkBias. Restarting...", displayTime);
displayMessage("Bad RxClkBias ---------- Restarting", displayTime);
}

void displayNoRingBuffer(uint16_t displayTime)
Expand Down
24 changes: 21 additions & 3 deletions Firmware/RTK_mosaic-T_Firmware/GNSS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,33 @@ void beginGNSS()
online.gnss = true;
}

// Kickstart the GNSS timing system - e.g. to resync on bad bias
bool setTimingSystem()
// Kickstart the GNSS - e.g. to resync on bad bias
bool gnssSoftReset()
{
if (!online.gnss)
return false;

int retries = 3; // GNSS is already begun. We shouldn't need to retry.

while (!sendWithResponse("sts,auto\n\r", "TimingSystem") && (retries > 0)) // Set timing system to auto
while (!sendWithResponse("erst,Soft,PVTData\n\r", "ResetReceiver") && (retries > 0)) // Soft reset - erase PVT data
{
systemPrintln("No response from mosaic. Retrying - with escape sequence...");
sendWithResponse("SSSSSSSSSSSSSSSSSSSS\n\r", "COM4>"); // Send escape sequence
retries--;
}

return (retries > 0);
}

// Revert to boot configuration
bool gnssHardReset()
{
if (!online.gnss)
return false;

int retries = 3; // GNSS is already begun. We shouldn't need to retry.

while (!sendWithResponse("erst,Hard\n\r", "ResetReceiver") && (retries > 0)) // Hard reset - revert to boot configuration
{
systemPrintln("No response from mosaic. Retrying - with escape sequence...");
sendWithResponse("SSSSSSSSSSSSSSSSSSSS\n\r", "COM4>"); // Send escape sequence
Expand Down
4 changes: 2 additions & 2 deletions Firmware/RTK_mosaic-T_Firmware/States.ino
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ void updateSystemState()
{
clkBiasLimitCount = 0; // Reset the counts before changing state
badBiasCount = 0;
displayBadBias(1000);
setTimingSystem(); // Kickstart the timing system
displayBadBias(2000);
gnssSoftReset(); // Kickstart the timing system
changeState(STATE_GNSS_CONFIGURED);
}
}
Expand Down
2 changes: 2 additions & 0 deletions Firmware/RTK_mosaic-T_Firmware/menuMain.ino
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void factoryReset(bool alreadyHasSemaphore)
{
displaySytemReset(); // Display friendly message on OLED

gnssHardReset(); // Probably redundant as initializeGNSS() will be called on restart

tasksStopUART1();

systemPrintln("Formatting internal file system...");
Expand Down
2 changes: 2 additions & 0 deletions Firmware/RTK_mosaic-T_Firmware/menuSystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ void menuDebugSoftware()
{
recordSystemSettings();

gnssHardReset();

ESP.restart();
}
else if (incoming == 'x')
Expand Down

0 comments on commit ac0a63b

Please sign in to comment.