aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-07 15:40:16 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-07 15:40:16 +0200
commitcb3d8b10b7c397184b70791c000582510215780c (patch)
treeca622387a4115567f547814f838eb24764e76c80 /CAN-binder
parent2e66a10937ca8189498b540e3e28047d829021ad (diff)
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder')
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.cpp6
1 files changed, 4 insertions, 2 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 0671f9eb..5a877af5 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);