AP_GPS: added optional NMEA debug log

compile time option for debugging
This commit is contained in:
Andrew Tridgell 2015-07-29 11:07:01 +10:00
parent a2e9d0488c
commit 25fe2b3fb0

View File

@ -40,6 +40,13 @@
extern const AP_HAL::HAL& hal;
// optionally log all NMEA data for debug purposes
// #define NMEA_LOG_PATH "nmea.log"
#ifdef NMEA_LOG_PATH
#include <stdio.h>
#endif
// SiRF init messages //////////////////////////////////////////////////////////
//
// Note that we will only see a SiRF in NMEA mode if we are explicitly configured
@ -117,7 +124,17 @@ bool AP_GPS_NMEA::read(void)
numc = port->available();
while (numc--) {
if (_decode(port->read())) {
char c = port->read();
#ifdef NMEA_LOG_PATH
static FILE *logf = NULL;
if (logf == NULL) {
logf = fopen(NMEA_LOG_PATH, "wb");
}
if (c >= 0 && logf != NULL) {
::fwrite(&c, 1, 1, logf);
}
#endif
if (_decode(c)) {
parsed = true;
}
}