2
2
// Report status if ~ received, otherwise present config menu
3
3
void terminalUpdate ()
4
4
{
5
+ char buffer[128 ];
5
6
static uint32_t lastPeriodicDisplay;
7
+ int length;
8
+ static bool passRtcmToGnss;
9
+ static uint32_t rtcmTimer;
6
10
7
11
// Determine which items are periodically displayed
8
12
if ((millis () - lastPeriodicDisplay) >= settings.periodicDisplayInterval )
@@ -16,45 +20,85 @@ void terminalUpdate()
16
20
{
17
21
byte incoming = systemRead ();
18
22
19
- if (incoming == ' ~' )
23
+ // Is this the start of an RTCM correction message
24
+ if (incoming == 0xd3 )
20
25
{
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);
23
42
}
24
- else
43
+
44
+ // Does incoming data consist of RTCM correction messages
45
+ if (passRtcmToGnss && ((millis () - rtcmTimer) < RTCM_CORRECTION_INPUT_TIMEOUT))
25
46
{
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;
31
50
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 ;
35
53
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
43
76
else
44
77
{
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
48
90
{
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
52
99
}
53
-
54
- // +++ was entered, display the main menu
55
100
}
56
101
}
57
- menuMain (); // Present user menu
58
102
}
59
103
}
60
104
}
0 commit comments