Skip to content

Commit 825057b

Browse files
authored
Merge pull request #331 from LeeLeahy2/rtcm-corrections
Enable input of RTCM correction data over USB serial
2 parents b07fea7 + d14f2a1 commit 825057b

File tree

3 files changed

+85
-28
lines changed

3 files changed

+85
-28
lines changed

Firmware/RTK_Everywhere/Display.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,16 @@ void setRadioIcons(std::vector<iconPropertyBlinking> *iconList)
792792
}
793793
}
794794

795+
if (usbSerialIncomingRtcm)
796+
{
797+
// Download : Columns 59 - 66
798+
iconPropertyBlinking prop;
799+
prop.icon = DownloadArrow128x64;
800+
prop.duty = 0b11111111;
801+
iconList->push_back(prop);
802+
usbSerialIncomingRtcm = false;
803+
}
804+
795805
if (wifiState == WIFI_STATE_CONNECTED)
796806
{
797807
if (netIncomingRTCM == true) // Download : Columns 59 - 66

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ const byte haeNumberOfDecimals = 8; // Used for printing and transmitting lat/
392392
bool lBandForceGetKeys; // Used to allow key update from display
393393
unsigned long rtcmLastPacketReceived; // Time stamp of RTCM coming in (from BT, NTRIP, etc)
394394
// Monitors the last time we received RTCM. Proctors PMP vs RTCM prioritization.
395+
396+
bool usbSerialIncomingRtcm; // Incoming RTCM over the USB serial port
397+
#define RTCM_CORRECTION_INPUT_TIMEOUT (2 * 1000)
395398
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
396399

397400
// GNSS configuration - UM980

Firmware/RTK_Everywhere/menuMain.ino

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// Report status if ~ received, otherwise present config menu
33
void terminalUpdate()
44
{
5+
char buffer[128];
56
static uint32_t lastPeriodicDisplay;
7+
int length;
8+
static bool passRtcmToGnss;
9+
static uint32_t rtcmTimer;
610

711
// Determine which items are periodically displayed
812
if ((millis() - lastPeriodicDisplay) >= settings.periodicDisplayInterval)
@@ -16,45 +20,85 @@ void terminalUpdate()
1620
{
1721
byte incoming = systemRead();
1822

19-
if (incoming == '~')
23+
// Is this the start of an RTCM correction message
24+
if (incoming == 0xd3)
2025
{
21-
// Output custom GNTXT message with all current system data
22-
printCurrentConditionsNMEA();
26+
// Enable RTCM reception
27+
passRtcmToGnss = true;
28+
29+
// Start the RTCM timer
30+
rtcmTimer = millis();
31+
rtcmLastPacketReceived = rtcmTimer;
32+
33+
// Tell the display about the serial RTCM message
34+
usbSerialIncomingRtcm = true;
35+
36+
// Read the beginning of the RTCM correction message
37+
buffer[0] = incoming;
38+
length = Serial.readBytes(&buffer[1], sizeof(buffer) - 1) + 1;
39+
40+
// Push RTCM to GNSS module over I2C / SPI
41+
gnssPushRawData((uint8_t *)buffer, length);
2342
}
24-
else
43+
44+
// Does incoming data consist of RTCM correction messages
45+
if (passRtcmToGnss && ((millis() - rtcmTimer) < RTCM_CORRECTION_INPUT_TIMEOUT))
2546
{
26-
// When outputting GNSS data to USB serial, check for +++
27-
if (forwardGnssDataToUsbSerial)
28-
{
29-
static uint32_t plusTimeout;
30-
static uint8_t plusCount;
47+
// Renew the RTCM timer
48+
rtcmTimer = millis();
49+
rtcmLastPacketReceived = rtcmTimer;
3150

32-
// Reset plusCount on timeout
33-
if ((millis() - plusTimeout) > PLUS_PLUS_PLUS_TIMEOUT)
34-
plusCount = 0;
51+
// Tell the display about the serial RTCM message
52+
usbSerialIncomingRtcm = true;
3553

36-
// Check for + input
37-
if (incoming != '+')
38-
{
39-
// Must start over looking for +++
40-
plusCount = 0;
41-
return;
42-
}
54+
// Read more of the RTCM correction message
55+
buffer[0] = incoming;
56+
length = Serial.readBytes(&buffer[1], sizeof(buffer) - 1) + 1;
57+
58+
// Push RTCM to GNSS module over I2C / SPI
59+
gnssPushRawData((uint8_t *)buffer, length);
60+
}
61+
else
62+
{
63+
// Allow regular serial input
64+
passRtcmToGnss = false;
65+
66+
if (incoming == '~')
67+
{
68+
// Output custom GNTXT message with all current system data
69+
printCurrentConditionsNMEA();
70+
}
71+
else
72+
{
73+
// When outputting GNSS data to USB serial, check for +++
74+
if (!forwardGnssDataToUsbSerial)
75+
menuMain(); // Present user menu
4376
else
4477
{
45-
// + entered, check for the +++ sequence
46-
plusCount++;
47-
if (plusCount < 3)
78+
static uint32_t plusTimeout;
79+
static uint8_t plusCount;
80+
81+
// Reset plusCount on timeout
82+
if ((millis() - plusTimeout) > PLUS_PLUS_PLUS_TIMEOUT)
83+
plusCount = 0;
84+
85+
// Check for + input
86+
if (incoming != '+')
87+
// Must start over looking for +++
88+
plusCount = 0;
89+
else
4890
{
49-
// Restart the timeout
50-
plusTimeout = millis();
51-
return;
91+
// + entered, check for the +++ sequence
92+
plusCount++;
93+
if (plusCount < 3)
94+
// Restart the timeout
95+
plusTimeout = millis();
96+
else
97+
// +++ was entered, display the main menu
98+
menuMain(); // Present user menu
5299
}
53-
54-
// +++ was entered, display the main menu
55100
}
56101
}
57-
menuMain(); // Present user menu
58102
}
59103
}
60104
}

0 commit comments

Comments
 (0)