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
2 changes: 1 addition & 1 deletion .github/workflows/build-for-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
env:
FILENAME_PREFIX: RTK_mosaic-T_Firmware
FIRMWARE_VERSION_MAJOR: 1
FIRMWARE_VERSION_MINOR: 0
FIRMWARE_VERSION_MINOR: 1
CORE_VERSION: 3.0.1

jobs:
Expand Down
28 changes: 28 additions & 0 deletions Firmware/RTK_mosaic-T_Firmware/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ void beginBoard()
pin_errorLED = 32;
pin_lockLED = 33;

pin_serial0TX_Alt = 23;
pin_serial0RX_Alt = 34;
pin_serial1TX = 14;
pin_serial1RX = 13;
pin_serial1CTS = 26;
Expand Down Expand Up @@ -174,6 +176,32 @@ void beginBoard()
}
}

void beginConsole(uint32_t baud, bool allowAlt)
{
// Don't try to print here. serialConsole may not have been initialized

if ((!allowAlt) || (!settings.enableTCPServer))
{
serialConsole.begin(baud, SERIAL_8N1, pin_serial0RX, pin_serial0TX);
}
else
{
if ((pin_serial0RX_Alt < 0) || (pin_serial0TX_Alt < 0))
{
reportFatalError("No Serial0 Alt pins");
}
else
{
serialConsole.begin(baud, SERIAL_8N1, pin_serial0RX_Alt, pin_serial0TX_Alt);
}
}

delay(10);

while (serialConsole.available())
serialConsole.read();
}

// We want the UART1 interrupts to be pinned to core 0 to avoid competing with I2C interrupts
// We do not start the UART1 here because the interrupts would be pinned to core 1
// We instead start a task that runs on core 0, that then begins serial
Expand Down
12 changes: 10 additions & 2 deletions Firmware/RTK_mosaic-T_Firmware/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@ void updateDisplay()
oled->print(textLine);
yPos += 8;

snprintf(textLine, sizeof(textLine), "IP %s",
gnssIP.toString().c_str());
if ((settings.enableTCPServer) && ((gnssSecond % 4) > 1)) // Print TCP Port for two seconds
{
snprintf(textLine, sizeof(textLine), "IP TCP Port %d",
settings.tcpServerPort);
}
else
{
snprintf(textLine, sizeof(textLine), "IP %s",
gnssIP.toString().c_str());
}
oled->setCursor(0, yPos);
oled->print(textLine);
yPos += 8;
Expand Down
63 changes: 62 additions & 1 deletion Firmware/RTK_mosaic-T_Firmware/GNSS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ bool initializeGNSS()
return false;
}

// Configure COM3 for daisy chain to IPS1
if (!sendWithResponse("sdio, COM3, DC1, DC2\n\r", "DataInOut"))
{
systemPrintln("GNSS FAIL (DataInOut COM3)");
return false;
}

if (!sendWithResponse("sso, Stream1, COM1, Group1, sec1\n\r", "SBFOutput"))
{
systemPrintln("GNSS FAIL (SBFOutput Stream1)");
Expand Down Expand Up @@ -218,7 +225,7 @@ bool configureGNSSPPS()

systemPrintln("Configuring GNSS PPS");

String ppsParams = String("setPPSParameters, ");
String ppsParams = String("spps, ");
ppsParams += String(mosaicPPSParametersInterval[settings.ppsInterval]) + String(", ");
ppsParams += String(mosaicPPSParametersPolarity[settings.ppsPolarity]) + String(", ");
ppsParams += String(settings.ppsDelay_ns) + String(", ");
Expand Down Expand Up @@ -246,3 +253,57 @@ bool configureGNSSPPS()
return true;
}

bool configureGNSSTCPServer()
{
if (!online.gnss)
return false;

systemPrintln("Configuring GNSS TCP Server");

String tcpParams = String("siss, IPS1, ");

if (settings.enableTCPServer)
{
tcpParams += String(settings.tcpServerPort) + String(", TCP2Way\n\r");
}
else
{
tcpParams += String("0\n\r");
}

int retries = 3;

while (!sendWithResponse(tcpParams, "IPServerSettings") && (retries > 0))
{
systemPrintln("No response from mosaic. Retrying - with escape sequence...");
sendWithResponse("SSSSSSSSSSSSSSSSSSSS\n\r", "COM4>"); // Send escape sequence
retries--;
}

if (retries == 0)
{
systemPrintln("GNSS FAIL (IPServerSettings)");
return false;
}

// Configure IPS1
if (settings.enableTCPServer)
{
if (!sendWithResponse("sdio, IPS1, DC2, DC1\n\r", "DataInOut"))
{
systemPrintln("GNSS FAIL (DataInOut IPS1)");
return false;
}
}
else
{
if (!sendWithResponse("sdio, IPS1, none, none\n\r", "DataInOut"))
{
systemPrintln("GNSS FAIL (DataInOut IPS1)");
return false;
}
}

systemPrintln("GNSS TCP Server configured");
return true;
}
7 changes: 7 additions & 0 deletions Firmware/RTK_mosaic-T_Firmware/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ void recordSystemSettingsToFile(File *settingsFile)
settingsFile->printf("%s=%0.3e\r\n", "Ik", settings.Ik);
settingsFile->printf("%s=%d\r\n", "preferNonCompositeGPSBias", settings.preferNonCompositeGPSBias);
settingsFile->printf("%s=%d\r\n", "preferNonCompositeGalileoBias", settings.preferNonCompositeGalileoBias);
settingsFile->printf("%s=%d\r\n", "enableTCPServer", settings.enableTCPServer);
settingsFile->printf("%s=%d\r\n", "tcpServerPort", settings.tcpServerPort);


//settingsFile->printf("%s=%d\r\n", "", settings.);

Expand Down Expand Up @@ -366,6 +369,10 @@ bool parseLine(char *str, Settings *settings)
settings->preferNonCompositeGPSBias = d;
else if (strcmp(settingName, "preferNonCompositeGalileoBias") == 0)
settings->preferNonCompositeGalileoBias = d;
else if (strcmp(settingName, "enableTCPServer") == 0)
settings->enableTCPServer = d;
else if (strcmp(settingName, "tcpServerPort") == 0)
settings->tcpServerPort = d;

//else if (strcmp(settingName, "") == 0)
// settings-> = d;
Expand Down
56 changes: 44 additions & 12 deletions Firmware/RTK_mosaic-T_Firmware/RTK_mosaic-T_Firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
Set the board to "ESP32 Wrover Module"

Settings are pulled from ESP32's file system LittleFS.

Version history:
1.0: Initial release
1.1: Add TCP support
The console can be accessed via TCP (COM3 is daisy chained to IPS1)
On the v1.0 PCB, link:
mosaic COM3 TX (TX3) to ESP32 GPIO 34
mosaic COM3 RX (RX3) to ESP32 GPIO 23
*/

// This is passed in from compiler extra flags
Expand Down Expand Up @@ -49,6 +57,12 @@
int pin_errorLED = -1;
int pin_lockLED = -1;

const int pin_serial0TX = 1;
const int pin_serial0RX = 3;

int pin_serial0TX_Alt = -1;
int pin_serial0RX_Alt = -1;

int pin_serial1TX = -1;
int pin_serial1RX = -1;
int pin_serial1CTS = -1;
Expand Down Expand Up @@ -142,6 +156,7 @@ GPS_PARSE_TABLE;
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

#include <driver/uart.h> // Required for uart_set_rx_full_threshold() on cores <v2.0.5
HardwareSerial serialConsole(0); // Use UART0 for Console
HardwareSerial serialGNSS(1); // Use UART1 for GNSS
HardwareSerial serialGNSSConfig(2); // Use UART2 for GNSS configuration

Expand Down Expand Up @@ -311,7 +326,7 @@ void setup()
{
initializeGlobals(); // Initialize any global variables that can't be given default values

Serial.begin(115200); // UART0 for programming and debugging
beginConsole(115200, false); // UART0 for programming and debugging. Don't allow Alt pins to be used yet
systemPrintln();
systemPrintln();

Expand Down Expand Up @@ -370,9 +385,15 @@ void setup()
DMW_c("beginGNSS");
beginGNSS(); // Connect to GNSS

Serial.flush(); // Complete any previous prints
DMW_c("configureGNSSTCPServer");
configureGNSSTCPServer(); // Configure TCP

systemPrintf("Boot time: %d\r\n", millis());

if (settings.enableTCPServer)
systemPrintf("TCP Server is enabled. Please connect on port %d to view the console\r\n", settings.tcpServerPort);

beginConsole(115200, true); // Swap to Alt pins if TCP is enabled
}

void loop()
Expand Down Expand Up @@ -402,22 +423,30 @@ void loop()
// Once we have a fix, sync system clock to GNSS
void updateRTC()
{
static uint16_t syncAge = 0;

static bool firstTime = true;
if (firstTime)
{
gnssTimeUpdated[0] = false; // This ensures gnssTimeUpdated[0] isn't stale
firstTime = false;
}

if (online.rtc == false) // Only do this if the rtc has not been sync'd previously
if (online.gnss == true) // Only do this if the GNSS is online
{
if (online.gnss == true) // Only do this if the GNSS is online
if (gnssTimeUpdated[0]) // Only do this if we have fresh time
{
if (gnssTimeUpdated[0])
{
gnssTimeUpdated[0] = false;
gnssTimeUpdated[0] = false;

syncAge++; // Update syncAge every second
if (syncAge == 3600) // Wrap every hour
syncAge = 0;

if (gnssWNSet && gnssToWSet && gnssFineTime)
if (gnssWNSet && gnssToWSet && gnssFineTime) // Only do this if FineTime is set
{
// Only do this if the rtc has not been sync'd previously
// or if it is an hour since the last sync
if ((online.rtc == false) || (syncAge == 0))
{
// To perform the time zone adjustment correctly, it's easiest if we convert the GNSS time and date
// into Unix epoch first and then correct for the arrival time
Expand All @@ -432,11 +461,14 @@ void updateRTC()

online.rtc = true;

systemPrint("System time set to: ");
systemPrintln(rtc.getDateTime(true));
if (settings.enablePrintRtcSync)
{
systemPrint("System time set to: ");
systemPrintln(rtc.getDateTime(true));
}
}
}
} // End online.gnss
} // End online.rtc
}
}
}

2 changes: 1 addition & 1 deletion Firmware/RTK_mosaic-T_Firmware/System.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void reportHeap()
{
if (settings.enableHeapReport == true)
{
if (millis() - lastHeapReport > 1000)
if (millis() - lastHeapReport >= settings.periodicPrintInterval_ms)
{
reportHeapNow(false);
}
Expand Down
13 changes: 10 additions & 3 deletions Firmware/RTK_mosaic-T_Firmware/Tasks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ void gnssReadTask(void *e)
while (true)
{
if ((settings.enableTaskReports == true) && !inMainMenu)
systemPrintf("SerialReadTask High watermark: %d\r\n", uxTaskGetStackHighWaterMark(nullptr));
{
static unsigned long lastPrint = 0;
if (millis() > (lastPrint + settings.periodicPrintInterval_ms))
{
systemPrintf("SerialReadTask High watermark: %d\r\n", uxTaskGetStackHighWaterMark(nullptr));
lastPrint = millis();
}
}

while (serialGNSS.available())
{
Expand Down Expand Up @@ -710,11 +717,11 @@ void ButtonCheckTask(void *e)
{
setupBtn->read();

if (setupBtn->isPressed()) // Switch is set to base mode
if (setupBtn->isPressed())
{
// Do stuff... Maybe change the display?
}
else if (setupBtn->wasReleased()) // Switch is set to Rover
else if (setupBtn->wasReleased())
{
// Do stuff... Maybe change the display?
}
Expand Down
7 changes: 7 additions & 0 deletions Firmware/RTK_mosaic-T_Firmware/menuMain.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ void menuMain()
printUnknown(incoming);
}

configureGNSSTCPServer(); // Configure TCP

if (settings.enableTCPServer)
systemPrintf("TCP Server is enabled. Please connect on port %d to view the console\r\n", settings.tcpServerPort);

beginConsole(115200, true); // Swap to Alt pins if TCP is enabled

recordSystemSettings(); // Once all menus have exited, record the new settings to LittleFS and config file

clearBuffer(); // Empty buffer of any newline chars
Expand Down
32 changes: 29 additions & 3 deletions Firmware/RTK_mosaic-T_Firmware/menuSystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ void menuOperation()
systemPrint("13) Pulse-Per-Second Pulse Width (ms): ");
systemPrintln(settings.ppsPulseWidth_ms);

systemPrint("14) TCP Server (IPS1): ");
systemPrintf("%s\r\n", settings.enableTCPServer ? "Enabled" : "Disabled");

systemPrint("15) TCP Server Port: ");
systemPrintln(settings.tcpServerPort);

systemPrintln("\r\nx) Exit");

byte incoming = getCharacterNumber();
Expand Down Expand Up @@ -534,6 +540,25 @@ void menuOperation()
ppsStarted = false; // Restart PPS afterwards
}
}
else if (incoming == 14)
{
settings.enableTCPServer ^= 1;
}
else if (incoming == 15)
{
systemPrint("Enter the TCP Server Port: ");
int port = getNumber(); // Returns EXIT, TIMEOUT, or long
if ((port != INPUT_RESPONSE_GETNUMBER_EXIT) &&
(port != INPUT_RESPONSE_GETNUMBER_TIMEOUT))
{
if (port < 1 || port > 65534)
systemPrintln("Error: Port is out of range");
else
{
settings.tcpServerPort = port;
}
}
}
// Menu exit control
else if (incoming == 'x')
break;
Expand Down Expand Up @@ -563,12 +588,13 @@ void printCurrentConditions(bool CSV)
firstTime = false;
}

systemPrintf("%04d/%02d/%02d,%02d:%02d:%02d",
gnssYear, gnssMonth, gnssDay, gnssHour, gnssMinute, gnssSecond);

uint32_t epochSecs;
uint32_t epochMillis;
convertGnssTimeToEpoch(&epochSecs, &epochMillis);

systemPrintf("%04d/%02d/%02d,%02d:%02d:%02d",
gnssYear, gnssMonth, gnssDay, gnssHour, gnssMinute, gnssSecond);

systemPrintf(",%lu.%03lu", epochSecs, epochMillis);

systemPrint(",");
Expand Down
Loading