Add noCRLF option to build()
new optional argument will leave the carriage return and linefeed off the end of an NMEA sentence.
This commit is contained in:
parent
deb312b293
commit
d14e220c1b
|
|
@ -349,7 +349,13 @@ size_t Adafruit_GPS::write(uint8_t c) {
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Read one character from the GPS device
|
@brief Read one character from the GPS device.
|
||||||
|
|
||||||
|
Call very frequently and multiple times per opportunity or the buffer
|
||||||
|
may overflow if there are frequent NMEA sentences. An 82 character NMEA
|
||||||
|
sentence 10 times per second will require 820 calls per second, and
|
||||||
|
once a loop() may not be enough. Check for newNMEAreceived() after at
|
||||||
|
least every 10 calls, or you may miss some short sentences.
|
||||||
@return The character that we received, or 0 if nothing was available
|
@return The character that we received, or 0 if nothing was available
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public:
|
||||||
// NMEA_build.cpp
|
// NMEA_build.cpp
|
||||||
#ifdef NMEA_EXTENSIONS
|
#ifdef NMEA_EXTENSIONS
|
||||||
char *build(char *nmea, const char *thisSource, const char *thisSentence,
|
char *build(char *nmea, const char *thisSource, const char *thisSentence,
|
||||||
char ref = 'R');
|
char ref = 'R', bool noCRLF = false);
|
||||||
#endif
|
#endif
|
||||||
void addChecksum(char *buff);
|
void addChecksum(char *buff);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
char *Adafruit_GPS::build(char *nmea, const char *thisSource,
|
char *Adafruit_GPS::build(char *nmea, const char *thisSource,
|
||||||
const char *thisSentence, char ref) {
|
const char *thisSentence, char ref, bool noCRLF) {
|
||||||
sprintf(nmea, "%6.2f",
|
sprintf(nmea, "%6.2f",
|
||||||
(double)123.45); // fail if sprintf() doesn't handle floats
|
(double)123.45); // fail if sprintf() doesn't handle floats
|
||||||
if (strcmp(nmea, "123.45"))
|
if (strcmp(nmea, "123.45"))
|
||||||
|
|
@ -569,8 +569,9 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
addChecksum(nmea); // Successful completion
|
addChecksum(nmea); // Successful completion
|
||||||
sprintf(nmea, "%s\r\n",
|
if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183
|
||||||
nmea); // Add Carriage Return and Line Feed to comply with NMEA-183
|
sprintf(nmea, "%s\r\n", nmea);
|
||||||
|
}
|
||||||
return nmea; // return pointer to finished product
|
return nmea; // return pointer to finished product
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue