From c9dbdd7a5c7bb8b391bea8416736e6b2287451b5 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 16 Feb 2018 20:25:36 -0200 Subject: [PATCH] AP_HAL_Linux: clarify method name, use common methods for setting time --- libraries/AP_HAL_Linux/Util.cpp | 15 +++++++-------- libraries/AP_HAL_Linux/Util.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libraries/AP_HAL_Linux/Util.cpp b/libraries/AP_HAL_Linux/Util.cpp index 965896af10..77f64f677e 100644 --- a/libraries/AP_HAL_Linux/Util.cpp +++ b/libraries/AP_HAL_Linux/Util.cpp @@ -84,21 +84,20 @@ void Util::_toneAlarm_timer_tick() { } else if (state == 3) { state = 1; } - + if (_toneAlarm.is_tune_comp()) { state = 0; } - + } -void Util::set_system_clock(uint64_t time_utc_usec) +void Util::set_hw_rtc(uint64_t time_utc_usec) { #if CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE - timespec ts; - ts.tv_sec = time_utc_usec/1000000ULL; - ts.tv_nsec = (time_utc_usec % 1000000ULL) * 1000ULL; - clock_settime(CLOCK_REALTIME, &ts); -#endif + // call superclass method to set time. We've guarded this so we + // don't reset the HW clock time on people's laptops. + AP_HAL::Util::set_hw_rtc(time_utc_usec); +#endif } bool Util::is_chardev_node(const char *path) diff --git a/libraries/AP_HAL_Linux/Util.h b/libraries/AP_HAL_Linux/Util.h index 0894c24226..7d83e94b15 100644 --- a/libraries/AP_HAL_Linux/Util.h +++ b/libraries/AP_HAL_Linux/Util.h @@ -44,7 +44,7 @@ public: /* set system clock in UTC microseconds */ - void set_system_clock(uint64_t time_utc_usec); + void set_hw_rtc(uint64_t time_utc_usec) override; const char *get_custom_log_directory() const override final { return custom_log_directory; } const char *get_custom_terrain_directory() const override final { return custom_terrain_directory; } const char *get_custom_storage_directory() const override final { return custom_storage_directory; }