Fixed some bugs with Xenomai and CAN/peak
authoretisserant
Mon, 19 Jun 2006 14:19:23 +0200
changeset 33 c767eabbaaac
parent 32 8afa33692372
child 34 3e24a4d68325
Fixed some bugs with Xenomai and CAN/peak
drivers/can_peak/can_peak.c
drivers/timers_xeno/timers_xeno.c
--- a/drivers/can_peak/can_peak.c	Fri Jun 16 14:44:23 2006 +0200
+++ b/drivers/can_peak/can_peak.c	Mon Jun 19 14:19:23 2006 +0200
@@ -62,7 +62,10 @@
   UNS8 data; 
   TPCANMsg peakMsg;
   if ((errno = CAN_Read(((CANPort*)fd0)->fd, & peakMsg))) {		// Blocks until no new message or error.
-    perror("!!! Peak board : error of reading. (from f_can_receive function) \n");
+    if(errno != -EIDRM) // error is not "Can Port closed while reading" 
+    {
+    	perror("!!! Peak board : error of reading. (from f_can_receive function) \n");
+    }
     return 1;
   }
   m->cob_id.w = peakMsg.ID;   
@@ -159,7 +162,7 @@
 int canClose(CAN_HANDLE fd0)
 {
   CAN_Close(((CANPort*)fd0)->fd);
+  WaitReceiveTaskEnd(&((CANPort*)fd0)->receiveTask);
   ((CANPort*)fd0)->used = 0;
-  WaitReceiveTaskEnd(&((CANPort*)fd0)->receiveTask);
   return 0;
 }
--- a/drivers/timers_xeno/timers_xeno.c	Fri Jun 16 14:44:23 2006 +0200
+++ b/drivers/timers_xeno/timers_xeno.c	Mon Jun 19 14:19:23 2006 +0200
@@ -52,8 +52,9 @@
 			EnterMutex();
 			TimeDispatch();
 			LeaveMutex();
-		}while ((ret =  rt_task_sleep_until(last_alarm_set)) == 0);
-	}while (ret == -EINTR && !stop_timer );
+			while ((ret = rt_task_sleep_until(last_alarm_set)) == -EINTR);
+		}while (ret == 0);
+	}while (!stop_timer);
 	printf("End of TimerLoop, code %d\n",ret);
 }
 
@@ -86,7 +87,8 @@
 		goto error;
 	}
 	
-
+	return;
+	
 error:
 	cleanup_all();
 }