Fix: invalid CAN frame read leads to an exception
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 7 Jun 2017 13:40:16 +0000 (15:40 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Wed, 7 Jun 2017 13:40:16 +0000 (15:40 +0200)
The frame is reported like before but ignored now.

Change-Id: I8314cdb5fa99d950023bf881c72daea2ef9bb935
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/binding/low-can-cb.cpp

index 0671f9e..5a877af 100644 (file)
@@ -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);