www.pudn.com > CAN.rar > 源程序.txt, change:2010-05-15,size:1440b


while (1) 
    {   
       
        
      canWriteByteBuf(GpReFrameBuf,&GtCanFrameTest); 
      canWriteByteBuf(GpReFrameBuf,&GtCanFrameTime); 
       
        if (GpReFrameBuf->ucSize > 0) //接收缓冲区有数据 
        {                               
            while (canReadByteBuf(GpReFrameBuf, &tCanFrame) != EMPTY) 
              //canReadByteBuf函数:读数据缓冲区 
              //缓冲区不为空,继续发送  
            {  
                GbCANTI = false;//CAN发送中断标志  
                canFrameSend(GpCanNodeInfo, &tCanFrame); 
                 
       //         break; 
                
                while (GbCANTI != true) 
                { 
                    delay(10 * (GulSysClock / 4000));                   /* 延时约10ms                   */ 
                }                 
            } 
            /*******接收远程帧 *******/ 
            canMsgObjSet(GpCanNodeInfo, 0x01, MASK, EXT_ID_FILTER, MSG_OBJ_TYPE_RX_REMOTE); 
                                                                       
                               
       } 
        else { 
           
          canWriteByteBuf(GpTxFrameBuf,GpTxFrameBuf); 
 //        GbCANTI=false;  
          canFrameSend(GpCanNodeInfo, GpTxFrameBuf);  
 //         break; 
//            canReadByteBuf(GpCanNodeInfo,GpReFrameBuf); 
            delay(20 * (GulSysClock / 4000));                           /* 延时约20ms                   */ 
        }   
    } 
}