From: José Bollo Date: Tue, 30 May 2017 17:21:22 +0000 (+0200) Subject: manage unset values with NAN X-Git-Tag: 5.0.2~156 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=829e92779abd4ea0e79d558242523d9757436332;p=apps%2Fagl-service-can-low-level.git manage unset values with NAN Change-Id: I144bc110864f507e57d5e4b7f03ee1c0aa61ff63 Signed-off-by: José Bollo --- 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 ace53488..4fa375bf 100644 --- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp +++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp @@ -395,12 +395,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, // poll a PID for nothing. if(sig->get_supported() && subscribe) { - float frequency; - - if(event_filter.frequency >= 0) - { frequency = event_filter.frequency; } - else - { frequency = sig->get_frequency(); } + float frequency = isnan(event_filter.frequency) ? sig->get_frequency() : event_filter.frequency; 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); diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.hpp b/CAN-binder/low-can-binding/binding/low-can-cb.hpp index 1608db7d..6490fdc6 100644 --- a/CAN-binder/low-can-binding/binding/low-can-cb.hpp +++ b/CAN-binder/low-can-binding/binding/low-can-cb.hpp @@ -16,6 +16,7 @@ */ #include +#include #include "../utils/socketcan-bcm.hpp" struct event_filter_t @@ -23,6 +24,7 @@ struct event_filter_t float frequency; float min; float max; + event_filter_t() : frequency{NAN}, min{NAN}, max{NAN} {} }; class low_can_subscription_t @@ -44,7 +46,7 @@ private: * don't need an offset. */ /// Filtering part - struct event_filter_t event_filter_ = {-1.0, -1.0, -1.0}; + struct event_filter_t event_filter_; utils::socketcan_bcm_t socket_; public: