Compare commits

..

No commits in common. "f31aa3261e76b6aceede2024adcf7eca11b5a145" and "ccfb4443691521365ad112b0722d25e78d2e6b43" have entirely different histories.

3 changed files with 4 additions and 19 deletions

View File

@ -1,5 +0,0 @@
idf_component_register(
SRC_DIRS "src"
INCLUDE_DIRS "." "src"
REQUIRES arduino-esp32
)

View File

@ -352,7 +352,7 @@ char Adafruit_GPS::read(void) {
// Serial.print(c); // Serial.print(c);
currentline[lineidx] = c; currentline[lineidx] = c;
lineidx = lineidx + 1; lineidx++;
if (lineidx >= MAXLINELENGTH) if (lineidx >= MAXLINELENGTH)
lineidx = MAXLINELENGTH - lineidx = MAXLINELENGTH -
1; // ensure there is someplace to put the next received character 1; // ensure there is someplace to put the next received character

View File

@ -565,15 +565,7 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
addChecksum(nmea); // Successful completion addChecksum(nmea); // Successful completion
if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183 if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183
size_t len = strlen(nmea); sprintf(nmea, "%s\r\n", nmea);
char *nmeaWithCRLF =
(char *)malloc(len + 3); // +2 for \r\n, +1 for null terminator
if (nmeaWithCRLF) {
strcpy(nmeaWithCRLF, nmea); // Copy original string
strcat(nmeaWithCRLF, "\r\n"); // Append \r\n
strcpy(nmea, nmeaWithCRLF); // Copy back to original buffer
free(nmeaWithCRLF); // Free the allocated memory
}
} }
return nmea; // return pointer to finished product return nmea; // return pointer to finished product
} }
@ -599,8 +591,7 @@ void Adafruit_GPS::addChecksum(char *buff) {
i++; i++;
} }
// Calculate the needed buffer size: original length + 3 (*XX) + 1 (null // Calculate the needed buffer size: original length + 3 (*XX) + 1 (null terminator)
// terminator)
int neededSize = strlen(buff) + 4; int neededSize = strlen(buff) + 4;
char *tempBuffer = (char *)malloc(neededSize); char *tempBuffer = (char *)malloc(neededSize);
@ -609,8 +600,7 @@ void Adafruit_GPS::addChecksum(char *buff) {
snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs); snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs);
// Copy the formatted string back to the original buffer // Copy the formatted string back to the original buffer
// Note: Make sure the original buffer is large enough to hold the new // Note: Make sure the original buffer is large enough to hold the new string.
// string.
strcpy(buff, tempBuffer); strcpy(buff, tempBuffer);
// Free the allocated memory to avoid memory leaks // Free the allocated memory to avoid memory leaks