summaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding/can/can-message.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/can/can-message.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/can/can-message.cpp')
-rw-r--r--CAN-binder/low-can-binding/can/can-message.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/CAN-binder/low-can-binding/can/can-message.cpp b/CAN-binder/low-can-binding/can/can-message.cpp
index 66a4f4f..772734d 100644
--- a/CAN-binder/low-can-binding/can/can-message.cpp
+++ b/CAN-binder/low-can-binding/can/can-message.cpp
@@ -27,7 +27,7 @@
/// Constructor about can_message_t class.
///
can_message_t::can_message_t()
- : maxdlen_{0}, id_{0}, length_{0}, format_{can_message_format_t::INVALID}, rtr_flag_{false}, flags_{0}
+ : maxdlen_{0}, id_{0}, length_{0}, format_{can_message_format_t::INVALID}, rtr_flag_{false}, flags_{0}, timestamp_{0}
{}
can_message_t::can_message_t(uint8_t maxdlen,
@@ -36,14 +36,16 @@ can_message_t::can_message_t(uint8_t maxdlen,
can_message_format_t format,
bool rtr_flag,
uint8_t flags,
- std::vector<uint8_t> data)
+ std::vector<uint8_t> data,
+ uint64_t timestamp)
: maxdlen_{maxdlen},
id_{id},
length_{length},
format_{format},
rtr_flag_{rtr_flag},
flags_{flags},
- data_{data}
+ data_{data},
+ timestamp_{timestamp}
{}
///
@@ -119,6 +121,16 @@ uint8_t can_message_t::get_length() const
return length_;
}
+uint64_t can_message_t::get_timestamp() const
+{
+ return timestamp_;
+}
+
+void can_message_t::set_timestamp(uint64_t timestamp)
+{
+ timestamp_ = timestamp;
+}
+
///
/// @brief Control whether the object is correctly initialized
/// to be sent over the CAN bus
@@ -162,7 +174,7 @@ void can_message_t::set_format(const can_message_format_t new_format)
///
/// @return A can_message_t object fully initialized with canfd_frame values.
///
-can_message_t can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes)
+can_message_t can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes, uint64_t timestamp)
{
uint8_t maxdlen, length, flags = (uint8_t)NULL;
uint32_t id;
@@ -239,10 +251,10 @@ can_message_t can_message_t::convert_from_frame(const struct canfd_frame& frame,
id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
- return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data);
+ return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp);
}
-can_message_t can_message_t::convert_from_frame(const struct can_frame& frame, size_t nbytes)
+can_message_t can_message_t::convert_from_frame(const struct can_frame& frame, size_t nbytes, uint64_t timestamp)
{
uint8_t maxdlen, length, flags = (uint8_t)NULL;
uint32_t id;
@@ -310,7 +322,7 @@ can_message_t can_message_t::convert_from_frame(const struct can_frame& frame, s
// id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
- return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data);
+ return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp);
}
///