aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-09 13:21:43 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-09 13:21:43 +0100
commitfa37dc8ca800a76f9b77c2fdeebd7a9c9587a358 (patch)
tree65c64431d4ea7e39140233e14a808b10afe76ffa
parent2ae3f4a6d1e4f45ebf877227d22e73b9015ce395 (diff)
diag-mng: Change way to initialize the diag bus
This was kind of hardcoded and now, it is initialized by a configuration key of the controller configuration JSON file. Change-Id: I6e24c28781c08bd8e99de33f16b5ae10d1a6a9a1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--low-can-binding/binding/application.hpp2
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp2
-rw-r--r--low-can-binding/diagnostic/diagnostic-manager.cpp19
-rw-r--r--low-can-binding/diagnostic/diagnostic-manager.hpp5
4 files changed, 15 insertions, 13 deletions
diff --git a/low-can-binding/binding/application.hpp b/low-can-binding/binding/application.hpp
index 30e21833..d6d0f67a 100644
--- a/low-can-binding/binding/application.hpp
+++ b/low-can-binding/binding/application.hpp
@@ -65,8 +65,6 @@ class application_t
std::map<std::string, std::shared_ptr<low_can_subscription_t> >& get_can_devices();
- const std::string get_diagnostic_bus() const;
-
diagnostic_manager_t& get_diagnostic_manager() ;
uint8_t get_active_message_set() const;
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index 8c314af7..e75bddf5 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -370,7 +370,7 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
if( subscription.signal_ )
ret = subscription.socket_->open(subscription.signal_->get_message()->get_bus_device_name());
else if(! subscription.diagnostic_message_.empty())
- ret = subscription.socket_->open(application_t::instance().get_diagnostic_bus());
+ ret = subscription.socket_->open(application_t::instance().get_diagnostic_manager().get_bus_name());
else if(! bus_name.empty())
ret = subscription.socket_->open(bus_name);
diff --git a/low-can-binding/diagnostic/diagnostic-manager.cpp b/low-can-binding/diagnostic/diagnostic-manager.cpp
index 91dba470..f3c513c5 100644
--- a/low-can-binding/diagnostic/diagnostic-manager.cpp
+++ b/low-can-binding/diagnostic/diagnostic-manager.cpp
@@ -56,16 +56,19 @@ diagnostic_manager_t::~diagnostic_manager_t()
///
/// this will initialize DiagnosticShims and cancel all active requests
/// if there are any.
-bool diagnostic_manager_t::initialize()
+bool diagnostic_manager_t::initialize(std::string diagnostic_bus)
{
- // Mandatory to set the bus before intialize shims.
- bus_ = application_t::instance().get_diagnostic_bus();
-
- init_diagnostic_shims();
- reset();
+ if (! diagnostic_bus.empty())
+ {
+ bus_ = diagnostic_bus;
+ init_diagnostic_shims();
+ reset();
- initialized_ = true;
- AFB_DEBUG("Diagnostic Manager initialized");
+ AFB_DEBUG("Diagnostic Manager initialized");
+ initialized_ = true;
+ return initialized_;
+ }
+ AFB_ERROR("Diagnostic Manager missing its bus name in the config");
return initialized_;
}
diff --git a/low-can-binding/diagnostic/diagnostic-manager.hpp b/low-can-binding/diagnostic/diagnostic-manager.hpp
index 784bcd70..c0a8255e 100644
--- a/low-can-binding/diagnostic/diagnostic-manager.hpp
+++ b/low-can-binding/diagnostic/diagnostic-manager.hpp
@@ -33,7 +33,7 @@
#define DIAGNOSTIC_RESPONSE_ARBITRATION_ID_OFFSET 0x8
///
-/// @brief The core structure for running the diagnostics module of the binding.
+/// @brief The binding structure for running the diagnostics module of the binding.
///
/// This stores details about the active requests and shims required to connect
/// the diagnostics library to the CAN device.
@@ -54,11 +54,12 @@ private:
static bool shims_send(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size);
static void shims_logger(const char* m, ...);
+
public:
diagnostic_manager_t();
~diagnostic_manager_t();
- bool initialize();
+ bool initialize(std::string diagnostic_bus);
const std::string get_bus_name() const;
const std::string get_bus_device_name() const;