diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2019-11-09 18:09:30 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2020-01-09 14:39:56 +0100 |
commit | db13354c18e888d04b776e584addb668d8614da4 (patch) | |
tree | 19f5b1b2a68eecfef6948ca92d4f6614f4cfde64 /low-can-binding/diagnostic | |
parent | e1caf27db81e9897af7512a0b47e0783593833d5 (diff) |
binding: add preinit function to load the config
Make as the others bindings using controller and load its configuration file
at preinit step.
diagnostic-manager: 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.
Bug-AGL: SPEC-2988
Change-Id: I344c1982893e47600a0b8cd03542de8069a42d24
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/diagnostic')
-rw-r--r-- | low-can-binding/diagnostic/diagnostic-manager.cpp | 19 | ||||
-rw-r--r-- | low-can-binding/diagnostic/diagnostic-manager.hpp | 5 |
2 files changed, 14 insertions, 10 deletions
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; |