X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Flow-can-binding.cpp;h=8ecf74243ee89deac7c4b40d83a8b42e6de43029;hb=63d31e29e366fb9dd85debc897fdbc91d9cb2e42;hp=23ab2da75a73af7d19493859ba67a39295bb63a0;hpb=34d859437e958d31e38bef4c2e696ed35a994234;p=apps%2Fagl-service-can-low-level.git diff --git a/src/low-can-binding.cpp b/src/low-can-binding.cpp index 23ab2da7..8ecf7424 100644 --- a/src/low-can-binding.cpp +++ b/src/low-can-binding.cpp @@ -42,6 +42,8 @@ extern "C" #include }; +#define MICRO 1000000 + // Interface between the daemon and the binding const struct afb_binding_interface *binder_interface; @@ -126,13 +128,11 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, //TODO: Implement way to dynamically call the right function no matter // how much signals types we have. - /// const std::string& can_prefix = configuration_t::instance().get_can_signals().front().get_prefix(); - const std::string& obd2_prefix = configuration_t::instance().get_obd2_signals().front().get_prefix(); for(const std::string& sig : signals) { int ret; - if (sig.find_first_of(obd2_prefix.c_str(), 0, obd2_prefix.size())) + if (active_diagnostic_request_t::is_diagnostic_signal(sig)) { std::vector found; configuration_t::instance().find_obd2_signals(build_DynamicField(sig), found); @@ -141,7 +141,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, configuration_t::instance().get_diagnostic_manager().add_recurring_request( diag_req, sig.c_str(), false, obd2_signal_t::decode_obd2_response, nullptr, (float)frequency); //TODO: Adding callback requesting ignition status: diag_req, sig.c_str(), false, obd2_signal_t::decode_obd2_response, obd2_signal_t::check_ignition_status, frequency); - sd_event_add_time(afb_daemon_get_event_loop(binder_interface->daemon), &source, CLOCK_MONOTONIC, frequency, 0, + sd_event_add_time(afb_daemon_get_event_loop(binder_interface->daemon), &source, CLOCK_MONOTONIC, frequency*MICRO, 0, configuration_t::instance().get_diagnostic_manager().send_request, diag_req); } @@ -252,9 +252,10 @@ extern "C" return 0; } - /// Initialize Diagnostic manager that will handle obd2 requests - diagnostic_manager_t& diag_manager = configuration_t::instance().get_diagnostic_manager(); - diag_manager.initialize(can_bus_manager.get_can_devices().front()); + /// 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. + configuration_t::instance().get_diagnostic_manager().initialize(can_bus_manager.get_can_devices().front()); ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe"); return 1;