From cb3d8b10b7c397184b70791c000582510215780c Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 7 Jun 2017 15:40:16 +0200 Subject: Fix: invalid CAN frame read leads to an exception The frame is reported like before but ignored now. Change-Id: I8314cdb5fa99d950023bf881c72daea2ef9bb935 Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/binding/low-can-cb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'CAN-binder/low-can-binding/binding/low-can-cb.cpp') 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 0671f9e..5a877af 100644 --- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp +++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp @@ -85,10 +85,12 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void * utils::socketcan_bcm_t& s = can_subscription->get_socket(); s >> cm; - push_n_notify(cm); + // Sure we got a valid CAN message ? + if(! cm.get_id() == 0 && ! cm.get_length() == 0) + {push_n_notify(cm);} } - /* check if error or hangup */ + // check if error or hangup if ((revents & (EPOLLERR|EPOLLRDHUP|EPOLLHUP)) != 0) { sd_event_source_unref(event_source); -- cgit 1.2.3-korg