diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-22 16:40:15 +0000 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-23 14:42:43 +0100 |
commit | 156b8f9c39a81cbbad7c32dbebdf321787611779 (patch) | |
tree | f089611edaeaf62b75310d18db7464c06ef14af5 /src/utils | |
parent | fe8235f257a009c911c63238885a47e0c3633293 (diff) |
Send diag request only if not other one with some id running
Fix: elapsed function return that do not compute elapsed_time at first time
Fix: reworked should_send() to get it work with our scheduling workflow
Reschedule trying to send request if recurring even it is in flight.
Change-Id: Idce54cb9bf62616c891a8a25a6c478f931350bc7
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/timer.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index 7c2560e..540cfe0 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -73,7 +73,7 @@ bool frequency_clock_t::started() time_function_t frequency_clock_t::get_time_function() { - return time_function_ != nullptr ? time_function_ : system_time_ms; + return time_function_ != nullptr ? time_function_ : system_time_us; } bool frequency_clock_t::elapsed(bool stagger) @@ -82,9 +82,9 @@ bool frequency_clock_t::elapsed(bool stagger) float elapsed_time = 0; if(!started() && stagger) last_tick_ = get_time_function()() - (rand() % int(period)); - else - // Make sure it ticks the the first call - elapsed_time = !started() ? period : get_time_function()() - last_tick_; + + // Make sure it ticks the the first call + elapsed_time = !started() ? period : get_time_function()() - last_tick_; return frequency_ == 0 || elapsed_time >= period; } |