Compare commits

...

11 Commits

Author SHA1 Message Date
franchioping f31aa3261e added idf.py support 2026-03-18 15:43:53 +00:00
Melissa LeBlanc-Williams f7bff30a01
Merge pull request #157 from makermelissa/master
Fix compiler warnings
2024-04-16 11:18:20 -07:00
Melissa LeBlanc-Williams 605dfc3f2b Add suggested fix 2024-04-01 13:10:56 -07:00
Melissa LeBlanc-Williams 792e13d2b2 Actually return NMEA string with CRLF 2024-03-28 08:25:16 -07:00
Melissa LeBlanc-Williams b9abc83581 Run clang format 2024-03-27 13:10:34 -07:00
Melissa LeBlanc-Williams 2850fdeff7 Attempt to fix compiler warnings 3 2024-03-27 13:00:29 -07:00
Melissa LeBlanc-Williams 02b1489f27 Attempt to fix compiler warnings 2 2024-03-27 12:54:27 -07:00
Melissa LeBlanc-Williams e8da4230f9 Merge branch 'master' of https://github.com/makermelissa/Adafruit_GPS 2024-03-27 12:43:20 -07:00
Melissa LeBlanc-Williams cd7138fb2e Merge branch 'master' of https://github.com/makermelissa/Adafruit_GPS 2024-03-27 12:43:05 -07:00
Melissa LeBlanc-Williams 1a77bf2001 Merge branch 'master' of https://github.com/makermelissa/Adafruit_GPS 2024-03-27 12:30:03 -07:00
Melissa LeBlanc-Williams 2a3cf8264d Attempt to fix compiler warnings 2024-03-27 12:27:44 -07:00
3 changed files with 19 additions and 4 deletions

5
CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
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);
currentline[lineidx] = c;
lineidx++;
lineidx = lineidx + 1;
if (lineidx >= MAXLINELENGTH)
lineidx = MAXLINELENGTH -
1; // ensure there is someplace to put the next received character

View File

@ -565,7 +565,15 @@ 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
sprintf(nmea, "%s\r\n", nmea);
size_t len = strlen(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
}
@ -591,7 +599,8 @@ void Adafruit_GPS::addChecksum(char *buff) {
i++;
}
// Calculate the needed buffer size: original length + 3 (*XX) + 1 (null terminator)
// Calculate the needed buffer size: original length + 3 (*XX) + 1 (null
// terminator)
int neededSize = strlen(buff) + 4;
char *tempBuffer = (char *)malloc(neededSize);
@ -600,7 +609,8 @@ void Adafruit_GPS::addChecksum(char *buff) {
snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs);
// Copy the formatted string back to the original buffer
// Note: Make sure the original buffer is large enough to hold the new string.
// Note: Make sure the original buffer is large enough to hold the new
// string.
strcpy(buff, tempBuffer);
// Free the allocated memory to avoid memory leaks