|
|
|
@ -748,19 +748,23 @@ UBX::payload_rx_done(void)
@@ -748,19 +748,23 @@ UBX::payload_rx_done(void)
|
|
|
|
|
timeinfo.tm_sec = _buf.payload_rx_nav_pvt.sec; |
|
|
|
|
time_t epoch = mktime(&timeinfo); |
|
|
|
|
|
|
|
|
|
// FMUv2+ boards have a hardware RTC, but GPS helps us to configure it
|
|
|
|
|
// and control its drift. Since we rely on the HRT for our monotonic
|
|
|
|
|
// clock, updating it from time to time is safe.
|
|
|
|
|
|
|
|
|
|
timespec ts; |
|
|
|
|
ts.tv_sec = epoch; |
|
|
|
|
ts.tv_nsec = _buf.payload_rx_nav_pvt.nano; |
|
|
|
|
if (clock_settime(CLOCK_REALTIME, &ts)) { |
|
|
|
|
warn("failed setting clock"); |
|
|
|
|
} |
|
|
|
|
if (epoch > GPS_EPOCH_SECS) { |
|
|
|
|
// FMUv2+ boards have a hardware RTC, but GPS helps us to configure it
|
|
|
|
|
// and control its drift. Since we rely on the HRT for our monotonic
|
|
|
|
|
// clock, updating it from time to time is safe.
|
|
|
|
|
|
|
|
|
|
timespec ts; |
|
|
|
|
ts.tv_sec = epoch; |
|
|
|
|
ts.tv_nsec = _buf.payload_rx_nav_pvt.nano; |
|
|
|
|
if (clock_settime(CLOCK_REALTIME, &ts)) { |
|
|
|
|
warn("failed setting clock"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_gps_position->time_utc_usec = static_cast<uint64_t>(epoch) * 1000000ULL; |
|
|
|
|
_gps_position->time_utc_usec += _buf.payload_rx_nav_timeutc.nano / 1000; |
|
|
|
|
_gps_position->time_utc_usec = static_cast<uint64_t>(epoch) * 1000000ULL; |
|
|
|
|
_gps_position->time_utc_usec += _buf.payload_rx_nav_timeutc.nano / 1000; |
|
|
|
|
} else { |
|
|
|
|
_gps_position->time_utc_usec = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_gps_position->timestamp_time = hrt_absolute_time(); |
|
|
|
@ -820,19 +824,25 @@ UBX::payload_rx_done(void)
@@ -820,19 +824,25 @@ UBX::payload_rx_done(void)
|
|
|
|
|
timeinfo.tm_sec = _buf.payload_rx_nav_timeutc.sec; |
|
|
|
|
time_t epoch = mktime(&timeinfo); |
|
|
|
|
|
|
|
|
|
// FMUv2+ boards have a hardware RTC, but GPS helps us to configure it
|
|
|
|
|
// and control its drift. Since we rely on the HRT for our monotonic
|
|
|
|
|
// clock, updating it from time to time is safe.
|
|
|
|
|
// only set the time if it makes sense
|
|
|
|
|
|
|
|
|
|
timespec ts; |
|
|
|
|
ts.tv_sec = epoch; |
|
|
|
|
ts.tv_nsec = _buf.payload_rx_nav_timeutc.nano; |
|
|
|
|
if (clock_settime(CLOCK_REALTIME, &ts)) { |
|
|
|
|
warn("failed setting clock"); |
|
|
|
|
} |
|
|
|
|
if (epoch > GPS_EPOCH_SECS) { |
|
|
|
|
// FMUv2+ boards have a hardware RTC, but GPS helps us to configure it
|
|
|
|
|
// and control its drift. Since we rely on the HRT for our monotonic
|
|
|
|
|
// clock, updating it from time to time is safe.
|
|
|
|
|
|
|
|
|
|
_gps_position->time_utc_usec = static_cast<uint64_t>(epoch) * 1000000ULL; |
|
|
|
|
_gps_position->time_utc_usec += _buf.payload_rx_nav_timeutc.nano / 1000; |
|
|
|
|
timespec ts; |
|
|
|
|
ts.tv_sec = epoch; |
|
|
|
|
ts.tv_nsec = _buf.payload_rx_nav_timeutc.nano; |
|
|
|
|
if (clock_settime(CLOCK_REALTIME, &ts)) { |
|
|
|
|
warn("failed setting clock"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_gps_position->time_utc_usec = static_cast<uint64_t>(epoch) * 1000000ULL; |
|
|
|
|
_gps_position->time_utc_usec += _buf.payload_rx_nav_timeutc.nano / 1000; |
|
|
|
|
} else { |
|
|
|
|
_gps_position->time_utc_usec = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_gps_position->timestamp_time = hrt_absolute_time(); |
|
|
|
|