summaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/message
diff options
context:
space:
mode:
authorArthur Guyader <arthur.guyader@iot.bzh>2019-08-12 16:27:51 +0200
committerArthur Guyader <arthur.guyader@iot.bzh>2019-08-29 18:03:23 +0200
commit4216b5e6af9979e1f49175be8db9e0578ff9cbf5 (patch)
treea55c33b4e10d439375c87b9ad618c439dfe64313 /low-can-binding/can/message
parent4693c2e0d9c72d98d4f94e0d756c85e0c1d6cbd5 (diff)
Add function get_data_vector with index
This commit adds the function get_data_vector to get another vector between the index indicates. Bug-AGL : SPEC-2779 Change-Id: I704d78467839ee7f9a2fec397e9b0db8da43d79d Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
Diffstat (limited to 'low-can-binding/can/message')
-rw-r--r--low-can-binding/can/message/message.cpp34
-rw-r--r--low-can-binding/can/message/message.hpp1
2 files changed, 35 insertions, 0 deletions
diff --git a/low-can-binding/can/message/message.cpp b/low-can-binding/can/message/message.cpp
index 5384c021..b0a33f78 100644
--- a/low-can-binding/can/message/message.cpp
+++ b/low-can-binding/can/message/message.cpp
@@ -76,6 +76,40 @@ const uint8_t* message_t::get_data() const
return data_.data();
}
+
+///
+/// @brief Retrieve data_ member value.
+///
+/// @return pointer to the first element
+/// of class member data_
+///
+const std::vector<uint8_t> message_t::get_data_vector(int start,int end) const
+{
+ std::vector<uint8_t> ret;
+ if(start >= 0)
+ {
+ if(end<length_)
+ {
+ for(int i=start;i<=end;i++)
+ {
+ ret.push_back(data_[i]);
+ }
+ }
+ else
+ {
+ for(int i=start;i<length_;i++)
+ {
+ ret.push_back(data_[i]);
+ }
+ }
+ }
+ else
+ {
+ AFB_ERROR("Error index to get data vector, [%d-%d] - for length %d",start,end,length_);
+ }
+ return ret;
+}
+
///
/// @brief Retrieve data_ member whole vector
///
diff --git a/low-can-binding/can/message/message.hpp b/low-can-binding/can/message/message.hpp
index 48f4d98b..f0e1bf0b 100644
--- a/low-can-binding/can/message/message.hpp
+++ b/low-can-binding/can/message/message.hpp
@@ -66,6 +66,7 @@ public:
int get_sub_id() const;
const uint8_t* get_data() const;
const std::vector<uint8_t> get_data_vector() const;
+ const std::vector<uint8_t> get_data_vector(int start,int end) const;
uint32_t get_length() const;
uint64_t get_timestamp() const;