From: Romain Forlot Date: Sun, 10 Nov 2019 09:18:45 +0000 (+0100) Subject: message_set: New methods to add messages at init X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=992f19cf8173b8a6b492ef3cacec2d8e67c837ef;p=apps%2Fagl-service-can-low-level.git message_set: New methods to add messages at init Change-Id: Ic2e8169c9e3392198f5e0f6f5d28c2eea1ec98d4 Signed-off-by: Romain Forlot --- diff --git a/low-can-binding/can/message-set.cpp b/low-can-binding/can/message-set.cpp index 5edd742f..1ca7f7f6 100644 --- a/low-can-binding/can/message-set.cpp +++ b/low-can-binding/can/message-set.cpp @@ -31,6 +31,37 @@ message_set_t::message_set_t( , diagnostic_messages_{diagnostic_messages} {} + +int message_set_t::add_message_definition(std::shared_ptr msg_def) +{ + for (auto old_msg_def : messages_definition_) + { + if(old_msg_def->get_id() == msg_def->get_id()) + { + AFB_ERROR("Same id between : %s and %s", old_msg_def->get_name(), msg_def->get_name()); + return -1; + } + } + messages_definition_.push_back(msg_def); + return 0; +} + + +int message_set_t::add_diagnostic_message(std::shared_ptr diag_msg) +{ + for (auto old_diag_msg : diagnostic_messages_) + { + if(old_diag_msg->get_pid() == diag_msg->get_pid()) + { + AFB_ERROR("Same pid between : %s and %s", old_diag_msg->get_generic_name(), diag_msg->get_generic_name()); + return -1; + } + } + diagnostic_messages_.push_back(diag_msg); + return 0; +} + + /// @brief Returns a vector holding all message definitions which are handled by this message set. vect_ptr_msg_def_t& message_set_t::get_messages_definition() { @@ -57,3 +88,8 @@ vect_ptr_diag_msg_t& message_set_t::get_diagnostic_messages() { return diagnostic_messages_; } + +uint8_t message_set_t::get_index() const +{ + return index_; +} diff --git a/low-can-binding/can/message-set.hpp b/low-can-binding/can/message-set.hpp index 5ce4ce38..68fc3859 100644 --- a/low-can-binding/can/message-set.hpp +++ b/low-can-binding/can/message-set.hpp @@ -48,7 +48,12 @@ public: const vect_ptr_msg_def_t& messages_definition, const vect_ptr_diag_msg_t& diagnostic_messages); + int add_message_definition(std::shared_ptr msg_def); + int add_diagnostic_message(std::shared_ptr diag_msg); + vect_ptr_msg_def_t& get_messages_definition(); vect_ptr_signal_t get_all_signals() const; vect_ptr_diag_msg_t& get_diagnostic_messages(); + + uint8_t get_index() const; };