From e4a50a3e96aa39346ad7212cae984524276973dd Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 19 May 2017 12:15:07 +0200 Subject: Added timestamp to received CAN messages and store into frequency_clock_t. Change-Id: If209070298bd9df49297fdcbed554770e1bc0e4a Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/utils/timer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'CAN-binder/low-can-binding/utils/timer.cpp') diff --git a/CAN-binder/low-can-binding/utils/timer.cpp b/CAN-binder/low-can-binding/utils/timer.cpp index 3d90a00..9c22bd0 100644 --- a/CAN-binder/low-can-binding/utils/timer.cpp +++ b/CAN-binder/low-can-binding/utils/timer.cpp @@ -62,6 +62,12 @@ frequency_clock_t::frequency_clock_t(float frequency) frequency_ = 1; } +frequency_clock_t::frequency_clock_t(float frequency, uint64_t last_tick, time_function_t time_function) + : unit_{1000000}, frequency_{frequency}, last_tick_{0}, time_function_{nullptr} +{ + if(frequency_ <= 0) + frequency_ = 1; +} /// @brief Return the period in ms given the frequency in hertz. /// @param[in] frequency - Frequency to convert, in hertz float frequency_clock_t::frequency_to_period() const @@ -109,7 +115,7 @@ float frequency_clock_t::get_frequency() const /// @brief Force the clock to tick, regardless of it its time has actually /// elapsed. -void frequency_clock_t::tick() +void frequency_clock_t::tick(uint64_t timestamp) { - last_tick_ = get_time_function()(); + last_tick_ = timestamp; } \ No newline at end of file -- cgit 1.2.3-korg