Set system real time clock once from GNSS data.

Fixes #7421

Tested with Pixracer and Zubax GNSS2.0
This commit is contained in:
Todd Stellanova 2017-06-15 14:48:42 -07:00 committed by Kabir Mohammed
parent bc406a122e
commit fd47e0cbb3
2 changed files with 19 additions and 0 deletions

View File

@ -346,6 +346,23 @@ void UavcanGnssBridge::process_fixx(const uavcan::ReceivedDataStructure<FixType>
}
}
//TODO px4_clock_settime does nothing on the Snapdragon platform
#ifndef __PX4_QURT
// If we haven't already done so, set the system clock using GPS data
if (valid_pos_cov && !_system_clock_set) {
timespec ts;
memset(&ts, 0, sizeof(ts));
// get the whole microseconds
ts.tv_sec = report.time_utc_usec / 1000000ULL;
// get the remainder microseconds and convert to nanoseconds
ts.tv_nsec = (report.time_utc_usec % 1000000ULL) * 1000;
px4_clock_settime(CLOCK_REALTIME, &ts);
_system_clock_set = true;
}
#endif
report.satellites_used = msg.sats_used;
// Using PDOP for HDOP and VDOP

View File

@ -111,4 +111,6 @@ private:
orb_advert_t _report_pub; ///< uORB pub for gnss position
int _orb_sub_gnss = -1; ///< uORB sub for gnss position, used for bridging uORB --> UAVCAN
bool _system_clock_set = false; ///< Have we set the system clock at least once from GNSS data?
};