aboutsummaryrefslogtreecommitdiffstats
path: root/src/diagnostic
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-20 09:08:12 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-20 09:08:12 +0000
commitc0fd6e1982353d056c26a292186ef0df315adde3 (patch)
tree6dce1b1866aab81b660aaae554c8f16c53f0d2d5 /src/diagnostic
parentd99b87ba4332fd0c1e51d2708e46c52bad713558 (diff)
Fix: Avoid segfault if diagnostic bus isn't correctly set.
There is a segfault when binding configuration doesn't matches configuration generated. Improve general CAN bus device initialization. Change-Id: I17ea94ee54841d09ac63a7ffad303a88d99e0173 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/diagnostic')
-rw-r--r--src/diagnostic/diagnostic-manager.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp
index 69e2a7c4..017601c9 100644
--- a/src/diagnostic/diagnostic-manager.cpp
+++ b/src/diagnostic/diagnostic-manager.cpp
@@ -81,7 +81,10 @@ void diagnostic_manager_t::reset()
bool diagnostic_manager_t::shims_send(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size)
{
std::shared_ptr<can_bus_dev_t> can_bus_dev = can_bus_t::get_can_device(configuration_t::instance().get_diagnostic_manager().bus_);
- return can_bus_dev->shims_send(arbitration_id, data, size);
+ if(can_bus_dev != nullptr)
+ return can_bus_dev->shims_send(arbitration_id, data, size);
+ ERROR(binder_interface, "shims_send: Can not retrieve diagnostic bus: %s", configuration_t::instance().get_diagnostic_manager().bus_.c_str());
+ return false;
}
/// @brief The type signature for an optional logging function, if the user
@@ -446,12 +449,18 @@ int diagnostic_manager_t::send_request(sd_event_source *s, uint64_t usec, void *
{
adr->get_frequency_clock().tick();
start_diagnostic_request(&dm.shims_, adr->get_handle());
- if(adr->get_handle()->completed && !adr->get_handle()->success)
+ if(adr->get_handle()->completed)
{
- DEBUG(binder_interface, "send_request: Fatal error sending diagnostic request");
- sd_event_source_unref(s);
- return -1;
+ if(!adr->get_handle()->success)
+ {
+ ERROR(binder_interface, "send_request: Fatal error sending diagnostic request");
+ sd_event_source_unref(s);
+ return -1;
+ }
}
+ else
+ WARNING(binder_interface, "send_request: There was a problem sending your request using bus %s.", adr->get_can_bus_dev()->get_device_name().c_str());
+
adr->get_timeout_clock().tick();
adr->set_in_flight(true);