drivers/can_peak/can_peak.c
changeset 33 c767eabbaaac
parent 0 4472ee7c6c3e
child 35 88812de1d7cc
equal deleted inserted replaced
32:8afa33692372 33:c767eabbaaac
    60 UNS8 canReceive(CAN_HANDLE fd0, Message *m)
    60 UNS8 canReceive(CAN_HANDLE fd0, Message *m)
    61 {
    61 {
    62   UNS8 data; 
    62   UNS8 data; 
    63   TPCANMsg peakMsg;
    63   TPCANMsg peakMsg;
    64   if ((errno = CAN_Read(((CANPort*)fd0)->fd, & peakMsg))) {		// Blocks until no new message or error.
    64   if ((errno = CAN_Read(((CANPort*)fd0)->fd, & peakMsg))) {		// Blocks until no new message or error.
    65     perror("!!! Peak board : error of reading. (from f_can_receive function) \n");
    65     if(errno != -EIDRM) // error is not "Can Port closed while reading" 
       
    66     {
       
    67     	perror("!!! Peak board : error of reading. (from f_can_receive function) \n");
       
    68     }
    66     return 1;
    69     return 1;
    67   }
    70   }
    68   m->cob_id.w = peakMsg.ID;   
    71   m->cob_id.w = peakMsg.ID;   
    69   if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST)         	/* bits of MSGTYPE_*/
    72   if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST)         	/* bits of MSGTYPE_*/
    70     m->rtr = 0;
    73     m->rtr = 0;
   157 
   160 
   158 /***************************************************************************/
   161 /***************************************************************************/
   159 int canClose(CAN_HANDLE fd0)
   162 int canClose(CAN_HANDLE fd0)
   160 {
   163 {
   161   CAN_Close(((CANPort*)fd0)->fd);
   164   CAN_Close(((CANPort*)fd0)->fd);
       
   165   WaitReceiveTaskEnd(&((CANPort*)fd0)->receiveTask);
   162   ((CANPort*)fd0)->used = 0;
   166   ((CANPort*)fd0)->used = 0;
   163   WaitReceiveTaskEnd(&((CANPort*)fd0)->receiveTask);
       
   164   return 0;
   167   return 0;
   165 }
   168 }