AP_HAL_Linux: clarify method name, use common methods for setting time

This commit is contained in:
Peter Barker 2018-02-16 20:25:36 -02:00 committed by Andrew Tridgell
parent e92b3f0a63
commit c9dbdd7a5c
2 changed files with 8 additions and 9 deletions

View File

@ -91,13 +91,12 @@ void Util::_toneAlarm_timer_tick() {
} }
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 #if CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_NONE
timespec ts; // call superclass method to set time. We've guarded this so we
ts.tv_sec = time_utc_usec/1000000ULL; // don't reset the HW clock time on people's laptops.
ts.tv_nsec = (time_utc_usec % 1000000ULL) * 1000ULL; AP_HAL::Util::set_hw_rtc(time_utc_usec);
clock_settime(CLOCK_REALTIME, &ts);
#endif #endif
} }

View File

@ -44,7 +44,7 @@ public:
/* /*
set system clock in UTC microseconds 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_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_terrain_directory() const override final { return custom_terrain_directory; }
const char *get_custom_storage_directory() const override final { return custom_storage_directory; } const char *get_custom_storage_directory() const override final { return custom_storage_directory; }