From 7f6c164aae3e7dbc558f21679b29c0a2d9d09e21 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 1 Jun 2017 13:48:36 +0200 Subject: Cleaning Change-Id: I73e9acf8b3a28db2134cf1f4bcb1b2aa7fd224fc Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/binding/low-can-cb.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'CAN-binder/low-can-binding/binding/low-can-cb.cpp') 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 245a9ce..712c83c 100644 --- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp +++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp @@ -349,18 +349,22 @@ int subscribe_unsubscribe_diagnostic_messages(struct afb_req request, bool subsc for(const auto& sig : diagnostic_messages) { - active_diagnostic_request_t* adr; DiagnosticRequest* diag_req = conf.get_request_from_diagnostic_message(sig->get_name()); + float frequency = std::isnan(event_filter.frequency) ? sig->get_frequency() : event_filter.frequency; // If the requested diagnostic message isn't supported by the car then unsubcribe it // no matter what we want, worse case will be a fail unsubscription but at least we don't // poll a PID for nothing. - if(sig->get_supported() && subscribe) + //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); + if(sig->get_supported() && subscribe && + diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), frequency) != nullptr) { - float frequency = std::isnan(event_filter.frequency) ? sig->get_frequency() : event_filter.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); + std::shared_ptr can_subscription(new low_can_subscription_t(event_filter, sig)); + int ret = subscribe_unsubscribe_signal(request, subscribe, can_subscription); + if(ret < 0) + return ret; + rets++; + DEBUG(binder_interface, "%s: Signal: %s subscribed", __FUNCTION__, sig->get_name().c_str()); } else { @@ -371,13 +375,6 @@ int subscribe_unsubscribe_diagnostic_messages(struct afb_req request, bool subsc diag_req = nullptr; return -1; } - - std::shared_ptr can_subscription(new low_can_subscription_t(event_filter, sig)); - int ret = subscribe_unsubscribe_signal(request, subscribe, can_subscription); - if(ret < 0) - return ret; - rets++; - DEBUG(binder_interface, "%s: Signal: %s subscribed", __FUNCTION__, sig->get_name().c_str()); } return rets; -- cgit 1.2.3-korg