Skip to content

Commit 11079e3

Browse files
committed
Add overlength debug messages
1 parent 420f8a9 commit 11079e3

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

Firmware/RTK_Everywhere/Tilt.ino

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ void applyCompensationGNS(char *nmeaSentence, int arraySize)
473473
uint8_t undulationStop = 0;
474474
uint8_t checksumStart = 0;
475475

476+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
477+
systemPrintf("Original GNGNS:\r\n%s\r\n", nmeaSentence);
478+
476479
int commaCount = 0;
477480
for (int x = 0; x < strnlen(nmeaSentence, arraySize); x++) // Assumes sentence is null terminated
478481
{
@@ -606,8 +609,17 @@ void applyCompensationGNS(char *nmeaSentence, int arraySize)
606609
// Add CRC
607610
strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1);
608611

612+
if (strlen(newSentence) > arraySize)
613+
{
614+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
615+
systemPrintf("New compensated sentence too long! Orig: %d New: %d\r\n", arraySize, strlen(newSentence));
616+
}
617+
609618
// Overwrite the original NMEA
610619
strncpy(nmeaSentence, newSentence, arraySize);
620+
621+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
622+
systemPrintf("Compensated GNGNS:\r\n%s\r\n", nmeaSentence);
611623
}
612624

613625
// Modify a GLL sentence with tilt compensation
@@ -619,6 +631,9 @@ void applyCompensationGLL(char *nmeaSentence, int arraySize)
619631
if (tiltIsCorrecting() == false)
620632
return;
621633

634+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
635+
systemPrintf("Original GNGLL:\r\n%s\r\n", nmeaSentence);
636+
622637
char coordinateStringDDMM[strlen("10511.12345678") + 1] = {0}; // UM980 outputs 8 decimals in GGA sentence
623638

624639
const int latitudeComma = 1;
@@ -700,8 +715,17 @@ void applyCompensationGLL(char *nmeaSentence, int arraySize)
700715
// Add CRC
701716
strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1);
702717

718+
if (strlen(newSentence) > arraySize)
719+
{
720+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
721+
systemPrintf("New compensated sentence too long! Orig: %d New: %d\r\n", arraySize, strlen(newSentence));
722+
}
723+
703724
// Overwrite the original NMEA
704725
strncpy(nmeaSentence, newSentence, arraySize);
726+
727+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
728+
systemPrintf("Compensated GNGLL:\r\n%s\r\n", nmeaSentence);
705729
}
706730

707731
// Modify a RMC sentence with tilt compensation
@@ -713,6 +737,9 @@ void applyCompensationRMC(char *nmeaSentence, int arraySize)
713737
if (tiltIsCorrecting() == false)
714738
return;
715739

740+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
741+
systemPrintf("Original GNRMC:\r\n%s\r\n", nmeaSentence);
742+
716743
char coordinateStringDDMM[strlen("10511.12345678") + 1] = {0}; // UM980 outputs 8 decimals in GGA sentence
717744

718745
const int latitudeComma = 3;
@@ -794,8 +821,17 @@ void applyCompensationRMC(char *nmeaSentence, int arraySize)
794821
// Add CRC
795822
strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1);
796823

824+
if (strlen(newSentence) > arraySize)
825+
{
826+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
827+
systemPrintf("New compensated sentence too long! Orig: %d New: %d\r\n", arraySize, strlen(newSentence));
828+
}
829+
797830
// Overwrite the original NMEA
798831
strncpy(nmeaSentence, newSentence, arraySize);
832+
833+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
834+
systemPrintf("Compensated GNRMC:\r\n%s\r\n", nmeaSentence);
799835
}
800836

801837
// Modify a GGA sentence with tilt compensation
@@ -825,7 +861,7 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
825861
uint8_t checksumStart = 0;
826862

827863
if (settings.enableImuCompensationDebug == true && !inMainMenu)
828-
systemPrintf("Original GNGGA: %s\r\n", nmeaSentence);
864+
systemPrintf("Original GNGGA:\r\n%s\r\n", nmeaSentence);
829865

830866
int commaCount = 0;
831867
for (int x = 0; x < strnlen(nmeaSentence, arraySize); x++) // Assumes sentence is null terminated
@@ -941,7 +977,7 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
941977
}
942978

943979
// Convert altitude double to string
944-
snprintf(coordinateStringDDMM, sizeof(coordinateStringDDMM), "%0.3f", newAltitude);
980+
snprintf(coordinateStringDDMM, sizeof(coordinateStringDDMM), "%0.4f", newAltitude);
945981

946982
// Add tilt-compensated Altitude
947983
strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1);
@@ -960,11 +996,17 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
960996
// Add CRC
961997
strncat(newSentence, coordinateStringDDMM, sizeof(newSentence) - 1);
962998

999+
if (strlen(newSentence) > arraySize)
1000+
{
1001+
if (settings.enableImuCompensationDebug == true && !inMainMenu)
1002+
systemPrintf("New compensated sentence too long! Orig: %d New: %d\r\n", arraySize, strlen(newSentence));
1003+
}
1004+
9631005
// Overwrite the original NMEA
9641006
strncpy(nmeaSentence, newSentence, arraySize);
9651007

9661008
if (settings.enableImuCompensationDebug == true && !inMainMenu)
967-
systemPrintf("Compensated GNGGA: %s\r\n", nmeaSentence);
1009+
systemPrintf("Compensated GNGGA:\r\n%s\r\n", nmeaSentence);
9681010
}
9691011

9701012
#endif // COMPILE_IM19_IMU

Firmware/RTK_Everywhere/menuSystem.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,9 +1385,7 @@ void menuInstrument()
13851385

13861386
if (getNewSetting("Enter the antenna height (a.k.a. pole length) in meters", -15.0, 15.0, &antennaHeight) ==
13871387
INPUT_RESPONSE_VALID)
1388-
{
13891388
settings.antennaHeight_mm = truncf(antennaHeight * 1000.0);
1390-
}
13911389
}
13921390
else if (incoming == 2)
13931391
{

0 commit comments

Comments
 (0)