aboutsummaryrefslogtreecommitdiffstats
path: root/obsolete/ll-can-binding.cpp
diff options
context:
space:
mode:
authorBuilder <devel@6b3797ab1e90>2017-02-03 08:58:52 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-14 10:06:35 +0100
commit91aab46150dacda677c8751942abc452998cdf8d (patch)
tree57b212aa2425237228cc6b53ab96736729850096 /obsolete/ll-can-binding.cpp
parent90e20942222d7b6142dbdaa05ab7e81bc0f79904 (diff)
Cleanup and add reading JSON conf file to define
CanBus object before open it. Signed-off-by: Builder <devel@6b3797ab1e90>
Diffstat (limited to 'obsolete/ll-can-binding.cpp')
-rw-r--r--obsolete/ll-can-binding.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/obsolete/ll-can-binding.cpp b/obsolete/ll-can-binding.cpp
index 627dd3c9..9c96a60e 100644
--- a/obsolete/ll-can-binding.cpp
+++ b/obsolete/ll-can-binding.cpp
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
@@ -33,6 +34,7 @@
#include <functional>
#include <memory>
+
#include <json-c/json.h>
#include <openxc.pb.h>
@@ -616,7 +618,27 @@ const struct afb_binding *afbBindingV1Register (const struct afb_binding_interfa
int afbBindingV1ServiceInit(struct afb_service service)
{
+ std::ifstream fd_conf;
+ std::string fd_conf_content;
+ json_object jo_canbus;
+
/* Open JSON conf file */
+ /* TODO: can't use this method in c++ for now. Need to reimplement it ? */
+ jo_canbus = json_object_new_object();
+ fd_conf = afb_daemon_rootdir_open_locale(interface->daemon, "canbus.json", O_RDONLY, NULL);
+ if (fd_conf)
+ {
+ fd_conf.seekg(0, std::ios::end);
+ fd_conf_content.resize(fd_conf.tellg());
+ fd_conf.seekg(0, std::ios::beg);
+ fd_conf.read(&fd_conf_content[0], fd_conf_content.size());
+ fd_conf.close();
+ }
+
+ jo_canbus = json_tokener_parse(&fd_conf_content);
+
+ CanBus CanBus_handler;
+ CanBus_handler.deviceName = json_object_get_string("deviceName")
/* Open CAN socket */
CanBus_handler.open();