From cea127e54c1d3bd4d814d4726e2a718f17076bf7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu>
Date: Thu, 2 Jul 2015 15:21:44 +0000
Subject: [PATCH] Added and exception in the read_frame function to notify that
 no data is available.

---
 src/can/can.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/can/can.cpp b/src/can/can.cpp
index 5755a5c..e65a287 100755
--- a/src/can/can.cpp
+++ b/src/can/can.cpp
@@ -304,13 +304,15 @@ void CCAN::read_frame(unsigned int *can_id, unsigned char *data, int *len)
     frame=this->rx_frames.front();
     this->rx_frames.pop();
     *can_id=frame.can_id;
-    *len=frame.can_dlc;
+    *len=frame.can_dlc; //COMMENT: Do we need a cast ? frame.can_dlc is __u8 type variable (see /usr/include/linux/can.h) 
     for(i=0;i<frame.can_dlc;i++)
       data[i]=frame.data[i];
   }
   else
   {
     /* handle exceptions */
+    this->can_access.exit();    
+    throw CCommException(_HERE_,"No data available",this->comm_id);
   }
   this->can_access.exit();
 }
-- 
GitLab