summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-26 16:19:43 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-28 16:11:47 +0100
commita16b570f1e8607f1c984cef4c281df9d5b7b129e (patch)
tree16a0dca0e37c74eb2323926c8013dd4f9c88da33 /low-can-binding/binding
parentb5401df91ef1ded2430b8337294f9a1d7a5cb77f (diff)
Change vector to list to allow to remove signal.
This commit allows to remove signals. We need that because subscription to an iso tp message needs to be individual. Bug-AGL : SPEC-2779 Bug-AGL: SPEC-2976 Change-Id: I1d6410ebfc8ea82d33addf1bb828d9cd810b006a Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/binding')
-rw-r--r--low-can-binding/binding/low-can-cb.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 2c6e2be3..6c8a1ee0 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -194,7 +194,7 @@ static int add_to_event_loop(std::shared_ptr<low_can_subscription_t>& can_subscr
static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
bool subscribe,
- std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages,
+ std::list<std::shared_ptr<diagnostic_message_t> > diagnostic_messages,
struct event_filter_t& event_filter,
std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
bool perm_rec_diag_req)
@@ -259,7 +259,7 @@ static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
static int subscribe_unsubscribe_signals(afb_req_t request,
bool subscribe,
- std::vector<std::shared_ptr<signal_t> > signals,
+ std::list<std::shared_ptr<signal_t> > signals,
struct event_filter_t& event_filter,
std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
{
@@ -353,6 +353,22 @@ static int one_subscribe_unsubscribe_events(afb_req_t request, bool subscribe, c
// subscribe or unsubscribe
openxc_DynamicField search_key = build_DynamicField(tag);
sf = utils::signals_manager_t::instance().find_signals(search_key);
+
+
+#ifdef USE_FEATURE_ISOTP
+ if(sf.signals.size() > 1)
+ {
+ sf.signals.remove_if([](std::shared_ptr<signal_t> x){
+ bool isotp = x->get_message()->is_isotp();
+ if(isotp)
+ {
+ AFB_NOTICE("ISO TP messages need to be subscribed one by one (rx, tx)");
+ }
+ return isotp;
+ });
+ }
+#endif
+
if (sf.signals.empty() && sf.diagnostic_messages.empty())
{
AFB_NOTICE("No signal(s) found for %s.", tag.c_str());
@@ -374,7 +390,7 @@ static int one_subscribe_unsubscribe_id(afb_req_t request, bool subscribe, const
if(message_definition)
{
- sf.signals = message_definition->get_signals();
+ sf.signals = std::list<std::shared_ptr<signal_t>>(message_definition->get_signals().begin(),message_definition->get_signals().end());
}
if(sf.signals.empty())
@@ -571,10 +587,10 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
if( !sf.signals.empty() )
{
- AFB_DEBUG("ID WRITE RAW : %d",sf.signals[0]->get_message()->get_id());
+ AFB_DEBUG("ID WRITE RAW : %d",sf.signals.front()->get_message()->get_id());
if(flags&BCM_PROTOCOL)
{
- if(sf.signals[0]->get_message()->is_fd())
+ if(sf.signals.front()->get_message()->is_fd())
{
AFB_DEBUG("CANFD_MAX_DLEN");
message->set_flags(CAN_FD_FRAME);
@@ -586,7 +602,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
message->set_maxdlen(CAN_MAX_DLEN);
}
- if(sf.signals[0]->get_message()->is_isotp())
+ if(sf.signals.front()->get_message()->is_isotp())
{
flags = ISOTP_PROTOCOL;
message->set_maxdlen(MAX_ISOTP_FRAMES * message->get_maxdlen());
@@ -632,7 +648,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
return;
}
- if(! send_message(message, application_t::instance().get_can_bus_manager().get_can_device_name(bus_name), flags, event_filter, sf.signals[0]))
+ if(! send_message(message, application_t::instance().get_can_bus_manager().get_can_device_name(bus_name), flags, event_filter, sf.signals.front()))
{
afb_req_success(request, nullptr, "Message correctly sent");
}
@@ -703,7 +719,7 @@ static void write_signal(afb_req_t request, const std::string& name, json_object
return;
}
- std::shared_ptr<signal_t> sig = sf.signals[0];
+ std::shared_ptr<signal_t> sig = sf.signals.front();
if(! sig->get_writable())
{
afb_req_fail_f(request, "%s isn't writable. Message not sent.", sig->get_name().c_str());