X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CAN-binder%2Flow-can-binding%2Fdiagnostic%2Factive-diagnostic-request.cpp;h=e9f0cd1051ea36c64134f42d58026c975286000b;hb=d35da77dcd5273b54177f8bc8ae7e5992bb3ca09;hp=2a939ed8b22740a556b035936c2f7880eb4250be;hpb=f04542587423e3b26d76c25d1c84acd5dea180b8;p=apps%2Fagl-service-can-low-level.git diff --git a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp index 2a939ed8..e9f0cd10 100644 --- a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp +++ b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp @@ -43,9 +43,9 @@ active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active callback_ = adr.callback_; recurring_ = adr.recurring_; wait_for_multiple_responses_ = adr.wait_for_multiple_responses_; - in_flight_ = adr.in_flight_; frequency_clock_ = adr.frequency_clock_; timeout_clock_ = adr.timeout_clock_; + socket_ = adr.socket_; } return *this; @@ -60,7 +60,6 @@ active_diagnostic_request_t::active_diagnostic_request_t() callback_{nullptr}, recurring_{false}, wait_for_multiple_responses_{false}, - in_flight_{false}, frequency_clock_{frequency_clock_t()}, timeout_clock_{frequency_clock_t()} {} @@ -79,7 +78,6 @@ active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus, callback_{callback}, recurring_{frequencyHz ? true : false}, wait_for_multiple_responses_{wait_for_multiple_responses}, - in_flight_{false}, frequency_clock_{frequency_clock_t(frequencyHz)}, timeout_clock_{frequency_clock_t(10)} {} @@ -89,11 +87,6 @@ uint32_t active_diagnostic_request_t::get_id() const return id_; } -const std::shared_ptr active_diagnostic_request_t::get_can_bus_dev() const -{ - return can_bus_t::get_can_device(bus_); -} - uint16_t active_diagnostic_request_t::get_pid() const { if (handle_->request.has_pid) @@ -131,11 +124,6 @@ bool active_diagnostic_request_t::get_recurring() const return recurring_; } -bool active_diagnostic_request_t::get_in_flight() const -{ - return in_flight_; -} - frequency_clock_t& active_diagnostic_request_t::get_frequency_clock() { return frequency_clock_; @@ -146,14 +134,14 @@ frequency_clock_t& active_diagnostic_request_t::get_timeout_clock() return timeout_clock_; } -void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticRequest* request) +utils::socketcan_bcm_t& active_diagnostic_request_t::get_socket() { - handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr)); + return socket_; } -void active_diagnostic_request_t::set_in_flight(bool val) +void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticRequest* request) { - in_flight_ = val; + handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr)); } /// @@ -172,26 +160,6 @@ bool active_diagnostic_request_t::is_diagnostic_signal(const std::string& name) return false; } -/// @brief Check is the request should be sent or not -/// -/// @return true if the request is not running or recurring nor completed, -/// or it's recurring, its clock elapsed -/// so it's time to send another one. -bool active_diagnostic_request_t::should_send() -{ - return !in_flight_ && ( (!recurring_ && !request_completed()) || - (recurring_ && frequency_clock_.elapsed(true)) ); -} - -/// @brief check if the timeout clock has elapsed -/// -/// @return true if elapsed, so it is a timeout, else false. -bool active_diagnostic_request_t::timed_out() -{ - // don't use staggered start with the timeout clock - return timeout_clock_.elapsed(false); -} - /// @brief Returns true if a sufficient response has been received for a /// diagnostic request. /// @@ -201,13 +169,5 @@ bool active_diagnostic_request_t::timed_out() bool active_diagnostic_request_t::response_received() const { return !wait_for_multiple_responses_ && - handle_->completed; -} - -/// @brief Returns true if the request has timed out waiting for a response, -/// or a sufficient number of responses has been received. -bool active_diagnostic_request_t::request_completed() -{ - return response_received() || - (timed_out() && diagnostic_request_sent(handle_)); + handle_->completed && handle_->success; }