summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding/low-can-cb.cpp
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-03-02 11:51:42 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-03-15 17:40:45 +0100
commit2debfc561d3ad517ad0c82ebd18cba8ec78ab6ce (patch)
tree7d0235e2aa8e9d43f45516326045b22d3a0df54e /low-can-binding/binding/low-can-cb.cpp
parent4becc6d7986cf656f10f02ecdd5202b5b0fdddf1 (diff)
Change subscribed signals search to check filters as well
When a new subscription is made, search in existing subscription for a combination of a signal and a filter instead of searching for just a signal. In this way, each subscription will receive signals according to their requesting filter. Bug-AGL: SPEC-1339 Change-Id: I22cb96a2dbaaf48dbd77025ff1610bde151b19b4 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'low-can-binding/binding/low-can-cb.cpp')
-rw-r--r--low-can-binding/binding/low-can-cb.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index edf464bc..16e31d13 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -188,7 +188,7 @@ static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request,
for(const auto& sig : diagnostic_messages)
{
DiagnosticRequest* diag_req = new DiagnosticRequest(sig->build_diagnostic_request());
- event_filter.frequency = std::isnan(event_filter.frequency) ? sig->get_frequency() : event_filter.frequency;
+ event_filter.frequency = event_filter.frequency == 0 ? sig->get_frequency() : event_filter.frequency;
std::shared_ptr<low_can_subscription_t> can_subscription;
auto it = std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return (! sub.second->get_diagnostic_message().empty());});
@@ -233,7 +233,6 @@ static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request,
return rets;
}
-// TODO: Create separate subscrition object if event_filter isn't the same.
static int subscribe_unsubscribe_can_signals(struct afb_req request,
bool subscribe,
std::vector<std::shared_ptr<can_signal_t> > can_signals,
@@ -243,7 +242,7 @@ static int subscribe_unsubscribe_can_signals(struct afb_req request,
int rets = 0;
for(const auto& sig: can_signals)
{
- auto it = std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return sub.second->get_can_signal() == sig; });
+ auto it = std::find_if(s.begin(), s.end(), [&sig, &event_filter](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return sub.second->is_signal_subscription_corresponding(sig, event_filter) ; });
std::shared_ptr<low_can_subscription_t> can_subscription;
if(it != s.end())
{