From: Jonathan Aillet Date: Mon, 9 Apr 2018 07:02:52 +0000 (+0200) Subject: Add saving of diagnostic messages information X-Git-Tag: 5.99.1~5 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=29de76e9beac2a8e7ffcd1ccba07a927df1f2bcc;p=apps%2Fagl-service-can-low-level.git Add saving of diagnostic messages information Add saving of diagnostic messages receive state, last value, and timestamp associated to it. Add methods to get/set these information. Add initialisation for added atributes. Add boolean to set receive state at initialisation. Generate all 'diagnostic-message.cpp' containing diagnostic messages to add receive state initialisation. Bug-AGL: SPEC-1347 Change-Id: Iee82ca3b5f79fd267717ae074d5456b8cbc1c377 Signed-off-by: Jonathan Aillet --- diff --git a/examples/OBD2/application-generated.cpp b/examples/OBD2/application-generated.cpp index f66748b6..4fef6315 100644 --- a/examples/OBD2/application-generated.cpp +++ b/examples/OBD2/application-generated.cpp @@ -18,7 +18,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 5, @@ -29,7 +30,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 10, @@ -40,7 +42,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 11, @@ -51,7 +54,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 12, @@ -62,7 +66,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 13, @@ -73,7 +78,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 15, @@ -84,7 +90,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 16, @@ -95,7 +102,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 17, @@ -106,7 +114,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 31, @@ -117,7 +126,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 45, @@ -128,7 +138,8 @@ application_t::application_t() 0.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 47, @@ -139,7 +150,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 51, @@ -150,7 +162,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 70, @@ -161,7 +174,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 76, @@ -172,7 +186,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 82, @@ -183,7 +198,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 90, @@ -194,7 +210,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 91, @@ -205,7 +222,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 92, @@ -216,7 +234,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 94, @@ -227,7 +246,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 99, @@ -238,7 +258,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} } // end diagnostic_messages_ vector diff --git a/examples/agl-vcar/application-generated.cpp b/examples/agl-vcar/application-generated.cpp index 876b95b9..9ec8fb33 100644 --- a/examples/agl-vcar/application-generated.cpp +++ b/examples/agl-vcar/application-generated.cpp @@ -384,7 +384,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 5, @@ -395,7 +396,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 10, @@ -406,7 +408,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 11, @@ -417,7 +420,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 12, @@ -428,7 +432,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 13, @@ -439,7 +444,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 15, @@ -450,7 +456,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 16, @@ -461,7 +468,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 17, @@ -472,7 +480,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 31, @@ -483,7 +492,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 45, @@ -494,7 +504,8 @@ application_t::application_t() 0.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 47, @@ -505,7 +516,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 51, @@ -516,7 +528,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 70, @@ -527,7 +540,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 76, @@ -538,7 +552,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 82, @@ -549,7 +564,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 90, @@ -560,7 +576,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 91, @@ -571,7 +588,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 92, @@ -582,7 +600,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 94, @@ -593,7 +612,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 99, @@ -604,7 +624,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} } // end diagnostic_messages_ vector diff --git a/examples/basic/application-generated.cpp b/examples/basic/application-generated.cpp index 88ee94b9..1cdf67c3 100644 --- a/examples/basic/application-generated.cpp +++ b/examples/basic/application-generated.cpp @@ -145,7 +145,8 @@ application_t::application_t() 1.00000f, handleObd2Pid, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 12, @@ -156,7 +157,8 @@ application_t::application_t() 1.00000f, nullptr, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 6, @@ -167,7 +169,8 @@ application_t::application_t() 1.00000f, handleMyDiagRequest, nullptr, - true + true, + false })} } // end diagnostic_messages_ vector diff --git a/examples/toyota/auris/application-generated.cpp b/examples/toyota/auris/application-generated.cpp index 60a21f51..3421969d 100644 --- a/examples/toyota/auris/application-generated.cpp +++ b/examples/toyota/auris/application-generated.cpp @@ -308,7 +308,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 5, @@ -319,7 +320,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 10, @@ -330,7 +332,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 11, @@ -341,7 +344,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 12, @@ -352,7 +356,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 13, @@ -363,7 +368,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 15, @@ -374,7 +380,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 16, @@ -385,7 +392,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 17, @@ -396,7 +404,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 31, @@ -407,7 +416,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 45, @@ -418,7 +428,8 @@ application_t::application_t() 0.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 47, @@ -429,7 +440,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 51, @@ -440,7 +452,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 70, @@ -451,7 +464,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 76, @@ -462,7 +476,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 82, @@ -473,7 +488,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 90, @@ -484,7 +500,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 91, @@ -495,7 +512,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 92, @@ -506,7 +524,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 94, @@ -517,7 +536,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 99, @@ -528,7 +548,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} } // end diagnostic_messages_ vector diff --git a/low-can-binding/binding/application-generated.cpp b/low-can-binding/binding/application-generated.cpp index 876b95b9..9ec8fb33 100644 --- a/low-can-binding/binding/application-generated.cpp +++ b/low-can-binding/binding/application-generated.cpp @@ -384,7 +384,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 5, @@ -395,7 +396,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 10, @@ -406,7 +408,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 11, @@ -417,7 +420,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 12, @@ -428,7 +432,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 13, @@ -439,7 +444,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 15, @@ -450,7 +456,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 16, @@ -461,7 +468,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 17, @@ -472,7 +480,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 31, @@ -483,7 +492,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 45, @@ -494,7 +504,8 @@ application_t::application_t() 0.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 47, @@ -505,7 +516,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 51, @@ -516,7 +528,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 70, @@ -527,7 +540,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 76, @@ -538,7 +552,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 82, @@ -549,7 +564,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 90, @@ -560,7 +576,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 91, @@ -571,7 +588,8 @@ application_t::application_t() 5.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 92, @@ -582,7 +600,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 94, @@ -593,7 +612,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} , {std::make_shared(diagnostic_message_t{ 99, @@ -604,7 +624,8 @@ application_t::application_t() 1.00000f, decoder_t::decode_obd2_response, nullptr, - true + true, + false })} } // end diagnostic_messages_ vector diff --git a/low-can-binding/diagnostic/diagnostic-manager.cpp b/low-can-binding/diagnostic/diagnostic-manager.cpp index 448133ef..86ff25b5 100644 --- a/low-can-binding/diagnostic/diagnostic-manager.cpp +++ b/low-can-binding/diagnostic/diagnostic-manager.cpp @@ -396,10 +396,14 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos /// @param[in] response - The response to decode from which the Vehicle message will be built and returned /// /// @return A filled openxc_VehicleMessage or a zeroed struct if there is an error. -openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response) +openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response, const uint64_t timestamp) { openxc_VehicleMessage message = build_VehicleMessage(); float value = (float)diagnostic_payload_to_integer(&response); + + struct utils::signals_found found_signals; + found_signals = utils::signals_manager_t::instance().find_signals(build_DynamicField((double) adr->get_pid())); + if(adr->get_decoder() != nullptr) { value = adr->get_decoder()(&response, value); @@ -425,8 +429,6 @@ openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_dia // If not success but completed then the pid isn't supported if(!response.success) { - struct utils::signals_found found_signals; - found_signals = utils::signals_manager_t::instance().find_signals(build_DynamicField(adr->get_name())); found_signals.diagnostic_messages.front()->set_supported(false); cleanup_request(adr, true); AFB_NOTICE("PID not supported or ill formed. Please unsubscribe from it. Error code : %d", response.negative_response_code); @@ -440,6 +442,20 @@ openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_dia // Reset the completed flag handle to make sure that it will be reprocessed the next time. adr->get_handle()->success = false; + + // Save value and timestamp of diagnostic message + if(!found_signals.diagnostic_messages.empty()) + { + // Then, for each diag_message found + for(const auto& diag_mess: found_signals.diagnostic_messages) + { + // Save value and timestamp for this message + diag_mess->set_received(true); + diag_mess->set_last_value(value); + diag_mess->set_timestamp(timestamp); + } + } + return message; } @@ -457,7 +473,7 @@ openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_handle(active_diagn if(response.completed && entry->get_handle()->completed) { if(entry->get_handle()->success) - return relay_diagnostic_response(entry, response); + return relay_diagnostic_response(entry, response, cm.get_timestamp()); } else if(!response.completed && response.multi_frame) { diff --git a/low-can-binding/diagnostic/diagnostic-manager.hpp b/low-can-binding/diagnostic/diagnostic-manager.hpp index ddbc97a2..1124ff95 100644 --- a/low-can-binding/diagnostic/diagnostic-manager.hpp +++ b/low-can-binding/diagnostic/diagnostic-manager.hpp @@ -83,7 +83,7 @@ public: const DiagnosticResponseCallback callback, float frequencyHz); // Decoding part - openxc_VehicleMessage relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response); + openxc_VehicleMessage relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response, const uint64_t timestamp); openxc_VehicleMessage relay_diagnostic_handle(active_diagnostic_request_t* entry, const can_message_t& cm); openxc_VehicleMessage find_and_decode_adr(const can_message_t& cm); bool is_diagnostic_response(const can_message_t& cm); diff --git a/low-can-binding/diagnostic/diagnostic-message.cpp b/low-can-binding/diagnostic/diagnostic-message.cpp index 69ca4e34..701248dc 100644 --- a/low-can-binding/diagnostic/diagnostic-message.cpp +++ b/low-can-binding/diagnostic/diagnostic-message.cpp @@ -34,11 +34,30 @@ const char *UNIT_NAMES[10] = { "NM" }; -diagnostic_message_t::diagnostic_message_t(uint8_t pid, const std::string& generic_name, const int min, - const int max, enum UNIT unit, float frequency, DiagnosticResponseDecoder decoder, - DiagnosticResponseCallback callback, bool supported) - : parent_{nullptr}, pid_{pid}, generic_name_{generic_name}, min_{min}, max_{max}, unit_{unit}, - frequency_{frequency}, decoder_{decoder}, callback_{callback}, supported_{supported} +diagnostic_message_t::diagnostic_message_t( + uint8_t pid, + const std::string& generic_name, + const int min, + const int max, + enum UNIT unit, + float frequency, + DiagnosticResponseDecoder decoder, + DiagnosticResponseCallback callback, + bool supported, + bool received) + : parent_{nullptr}, + pid_{pid}, + generic_name_{generic_name}, + min_{min}, + max_{max}, + unit_{unit}, + frequency_{frequency}, + decoder_{decoder}, + callback_{callback}, + supported_{supported}, + last_timestamp_{0}, + received_{received}, + last_value_{.0f} {} uint32_t diagnostic_message_t::get_pid() @@ -75,6 +94,21 @@ bool diagnostic_message_t::get_supported() const return supported_; } +bool diagnostic_message_t::get_received() const +{ + return received_; +} + +float diagnostic_message_t::get_last_value() const +{ + return last_value_; +} + +std::pair diagnostic_message_t::get_last_value_with_timestamp() const +{ + return std::make_pair(last_value_, last_timestamp_); +} + void diagnostic_message_t::set_supported(bool value) { supported_ = value; @@ -85,6 +119,21 @@ void diagnostic_message_t::set_parent(can_message_set_t* parent) parent_ = parent; } +void diagnostic_message_t::set_received(bool r) +{ + received_ = r; +} + +void diagnostic_message_t::set_last_value(float val) +{ + last_value_ = val; +} + +void diagnostic_message_t::set_timestamp(uint64_t timestamp) +{ + last_timestamp_ = timestamp; +} + /// /// @brief Build a DiagnosticRequest struct to be passed /// to diagnostic manager instance. diff --git a/low-can-binding/diagnostic/diagnostic-message.hpp b/low-can-binding/diagnostic/diagnostic-message.hpp index 873c7ff2..c2f31e35 100644 --- a/low-can-binding/diagnostic/diagnostic-message.hpp +++ b/low-can-binding/diagnostic/diagnostic-message.hpp @@ -60,10 +60,25 @@ class diagnostic_message_t bool supported_; /*!< supported_ - boolean indicating whether this pid is supported by the vehicle or not.*/ + uint64_t last_timestamp_; /*!< last_timestamp_ - the last time (in microseconds since epoch) + * that the message has been received. */ + + bool received_; /*!< received_ - True if this signal has ever been received. */ + float last_value_; /*!< last_value_ - The last received value of the diagnostic message. + * If 'received_' is false, this value is undefined. */ + public: const char* generic_name = generic_name_.c_str(); - diagnostic_message_t(uint8_t pid, const std::string& generic_name, const int min, const int max, enum UNIT unit, float frequency, - DiagnosticResponseDecoder decoder, DiagnosticResponseCallback callback, bool supported); + diagnostic_message_t(uint8_t pid, + const std::string& generic_name, + const int min, + const int max, + enum UNIT unit, + float frequency, + DiagnosticResponseDecoder decoder, + DiagnosticResponseCallback callback, + bool supported, + bool received); uint32_t get_pid(); const std::string get_generic_name() const; @@ -73,6 +88,14 @@ class diagnostic_message_t DiagnosticResponseCallback get_callback() const; bool get_supported() const; + bool get_received() const; + float get_last_value() const; + std::pair get_last_value_with_timestamp() const; + + void set_received(bool r); + void set_last_value(float val); + void set_timestamp(uint64_t timestamp); + void set_supported(bool value); void set_parent(can_message_set_t* parent); const DiagnosticRequest build_diagnostic_request() const;