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>
static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
bool subscribe,
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)
struct event_filter_t& event_filter,
std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
bool perm_rec_diag_req)
static int subscribe_unsubscribe_signals(afb_req_t request,
bool subscribe,
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)
{
struct event_filter_t& event_filter,
std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
{
// subscribe or unsubscribe
openxc_DynamicField search_key = build_DynamicField(tag);
sf = utils::signals_manager_t::instance().find_signals(search_key);
// 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());
if (sf.signals.empty() && sf.diagnostic_messages.empty())
{
AFB_NOTICE("No signal(s) found for %s.", tag.c_str());
- 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() )
{
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(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);
{
AFB_DEBUG("CANFD_MAX_DLEN");
message->set_flags(CAN_FD_FRAME);
message->set_maxdlen(CAN_MAX_DLEN);
}
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());
{
flags = ISOTP_PROTOCOL;
message->set_maxdlen(MAX_ISOTP_FRAMES * message->get_maxdlen());
- 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");
}
{
afb_req_success(request, nullptr, "Message correctly sent");
}
- 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());
if(! sig->get_writable())
{
afb_req_fail_f(request, "%s isn't writable. Message not sent.", sig->get_name().c_str());
#include <vector>
#include <string>
#include <fnmatch.h>
#include <vector>
#include <string>
#include <fnmatch.h>
- std::vector<std::shared_ptr<signal_t> > signals;
- std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
+ std::list<std::shared_ptr<signal_t> > signals;
+ std::list<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
};
/// @brief Signal manager singleton hold subscription object with attached afb_event_t and its mutex
};
/// @brief Signal manager singleton hold subscription object with attached afb_event_t and its mutex
void find_signals(const openxc_DynamicField &key, std::vector<std::shared_ptr<signal_t> >& found_signals);
template <typename T>
void find_signals(const openxc_DynamicField &key, std::vector<std::shared_ptr<signal_t> >& found_signals);
template <typename T>
- void lookup_signals_by_name(const std::string& key, std::vector<std::shared_ptr<T> > signals, std::vector<std::shared_ptr<T> >& found_signals)
+ void lookup_signals_by_name(const std::string& key, std::vector<std::shared_ptr<T> > signals, std::list<std::shared_ptr<T> >& found_signals)
{
for(std::shared_ptr<T> s : signals)
{
{
for(std::shared_ptr<T> s : signals)
{
- void lookup_signals_by_id(const double key, std::vector<std::shared_ptr<T> > signals, std::vector<std::shared_ptr<T> >& found_signals)
+ void lookup_signals_by_id(const double key, std::vector<std::shared_ptr<T> > signals, std::list<std::shared_ptr<T> >& found_signals)
{
for(std::shared_ptr<T> s : signals)
{
{
for(std::shared_ptr<T> s : signals)
{