Skip to content

Commit 6f62d33

Browse files
committed
Add support for PQTM logging.
Fix #541. This suppresses passing Quectel proprietary messages to circular buffer unless the user explicitly enables the message. Note: Only PVT and EPE messages have been added because these are explicitly turned on during LG290P library initialization. More work will need to be done to support other messages during the LG290P configureRover() type functions.
1 parent 1824402 commit 6f62d33

File tree

5 files changed

+117
-5
lines changed

5 files changed

+117
-5
lines changed

Firmware/RTK_Everywhere/GNSS_LG290P.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ const lg290pMsg lgMessagesRTCM[] = {
5151
{"RTCM3-107X", 1, 0}, {"RTCM3-108X", 1, 0}, {"RTCM3-109X", 1, 0}, {"RTCM3-111X", 1, 0}, {"RTCM3-112X", 1, 0}, {"RTCM3-113X", 1, 0},
5252
};
5353

54+
// Quectel Proprietary messages
55+
const lg290pMsg lgMessagesPQTM[] = {
56+
{"EPE", 0, 0}, {"PVT", 0, 0},
57+
};
58+
5459
#define MAX_LG290P_NMEA_MSG (sizeof(lgMessagesNMEA) / sizeof(lg290pMsg))
5560
#define MAX_LG290P_RTCM_MSG (sizeof(lgMessagesRTCM) / sizeof(lg290pMsg))
61+
#define MAX_LG290P_PQTM_MSG (sizeof(lgMessagesPQTM) / sizeof(lg290pMsg))
5662

5763
enum lg290p_Models
5864
{

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ void GNSS_LG290P::menuMessages()
15741574
systemPrintln("1) Set NMEA Messages");
15751575
systemPrintln("2) Set Rover RTCM Messages");
15761576
systemPrintln("3) Set Base RTCM Messages");
1577+
systemPrintln("4) Set PQTM Messages");
15771578

15781579
systemPrintln("10) Reset to Defaults");
15791580

@@ -1587,6 +1588,8 @@ void GNSS_LG290P::menuMessages()
15871588
menuMessagesSubtype(settings.lg290pMessageRatesRTCMRover, "RTCMRover");
15881589
else if (incoming == 3)
15891590
menuMessagesSubtype(settings.lg290pMessageRatesRTCMBase, "RTCMBase");
1591+
else if (incoming == 4)
1592+
menuMessagesSubtype(settings.lg290pMessageRatesPQTM, "PQTM");
15901593
else if (incoming == 10)
15911594
{
15921595
// Reset rates to defaults
@@ -1601,6 +1604,10 @@ void GNSS_LG290P::menuMessages()
16011604
for (int x = 0; x < MAX_LG290P_RTCM_MSG; x++)
16021605
settings.lg290pMessageRatesRTCMBase[x] = lgMessagesRTCM[x].msgDefaultRate;
16031606

1607+
// Reset PQTM rates to defaults
1608+
for (int x = 0; x < MAX_LG290P_PQTM_MSG; x++)
1609+
settings.lg290pMessageRatesPQTM[x] = lgMessagesPQTM[x].msgDefaultRate;
1610+
16041611
systemPrintln("Reset to Defaults");
16051612
}
16061613

@@ -1638,7 +1645,7 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
16381645
{
16391646
endOfBlock = MAX_LG290P_NMEA_MSG;
16401647

1641-
for (int x = 0; x < MAX_LG290P_NMEA_MSG; x++)
1648+
for (int x = 0; x < endOfBlock; x++)
16421649
{
16431650
if (lg290pFirmwareVersion <= lgMessagesNMEA[x].firmwareVersionSupported)
16441651
systemPrintf("%d) Message %s: %d - Requires firmware update\r\n", x + 1,
@@ -1652,7 +1659,7 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
16521659
{
16531660
endOfBlock = MAX_LG290P_RTCM_MSG;
16541661

1655-
for (int x = 0; x < MAX_LG290P_RTCM_MSG; x++)
1662+
for (int x = 0; x < endOfBlock; x++)
16561663
{
16571664
if (lg290pFirmwareVersion <= lgMessagesRTCM[x].firmwareVersionSupported)
16581665
systemPrintf("%d) Message %s: %d - Requires firmware update\r\n", x + 1,
@@ -1666,16 +1673,30 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
16661673
{
16671674
endOfBlock = MAX_LG290P_RTCM_MSG;
16681675

1669-
for (int x = 0; x < MAX_LG290P_RTCM_MSG; x++)
1676+
for (int x = 0; x < endOfBlock; x++)
16701677
{
16711678
if (lg290pFirmwareVersion <= lgMessagesRTCM[x].firmwareVersionSupported)
1672-
systemPrintf("%d) Message %s: %d - Requires firmware update\r\n", x + 1, lgMessagesRTCM[x].msgTextName,
1673-
settings.lg290pMessageRatesRTCMBase[x]);
1679+
systemPrintf("%d) Message %s: %d - Requires firmware update\r\n", x + 1,
1680+
lgMessagesRTCM[x].msgTextName, settings.lg290pMessageRatesRTCMBase[x]);
16741681
else
16751682
systemPrintf("%d) Message %s: %d\r\n", x + 1, lgMessagesRTCM[x].msgTextName,
16761683
settings.lg290pMessageRatesRTCMBase[x]);
16771684
}
16781685
}
1686+
else if (strcmp(messageType, "PQTM") == 0)
1687+
{
1688+
endOfBlock = MAX_LG290P_PQTM_MSG;
1689+
1690+
for (int x = 0; x < endOfBlock; x++)
1691+
{
1692+
if (lg290pFirmwareVersion <= lgMessagesPQTM[x].firmwareVersionSupported)
1693+
systemPrintf("%d) Message %s: %d - Requires firmware update\r\n", x + 1,
1694+
lgMessagesPQTM[x].msgTextName, settings.lg290pMessageRatesPQTM[x]);
1695+
else
1696+
systemPrintf("%d) Message %s: %d\r\n", x + 1, lgMessagesPQTM[x].msgTextName,
1697+
settings.lg290pMessageRatesPQTM[x]);
1698+
}
1699+
}
16791700

16801701
systemPrintln("x) Exit");
16811702

@@ -1698,6 +1719,11 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
16981719
sprintf(messageString, "Enter number of fixes required before %s is reported (0 to disable)",
16991720
lgMessagesRTCM[incoming].msgTextName);
17001721
}
1722+
else if (strcmp(messageType, "PQTM") == 0)
1723+
{
1724+
sprintf(messageString, "Enter number of fixes required before %s is reported (0 to disable)",
1725+
lgMessagesPQTM[incoming].msgTextName);
1726+
}
17011727

17021728
int newSetting = 0;
17031729

@@ -1718,6 +1744,11 @@ void GNSS_LG290P::menuMessagesSubtype(int *localMessageRate, const char *message
17181744
if (getNewSetting(messageString, 0, 1200, &newSetting) == INPUT_RESPONSE_VALID)
17191745
settings.lg290pMessageRatesRTCMBase[incoming] = newSetting;
17201746
}
1747+
if (strcmp(messageType, "PQTM") == 0)
1748+
{
1749+
if (getNewSetting(messageString, 0, 1, &newSetting) == INPUT_RESPONSE_VALID)
1750+
settings.lg290pMessageRatesPQTM[incoming] = newSetting;
1751+
}
17211752
}
17221753
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
17231754
break;
@@ -2134,3 +2165,56 @@ void lg290pReset()
21342165
{
21352166
digitalWrite(pin_GNSS_Reset, LOW);
21362167
}
2168+
2169+
// Given a NMEA or PQTM sentence, determine if it is enabled in settings
2170+
// This is used to signal to the processUart1Message() task to remove messages that are needed
2171+
// by the library to function (ie, PQTMEPE, PQTMPVT, GNGSV) but should not be logged or passed to other consumers
2172+
// If unknown, allow messages through. Filtering and suppression should be selectively added in.
2173+
bool lg290pMessageEnabled(char *nmeaSentence, int sentenceLength)
2174+
{
2175+
// Identify message type: PQTM or NMEA
2176+
char messageType[strlen("PQTM") + 1] = {0};
2177+
strncpy(messageType, &nmeaSentence[1],
2178+
4); // Copy four letters, starting in spot 1. Null terminated from array initializer.
2179+
2180+
if (strncmp(messageType, "PQTM", sizeof(messageType)) == 0)
2181+
{
2182+
// Identify sentence type
2183+
char sentenceType[strlen("EPE") + 1] = {0};
2184+
strncpy(sentenceType, &nmeaSentence[5],
2185+
3); // Copy three letters, starting in spot 5. Null terminated from array initializer.
2186+
2187+
// Find this sentence type in the settings array
2188+
for (int messageNumber = 0; messageNumber < MAX_LG290P_PQTM_MSG; messageNumber++)
2189+
{
2190+
if (strncmp(lgMessagesPQTM[messageNumber].msgTextName, sentenceType, sizeof(sentenceType)) == 0)
2191+
{
2192+
if (settings.lg290pMessageRatesPQTM[messageNumber] > 0)
2193+
return (true);
2194+
return (false);
2195+
}
2196+
}
2197+
}
2198+
2199+
else // We have to assume $G????
2200+
{
2201+
// Identify sentence type
2202+
char sentenceType[strlen("GSV") + 1] = {0};
2203+
strncpy(sentenceType, &nmeaSentence[3],
2204+
3); // Copy three letters, starting in spot 3. Null terminated from array initializer.
2205+
2206+
// Find this sentence type in the settings array
2207+
for (int messageNumber = 0; messageNumber < MAX_LG290P_NMEA_MSG; messageNumber++)
2208+
{
2209+
if (strncmp(lgMessagesNMEA[messageNumber].msgTextName, sentenceType, sizeof(sentenceType)) == 0)
2210+
{
2211+
if (settings.lg290pMessageRatesNMEA[messageNumber] > 0)
2212+
return (true);
2213+
return (false);
2214+
}
2215+
}
2216+
}
2217+
2218+
// If we can't ID this message, allow it by default. The device configuration should control most message flow.
2219+
return (true);
2220+
}

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,16 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
641641
{
642642
// Give this data to the library to update its internal variables
643643
lg290pHandler(parse->buffer, parse->length);
644+
645+
if (type == RTK_NMEA_PARSER_INDEX)
646+
{
647+
// Suppress PQTM/NMEA messages as needed
648+
if (lg290pMessageEnabled((char *)parse->buffer, parse->length) == false)
649+
{
650+
parse->buffer[0] = 0;
651+
parse->length = 0;
652+
}
653+
}
644654
}
645655

646656
// Handle LLA compensation due to tilt or outputTipAltitude setting

Firmware/RTK_Everywhere/menuMessages.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,16 @@ void checkGNSSArrayDefaults()
705705
for (int x = 0; x < MAX_LG290P_RTCM_MSG; x++)
706706
settings.lg290pMessageRatesRTCMBase[x] = lgMessagesRTCM[x].msgDefaultRate;
707707
}
708+
709+
if (settings.lg290pMessageRatesPQTM[0] == 254)
710+
{
711+
defaultsApplied = true;
712+
713+
// Reset rates to defaults
714+
for (int x = 0; x < MAX_LG290P_PQTM_MSG; x++)
715+
settings.lg290pMessageRatesPQTM[x] = lgMessagesPQTM[x].msgDefaultRate;
716+
}
717+
708718
}
709719
#endif // COMPILE_LG290P
710720

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ struct Settings
997997
int lg290pMessageRatesRTCMRover[MAX_LG290P_RTCM_MSG] = {
998998
254}; // Mark first record with key so defaults will be applied. Int value for each supported message - Report
999999
// rates for RTCM Base. Default to Quectel recommended rates.
1000+
int lg290pMessageRatesPQTM[MAX_LG290P_PQTM_MSG] = {254}; // Mark first record with key so defaults will be applied.
10001001
#endif // COMPILE_LG290P
10011002

10021003
bool debugSettings = false;
@@ -1606,6 +1607,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
16061607
{ 0, 1, 1, 0, 0, 0, 0, 0, 1, tLgMRNmea, MAX_LG290P_NMEA_MSG, & settings.lg290pMessageRatesNMEA, "messageRateNMEA_", },
16071608
{ 0, 1, 1, 0, 0, 0, 0, 0, 1, tLgMRBaRT, MAX_LG290P_RTCM_MSG, & settings.lg290pMessageRatesRTCMBase, "messageRateRTCMBase_", },
16081609
{ 0, 1, 1, 0, 0, 0, 0, 0, 1, tLgMRRvRT, MAX_LG290P_RTCM_MSG, & settings.lg290pMessageRatesRTCMRover, "messageRateRTCMRover_", },
1610+
{ 0, 1, 1, 0, 0, 0, 0, 0, 1, tLgMRNmea, MAX_LG290P_PQTM_MSG, & settings.lg290pMessageRatesPQTM, "messageRatePQTM_", },
16091611
#endif // COMPILE_LG290P
16101612

16111613
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.debugSettings, "debugSettings", },

0 commit comments

Comments
 (0)