@@ -2229,137 +2229,3 @@ bool lg290pMessageEnabled(char *nmeaSentence, int sentenceLength)
22292229 // If we can't ID this message, allow it by default. The device configuration should control most message flow.
22302230 return (true );
22312231}
2232-
2233- // Re-create the GST sentence to increase the horizontal and vertical precision number of decimals
2234- // ie, 0.0 becomes 0.009
2235- // See issue: https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/issues/513
2236- // $GNGST,223954.500,1.7,1.5,1.0,109.3,1.412,1.055,2.4*7E
2237- // Modifies the sentence length with new length
2238- void lg290pModifyGst (char *nmeaSentence, uint16_t *sentenceLength)
2239- {
2240- // This issue currently only applies to LG290P firmware version 4
2241- // Version 3 does not support GST messages. Version 5 should fix the issue.
2242- if (lg290pFirmwareVersion != 4 )
2243- return ;
2244-
2245- if (online.gnss == false )
2246- return ;
2247-
2248- // Only apply the GST patch if our HPA is very small (<0.1m), ie RTK Float or Fix.
2249- if (gnss->isRTKFix () == false && gnss->isRTKFloat () == false )
2250- return ;
2251-
2252- GNSS_LG290P *lg290p = (GNSS_LG290P *)gnss;
2253-
2254- // Identify sentence type
2255- char sentenceType[strlen (" GST" ) + 1 ] = {0 };
2256- strncpy (sentenceType, &nmeaSentence[3 ],
2257- 3 ); // Copy three letters, starting in spot 3. Null terminated from array initializer.
2258-
2259- // We only care about GST sentences
2260- if (strncmp (sentenceType, " GST" , sizeof (sentenceType)) != 0 )
2261- return ;
2262-
2263- const int latitudeErrorComma = 6 ;
2264- const int longitudeErrorComma = 7 ;
2265- const int altitudeErrorComma = 8 ;
2266-
2267- uint8_t latitudeStart = 0 ;
2268- uint8_t latitudeStop = 0 ;
2269- uint8_t longitudeStart = 0 ;
2270- uint8_t longitudeStop = 0 ;
2271- uint8_t altitudeStart = 0 ;
2272- uint8_t checksumStart = 0 ;
2273-
2274- if (settings.enableImuCompensationDebug == true && !inMainMenu)
2275- systemPrintf (" Original GNGST:\r\n %s\r\n " , nmeaSentence);
2276-
2277- int commaCount = 0 ;
2278- for (int x = 0 ; x < strnlen (nmeaSentence, *sentenceLength); x++) // Assumes sentence is null terminated
2279- {
2280- if (nmeaSentence[x] == ' ,' )
2281- {
2282- commaCount++;
2283- if (commaCount == latitudeErrorComma)
2284- latitudeStart = x + 1 ;
2285- if (commaCount == latitudeErrorComma + 1 )
2286- latitudeStop = x;
2287- if (commaCount == longitudeErrorComma)
2288- longitudeStart = x + 1 ;
2289- if (commaCount == longitudeErrorComma + 1 )
2290- longitudeStop = x;
2291- if (commaCount == altitudeErrorComma)
2292- altitudeStart = x + 1 ;
2293- }
2294- if (nmeaSentence[x] == ' *' )
2295- {
2296- checksumStart = x;
2297- break ;
2298- }
2299- }
2300-
2301- if (latitudeStart == 0 || latitudeStop == 0 || longitudeStart == 0 || longitudeStop == 0 || altitudeStart == 0 ||
2302- checksumStart == 0 )
2303- {
2304- systemPrintln (" Delineator not found" );
2305- return ;
2306- }
2307-
2308- char newSentence[150 ] = {0 };
2309-
2310- if (sizeof (newSentence) < *sentenceLength)
2311- {
2312- systemPrintln (" newSentence not big enough!" );
2313- return ;
2314- }
2315-
2316- char errorString[strlen (" 0.000" ) + 1 ] = {0 };
2317-
2318- // strncat terminates
2319-
2320- // Add start of message up to latitude
2321- strncat (newSentence, nmeaSentence, latitudeStart);
2322-
2323- // Convert error from EPE message to string. We don't have pure lat error, only 2D and 3D.
2324- snprintf (errorString, sizeof (errorString), " %0.3f" , lg290p->getHorizontalAccuracy ());
2325-
2326- // Add latitude error
2327- strncat (newSentence, errorString, sizeof (newSentence) - 1 );
2328-
2329- // Add interstitial between end of lat and beginning of lon
2330- strncat (newSentence, nmeaSentence + latitudeStop, longitudeStart - latitudeStop);
2331-
2332- // Add same error for longitude error
2333- strncat (newSentence, errorString, sizeof (newSentence) - 1 );
2334-
2335- // Add interstitial between end of lon and beginning of alt
2336- strncat (newSentence, nmeaSentence + longitudeStop, altitudeStart - longitudeStop);
2337-
2338- // Convert error from EPE message to string. We don't have pure altitude error, use double 2D error as stand-in.
2339- snprintf (errorString, sizeof (errorString), " %0.3f" , lg290p->getHorizontalAccuracy () * 2 );
2340-
2341- // Add altitude error. We don't really have altitude so use 3D error in its place.
2342- strncat (newSentence, errorString, sizeof (newSentence) - 1 );
2343-
2344- // From: http://engineeringnotes.blogspot.com/2015/02/generate-crc-for-nmea-strings-arduino.html
2345- byte CRC = 0 ; // XOR chars between '$' and '*'
2346- for (byte x = 1 ; x < strlen (newSentence); x++)
2347- CRC = CRC ^ newSentence[x];
2348-
2349- // Convert CRC to string, add * and CR LF
2350- snprintf (errorString, sizeof (errorString), " *%02X\r\n " , CRC);
2351-
2352- // Add CRC
2353- strncat (newSentence, errorString, sizeof (newSentence) - 1 );
2354-
2355- // Increase length of sentence
2356- *sentenceLength = strlen (newSentence);
2357-
2358- // Overwrite the original NMEA
2359- strncpy (nmeaSentence, newSentence, *sentenceLength);
2360-
2361- nmeaSentence[*sentenceLength] = ' \0 ' ; // Terminate string
2362-
2363- if (settings.enableImuCompensationDebug == true && !inMainMenu)
2364- systemPrintf (" Corrected GNGST:\r\n %s\r\n " , nmeaSentence);
2365- }
0 commit comments