aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2015-02-09 21:58:10 +0100
committerLorenz Meier <lm@inf.ethz.ch>2015-02-15 10:17:01 +0100
commit1b8f5de13468d8d05759f840b240a6fabb402231 (patch)
tree6484a531566cc666d3dc1ba7307a2536dab43275
parenta74c7c8009a165944f6cc62189aa7d541800da83 (diff)
downloadpx4-firmware-1b8f5de13468d8d05759f840b240a6fabb402231.tar.gz
px4-firmware-1b8f5de13468d8d05759f840b240a6fabb402231.tar.bz2
px4-firmware-1b8f5de13468d8d05759f840b240a6fabb402231.zip
GPS / ashtech: Use double for time where NMEA uses floating point numbers
-rw-r--r--src/drivers/gps/ashtech.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/drivers/gps/ashtech.cpp b/src/drivers/gps/ashtech.cpp
index 2734eb179..c88134492 100644
--- a/src/drivers/gps/ashtech.cpp
+++ b/src/drivers/gps/ashtech.cpp
@@ -68,10 +68,10 @@ int ASHTECH::handle_message(int len)
7 The checksum data, always begins with *
Fields 5 and 6 together yield the total offset. For example, if field 5 is -5 and field 6 is +15, local time is 5 hours and 15 minutes earlier than GMT.
*/
- unsigned long long ashtech_time = 0;
+ double ashtech_time = 0.0;
int day = 0, month = 0, year = 0, local_time_off_hour __attribute__((unused)) = 0, local_time_off_min __attribute__((unused)) = 0;
- if (bufptr && *(++bufptr) != ',') { ashtech_time = static_cast<unsigned long long>(strtod(bufptr, &endp)); bufptr = endp; }
+ if (bufptr && *(++bufptr) != ',') { ashtech_time = strtod(bufptr, &endp); bufptr = endp; }
if (bufptr && *(++bufptr) != ',') { day = strtol(bufptr, &endp, 10); bufptr = endp; }
@@ -84,9 +84,10 @@ int ASHTECH::handle_message(int len)
if (bufptr && *(++bufptr) != ',') { local_time_off_min = strtol(bufptr, &endp, 10); bufptr = endp; }
- int ashtech_hour = ashtech_time / 10000;
- int ashtech_minute = (ashtech_time - ashtech_hour * 10000) / 100;
- double ashtech_sec = ashtech_time - ashtech_hour * 10000 - ashtech_minute * 100;
+ int ashtech_hour = static_cast<int>(ashtech_time / 10000);
+ int ashtech_minute = static_cast<int>((ashtech_time - ashtech_hour * 10000) / 100);
+ double ashtech_sec = static_cast<float>(ashtech_time - ashtech_hour * 10000 - ashtech_minute * 100);
+
/*
* convert to unix timestamp
*/