From 53cd923a034162273fea2f4fb045b28686f51df5 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 15 Mar 2017 23:10:46 +0100 Subject: Make available decoding OBD2 messages method to be use as callback. Change the method to static 'cause it will be call from outside of the class. Change-Id: I88dcd845559fac7892cd489cd6e8198c143ee2a8 Signed-off-by: Romain Forlot --- src/can/can-decoder.cpp | 19 +++++++++++++++++++ src/can/can-decoder.hpp | 3 +++ src/diagnostic/diagnostic-message.cpp | 18 ------------------ src/diagnostic/diagnostic-message.hpp | 1 - 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/can/can-decoder.cpp b/src/can/can-decoder.cpp index aef042c..fce43fc 100644 --- a/src/can/can-decoder.cpp +++ b/src/can/can-decoder.cpp @@ -215,3 +215,22 @@ openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, float value = parseSignalBitfield(signal, message); return decodeSignal(signal, value, signals, send); } + + +/** +* @brief Decode the payload of an OBD-II PID. +* +* This function matches the type signature for a DiagnosticResponseDecoder, so +* it can be used as the decoder for a DiagnosticRequest. It returns the decoded +* value of the PID, using the standard formulas (see +* http://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_01). +* +* @param[in] response - the received DiagnosticResponse (the data is in response.payload, +* a byte array). This is most often used when the byte order is +* signiticant, i.e. with many OBD-II PID formulas. +* @param[in] parsed_payload - the entire payload of the response parsed as an int. +*/ +float decoder_t::decode_obd2_response(const DiagnosticResponse* response, float parsedPayload) +{ + return diagnostic_decode_obd2_pid(response); +} \ No newline at end of file diff --git a/src/can/can-decoder.hpp b/src/can/can-decoder.hpp index 326a2b7..ee601c6 100644 --- a/src/can/can-decoder.hpp +++ b/src/can/can-decoder.hpp @@ -41,4 +41,7 @@ public: static openxc_DynamicField decodeSignal(can_signal_t& signal, float value, const std::vector& signals, bool* send); + + static float decode_obd2_response(const DiagnosticResponse* response, float parsedPayload); + }; \ No newline at end of file diff --git a/src/diagnostic/diagnostic-message.cpp b/src/diagnostic/diagnostic-message.cpp index 5a8f9e5..a460ac5 100644 --- a/src/diagnostic/diagnostic-message.cpp +++ b/src/diagnostic/diagnostic-message.cpp @@ -84,21 +84,3 @@ bool obd2_signal_t::is_obd2_request(const DiagnosticRequest* request) { return request->mode == 0x1 && request->has_pid && request->pid < 0xff; } - -/** -* @brief Decode the payload of an OBD-II PID. -* -* This function matches the type signature for a DiagnosticResponseDecoder, so -* it can be used as the decoder for a DiagnosticRequest. It returns the decoded -* value of the PID, using the standard formulas (see -* http://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_01). -* -* @param[in] response - the received DiagnosticResponse (the data is in response.payload, -* a byte array). This is most often used when the byte order is -* signiticant, i.e. with many OBD-II PID formulas. -* @param[in] parsed_payload - the entire payload of the response parsed as an int. -*/ -float obd2_signal_t::decode_obd2_response(const DiagnosticResponse* response, float parsedPayload) -{ - return diagnostic_decode_obd2_pid(response); -} \ No newline at end of file diff --git a/src/diagnostic/diagnostic-message.hpp b/src/diagnostic/diagnostic-message.hpp index 7f407b4..e806257 100644 --- a/src/diagnostic/diagnostic-message.hpp +++ b/src/diagnostic/diagnostic-message.hpp @@ -66,5 +66,4 @@ class obd2_signal_t { bool is_obd2_response(const can_message_t& can_message); bool is_obd2_request(const DiagnosticRequest *request); - static float decode_obd2_response(const DiagnosticResponse* response, float parsedPayload); }; -- cgit 1.2.3-korg