@@ -473,6 +473,9 @@ void applyCompensationGNS(char *nmeaSentence, int arraySize)
473
473
uint8_t undulationStop = 0 ;
474
474
uint8_t checksumStart = 0 ;
475
475
476
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
477
+ systemPrintf (" Original GNGNS:\r\n %s\r\n " , nmeaSentence);
478
+
476
479
int commaCount = 0 ;
477
480
for (int x = 0 ; x < strnlen (nmeaSentence, arraySize); x++) // Assumes sentence is null terminated
478
481
{
@@ -606,8 +609,17 @@ void applyCompensationGNS(char *nmeaSentence, int arraySize)
606
609
// Add CRC
607
610
strncat (newSentence, coordinateStringDDMM, sizeof (newSentence) - 1 );
608
611
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
+
609
618
// Overwrite the original NMEA
610
619
strncpy (nmeaSentence, newSentence, arraySize);
620
+
621
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
622
+ systemPrintf (" Compensated GNGNS:\r\n %s\r\n " , nmeaSentence);
611
623
}
612
624
613
625
// Modify a GLL sentence with tilt compensation
@@ -619,6 +631,9 @@ void applyCompensationGLL(char *nmeaSentence, int arraySize)
619
631
if (tiltIsCorrecting () == false )
620
632
return ;
621
633
634
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
635
+ systemPrintf (" Original GNGLL:\r\n %s\r\n " , nmeaSentence);
636
+
622
637
char coordinateStringDDMM[strlen (" 10511.12345678" ) + 1 ] = {0 }; // UM980 outputs 8 decimals in GGA sentence
623
638
624
639
const int latitudeComma = 1 ;
@@ -700,8 +715,17 @@ void applyCompensationGLL(char *nmeaSentence, int arraySize)
700
715
// Add CRC
701
716
strncat (newSentence, coordinateStringDDMM, sizeof (newSentence) - 1 );
702
717
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
+
703
724
// Overwrite the original NMEA
704
725
strncpy (nmeaSentence, newSentence, arraySize);
726
+
727
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
728
+ systemPrintf (" Compensated GNGLL:\r\n %s\r\n " , nmeaSentence);
705
729
}
706
730
707
731
// Modify a RMC sentence with tilt compensation
@@ -713,6 +737,9 @@ void applyCompensationRMC(char *nmeaSentence, int arraySize)
713
737
if (tiltIsCorrecting () == false )
714
738
return ;
715
739
740
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
741
+ systemPrintf (" Original GNRMC:\r\n %s\r\n " , nmeaSentence);
742
+
716
743
char coordinateStringDDMM[strlen (" 10511.12345678" ) + 1 ] = {0 }; // UM980 outputs 8 decimals in GGA sentence
717
744
718
745
const int latitudeComma = 3 ;
@@ -794,8 +821,17 @@ void applyCompensationRMC(char *nmeaSentence, int arraySize)
794
821
// Add CRC
795
822
strncat (newSentence, coordinateStringDDMM, sizeof (newSentence) - 1 );
796
823
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
+
797
830
// Overwrite the original NMEA
798
831
strncpy (nmeaSentence, newSentence, arraySize);
832
+
833
+ if (settings.enableImuCompensationDebug == true && !inMainMenu)
834
+ systemPrintf (" Compensated GNRMC:\r\n %s\r\n " , nmeaSentence);
799
835
}
800
836
801
837
// Modify a GGA sentence with tilt compensation
@@ -825,7 +861,7 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
825
861
uint8_t checksumStart = 0 ;
826
862
827
863
if (settings.enableImuCompensationDebug == true && !inMainMenu)
828
- systemPrintf (" Original GNGGA: %s\r\n " , nmeaSentence);
864
+ systemPrintf (" Original GNGGA:\r\n %s\r\n " , nmeaSentence);
829
865
830
866
int commaCount = 0 ;
831
867
for (int x = 0 ; x < strnlen (nmeaSentence, arraySize); x++) // Assumes sentence is null terminated
@@ -941,7 +977,7 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
941
977
}
942
978
943
979
// Convert altitude double to string
944
- snprintf (coordinateStringDDMM, sizeof (coordinateStringDDMM), " %0.3f " , newAltitude);
980
+ snprintf (coordinateStringDDMM, sizeof (coordinateStringDDMM), " %0.4f " , newAltitude);
945
981
946
982
// Add tilt-compensated Altitude
947
983
strncat (newSentence, coordinateStringDDMM, sizeof (newSentence) - 1 );
@@ -960,11 +996,17 @@ void applyCompensationGGA(char *nmeaSentence, int arraySize)
960
996
// Add CRC
961
997
strncat (newSentence, coordinateStringDDMM, sizeof (newSentence) - 1 );
962
998
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
+
963
1005
// Overwrite the original NMEA
964
1006
strncpy (nmeaSentence, newSentence, arraySize);
965
1007
966
1008
if (settings.enableImuCompensationDebug == true && !inMainMenu)
967
- systemPrintf (" Compensated GNGGA: %s\r\n " , nmeaSentence);
1009
+ systemPrintf (" Compensated GNGGA:\r\n %s\r\n " , nmeaSentence);
968
1010
}
969
1011
970
1012
#endif // COMPILE_IM19_IMU
0 commit comments