summaryrefslogtreecommitdiffstats
path: root/CAN-binder
diff options
context:
space:
mode:
Diffstat (limited to 'CAN-binder')
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.cpp10
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.hpp3
2 files changed, 11 insertions, 2 deletions
diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.cpp b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
index 48e22411..0f94d05a 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
@@ -19,6 +19,7 @@
#include "low-can-hat.hpp"
#include <map>
+#include <memory>
#include <queue>
#include <mutex>
#include <vector>
@@ -58,6 +59,10 @@ low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filte
: event_filter_{event_filter}
{}
+low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<diagnostic_message_t> diagnostic_message)
+ : event_filter_{event_filter}, diagnostic_message_{diagnostic_message}
+{}
+
low_can_subscription_t::low_can_subscription_t( low_can_subscription_t&& s)
: index_{s.index_},
event_filter_{s.event_filter_},
@@ -339,6 +344,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
for(const auto& sig : signals.diagnostic_messages)
{
int ret = 0;
+ active_diagnostic_request_t* adr;
diagnostic_manager_t& diag_m = conf.get_diagnostic_manager();
DiagnosticRequest* diag_req = conf.get_request_from_diagnostic_message(sig->get_name());
@@ -349,7 +355,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
{
float frequency = std::isnan(event_filter.frequency) ? sig->get_frequency() : event_filter.frequency;
- diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), frequency);
+ adr = diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), frequency);
//TODO: Adding callback requesting ignition status: diag_req, sig.c_str(), false, diagnostic_message_t::decode_obd2_response, diagnostic_message_t::check_ignition_status, frequency);
}
else
@@ -362,7 +368,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
return -1;
}
- std::shared_ptr<low_can_subscription_t> can_subscription(new low_can_subscription_t(event_filter));
+ std::shared_ptr<low_can_subscription_t> can_subscription(new low_can_subscription_t(event_filter, std::make_shared(adr)));
ret = subscribe_unsubscribe_signal(request, subscribe, can_subscription);
if(ret < 0)
return ret;
diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.hpp b/CAN-binder/low-can-binding/binding/low-can-cb.hpp
index 6dc2221d..e4e7ce9e 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.hpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.hpp
@@ -20,6 +20,7 @@
#include <utility>
#include "../can/can-signals.hpp"
+#include "../diagnostic/diagnostic-message.hpp"
#include "../utils/socketcan-bcm.hpp"
struct event_filter_t
@@ -37,6 +38,7 @@ private:
/// Signal part
std::shared_ptr<can_signal_t> can_signal_;
+ std::shared_ptr<diagnostic_message_t> diagnostic_message_;
/// Filtering part
struct event_filter_t event_filter_;
@@ -45,6 +47,7 @@ private:
public:
low_can_subscription_t();
low_can_subscription_t(struct event_filter_t event_filter);
+ low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<diagnostic_message_t> sig_name);
low_can_subscription_t(const low_can_subscription_t& s) = delete;
low_can_subscription_t(low_can_subscription_t&& s);