diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-04-09 09:25:47 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-04-17 11:42:37 +0200 |
commit | e4e00c65f8b686dd93e68a3226020692a62e1d26 (patch) | |
tree | 6e1e1f14cc147f3eb29cac8aceaf91503cca27bf /low-can-binding/diagnostic | |
parent | 29de76e9beac2a8e7ffcd1ccba07a927df1f2bcc (diff) |
Add possibility to subscribe to a recurring request permanently
Add possibility to subscribe to a recurring request that won't be deleted
when no subscriber is detected.
For now, this functionnality is implemented for internal use only.
Bug-AGL: SPEC-1347
Change-Id: I48f6f647677596ba7920c4348d5406ea7bf1081b
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'low-can-binding/diagnostic')
4 files changed, 17 insertions, 6 deletions
diff --git a/low-can-binding/diagnostic/active-diagnostic-request.cpp b/low-can-binding/diagnostic/active-diagnostic-request.cpp index 71f5980d..a242147a 100644 --- a/low-can-binding/diagnostic/active-diagnostic-request.cpp +++ b/low-can-binding/diagnostic/active-diagnostic-request.cpp @@ -42,6 +42,7 @@ active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active decoder_ = adr.decoder_; callback_ = adr.callback_; recurring_ = adr.recurring_; + permanent_ = adr.permanent_; wait_for_multiple_responses_ = adr.wait_for_multiple_responses_; frequency_clock_ = adr.frequency_clock_; timeout_clock_ = adr.timeout_clock_; @@ -59,6 +60,7 @@ active_diagnostic_request_t::active_diagnostic_request_t() decoder_{nullptr}, callback_{nullptr}, recurring_{false}, + permanent_{false}, wait_for_multiple_responses_{false}, frequency_clock_{frequency_clock_t()}, timeout_clock_{frequency_clock_t()}, @@ -70,7 +72,8 @@ active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus, bool wait_for_multiple_responses, const DiagnosticResponseDecoder decoder, const DiagnosticResponseCallback callback, - float frequencyHz) + float frequencyHz, + bool permanent) : bus_{bus}, id_{id}, handle_{nullptr}, @@ -78,6 +81,7 @@ active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus, decoder_{decoder}, callback_{callback}, recurring_{frequencyHz ? true : false}, + permanent_{permanent}, wait_for_multiple_responses_{wait_for_multiple_responses}, frequency_clock_{frequency_clock_t(frequencyHz)}, timeout_clock_{frequency_clock_t(10)}, @@ -133,6 +137,11 @@ bool active_diagnostic_request_t::get_recurring() const return recurring_; } +bool active_diagnostic_request_t::get_permanent() const +{ + return permanent_; +} + frequency_clock_t& active_diagnostic_request_t::get_frequency_clock() { return frequency_clock_; diff --git a/low-can-binding/diagnostic/active-diagnostic-request.hpp b/low-can-binding/diagnostic/active-diagnostic-request.hpp index 892feb50..8e5333b5 100644 --- a/low-can-binding/diagnostic/active-diagnostic-request.hpp +++ b/low-can-binding/diagnostic/active-diagnostic-request.hpp @@ -76,6 +76,7 @@ private: ///< response is received for this request. bool recurring_; ///< bool recurring_ - If true, this is a recurring request and it will remain as active until explicitly cancelled. ///< The frequencyClock attribute controls how often a recurring request is made. + bool permanent_; ///< bool permanent_ - If true, this a permanent recurring request and will remain as active indefinitely (can't be cancelled). bool wait_for_multiple_responses_; ///< wait_for_multiple_responses_ - False by default, when any response is received for a request ///< it will be removed from the active list. If true, the request will remain active until the timeout ///< clock expires, to allow it to receive multiple response (e.g. to a functional broadcast request). @@ -93,7 +94,7 @@ public: active_diagnostic_request_t(const std::string& bus, uint32_t id, const std::string& name, bool wait_for_multiple_responses, const DiagnosticResponseDecoder decoder, - const DiagnosticResponseCallback callback, float frequencyHz); + const DiagnosticResponseCallback callback, float frequencyHz, bool permanent); ~active_diagnostic_request_t(); uint32_t get_id() const; @@ -104,6 +105,7 @@ public: DiagnosticResponseDecoder& get_decoder(); DiagnosticResponseCallback& get_callback(); bool get_recurring() const; + bool get_permanent() const; frequency_clock_t& get_frequency_clock(); frequency_clock_t& get_timeout_clock(); utils::socketcan_bcm_t& get_socket(); diff --git a/low-can-binding/diagnostic/diagnostic-manager.cpp b/low-can-binding/diagnostic/diagnostic-manager.cpp index 86ff25b5..2f22b14d 100644 --- a/low-can-binding/diagnostic/diagnostic-manager.cpp +++ b/low-can-binding/diagnostic/diagnostic-manager.cpp @@ -293,7 +293,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_request(DiagnosticRequest if (non_recurring_requests_.size() <= MAX_SIMULTANEOUS_DIAG_REQUESTS) { active_diagnostic_request_t* entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name, - wait_for_multiple_responses, decoder, callback, 0); + wait_for_multiple_responses, decoder, callback, 0, false); entry->set_handle(shims_, request); char request_string[128] = {0}; @@ -359,7 +359,7 @@ bool diagnostic_manager_t::validate_optional_request_attributes(float frequencyH /// was too much already running requests, or if the frequency was too high. active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, const char* name, bool wait_for_multiple_responses, const DiagnosticResponseDecoder decoder, - const DiagnosticResponseCallback callback, float frequencyHz) + const DiagnosticResponseCallback callback, float frequencyHz, bool permanent) { active_diagnostic_request_t* entry = nullptr; @@ -373,7 +373,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos if(recurring_requests_.size() <= MAX_SIMULTANEOUS_DIAG_REQUESTS) { entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name, - wait_for_multiple_responses, decoder, callback, frequencyHz); + wait_for_multiple_responses, decoder, callback, frequencyHz, permanent); recurring_requests_.push_back(entry); entry->set_handle(shims_, request); diff --git a/low-can-binding/diagnostic/diagnostic-manager.hpp b/low-can-binding/diagnostic/diagnostic-manager.hpp index 1124ff95..75d08e20 100644 --- a/low-can-binding/diagnostic/diagnostic-manager.hpp +++ b/low-can-binding/diagnostic/diagnostic-manager.hpp @@ -80,7 +80,7 @@ public: bool validate_optional_request_attributes(float frequencyHz); active_diagnostic_request_t* add_recurring_request(DiagnosticRequest* request, const char* name, bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder, - const DiagnosticResponseCallback callback, float frequencyHz); + const DiagnosticResponseCallback callback, float frequencyHz, bool permanent); // Decoding part openxc_VehicleMessage relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response, const uint64_t timestamp); |