summaryrefslogtreecommitdiffstats
path: root/binding/hvac-demo-binding.c
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:19:15 +0000
commit1292f584612281fc084405d8a4722b38ee5be36c (patch)
tree22e554c00597b50ab7c3efeb8002639297c4f96c /binding/hvac-demo-binding.c
parent8edd1d56d9d455c0c7b833e13d9b1b7861f5a4cc (diff)
Fix CAN device configuration
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
Diffstat (limited to 'binding/hvac-demo-binding.c')
-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);