Is there is no diagnostic message corresponding then do nothing
Change-Id: Ib6627b3c10b1b7a0a46d41323a6623efe808a015
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
{
std::vector<diagnostic_message_t*> found;
configuration_t::instance().find_diagnostic_messages(build_DynamicField(message_name), found);
- return found.front();
+ if(! found.empty())
+ return found.front();
+ return nullptr;
}
DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(diagnostic_message_t* diag_msg) const
DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(std::string message_name) const
{
- return new DiagnosticRequest(get_diagnostic_message(message_name)->build_diagnostic_request());
+ diagnostic_message_t* diag_msg = get_diagnostic_message(message_name);
+ if( diag_msg != nullptr)
+ return new DiagnosticRequest(diag_msg->build_diagnostic_request());
+ return nullptr;
}
/// @brief return signals name found searching through CAN signals list.
void on_no_clients(std::string message)
{
DiagnosticRequest* diag_req = configuration_t::instance().get_request_from_diagnostic_message(message);
- active_diagnostic_request_t* adr = configuration_t::instance().get_diagnostic_manager().find_recurring_request(diag_req);
- configuration_t::instance().get_diagnostic_manager().cleanup_request(adr, true);
+ if(diag_req != nullptr)
+ {
+ active_diagnostic_request_t* adr = configuration_t::instance().get_diagnostic_manager().find_recurring_request(diag_req);
+ if( adr != nullptr)
+ configuration_t::instance().get_diagnostic_manager().cleanup_request(adr, true);
+ }
}
///******************************************************************************