From 0224ecc39e8cd17dcaea49a580233997ac2020db Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 16 May 2017 12:49:03 +0200 Subject: Use common timer method to get BCM timeval values. Change-Id: I3c4364d6038bd60546726fba940f043f5abcb6d2 Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/can/can-signals.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'CAN-binder') diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp index 6a682146..0b589675 100644 --- a/CAN-binder/low-can-binding/can/can-signals.cpp +++ b/CAN-binder/low-can-binding/can/can-signals.cpp @@ -233,15 +233,13 @@ int can_signal_t::create_rx_filter() memset(&cfd, 0, sizeof(cfd)); memset(&bcm_msg.msg_head, 0, sizeof(bcm_msg.msg_head)); float val = (float)(1 << bit_size_)-1; - float freq = frequency_.frequency_to_period(); - if(freq <= 0) - freq = 0.000001f; + struct timeval freq = frequency_.get_timeval_from_period(); bcm_msg.msg_head.opcode = RX_SETUP; bcm_msg.msg_head.can_id = can_id; bcm_msg.msg_head.flags = SETTIMER|RX_NO_AUTOTIMER; - bcm_msg.msg_head.ival2.tv_sec = long(freq); - bcm_msg.msg_head.ival2.tv_usec = (freq - (long)freq) * 1000000; + bcm_msg.msg_head.ival2.tv_sec = freq.tv_sec ; + bcm_msg.msg_head.ival2.tv_usec = freq.tv_usec; bcm_msg.msg_head.nframes = 1; bitfield_encode_float(val, bit_position_, -- cgit 1.2.3-korg