Update signals.json and generated files.
[apps/agl-service-can-low-level.git] / CAN-binder / low-can-binding / can / can-bus.cpp
index cc0a3d6..5e7ac27 100644 (file)
@@ -47,11 +47,15 @@ can_bus_t::can_bus_t(utils::config_parser_t conf_file)
 
 bool can_bus_t::apply_filter(const openxc_VehicleMessage& vehicle_message, std::shared_ptr<low_can_subscription_t> can_subscription)
 {
+       bool send = false;
        if(is_valid(vehicle_message))
        {
-               return true;
+               float min = std::isnan(can_subscription->get_min()) ? -INFINITY : can_subscription->get_min();
+               float max = std::isnan(can_subscription->get_max()) ? INFINITY : can_subscription->get_max();
+               double value = get_numerical_from_DynamicField(vehicle_message);
+               send = (value < min && value > max) ? false : true;
        }
-       return false;
+       return send;
 }
 
 /// @brief Will make the decoding operation on a classic CAN message. It will not
@@ -185,7 +189,11 @@ void can_bus_t::can_event_push()
                                        jo = json_object_new_object();
                                        jsonify_simple(s_message, jo);
                                        if(afb_event_push(s[v_message.first]->get_event(), jo) == 0)
-                                               on_no_clients(std::string(s_message.name));
+                                       {
+                                               if(v_message.second.has_diagnostic_response)
+                                                       {on_no_clients(s[v_message.first], v_message.second.diagnostic_response.pid);}
+                                               on_no_clients(s[v_message.first]);
+                                       }
                                }
                        }
                }
@@ -198,13 +206,11 @@ void can_bus_t::start_threads()
 {
        is_decoding_ = true;
        th_decoding_ = std::thread(&can_bus_t::can_decode_message, this);
-       if(!th_decoding_.joinable())
-               is_decoding_ = false;
+       th_decoding_.detach();
 
        is_pushing_ = true;
        th_pushing_ = std::thread(&can_bus_t::can_event_push, this);
-       if(!th_pushing_.joinable())
-               is_pushing_ = false;
+       th_pushing_.detach();
 }
 
 /// @brief Will stop all threads holded by can_bus_t object