summaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-19 12:15:07 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-19 16:19:08 +0200
commite4a50a3e96aa39346ad7212cae984524276973dd (patch)
tree8a8ba1e7c4db73c5c94d025e0364e1fef87c04c6 /CAN-binder/low-can-binding/utils/socketcan-bcm.cpp
parent7bde3f53dbbbf688506a32e89c27c8aa69a86a3f (diff)
Added timestamp to received CAN messages
and store into frequency_clock_t. Change-Id: If209070298bd9df49297fdcbed554770e1bc0e4a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils/socketcan-bcm.cpp')
-rw-r--r--CAN-binder/low-can-binding/utils/socketcan-bcm.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp b/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp
index 7323565c..38f48522 100644
--- a/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp
+++ b/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp
@@ -84,7 +84,12 @@ namespace utils
DEBUG(binder_interface, "read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", ifr.ifr_name, msg.msg_head.can_id, msg.frames.can_dlc,
msg.frames.data[0], msg.frames.data[1], msg.frames.data[2], msg.frames.data[3], msg.frames.data[4], msg.frames.data[5], msg.frames.data[6], msg.frames.data[7]);
- cm = ::can_message_t::convert_from_frame(msg.frames , nbytes-sizeof(struct bcm_msg_head));
+ struct timeval tv;
+ ioctl(s.socket(), SIOCGSTAMP, &tv);
+ uint64_t timestamp = 1000000 * tv.tv_sec + tv.tv_usec;
+ cm = ::can_message_t::convert_from_frame(msg.frames ,
+ nbytes-sizeof(struct bcm_msg_head),
+ timestamp);
return s;
}