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/can-bus.cpp8
-rw-r--r--low-can-binding/can/can-bus.hpp4
-rw-r--r--low-can-binding/can/message-definition.cpp6
-rw-r--r--low-can-binding/can/message-definition.hpp8
-rw-r--r--low-can-binding/can/message-set.cpp8
-rw-r--r--low-can-binding/can/message-set.hpp14
6 files changed, 26 insertions, 22 deletions
diff --git a/low-can-binding/can/can-bus.cpp b/low-can-binding/can/can-bus.cpp
index 48ac697a..6cd99ba3 100644
--- a/low-can-binding/can/can-bus.cpp
+++ b/low-can-binding/can/can-bus.cpp
@@ -81,7 +81,7 @@ bool can_bus_t::apply_filter(const openxc_VehicleMessage& vehicle_message, std::
/// @param[in] can_message - a single CAN message from the CAN socket read, to be decode.
///
/// @return How many signals has been decoded.
-void can_bus_t::process_signals(std::shared_ptr<message_t> message, std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+void can_bus_t::process_signals(std::shared_ptr<message_t> message, map_subscription& s)
{
int subscription_id = message->get_sub_id();
openxc_DynamicField decoded_message;
@@ -114,7 +114,7 @@ void can_bus_t::process_signals(std::shared_ptr<message_t> message, std::map<int
/// @param[in] can_message - a single CAN message from the CAN socket read, to be decode.
///
/// @return How many signals has been decoded.
-void can_bus_t::process_diagnostic_signals(diagnostic_manager_t& manager, std::shared_ptr<message_t> message, std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+void can_bus_t::process_diagnostic_signals(diagnostic_manager_t& manager, std::shared_ptr<message_t> message, map_subscription& s)
{
int subscription_id = message->get_sub_id();
@@ -160,7 +160,7 @@ void can_bus_t::can_decode_message()
{
std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex());
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s = sm.get_subscribed_signals();
+ map_subscription& s = sm.get_subscribed_signals();
if(application_t::instance().get_diagnostic_manager().is_diagnostic_response(message))
{
process_diagnostic_signals(application_t::instance().get_diagnostic_manager(), message, s);
@@ -192,7 +192,7 @@ void can_bus_t::can_event_push()
decoded_can_message_lock.unlock();
{
std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex());
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s = sm.get_subscribed_signals();
+ map_subscription& s = sm.get_subscribed_signals();
if(s.find(v_message.first) != s.end() && afb_event_is_valid(s[v_message.first]->get_event()))
{
jo = json_object_new_object();
diff --git a/low-can-binding/can/can-bus.hpp b/low-can-binding/can/can-bus.hpp
index 53e6b9ae..a9f6b0c1 100644
--- a/low-can-binding/can/can-bus.hpp
+++ b/low-can-binding/can/can-bus.hpp
@@ -46,8 +46,8 @@ private:
utils::config_parser_t conf_file_; ///< configuration file handle used to initialize can_bus_dev_t objects.
bool apply_filter(const openxc_VehicleMessage& vehicle_message, std::shared_ptr<low_can_subscription_t> can_subscription);
- void process_signals(std::shared_ptr<message_t> message, std::map<int, std::shared_ptr<low_can_subscription_t> >& s);
- void process_diagnostic_signals(diagnostic_manager_t& manager, std::shared_ptr<message_t> can_message, std::map<int, std::shared_ptr<low_can_subscription_t> >& s);
+ void process_signals(std::shared_ptr<message_t> message, map_subscription& s);
+ void process_diagnostic_signals(diagnostic_manager_t& manager, std::shared_ptr<message_t> can_message, map_subscription& s);
void can_decode_message();
std::thread th_decoding_; ///< thread that will handle decoding a can frame
diff --git a/low-can-binding/can/message-definition.cpp b/low-can-binding/can/message-definition.cpp
index a875dafa..ab7a884b 100644
--- a/low-can-binding/can/message-definition.cpp
+++ b/low-can-binding/can/message-definition.cpp
@@ -25,7 +25,7 @@ message_definition_t::message_definition_t(
uint32_t flags,
frequency_clock_t frequency_clock,
bool force_send_changed,
- const std::vector<std::shared_ptr<signal_t> >& signals)
+ const vect_ptr_signal_t& signals)
: parent_{nullptr},
bus_{bus},
id_{id},
@@ -43,7 +43,7 @@ message_definition_t::message_definition_t(const std::string bus,
uint32_t flags,
frequency_clock_t frequency_clock,
bool force_send_changed,
- const std::vector<std::shared_ptr<signal_t> >& signals)
+ const vect_ptr_signal_t& signals)
: parent_{nullptr},
bus_{bus},
id_{id},
@@ -82,7 +82,7 @@ bool message_definition_t::is_isotp() const
return (flags_&ISOTP_PROTOCOL);
}
-std::vector<std::shared_ptr<signal_t>>& message_definition_t::get_signals()
+vect_ptr_signal_t& message_definition_t::get_signals()
{
return signals_;
}
diff --git a/low-can-binding/can/message-definition.hpp b/low-can-binding/can/message-definition.hpp
index f46d3adb..cce42e14 100644
--- a/low-can-binding/can/message-definition.hpp
+++ b/low-can-binding/can/message-definition.hpp
@@ -54,7 +54,7 @@ private:
std::vector<uint8_t> last_value_; ///< last_value_ - The last received value of the message. Defaults to undefined.
/// This is required for the forceSendChanged functionality, as the stack
/// needs to compare an incoming CAN message with the previous frame.*/
- std::vector<std::shared_ptr<signal_t> > signals_; ///< signals_ - Vector holding signal_t object which share the same arbitration ID */
+ vect_ptr_signal_t signals_; ///< signals_ - Vector holding signal_t object which share the same arbitration ID */
public:
//message_definition_t(const message_definition_t& b);
@@ -66,7 +66,7 @@ public:
uint32_t flags,
frequency_clock_t frequency_clock,
bool force_send_changed,
- const std::vector<std::shared_ptr<signal_t> >& signals);
+ const vect_ptr_signal_t& signals);
message_definition_t(const std::string bus,
uint32_t id,
std::string name,
@@ -74,7 +74,7 @@ public:
uint32_t flags,
frequency_clock_t frequency_clock,
bool force_send_changed,
- const std::vector<std::shared_ptr<signal_t> >& signals);
+ const vect_ptr_signal_t& signals);
const std::string get_bus_name() const;
@@ -83,7 +83,7 @@ public:
bool is_fd() const;
bool is_j1939() const;
bool is_isotp() const;
- std::vector<std::shared_ptr<signal_t>>& get_signals();
+ vect_ptr_signal_t& get_signals();
uint32_t get_length() const;
uint32_t get_flags() const;
diff --git a/low-can-binding/can/message-set.cpp b/low-can-binding/can/message-set.cpp
index 69682e1a..2fc300ac 100644
--- a/low-can-binding/can/message-set.cpp
+++ b/low-can-binding/can/message-set.cpp
@@ -24,7 +24,7 @@ message_set_t::message_set_t(
uint8_t index,
const std::string& name,
const std::vector<std::shared_ptr<message_definition_t> >& messages_definition,
- const std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages)
+ const vect_ptr_diag_msg_t& diagnostic_messages)
: index_{index}
, name_{name}
, messages_definition_{messages_definition}
@@ -32,14 +32,14 @@ message_set_t::message_set_t(
{}
/// @brief Returns a vector holding all message definitions which are handled by this message set.
-std::vector<std::shared_ptr<message_definition_t>>& message_set_t::get_messages_definition()
+vect_ptr_msg_def_t& message_set_t::get_messages_definition()
{
return messages_definition_;
}
std::vector<std::shared_ptr<signal_t>> message_set_t::get_all_signals() const
{
- std::vector<std::shared_ptr<signal_t> > signals;
+ vect_ptr_signal_t signals;
for(const auto& cmd: messages_definition_)
{
std::vector<std::shared_ptr<signal_t>> cmd_signals = cmd->get_signals();
@@ -53,7 +53,7 @@ std::vector<std::shared_ptr<signal_t>> message_set_t::get_all_signals() const
}
/// @brief Returns a vector holding all diagnostic message definitions which are handled by this message set.
-std::vector<std::shared_ptr<diagnostic_message_t>>& message_set_t::get_diagnostic_messages()
+vect_ptr_diag_msg_t& message_set_t::get_diagnostic_messages()
{
return diagnostic_messages_;
}
diff --git a/low-can-binding/can/message-set.hpp b/low-can-binding/can/message-set.hpp
index 4af97fa6..d54f27ac 100644
--- a/low-can-binding/can/message-set.hpp
+++ b/low-can-binding/can/message-set.hpp
@@ -27,6 +27,10 @@ class signal_t;
class message_definition_t;
class diagnostic_message_t;
+typedef std::vector<std::shared_ptr<signal_t>> vect_ptr_signal_t;
+typedef std::vector<std::shared_ptr<diagnostic_message_t>> vect_ptr_diag_msg_t;
+typedef std::vector<std::shared_ptr<message_definition_t>> vect_ptr_msg_def_t;
+
/// @brief A parent wrapper for a particular set of CAN messages and diagnostic messages
/// (e.g. a vehicle or program).
class message_set_t
@@ -35,16 +39,16 @@ private:
uint8_t index_; /// < A numerical ID for the message set, ideally the index is in an array for fast lookup
const std::string name_; /// < The name of the message set.
std::vector<std::shared_ptr<message_definition_t> > messages_definition_; ///< Vector holding all message definitions handled by the message set.
- std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages_; ///< Vector holding all diagnostics messages from JSON signals description file. First vector map to message set
+ vect_ptr_diag_msg_t diagnostic_messages_; ///< Vector holding all diagnostics messages from JSON signals description file. First vector map to message set
public:
message_set_t(
uint8_t index,
const std::string& name,
const std::vector<std::shared_ptr<message_definition_t> >& messages_definition,
- const std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages);
+ const vect_ptr_diag_msg_t& diagnostic_messages);
- std::vector<std::shared_ptr<message_definition_t>>& get_messages_definition();
- std::vector<std::shared_ptr<signal_t>> get_all_signals() const;
- std::vector<std::shared_ptr<diagnostic_message_t>>& get_diagnostic_messages();
+ vect_ptr_msg_def_t& get_messages_definition();
+ vect_ptr_signal_t get_all_signals() const;
+ vect_ptr_diag_msg_t& get_diagnostic_messages();
};