summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.cpp13
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.cpp4
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.hpp2
3 files changed, 12 insertions, 7 deletions
diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.cpp b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
index 414fa910..21838936 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
@@ -55,9 +55,16 @@ void on_no_clients(std::string message)
int read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
{
can_signal_t* sig= (can_signal_t*)userdata;
- if(sig->read_socket() != can_message_format_t::ERROR)
- return 0;
- return -1;
+ sig->read_socket();
+
+ /* check if error or hangup */
+ if ((revents & (EPOLLERR|EPOLLRDHUP|EPOLLHUP)) != 0)
+ {
+ sd_event_source_unref(s);
+ sig->get_socket().close();
+ sig->create_rx_filter();
+ }
+ return 0;
}
///******************************************************************************
diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp
index c8098a51..d072fb36 100644
--- a/CAN-binder/low-can-binding/can/can-signals.cpp
+++ b/CAN-binder/low-can-binding/can/can-signals.cpp
@@ -235,7 +235,7 @@ int can_signal_t::create_rx_filter()
return -1;
}
-can_message_format_t can_signal_t::read_socket()
+void can_signal_t::read_socket()
{
can_message_t msg;
can_bus_t& cbm = configuration_t::instance().get_can_bus_manager();
@@ -243,6 +243,4 @@ can_message_format_t can_signal_t::read_socket()
std::lock_guard<std::mutex> can_message_lock(cbm.get_can_message_mutex());
{ cbm.push_new_can_message(msg); }
cbm.get_new_can_message_cv().notify_one();
-
- return msg.get_format();
} \ No newline at end of file
diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp
index 8196c7eb..6152b79a 100644
--- a/CAN-binder/low-can-binding/can/can-signals.hpp
+++ b/CAN-binder/low-can-binding/can/can-signals.hpp
@@ -159,5 +159,5 @@ public:
void set_last_value(float val);
int create_rx_filter();
- can_message_format_t read_socket();
+ void read_socket();
}; \ No newline at end of file