X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CAN-binder%2Flow-can-binding%2Fcan%2Fcan-message.cpp;h=057bc71f0424a2917ceabf79fed25757a6daaa1c;hb=76c43dec62b2e21cd6446360c00d4fe6b437533f;hp=3575348f9d2fbe5b46739655e127088ad93b015e;hpb=f44a5b1549bc4c8a84d0dedf4a8b1e4220a34f42;p=apps%2Fagl-service-can-low-level.git diff --git a/CAN-binder/low-can-binding/can/can-message.cpp b/CAN-binder/low-can-binding/can/can-message.cpp index 3575348f..057bc71f 100644 --- a/CAN-binder/low-can-binding/can/can-message.cpp +++ b/CAN-binder/low-can-binding/can/can-message.cpp @@ -19,7 +19,7 @@ #include -#include "../low-can-binding.hpp" +#include "../binding/low-can-hat.hpp" /// /// @brief Class constructor @@ -27,7 +27,14 @@ /// Constructor about can_message_t class. /// 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,6 +66,11 @@ uint32_t can_message_t::get_id() const return id_; } +int can_message_t::get_sub_id() const +{ + return sub_id_; +} + /// /// @brief Retrieve RTR flag member. /// @@ -69,12 +84,12 @@ bool can_message_t::get_rtr_flag_() const /// /// @brief Retrieve format_ member value. /// -/// @return format_ class member +/// @return format_ class member. Default to INVALID. /// 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 can_message_format_t::INVALID; return format_; } @@ -99,6 +114,16 @@ const uint8_t* can_message_t::get_data() const return data_.data(); } +/// +/// @brief Retrieve data_ member whole vector +/// +/// @return the vector as is +/// +const std::vector can_message_t::get_data_vector() const +{ + return data_; +} + /// /// @brief Retrieve length_ member value. /// @@ -109,15 +134,28 @@ 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_; +} + +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 /// -/// @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