-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Prompted by #806 and this forum post:
I suspect applyCompensationGGA can cause the GGA LF (Line Feed) to be truncated...!
I'm still thinking this through, so bear with me.
Two Postcard users have reported the LF being truncated after upgrading to firmware 2.3. Doing a factory reset (s r y) appears to clear the issue.
Could it be dependent on settings.outputTipAltitude?
nmeaApplyCompensation is called on all NMEA messages:
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tasks.ino
Lines 892 to 896 in 191c2b6
| // Handle LLA compensation due to tilt or outputTipAltitude setting | |
| if (type == RTK_NMEA_PARSER_INDEX) | |
| { | |
| nmeaApplyCompensation((char *)parse->buffer, parse->length); | |
| } |
If settings.outputTipAltitude is true then applyCompensationGGA is always called (even if tiltIsCorrecting() is false):
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tilt.ino
Lines 427 to 440 in 191c2b6
| // If tilt is off, and outputTipAltitude is disabled, then pass GNSS data without modification | |
| if (tiltIsCorrecting() == false && settings.outputTipAltitude == false) | |
| return; | |
| // Identify sentence type | |
| char sentenceType[strlen("GGA") + 1] = {0}; | |
| strncpy(sentenceType, &nmeaSentence[3], | |
| 3); // Copy three letters, starting in spot 3. Null terminated from array initializer. | |
| // GGA and GNS sentences get modified in the same way | |
| if (strncmp(sentenceType, "GGA", sizeof(sentenceType)) == 0) | |
| { | |
| applyCompensationGGA(nmeaSentence, sentenceLength); | |
| } |
The altitude is extracted and converted to float:
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tilt.ino
Lines 916 to 919 in 191c2b6
| // Extract the altitude | |
| char altitudeStr[strlen("-1602.3481") + 1]; // 4 decimals | |
| strncpy(altitudeStr, &nmeaSentence[altitudeStart], altitudeStop - altitudeStart); | |
| float altitude = (float)atof(altitudeStr); |
newAltitude is altitude minus antennaHeight_mm + antennaPhaseCenter_mm:
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tilt.ino
Lines 985 to 987 in 191c2b6
| // If tilt is off and outputTipAltitude is enabled, then subtract pole+ARP from altitude | |
| if (settings.outputTipAltitude == true) | |
| newAltitude = altitude - ((settings.antennaHeight_mm + settings.antennaPhaseCenter_mm) / 1000.0); |
newAltitude is always written and always with 4 decimal places:
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tilt.ino
Lines 992 to 996 in 191c2b6
| // Convert altitude double to string | |
| snprintf(coordinateStringDDMM, sizeof(coordinateStringDDMM), "%0.4f", newAltitude); | |
| // Add tilt-compensated Altitude | |
| strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1); |
From #806, the LG290P is only outputting 3 decimal places. Because 4 are written, the altitude will always be one character longer.
There is a debug warning. But you would only see it if enableImuCompensationDebug is enabled:
SparkFun_RTK_Everywhere_Firmware/Firmware/RTK_Everywhere/Tilt.ino
Lines 1012 to 1017 in 191c2b6
| if (strlen(newSentence) > sentenceLength) | |
| { | |
| if (settings.enableImuCompensationDebug == true && !inMainMenu) | |
| systemPrintf("New compensated sentence too long! Orig: %d New: %d\r\n", sentenceLength, | |
| strlen(newSentence)); | |
| } |
Long story short, the LF gets truncated...