Skip to content

Commit ab57f25

Browse files
committed
Limit allowable baud rate settings for GNSS receivers
LG290P has more stringent requirements. Port menu was allowing LG290P to be set to illegal values.
1 parent ab48039 commit ab57f25

File tree

11 files changed

+147
-21
lines changed

11 files changed

+147
-21
lines changed

Firmware/RTK_Everywhere/GNSS.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class GNSS
6868
// Reset to Low Bandwidth Link (1074/1084/1094/1124 0.5Hz & 1005/1230 0.1Hz)
6969
virtual void baseRtcmLowDataRate();
7070

71+
// Check if a given baud rate is supported by this module
72+
virtual bool baudIsAllowed(uint32_t baudRate);
73+
virtual uint32_t baudGetMinimum();
74+
virtual uint32_t baudGetMaximum();
75+
7176
// Connect to GNSS and identify particulars
7277
virtual void begin();
7378

Firmware/RTK_Everywhere/GNSS_LG290P.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ typedef struct
2626
const char msgTextName[11];
2727
const float msgDefaultRate;
2828
const uint8_t firmwareVersionSupported; // The minimum version this message is supported.
29-
// 0 = all versions.
30-
// 9999 = Not supported
29+
// 0 = all versions.
30+
// 9999 = Not supported
3131
} lg290pMsg;
3232

3333
// Static array containing all the compatible messages
3434
// Rate = Output once every N position fix(es).
3535
const lg290pMsg lgMessagesNMEA[] = {
36-
{"RMC", 1, 0}, {"GGA", 1, 0}, {"GSV", 1, 0}, {"GSA", 1, 0}, {"VTG", 1, 0}, {"GLL", 1, 0},
37-
{"GBS", 0, 4}, {"GNS", 0, 4}, {"GST", 1, 4}, {"ZDA", 0, 4},
36+
{"RMC", 1, 0}, {"GGA", 1, 0}, {"GSV", 1, 0}, {"GSA", 1, 0}, {"VTG", 1, 0},
37+
{"GLL", 1, 0}, {"GBS", 0, 4}, {"GNS", 0, 4}, {"GST", 1, 4}, {"ZDA", 0, 4},
3838
};
3939

4040
const lg290pMsg lgMessagesRTCM[] = {
@@ -44,16 +44,18 @@ const lg290pMsg lgMessagesRTCM[] = {
4444

4545
{"RTCM3-1020", 0, 0},
4646

47-
{"RTCM3-1033", 0, 4}, //v4 and above
47+
{"RTCM3-1033", 0, 4}, // v4 and above
4848

4949
{"RTCM3-1041", 0, 0}, {"RTCM3-1042", 0, 0}, {"RTCM3-1044", 0, 0}, {"RTCM3-1046", 0, 0},
5050

51-
{"RTCM3-107X", 1, 0}, {"RTCM3-108X", 1, 0}, {"RTCM3-109X", 1, 0}, {"RTCM3-111X", 1, 0}, {"RTCM3-112X", 1, 0}, {"RTCM3-113X", 1, 0},
51+
{"RTCM3-107X", 1, 0}, {"RTCM3-108X", 1, 0}, {"RTCM3-109X", 1, 0}, {"RTCM3-111X", 1, 0},
52+
{"RTCM3-112X", 1, 0}, {"RTCM3-113X", 1, 0},
5253
};
5354

5455
// Quectel Proprietary messages
5556
const lg290pMsg lgMessagesPQTM[] = {
56-
{"EPE", 0, 0}, {"PVT", 0, 0},
57+
{"EPE", 0, 0},
58+
{"PVT", 0, 0},
5759
};
5860

5961
#define MAX_LG290P_NMEA_MSG (sizeof(lgMessagesNMEA) / sizeof(lg290pMsg))
@@ -125,6 +127,11 @@ class GNSS_LG290P : GNSS
125127
// Reset to Low Bandwidth Link (1074/1084/1094/1124 0.5Hz & 1005/1230 0.1Hz)
126128
void baseRtcmLowDataRate();
127129

130+
// Check if a given baud rate is supported by this module
131+
bool baudIsAllowed(uint32_t baudRate);
132+
uint32_t baudGetMinimum();
133+
uint32_t baudGetMaximum();
134+
128135
// Connect to GNSS and identify particulars
129136
void begin();
130137

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ bool GNSS_LG290P::configureBase()
392392
// If the device is set to Survey-In, we must allow the device to be configured.
393393
// Otherwise PQTMEPE (estimated position error) is never populated, so the survey
394394
// never starts (Waiting for Horz Accuracy < 2.00m...)
395-
if (settings.fixedBase == false) //Not a fixed base = Survey-in
395+
if (settings.fixedBase == false) // Not a fixed base = Survey-in
396396
{
397397
if (settings.gnssConfiguredBase)
398398
{
@@ -2267,6 +2267,30 @@ void GNSS_LG290P::update()
22672267
// We don't check serial data here; the gnssReadTask takes care of serial consumption
22682268
}
22692269

2270+
//----------------------------------------
2271+
// Check if given baud rate is allowed
2272+
//----------------------------------------
2273+
const uint32_t lg290pAllowedRates[] = {9600, 115200, 230400, 460800, 921600};
2274+
const int lg290pAllowedRatesCount = sizeof(lg290pAllowedRates) / sizeof(lg290pAllowedRates[0]);
2275+
2276+
bool GNSS_LG290P::baudIsAllowed(uint32_t baudRate)
2277+
{
2278+
for (int x = 0; x < lg290pAllowedRatesCount; x++)
2279+
if (lg290pAllowedRates[x] == baudRate)
2280+
return (true);
2281+
return (false);
2282+
}
2283+
2284+
uint32_t GNSS_LG290P::baudGetMinimum()
2285+
{
2286+
return (lg290pAllowedRates[0]);
2287+
}
2288+
2289+
uint32_t GNSS_LG290P::baudGetMaximum()
2290+
{
2291+
return (lg290pAllowedRates[lg290pAllowedRatesCount - 1]);
2292+
}
2293+
22702294
//----------------------------------------
22712295
void lg290pBoot()
22722296
{

Firmware/RTK_Everywhere/GNSS_Mosaic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ class GNSS_MOSAIC : GNSS
618618
// Reset to Low Bandwidth Link (MSM4 0.5Hz & 1005/1033 0.1Hz)
619619
void baseRtcmLowDataRate();
620620

621+
// Check if a given baud rate is supported by this module
622+
bool baudIsAllowed(uint32_t baudRate);
623+
uint32_t baudGetMinimum();
624+
uint32_t baudGetMaximum();
625+
621626
// Connect to GNSS and identify particulars
622627
void begin();
623628

Firmware/RTK_Everywhere/GNSS_Mosaic.ino

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,6 +2844,26 @@ void GNSS_MOSAIC::waitSBFReceiverSetup(unsigned long timeout)
28442844
sempStopParser(&sbfParse);
28452845
}
28462846

2847+
//----------------------------------------
2848+
// Check if given baud rate is allowed
2849+
//----------------------------------------
2850+
bool GNSS_MOSAIC::baudIsAllowed(uint32_t baudRate)
2851+
{
2852+
for (int x = 0; x < MAX_MOSAIC_COM_RATES; x++)
2853+
if (mosaicComRates[x].rate == baudRate) return (true);
2854+
return (false);
2855+
}
2856+
2857+
uint32_t GNSS_MOSAIC::baudGetMinimum()
2858+
{
2859+
return (mosaicComRates[0].rate);
2860+
}
2861+
2862+
uint32_t GNSS_MOSAIC::baudGetMaximum()
2863+
{
2864+
return (mosaicComRates[MAX_MOSAIC_COM_RATES - 1].rate);
2865+
}
2866+
28472867
//==========================================================================
28482868
// Parser support routines
28492869
//==========================================================================

Firmware/RTK_Everywhere/GNSS_None.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ class GNSS_None : public GNSS
4747
{
4848
}
4949

50+
// Check if a given baud rate is supported by this module
51+
bool baudIsAllowed(uint32_t baudRate) {
52+
return false;
53+
}
54+
uint32_t baudGetMinimum() {
55+
return 0;
56+
}
57+
uint32_t baudGetMaximum() {
58+
return 0;
59+
}
60+
5061
// Connect to GNSS and identify particulars
5162
void begin()
5263
{

Firmware/RTK_Everywhere/GNSS_UM980.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ class GNSS_UM980 : GNSS
171171
// Reset to Low Bandwidth Link (1074/1084/1094/1124 0.5Hz & 1005/1230 0.1Hz)
172172
void baseRtcmLowDataRate();
173173

174+
// Check if a given baud rate is supported by this module
175+
bool baudIsAllowed(uint32_t baudRate);
176+
uint32_t baudGetMinimum();
177+
uint32_t baudGetMaximum();
178+
174179
// Connect to GNSS and identify particulars
175180
void begin();
176181

Firmware/RTK_Everywhere/GNSS_UM980.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,31 @@ bool GNSS_UM980::surveyInStart()
19031903
return false;
19041904
}
19051905

1906+
//----------------------------------------
1907+
// Check if given baud rate is allowed
1908+
//----------------------------------------
1909+
const uint32_t um980AllowedRates[] = {9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600};
1910+
const int um980AllowedRatesCount = sizeof(um980AllowedRates) / sizeof(um980AllowedRates[0]);
1911+
1912+
bool GNSS_UM980::baudIsAllowed(uint32_t baudRate)
1913+
{
1914+
for (int x = 0; x < um980AllowedRatesCount; x++)
1915+
if (um980AllowedRates[x] == baudRate)
1916+
return (true);
1917+
return (false);
1918+
}
1919+
1920+
uint32_t GNSS_UM980::baudGetMinimum()
1921+
{
1922+
return (um980AllowedRates[0]);
1923+
}
1924+
1925+
uint32_t GNSS_UM980::baudGetMaximum()
1926+
{
1927+
return (um980AllowedRates[um980AllowedRatesCount - 1]);
1928+
}
1929+
1930+
19061931
//----------------------------------------
19071932
// If we have received serial data from the UM980 outside of the Unicore library (ie, from processUart1Message task)
19081933
// we can pass data back into the Unicore library to allow it to update its own variables

Firmware/RTK_Everywhere/GNSS_ZED.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ class GNSS_ZED : GNSS
395395
// Reset to Low Bandwidth Link (1074/1084/1094/1124 0.5Hz & 1005/1230 0.1Hz)
396396
virtual void baseRtcmLowDataRate();
397397

398+
// Check if a given baud rate is supported by this module
399+
bool baudIsAllowed(uint32_t baudRate);
400+
uint32_t baudGetMinimum();
401+
uint32_t baudGetMaximum();
402+
398403
// Connect to GNSS and identify particulars
399404
void begin();
400405

Firmware/RTK_Everywhere/GNSS_ZED.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,6 +2812,29 @@ void GNSS_ZED::updateCorrectionsSource(uint8_t source)
28122812
//_zed->softwareResetGNSSOnly(); // Restart the GNSS? Not sure if this helps...
28132813
}
28142814

2815+
//----------------------------------------
2816+
// Check if given baud rate is allowed
2817+
//----------------------------------------
2818+
const uint32_t zedAllowedRates[] = {4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600};
2819+
const int zedAllowedRatesCount = sizeof(zedAllowedRates) / sizeof(zedAllowedRates[0]);
2820+
2821+
bool GNSS_ZED::baudIsAllowed(uint32_t baudRate)
2822+
{
2823+
for (int x = 0; x < zedAllowedRatesCount; x++)
2824+
if (zedAllowedRates[x] == baudRate) return (true);
2825+
return (false);
2826+
}
2827+
2828+
uint32_t GNSS_ZED::baudGetMinimum()
2829+
{
2830+
return (zedAllowedRates[0]);
2831+
}
2832+
2833+
uint32_t GNSS_ZED::baudGetMaximum()
2834+
{
2835+
return (zedAllowedRates[zedAllowedRatesCount - 1]);
2836+
}
2837+
28152838
// When new PMP message arrives from NEO-D9S push it back to ZED-F9P
28162839
void pushRXMPMP(UBX_RXM_PMP_message_data_t *pmpData)
28172840
{

0 commit comments

Comments
 (0)