summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-11-12 20:16:06 -0500
committerScott Murray <scott.murray@konsulko.com>2019-11-13 01:18:29 +0000
commit8554afd321db96bdf0c82e9df0bdf934c7692c39 (patch)
tree22e554c00597b50ab7c3efeb8002639297c4f96c
parent8edd1d56d9d455c0c7b833e13d9b1b7861f5a4cc (diff)
Move the configuration file parsing to pre-init so that CAN device configuration will work. Bug-AGL: SPEC-2949 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I0d3fbaf5853f8e13675df6843fcab7416acf7170
-rw-r--r--binding/hvac-demo-binding.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/binding/hvac-demo-binding.c b/binding/hvac-demo-binding.c
index 5a6debd..1d5e6ac 100644
--- a/binding/hvac-demo-binding.c
+++ b/binding/hvac-demo-binding.c
@@ -278,13 +278,13 @@ static int parse_config()
}
// Extract can device
- json_object_object_get_ex(jobj, "can_device", &candevice); {
+ if (json_object_object_get_ex(jobj, "can_device", &candevice)) {
can_dev.name = json_object_get_string(candevice);
}
+ AFB_INFO("Using CAN device %s\n", can_dev.name);
// return 0 if all succeeded
return 0;
-
}
/*
@@ -700,14 +700,16 @@ static void set(afb_req_t request)
static int bindingServicePreInit(afb_api_t api)
{
- return open_can_dev();
+ if(parse_config() != 0)
+ AFB_WARNING("Default values are being used!\n");
+
+ open_can_dev();
}
static int bindingServiceInit(afb_api_t api)
{
event = afb_daemon_make_event("language");
- if(parse_config() != 0)
- AFB_WARNING("Default values are being used!\n");
+
if(afb_daemon_require_api("identity", 1))
return -1;
return afb_api_call_sync(api, "identity", "subscribe", json_object_new_object(), NULL, NULL, NULL);