added a socket class to wrap the C socket API.
[apps/agl-service-can-low-level.git] / src / low-can-binding.cpp
index 41a6ab6..79b1691 100644 (file)
@@ -40,13 +40,9 @@ extern "C"
        #include <afb/afb-service-itf.h>
 };
 
-/*
- *     Interface between the daemon and the binding
- */
+// Interface between the daemon and the binding
 const struct afb_binding_interface *binder_interface;
 
-can_bus_t *can_bus_handler;
-
 /********************************************************************************
 *
 *              Subscription and unsubscription
@@ -224,16 +220,14 @@ extern "C"
        */
        int afbBindingV1ServiceInit(struct afb_service service)
        {
-               int fd_conf;
-               fd_conf = afb_daemon_rootdir_open_locale(binder_interface->daemon, "can_buses.json", O_RDONLY, NULL);
+               configuration_t config;
 
-               /* Initialize the CAN bus handler */
-               can_bus_handler = new can_bus_t(fd_conf);
+               can_bus_manager = config.get_can_bus_manager();
 
                /* Open CAN socket */
-               if(can_bus_handler->init_can_dev() == 0)
+               if(can_bus_manager.init_can_dev() == 0)
                {
-                       can_bus_handler->start_threads();
+                       can_bus_manager.start_threads();
                        return 0;
                }
                ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe");