X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Fcan%2Fcan-message.cpp;h=074f5990396d5b0068083a9c3af28277272870e1;hb=7cf3679da71727f59c56b446ebf17ad2ce7bfddf;hp=f61de67e40194ef9ac17bf7c392fdb642a41aa04;hpb=9e444ade872bc436cf12bc12d03c3a5d51ac0b9e;p=apps%2Fagl-service-can-low-level.git diff --git a/low-can-binding/can/can-message.cpp b/low-can-binding/can/can-message.cpp index f61de67e..074f5990 100644 --- a/low-can-binding/can/can-message.cpp +++ b/low-can-binding/can/can-message.cpp @@ -19,15 +19,22 @@ #include -#include "../low-can-binding.hpp" +#include "../binding/low-can-hat.hpp" /// /// @brief Class constructor /// -/// Constructor about can_message_t class. +/// can_message_t class constructor. /// can_message_t::can_message_t() - : maxdlen_{0}, id_{0}, length_{0}, format_{can_message_format_t::ERROR}, rtr_flag_{false}, flags_{0} + : maxdlen_{0}, + id_{0}, + length_{0}, + format_{can_message_format_t::INVALID}, + rtr_flag_{false}, + flags_{0}, + timestamp_{0}, + sub_id_{-1} {} can_message_t::can_message_t(uint8_t maxdlen, @@ -36,14 +43,17 @@ can_message_t::can_message_t(uint8_t maxdlen, can_message_format_t format, bool rtr_flag, uint8_t flags, - std::vector data) + std::vector& data, + uint64_t timestamp) : maxdlen_{maxdlen}, id_{id}, length_{length}, format_{format}, rtr_flag_{rtr_flag}, flags_{flags}, - data_{data} + data_{data}, + timestamp_{timestamp}, + sub_id_{-1} {} /// @@ -56,47 +66,30 @@ uint32_t can_message_t::get_id() const return id_; } -/// -/// @brief Retrieve RTR flag member. -/// -/// @return rtr_flags_ class member -/// -bool can_message_t::get_rtr_flag_() const +int can_message_t::get_sub_id() const { - return rtr_flag_; + return sub_id_; } /// -/// @brief Retrieve format_ member value. -/// -/// @return format_ class member -/// -can_message_format_t can_message_t::get_format() const -{ - if (format_ != can_message_format_t::STANDARD || format_ != can_message_format_t::EXTENDED) - return can_message_format_t::ERROR; - return format_; -} - -/// -/// @brief Retrieve flags_ member value. +/// @brief Retrieve data_ member value. /// -/// @return flags_ class member +/// @return pointer to the first element +/// of class member data_ /// -uint8_t can_message_t::get_flags() const +const uint8_t* can_message_t::get_data() const { - return flags_; + return data_.data(); } /// -/// @brief Retrieve data_ member value. +/// @brief Retrieve data_ member whole vector /// -/// @return pointer to the first element -/// of class member data_ +/// @return the vector as is /// -const uint8_t* can_message_t::get_data() const +const std::vector can_message_t::get_data_vector() const { - return data_.data(); + return data_; } /// @@ -109,15 +102,23 @@ uint8_t can_message_t::get_length() const return length_; } -/// +void can_message_t::set_sub_id(int sub_id) +{ + sub_id_ = sub_id; +} + +uint64_t can_message_t::get_timestamp() const +{ + return timestamp_; +} + /// @brief Control whether the object is correctly initialized /// to be sent over the CAN bus /// -/// @return true if object correctly initialized and false if not. -/// +/// @return True if object correctly initialized and false if not. bool can_message_t::is_correct_to_send() { - if (id_ != 0 && length_ != 0 && format_ != can_message_format_t::ERROR) + if (id_ != 0 && length_ != 0 && format_ != can_message_format_t::INVALID) { int i; for(i=0;i