summaryrefslogtreecommitdiffstats
path: root/src/low-can-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-28 21:09:26 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-28 21:45:49 +0100
commitca998f6733e3de11886ac6c3ee6525dbaaf3b525 (patch)
tree6298de2bd40417297129680a994135282ac5a3b5 /src/low-can-binding.cpp
parentabded1a649deb14f7e7fbc67d34d02ff4a9b5fa6 (diff)
Fix: can bus object life is now expanded and don't
die prematuraly. can_bus_handler object is now a pointer living forever. can_bus_dev_t object is now stored as a shared pointer into a variable member into can_bus_t. So everyone survive now. Change-Id: I52768dd7fe3c203a5f679f59afd1bcf330f3af35 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/low-can-binding.cpp')
-rw-r--r--src/low-can-binding.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/low-can-binding.cpp b/src/low-can-binding.cpp
index 0ffef5e..24d1457 100644
--- a/src/low-can-binding.cpp
+++ b/src/low-can-binding.cpp
@@ -44,6 +44,8 @@ extern "C"
*/
const struct afb_binding_interface *binder_interface;
+can_bus_t *can_bus_handler;
+
/********************************************************************************
*
* Subscription and unsubscription
@@ -235,12 +237,12 @@ extern "C"
fd_conf = afb_daemon_rootdir_open_locale(binder_interface->daemon, "can_buses.json", O_RDONLY, NULL);
/* Initialize the CAN bus handler */
- can_bus_t can_bus_handler(fd_conf);
+ can_bus_handler = new can_bus_t(fd_conf);
/* Open CAN socket */
- if(can_bus_handler.init_can_dev() == 0)
+ if(can_bus_handler->init_can_dev() == 0)
{
- can_bus_handler.start_threads();
+ can_bus_handler->start_threads();
return 0;
}
ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe");