From 2fce82db10f277d6a3f357fc1fef24da92ee0e32 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jan 2021 22:51:50 +0100 Subject: [PATCH] bugfix for clock --- osal/rtems/Clock.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osal/rtems/Clock.cpp b/osal/rtems/Clock.cpp index 8bd7ac37e..9f4634cca 100644 --- a/osal/rtems/Clock.cpp +++ b/osal/rtems/Clock.cpp @@ -104,9 +104,13 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { - // TIsn't this a bug? Are RTEMS ticks always microseconds? + /* For all but the last field, the struct will be filled with the correct values */ rtems_time_of_day* timeRtems = reinterpret_cast(time); rtems_status_code status = rtems_clock_get_tod(timeRtems); + /* The last field now contains the RTEMS ticks of the seconds from 0 + to rtems_clock_get_ticks_per_second() minus one. We calculate the microseconds accordingly */ + timeRtems->ticks = static_cast(timeRtems->ticks) / + rtems_clock_get_ticks_per_second() * 1e6; switch (status) { case RTEMS_SUCCESSFUL: return HasReturnvaluesIF::RETURN_OK;