aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/diagnostic/diagnostic-manager.cpp
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-04-09 09:02:52 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-04-17 11:42:07 +0200
commit29de76e9beac2a8e7ffcd1ccba07a927df1f2bcc (patch)
tree7e4c60d31d0283a0e67dba8b9ae11e35e9e52c02 /low-can-binding/diagnostic/diagnostic-manager.cpp
parentddd4374f35df2d8b8e9b4ecf4890abba6fab3734 (diff)
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 <jonathan.aillet@iot.bzh>
Diffstat (limited to 'low-can-binding/diagnostic/diagnostic-manager.cpp')
-rw-r--r--low-can-binding/diagnostic/diagnostic-manager.cpp24
1 files changed, 20 insertions, 4 deletions
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)
{