From 5d7fbc236e5778a54c39afd51ed353c0e8761dec Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 15 Mar 2017 23:20:27 +0100 Subject: Retrieve easily Diagnostic Request PID from an Active Diagnostic Request Change-Id: I787cd94b338c458fda0259bd2bcf47a1fa85cc3f Signed-off-by: Romain Forlot --- src/diagnostic/active-diagnostic-request.cpp | 9 +++++++++ src/diagnostic/active-diagnostic-request.hpp | 1 + 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/diagnostic/active-diagnostic-request.cpp b/src/diagnostic/active-diagnostic-request.cpp index fcdbc97a..4f288663 100644 --- a/src/diagnostic/active-diagnostic-request.cpp +++ b/src/diagnostic/active-diagnostic-request.cpp @@ -22,6 +22,8 @@ #include "../configuration.hpp" +#define ERROR_PID 0xFF + std::string active_diagnostic_request_t::prefix_ = "diagnostic_messages"; bool active_diagnostic_request_t::operator==(const active_diagnostic_request_t& b) @@ -73,6 +75,13 @@ const std::shared_ptr active_diagnostic_request_t::get_can_bus_de return can_bus_t::get_can_device(bus_); } +uint16_t active_diagnostic_request_t::get_pid() const +{ + if (handle_->request.has_pid) + return handle_->request.pid; + return ERROR_PID; +} + DiagnosticRequestHandle* active_diagnostic_request_t::get_handle() { return handle_; diff --git a/src/diagnostic/active-diagnostic-request.hpp b/src/diagnostic/active-diagnostic-request.hpp index b40ae08a..cb9b1d09 100644 --- a/src/diagnostic/active-diagnostic-request.hpp +++ b/src/diagnostic/active-diagnostic-request.hpp @@ -93,6 +93,7 @@ public: uint32_t get_id() const; const std::shared_ptr get_can_bus_dev() const; DiagnosticRequestHandle* get_handle(); + uint16_t get_pid() const; const std::string get_name() const; static std::string& get_prefix(); DiagnosticResponseDecoder& get_decoder(); -- cgit 1.2.3-korg