summaryrefslogtreecommitdiffstats
path: root/CAN-binder
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-16 12:47:22 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-19 11:36:43 +0200
commit2adb1633620d669fc754e0990aa1033b57c03e23 (patch)
treec263a92a014babd9b137aa753374c87b211768ad /CAN-binder
parent8e67e90410d448d2dc3340795ca8de414d1fe3a9 (diff)
Fix: wrong calculation doesn't match method name.
Multiplication was a very specific needs for diagnostic manager when using systemd event loop timer. Now it is the right period that is calculated and multiplication is done into the right place. Cleaner. Change-Id: Ie3dffe8daa0fa9bd9bde408e62a8d7a06a333a25 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder')
-rw-r--r--CAN-binder/low-can-binding/utils/timer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/CAN-binder/low-can-binding/utils/timer.cpp b/CAN-binder/low-can-binding/utils/timer.cpp
index 7edb0d5..5c659ca 100644
--- a/CAN-binder/low-can-binding/utils/timer.cpp
+++ b/CAN-binder/low-can-binding/utils/timer.cpp
@@ -66,14 +66,14 @@ frequency_clock_t::frequency_clock_t(float frequency)
/// @param[in] frequency - Frequency to convert, in hertz
float frequency_clock_t::frequency_to_period()
{
- return frequency_ == 0 ? 0 : 1 / frequency_ * unit_;
+ return frequency_ == 0 ? 0 : 1 / frequency_;
}
const struct timeval frequency_clock_t::get_timeval_from_period() const
{
struct timeval freq = {0, 0};
float f;
- freq.tv_usec = (long int)std::modf(frequency_, &f);
+ freq.tv_usec = (long int)(std::modf(frequency_to_period(), &f) * unit_);
freq.tv_sec = (time_t)f;
return freq;