diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-24 11:10:02 +0000 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-24 11:12:55 +0000 |
commit | 5c0c41e87ed5d1a2de7d336465c3beb3987a299f (patch) | |
tree | 7ac1dcf406354f489c095664739a3a15d754601d /src/can-utils.cpp | |
parent | ec6579686e46f39205547a5a54efe3c9e671aee8 (diff) |
Remove socket read management by systemd event
loop and use classic thread with a blocking
read
Change-Id: Iac5428009b57c727bb32bd4893bc3fe282ba35c7
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-utils.cpp')
-rw-r--r-- | src/can-utils.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/can-utils.cpp b/src/can-utils.cpp index 8a91bd1..c6f2d57 100644 --- a/src/can-utils.cpp +++ b/src/can-utils.cpp @@ -28,7 +28,6 @@ #include <sys/socket.h> #include <json-c/json.h> #include <linux/can/raw.h> -#include <systemd/sd-event.h> extern "C" { @@ -187,7 +186,6 @@ int can_bus_t::init_can_dev() t = devices_name.size(); i=0; - std::lock_guard<std::mutex> can_frame_lock(can_frame_mutex); for(const auto& device : devices_name) { can_bus_dev_t can_bus_device_handler(device); @@ -197,7 +195,6 @@ int can_bus_t::init_can_dev() ERROR(binder_interface, "Can't open device %s", device); can_bus_device_handler.start_reading(std::ref(*this)); } - can_frame_mutex.unlock(); NOTICE(binder_interface, "Initialized %d/%d can bus device(s)", i, t); return 0; @@ -301,15 +298,6 @@ bool can_bus_t::has_vehicle_message() const /******************************************************************************** * -* This is the sd_event_add_io callback function declaration. -* Its implementation can be found into low-can-binding.cpp. -* -*********************************************************************************/ - -int can_frame_received(sd_event_source *s, int fd, uint32_t revents, void *userdata); - -/******************************************************************************** -* * can_bus_dev_t method implementation * *********************************************************************************/ @@ -319,22 +307,6 @@ can_bus_dev_t::can_bus_dev_t(const std::string &dev_name) { } -int can_bus_dev_t::event_loop_connection() -{ - sd_event_source *source; - int rc; - - /* adds to the event loop */ - rc = sd_event_add_io(afb_daemon_get_event_loop(binder_interface->daemon), &source, can_socket_, EPOLLIN, can_frame_received, this); - if (rc < 0) { - close(); - ERROR(binder_interface, "Can't coonect CAN device %s to the event loop", device_name_); - } else { - NOTICE(binder_interface, "Connected to %s", device_name_); - } - return rc; -} - int can_bus_dev_t::open() { const int canfd_on = 1; @@ -374,14 +346,9 @@ int can_bus_dev_t::open() /* And bind it to txAddress */ if (::bind(can_socket_, (struct sockaddr *)&txAddress_, sizeof(txAddress_)) < 0) - { ERROR(binder_interface, "Bind failed"); - } else - { - ::fcntl(can_socket_, F_SETFL, O_NONBLOCK); return 0; - } } close(); } |