summaryrefslogtreecommitdiffstats
path: root/low-can-binding/can
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding/can')
-rw-r--r--low-can-binding/can/message-definition.cpp4
-rw-r--r--low-can-binding/can/message-definition.hpp1
-rw-r--r--low-can-binding/can/message-set.cpp36
-rw-r--r--low-can-binding/can/message-set.hpp5
4 files changed, 46 insertions, 0 deletions
diff --git a/low-can-binding/can/message-definition.cpp b/low-can-binding/can/message-definition.cpp
index b761ad68..114307e5 100644
--- a/low-can-binding/can/message-definition.cpp
+++ b/low-can-binding/can/message-definition.cpp
@@ -62,6 +62,10 @@ const std::string message_definition_t::get_bus_device_name() const
.get_can_device_name(bus_);
}
+const std::string message_definition_t::get_name() const{
+ return name_;
+}
+
uint32_t message_definition_t::get_id() const
{
return id_ & CAN_EFF_MASK ?
diff --git a/low-can-binding/can/message-definition.hpp b/low-can-binding/can/message-definition.hpp
index cce42e14..ca264b7e 100644
--- a/low-can-binding/can/message-definition.hpp
+++ b/low-can-binding/can/message-definition.hpp
@@ -79,6 +79,7 @@ public:
const std::string get_bus_name() const;
const std::string get_bus_device_name() const;
+ const std::string get_name() const;
uint32_t get_id() const;
bool is_fd() const;
bool is_j1939() const;
diff --git a/low-can-binding/can/message-set.cpp b/low-can-binding/can/message-set.cpp
index 2fc300ac..6bf80c97 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<message_definition_t> 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().c_str(), msg_def->get_name().c_str());
+ return -1;
+ }
+ }
+ messages_definition_.push_back(msg_def);
+ return 0;
+}
+
+
+int message_set_t::add_diagnostic_message(std::shared_ptr<diagnostic_message_t> 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().c_str(), diag_msg->get_generic_name().c_str());
+ 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 d54f27ac..eab4ed69 100644
--- a/low-can-binding/can/message-set.hpp
+++ b/low-can-binding/can/message-set.hpp
@@ -48,7 +48,12 @@ public:
const std::vector<std::shared_ptr<message_definition_t> >& messages_definition,
const vect_ptr_diag_msg_t& diagnostic_messages);
+ int add_message_definition(std::shared_ptr<message_definition_t> msg_def);
+ int add_diagnostic_message(std::shared_ptr<diagnostic_message_t> 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;
};