mirror of
https://github.com/adafruit/Adafruit_GPS.git
synced 2026-07-28 04:08:15 +00:00
Actually return NMEA string with CRLF
This commit is contained in:
+5
-4
@@ -566,11 +566,12 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
|
||||
addChecksum(nmea); // Successful completion
|
||||
if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183
|
||||
size_t len = strlen(nmea);
|
||||
char *newStr =
|
||||
char *nmeaWithCRLF =
|
||||
(char *)malloc(len + 3); // +2 for \r\n, +1 for null terminator
|
||||
if (newStr) {
|
||||
strcpy(newStr, nmea); // Copy original string
|
||||
strcat(newStr, "\r\n"); // Append \r\n
|
||||
if (nmeaWithCRLF) {
|
||||
strcpy(nmeaWithCRLF, nmea); // Copy original string
|
||||
strcat(nmeaWithCRLF, "\r\n"); // Append \r\n
|
||||
return nmeaWithCRLF; // return pointer to finished product
|
||||
}
|
||||
}
|
||||
return nmea; // return pointer to finished product
|
||||
|
||||
Reference in New Issue
Block a user