diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 45b0bf9dee..1aed99813b 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -119,7 +119,7 @@ Format characters in the format string for binary log messages C : uint16_t * 100 e : int32_t * 100 E : uint32_t * 100 - L : uint32_t latitude/longitude + L : int32_t latitude/longitude */ // structure used to define logging format diff --git a/libraries/DataFlash/LogFile.cpp b/libraries/DataFlash/LogFile.cpp index 7907f03406..291543eb01 100644 --- a/libraries/DataFlash/LogFile.cpp +++ b/libraries/DataFlash/LogFile.cpp @@ -4,6 +4,7 @@ #include "DataFlash.h" #include #include +#include extern const AP_HAL::HAL& hal; @@ -364,20 +365,7 @@ void DataFlash_Class::_print_log_entry(uint8_t msg_type, case 'L': { int32_t v; memcpy(&v, &pkt[ofs], sizeof(v)); - int32_t dec_portion, frac_portion; - int32_t abs_lat_or_lon = labs(v); - - // extract decimal portion (special handling of negative numbers to ensure we round towards zero) - dec_portion = abs_lat_or_lon / 10000000UL; - - // extract fractional portion - frac_portion = abs_lat_or_lon - dec_portion*10000000UL; - - // print output including the minus sign - if (v < 0) { - port->printf_P(PSTR("-")); - } - port->printf_P(PSTR("%ld.%07ld"),(long)dec_portion,(long)frac_portion); + print_latlon(port, v); ofs += sizeof(v); break; }