Change binder to binding in title in use with gitbook
[apps/agl-service-can-low-level.git] / src / low-can-binding.cpp
index 2b04fa8..ed1aa34 100644 (file)
@@ -45,11 +45,11 @@ extern "C"
 // Interface between the daemon and the binding
 const struct afb_binding_interface *binder_interface;
 
-/********************************************************************************
-*
-*              Subscription and unsubscription
-*
-*********************************************************************************/
+///******************************************************************************
+///
+///            Subscription and unsubscription
+///
+///*******************************************************************************/
 
 static int make_subscription_unsubscription(struct afb_req request, const std::string& sig_name, std::map<std::string, struct afb_event>& s, bool subscribe)
 {
@@ -109,16 +109,16 @@ static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
        return make_subscription_unsubscription(request, sig, s, subscribe);
 }
 
-/**
- * @fn static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, const std::vector<can_signal_t>& signals)
- * @brief subscribe to all signals in the vector signals
- *
- * @param[in] afb_req request : contain original request use to subscribe or unsubscribe
- * @param[in] subscribe boolean value used to chose between a subscription operation or an unsubscription
- * @param[in] can_signal_t  vector with can_signal_t to subscribe
- *
- * @return Number of correctly subscribed signal
- */
+///
+/// @fn static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, const std::vector<can_signal_t>& signals)
+/// @brief subscribe to all signals in the vector signals
+///
+/// @param[in] afb_req request : contain original request use to subscribe or unsubscribe
+/// @param[in] subscribe boolean value used to chose between a subscription operation or an unsubscription
+/// @param[in] can_signal_t  vector with can_signal_t to subscribe
+///
+/// @return Number of correctly subscribed signal
+///
 static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, const std::vector<std::string>& signals)
 {
        int rets = 0;
@@ -139,8 +139,6 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
                        // no matter what we want, worse case will be a fail unsubscription but at least we don't
                        // poll a PID for nothing.
                        if(found.front()->get_supported())
-                               subscribe = false;
-                       if(subscribe)
                        {
                                float frequency = found.front()->get_frequency();
                                configuration_t::instance().get_diagnostic_manager().add_recurring_request(
@@ -151,6 +149,8 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
                        {
                                configuration_t::instance().get_diagnostic_manager().cleanup_request(
                                        configuration_t::instance().get_diagnostic_manager().find_recurring_request(diag_req), true);
+                               DEBUG(binder_interface, "Signal: %s isn't supported. Canceling operation.", sig.c_str());
+                               return -1;
                        }
                }
 
@@ -243,26 +243,26 @@ extern "C"
                return &binding_desc;
        }
 
-       /**
-       * @brief Initialize the binding.
-       *
-       * @param[in] service Structure which represent the Application Framework Binder.
-       *
-       * @return Exit code, zero if success.
-       */
+       /// @brief Initialize the binding.
+       ///
+       /// @param[in] service Structure which represent the Application Framework Binder.
+       ///
+       /// @return Exit code, zero if success.
        int afbBindingV1ServiceInit(struct afb_service service)
        {
                can_bus_t& can_bus_manager = configuration_t::instance().get_can_bus_manager();
 
                /// Initialize CAN socket
                if(can_bus_manager.init_can_dev() == 0)
+               {
                        can_bus_manager.start_threads();
 
-               /// Initialize Diagnostic manager that will handle obd2 requests.
-               /// We pass by default the first CAN bus device to its Initialization.
-               /// TODO: be able to choose the CAN bus device that will be use as Diagnostic bus.
-               if(configuration_t::instance().get_diagnostic_manager().initialize())
-                       return 0;
+                       /// Initialize Diagnostic manager that will handle obd2 requests.
+                       /// We pass by default the first CAN bus device to its Initialization.
+                       /// TODO: be able to choose the CAN bus device that will be use as Diagnostic bus.
+                       if(configuration_t::instance().get_diagnostic_manager().initialize())
+                               return 0;
+               }
 
                ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe");
                return 1;