diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp index e6fbec8..69173c3 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -93,8 +93,12 @@ int loc_eng_nmea_put_checksum(char *pNmea, int maxSize) length++; } + // length now contains nmea sentence string length not including $ sign. int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum); - return (length + checksumLength); + + // total length of nmea sentence is length of nmea sentence inc $ sign plus + // length of checksum (+1 is to cover the $ character in the length). + return (length + checksumLength + 1); } /*===========================================================================