diff --git a/libraries/AP_HAL_SITL/Util.cpp b/libraries/AP_HAL_SITL/Util.cpp new file mode 100644 index 0000000000..00c34de66e --- /dev/null +++ b/libraries/AP_HAL_SITL/Util.cpp @@ -0,0 +1,10 @@ +#include "Util.h" + +uint64_t HALSITL::Util::get_hw_rtc() const +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + const uint64_t seconds = ts.tv_sec; + const uint64_t nanoseconds = ts.tv_nsec; + return (seconds * 1000000ULL + nanoseconds/1000ULL); +} diff --git a/libraries/AP_HAL_SITL/Util.h b/libraries/AP_HAL_SITL/Util.h index 26821ebcef..9a7113eab1 100644 --- a/libraries/AP_HAL_SITL/Util.h +++ b/libraries/AP_HAL_SITL/Util.h @@ -28,6 +28,9 @@ public: const char* get_custom_defaults_file() const override { return sitlState->defaults_path; } + + uint64_t get_hw_rtc() const override; + private: SITL_State *sitlState; };