From 04b7efcdd1a8dfdf461c78d083aabee5445e54bd Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 20 Nov 2019 15:31:14 +0100 Subject: can-bus: Use configuration from JSON file Use configuration from JSON file instead of the old INI file. Now all configuration files lies within the binding tree. Bug-AGL: SPEC-2988 Change-Id: Id986d19751db958ad5cf3b7f2b2c5443d4ceb062 Signed-off-by: Romain Forlot --- low-can-binding/binding/application.cpp | 5 +++++ low-can-binding/binding/low-can-cb.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'low-can-binding/binding') diff --git a/low-can-binding/binding/application.cpp b/low-can-binding/binding/application.cpp index 063a11da..bb3bf15b 100644 --- a/low-can-binding/binding/application.cpp +++ b/low-can-binding/binding/application.cpp @@ -25,6 +25,11 @@ #define MICROSECONDS_IN_SECOND 1000000 #define ENGINE_VALUE_TIMEOUT 5 +application_t::application_t() + : can_bus_manager_{} + , message_set_{} +{} + /// @brief Return singleton instance of configuration object. application_t& application_t::instance() { diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp index 35c6d9ee..3037994a 100644 --- a/low-can-binding/binding/low-can-cb.cpp +++ b/low-can-binding/binding/low-can-cb.cpp @@ -65,6 +65,7 @@ int config_low_can(afb_api_t apiHandle, CtlSectionT *section, json_object *json_ application_t *application = (application_t*) ctrlConfig->external; int active_message_set; + json_object *dev_mapping = nullptr; const char *diagnotic_bus = nullptr; if(wrap_json_unpack(json_obj, "{si, ss}", @@ -74,6 +75,12 @@ int config_low_can(afb_api_t apiHandle, CtlSectionT *section, json_object *json_ application->set_active_message_set((uint8_t)active_message_set); + if(wrap_json_unpack(json_obj, "{so}", + "dev-mapping", &dev_mapping)) + return -1; + + application->get_can_bus_manager().set_can_devices(dev_mapping); + /// Initialize Diagnostic manager that will handle obd2 requests. /// We pass by default the first CAN bus device to its Initialization. if(! application_t::instance().get_diagnostic_manager().initialize(diagnotic_bus)) @@ -867,7 +874,6 @@ int init_binding(afb_api_t api) return -1; } - can_bus_manager.set_can_devices(); can_bus_manager.start_threads(); utils::signals_manager_t& sm = utils::signals_manager_t::instance(); -- cgit 1.2.3-korg