#define  GLOBALS_APP_CAN
#include "../App_Headers/includes.h"

#pragma CODE_SEG OTHER_ROM
/*-------------------------------------------------------------------------
函数名称：App_CheckCanDrop
功    能：
参    数：None
返回数值：None
使用说明：
--------------------------------------------------------------------------*/

INT8U    CanMsg1CFFBE18_On=0;
void App_CheckCanDrop(void)
{
  if(Curkeyinput == KeyOFF)
  {
    CanMsgF004.ProceF = empoty;
    CanMsgFEEE.ProceF = empoty;
    CanMsgEECA00.ProceF = empoty;
 //   CanMsgEECA3D.ProceF = empoty;
    CanMsgFEFF.ProceF = empoty;
    CanMsgFEE4.ProceF = empoty;
    CanMsgFF08.ProceF = empoty;
    CanMsgFE5600.ProceF = empoty;
    CanMsgFE563D.ProceF = empoty;
    CanMsgFE40.ProceF = empoty;
  //  CanMsgFF0A.ProceF = empoty;      lzs--shan
    CanMsgF001.ProceF = empoty;
    //CanMsg18ECFF00.ProceF = empoty;
    //CanMsg18EBFF00.ProceF = empoty;
    CanMsgFD0700.ProceF = empoty;
    CanMsg18FD7C00.ProceF = empoty;
    CanMsg18E0FF00.ProceF = empoty;
    //--lzs--jia----
    CanMsg18FEFF00.ProceF = empoty;   //驾驶员警告灯---潍柴报文---。
  //  CanMsg18FECA10.ProceF = empoty;   //驾驶员警告灯---潍柴报文---。
    CanMsg1CFFBE18.ProceF = empoty;
    CanMsg5F2.ProceF = empoty;
  }
  //转速报文
  if(CanClk.Signal.ExistF004 == Enable)
  {
    if(CanClk.IDF004Time >= T_100ms)
    {
      CanClk.IDF004Time = null;
      if(CanClk.IDF004Cn == null)
      {
        bF004Flag=0;
        RevMeter.CurBoardVal=0;
        CanClk.Signal.ExistF004 = Disable;
      }
      if(CanClk.IDF004Cn > null)
      {
        CanClk.IDF004Cn --;
      }
    }
  }
  //--------------
  if(CanClk.IDDropTime >= T_100ms)
  {
    CanClk.IDDropTime = null;        
    if(CanClk.Signal.ExistFEF1 == Enable)
    {
      if(CanClk.IDFEF1Cn == null)
      {
        bDSTable[ID_CRUISELAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        CanClk.Signal.ExistFEF1 = Disable;
        Cruise_OUT =0;                
      }
      if(CanClk.IDFEF1Cn > null)
      {
        CanClk.IDFEF1Cn --;
      }            
    }
    //-----------------------------------        
    if(CanClk.Signal.ExistFD7C == Enable)
    {
      if(CanClk.IDFD7CCn == null)
      {
        CanMsg18FD7C00.Data[0].bbyte = 0;
        bDSTable[ID_DPFLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_DPFRLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_DPFLAMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_HOUTPUTTEMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));
        bDSTable[ID_DPFForbit]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        DPF_OUT =0;
        HOutputTempL_OUT =0;
        HOutputTempR_OUT =0;
        CanMsg18FD7C00.Data[2].bbyte = 0;                
        CanClk.Signal.ExistFD7C  = Disable;
      }
      if(CanClk.IDFD7CCn > null)
      {
        CanClk.IDFD7CCn --;
      }
    }
    if(CanClk.Signal.ExistE0FF00 == Enable)
    {
      if(CanClk.IDE0FF00Cn == null)
      {              
        bDSTable[ID_DPFForbit]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        CanMsg18E0FF00.Data[5].bbyte = 0;                
        CanClk.Signal.ExistE0FF00  = Disable;
      }
      if(CanClk.IDE0FF00Cn > null)
      {
        CanClk.IDE0FF00Cn --;
      }
    }
  }
  //水温报文------------------------------
  if(CanClk.Signal.ExistFEEE == Enable)
  {
    if(CanClk.IDFEEETime >= T_100ms)
    {
      CanClk.IDFEEETime = null;
      if(CanClk.IDFEEECn == null)
      {                
        bFEEEFlag=0;
        TempMeter.CurBoardVal=0;
        CanClk.Signal.ExistFEEE = Disable;
      }
      if(CanClk.IDFEEECn > null)
      {
        CanClk.IDFEEECn --;
      }
    }
  }
  //油水分离--------------------------------
  if(CanClk.Signal.ExistFEFF == Enable)
  {
    if(CanClk.IDFEFFTime >= T_100ms)
    {
      CanClk.IDFEFFTime = null;
      if(CanClk.IDFEFFCn == null)
      {                
        bFEFFFlag=0;
        bDSTable[ID_WIF]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_DRIVERLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        OILWATER_LED_P = 1;
        CanMsgFEFF.Data[0].bbyte = 0;
        CanMsgFEFF.Data[1].bbyte = 0x07;
                
        CanClk.Signal.ExistFEFF = Disable;
      }
      if(CanClk.IDFEFFCn > null)
      {
        CanClk.IDFEFFCn --;
      }
    }
  }
  // 预热---------------------------------
  if(CanClk.Signal.ExistFEE4 == Enable)
  {
    if(CanClk.IDFEE4Time >= T_100ms)
    {
      CanClk.IDFEE4Time = null;
      if(CanClk.IDFEE4Cn == null)
      {                
        bFEE4Flag=0;
        bDSTable[ID_HEAT]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        CanClk.Signal.ExistFEE4 = Disable;
      }
      if(CanClk.IDFEE4Cn > null)
      {
        CanClk.IDFEE4Cn --;
      }
    }
  }    
  //天蓝液00
  if(CanClk.Signal.ExistFE5600 == Enable)
  {
    if(CanClk.IDFE5600Time >= T_100ms)
    {
      CanClk.IDFE5600Time = null;
      if(CanClk.IDFE5600Cn == null)
      {
        bFE5600Flag=0;
        CanMsgFE5600.Data[0].bbyte = 0;
        CanClk.Signal.ExistFE5600 = Disable;
      }
      if(CanClk.IDFE5600Cn > null)
      {
        CanClk.IDFE5600Cn --;
      }
    }
  }
  //天蓝液3D
  if(CanClk.Signal.ExistFE563D == Enable)
  {
    if(CanClk.IDFE563DTime >= T_100ms)
    {
      CanClk.IDFE563DTime = null;
      if(CanClk.IDFE563DCn == null)
      {
        bFE563DFlag=0;
        CanMsgFE563D.Data[0].bbyte = 0;
        CanClk.Signal.ExistFE563D = Disable;
      }
      if(CanClk.IDFE563DCn > null)
      {
        CanClk.IDFE563DCn --;
      }
    }
  }
  //--------------------------------------
  if((CanClk.Signal.ExistFE563D==Disable)&&(CanClk.Signal.ExistFE5600==Disable))
  {
    bCatalystLevel = 0;
    AdbuleMeter.CurBoardVal = 0;
  }
  //转向后雾报文
  if(CanClk.Signal.ExistFE40 == Enable)
  {
    if(CanClk.IDFE40Time >= T_100ms)
    {
      CanClk.IDFE40Time = null;
      if(CanClk.IDFE40Cn == null)
      {                
        bFE40Flag=0;                
        CanClk.Signal.ExistFE40 = Disable;
      }
      if(CanClk.IDFE40Cn > null)
      {
        CanClk.IDFE40Cn --;
      }
    }
  }
  // ABS报文
  if(CanClk.Signal.ExistF001 == Enable)
  {
    if(CanClk.IDF001Time >= T_100ms)
    {
      CanClk.IDF001Time = null;
      if(CanClk.IDF001Cn == null)
      {
        bF001Flag=0;
        CanMsgF001.Data[5].bbyte = 0;
        bDSTable[ID_ABS]&=(~(DS0_MASK|DS1_MASK));
                
        CanClk.Signal.ExistF001 = Disable;
      }
      if(CanClk.IDF001Cn > null)
      {
        CanClk.IDF001Cn --;
      }
    }
  }    
  //油门开度
  if(CanClk.Signal.Exist0CF00300 == Enable)
  {
    if(CanClk.ID0CF00300Time >= T_100ms)
    {
      CanClk.ID0CF00300Time = null;
      if(CanClk.ID0CF00300Cn == null)
      {
        b0CF00300Flag = 0;
        CanMsg0CF00300.Data[1].bbyte= 0xFF;
        OilScale = 255;
                
        CanClk.Signal.Exist0CF00300 = Disable;
      }
      if(CanClk.ID0CF00300Cn > null)
      {
        CanClk.ID0CF00300Cn --;
      }
    }
  }
  //油耗---------------
  if(CanClk.Signal.ExistFEF200 == Enable)
  {
    if(CanClk.IDFEF200Time >= T_100ms)
    {
      CanClk.IDFEF200Time = null;
      if(CanClk.IDFEF200Cn == null)
      {
        bFEF200Flag = 0;
                
        CanMsg18FEF200.Data[2].bbyte= 0;
        CanMsg18FEF200.Data[3].bbyte= 0;
        CanMsg18FEF200.Data[4].bbyte= 0;
        CanMsg18FEF200.Data[5].bbyte= 0;
        InstFuelConsump = 0;
        AvgFuelConsump = 0;
                
        CanClk.Signal.ExistFEF200 = Disable;
      }
      if(CanClk.IDFEF200Cn > null)
      {
        CanClk.IDFEF200Cn --;
      }
    }
  }
  //机油压力
  if(CanClk.Signal.ExistFEEF == Enable)
  {
    if(CanClk.IDFEEFTime >= T_100ms)
    {
      CanClk.IDFEEFTime = null;
      if(CanClk.IDFEEFCn == null)
      {
        bFEEFlag = 0;
                
        CanMsgFEEF.Data[3].bbyte= 0;
        OilPressure = 255;
        Oil_LED_P = 0;//灭
                
        CanClk.Signal.ExistFEF200 = Disable;
      }
      if(CanClk.IDFEF200Cn > null)
      {
        CanClk.IDFEF200Cn --;
      } 
    }
  }
  //----hyq--20180318   18ECFF00
  /*if(CanClk.Signal.Exist18ECFF00)
  {   
    if(CanClk.ID18ECFF00Time >= T_100ms)
    {
      CanClk.ID18ECFF00Time = null;
      if(CanClk.ID18ECFF00Cn == null)
      {
        EcmDtcTbl[0].Err=0;
        bEcmDtcCnt=0;
        Engine21_18EBFF00 = 0;  
        OBDLamp87_18EBFF00 = 0;    
        MulCanMsg_ECM18EBFF00.bBuf[0] = 0x00;          
                       
        CanClk.Signal.Exist18ECFF00 = Disable;                
      }
      if(CanClk.ID18ECFF00Cn > null)
      {
        CanClk.ID18ECFF00Cn --;
      }
    }    
  } */
  //OBD黄 OBD(Check)
  if(CanClk.Signal.ExistFECA00 == Enable)
  {      
    if(CanClk.IDFECA00Time >= T_100ms)
    {
      CanClk.IDFECA00Time = null;
      if(CanClk.IDFECA00Cn == null)
      {
        bFECA00Flag=0;
	      bDSTable[ID_EWLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
	      bDSTable[ID_EWLAMP1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1               
        CanMsgEECA00.Data[1].bbyte = 0x3c;
        CanMsgEECA00.Data[0].bbyte = 0x30;
               
        CanClk.Signal.ExistFECA00 = Disable;                
      }
      if(CanClk.IDFECA00Cn > null)
      {
        CanClk.IDFECA00Cn --;
      }
    } 
  }   
  //OBD黄 OBD(Check)
  if(CanClk.Signal.ExistFECA3D == Enable)
  {      
    if(CanClk.IDFECA3DTime >= T_100ms)
    {
      CanClk.IDFECA3DTime = null;
      if(CanClk.IDFECA3DCn == null)
      {
        bFECA3DFlag=0;
        bDSTable[ID_ESLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
                
        CanClk.Signal.ExistFECA3D = Disable;                
      }
      if(CanClk.IDFECA3DCn > null)
      {
        CanClk.IDFECA3DCn --;
      }
    } 
  }          
  //
  if(CanClk.Signal.ExistFF08 == Enable)
  {      
    if(CanClk.IDFF08Time >= T_100ms)
    {
      CanClk.IDFF08Time = null;
      if(CanClk.IDFF08Cn == null)
      {
        bFF08Flag=0;               
        CanClk.Signal.ExistFF08 = Disable;                
      }
      if(CanClk.IDFF08Cn > null)
      {
        CanClk.IDFF08Cn --;
      }
    } 
  }
  //
  if(CanClk.Signal.ExistFEBF0B == Enable)
  {      
    if(CanClk.IDFEBF0BTime >= T_100ms)
    {
      CanClk.IDFEBF0BTime = null;
      if(CanClk.IDFEBF0BCn == null)
      {              
        CanMsgFEBF0B.Data[1].bbyte  = 0;
        VehMeter.CurBoardVal = 0;
                    
        CanClk.Signal.ExistFEBF0B = Disable;                
      }
      if(CanClk.IDFEBF0BCn > null)
      {
        CanClk.IDFEBF0BCn --;
      }
    } 
  }  
  //
  if(CanClk.Signal.ExistFD0700 == Enable)
  {      
    if(CanClk.IDFD0700Time >= T_100ms)
    {
      CanClk.IDFD0700Time = null;
      if(CanClk.IDFD0700Cn == null)
      {              
        CanMsgFD0700.Data[0].bbyte  = 0x0c;
                    
        CanClk.Signal.ExistFD0700 = Disable;                
      }
      if(CanClk.IDFD0700Cn > null)
      {
        CanClk.IDFD0700Cn --;
      }
    } 
  } 
  //--驾驶员警告灯--潍柴报文------------------------
  if(CanClk.Signal.Exist18FEFF00 == Enable)
  {
    if(CanClk.ID18FEFF00Time >= T_100ms)
    {
      CanClk.ID18FEFF00Time = null;
      if(CanClk.ID18FEFF00Cn == null)
      {
        CanMsg18FEFF00.Data[1].bbyte  = 0;
        CanClk.Signal.Exist18FEFF00 = Disable;                        
      }
      if(CanClk.ID18FEFF00Cn > null)
      {
        CanClk.ID18FEFF00Cn --;
      }
    }
  }
  //T-BOX
  //CanMsg1CFFBE18_On = 0;
  if(CanClk.Signal.Exist1CFFBE18 == Enable)
  {
    if(CanClk.ID1CFFBE18Time >= T_100ms)
    {
      CanClk.ID1CFFBE18Time = null;
      if(CanClk.ID1CFFBE18Cn == null)
      {
        CanMsg1CFFBE18.Data[2].bbyte  = 0;
        CanClk.Signal.Exist1CFFBE18 = Disable;
        CanMsg1CFFBE18_On = 0;                        
      }
      if(CanClk.ID1CFFBE18Cn > null)
      {
        CanClk.ID1CFFBE18Cn --;
        CanMsg1CFFBE18_On = 1;
      }
    }
  }
  //--驾驶员警告灯--玉柴报文------------------------
 /* if(CanClk.Signal.Exist18FECA10 == Enable)
  {
    if(CanClk.ID18FECA10Time >= T_100ms)
    {
      CanClk.ID18FECA10Time = null;
      if(CanClk.ID18FECA10Cn == null)
      {
        CanMsg18FECA10.Data[1].bbyte  = 0;
        
        CanClk.Signal.Exist18FECA10 = Disable;                        
      }
      if(CanClk.ID18FECA10Cn > null)
      {
        CanClk.ID18FECA10Cn --;
      }
    }
  }     */
  //远程清零
  if(CanClk.Signal.Exist5F2 == Enable)
  {
    if(CanClk.ID5F2Time >= T_100ms)
    {
      CanClk.ID5F2Time = null;
      
      if (CanClk.ID5F2Cn == null)
      {
        CanMsg5F2.Data[7].bbyte = 0;
        ClearOdoCanTimes = 0;
        CanClk.Signal.Exist5F2 = Disable;
      }
      
      if (CanClk.ID5F2Cn > null)
      {
        CanClk.ID5F2Cn --;
      }
    }
  }
}
/*-------------------------------------------------------------------------
函数名称：App_GetNormalData
功    能：
参    数：None
返回数值：None
使用说明：
--------------------------------------------------------------------------*/
INT8U quzhi;
INT8U temp_State_keep;
void App_GetNormalData(void)
{
  INT32U  temp1 = null;
  INT32U  temp2 = null; 
  
  //
  if(CanMsgF004.ProceF)
  {
    RevMeter.CurBoardVal=(((INT16U)CanMsgF004.Data[4].bbyte)<<8)|CanMsgF004.Data[3].bbyte;
    RevMeter.CurBoardVal>>=3;
    if(RevMeter.CurBoardVal>200)
    {
      RevFlag=1;
    }
    CanMsgF004.ProceF = Disable;
  }
  // 
  
  if(CanMsgFEEE.ProceF)
  {
    if(CanMsgFEEE.Data[0].bbyte>40)
    {      
      TempMeter.CurBoardVal=(INT16U)(CanMsgFEEE.Data[0].bbyte-40);
    }
    else
      TempMeter.CurBoardVal=50;
    CanMsgFEEE.ProceF = Disable;
  
    quzhi=CanMsgFEEE.Data[0].bbyte;
   
    if(CanMsgFEEE.Data[0].bbyte>145)
    {      
      temp_State_keep=1;
    } 
    if(CanMsgFEEE.Data[0].bbyte<143)
    {      
      temp_State_keep=0;
    }
    if(temp_State_keep)
    {
     //报警灯+声音
    // bDSTable[ID_WIF]|=DS0_MASK;
       // bDSTable[ID_WIF]&=(~DS1_MASK);
        FDJ2_LED_P=0;
        DIRC_FDJ2_LED_P=1;  
    }
    else 
    {
     //关闭报警灯+关闭声音
     //bDSTable[ID_WIF]&=(~(DS0_MASK|DS1_MASK));
     FDJ2_LED_P=1;
     DIRC_FDJ2_LED_P=1;
    }  
    CanMsgFEEE.ProceF = Disable;
  } 
  //
  if(CanMsgFEFF.ProceF)
  {
    if(CanMsgFEFF.Data[0].bbib.bib0!=3 ) //油水分离
    {
      if(1==CanMsgFEFF.Data[0].bbib.bib0 )
      {
        bDSTable[ID_WIF]|=DS0_MASK;
        bDSTable[ID_WIF]&=(~DS1_MASK);
      }
      else
      {
        bDSTable[ID_WIF]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
    }
    else
    {
      bDSTable[ID_WIF]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
      
    CanMsgFEFF.ProceF = Disable;
  }
  //
  if(CanMsg18FEF100.ProceF)
  {
    if(CanMsg18FEF100.Data[3].bbib.bib0!=3 ) //巡航
    {
      if(1==CanMsg18FEF100.Data[3].bbib.bib0 )
      {
        bDSTable[ID_CRUISELAMP]|=DS0_MASK;   
      }
      else
      {
        bDSTable[ID_CRUISELAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
    }
    else
    {
      bDSTable[ID_CRUISELAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }   
    CanMsg18FEF100.ProceF = Disable;
  }
  ////
  if((CanMsg18FD7C00.ProceF)||(CanMsg18E0FF00.ProceF))
  {
   /* if(((CanMsg18FD7C00.Data[0].bbyte&0x07)!=0x07)||((CanMsg18FD7C00.Data[6].bbyte&0x1C)!=0x00)) //高排温度报警     
    {
      if(((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x07)||((CanMsg18FD7C00.Data[6].bbyte&0x1C)==0x04))
      {
        bDSTable[ID_HOUTPUTTEMP]|=DS0_MASK;
        bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));
        bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));
      }
      //
      else if((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x04 )
      {
        bDSTable[ID_HOUTPUTTEMPBlink]|=DS0_MASK;
        bDSTable[ID_HOUTPUTTEMP]&=(~(DS0_MASK|DS1_MASK));
        bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));          
      }
      else if((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x02 )
      {
        bDSTable[ID_HOUTPUTTEMPRed]|=DS0_MASK;
        bDSTable[ID_HOUTPUTTEMP]&=(~(DS0_MASK|DS1_MASK));
        bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));       
      }
      else
      {
        bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_HOUTPUTTEMP]&=(~(DS0_MASK|DS1_MASK));
        bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));
      }
    }  */
    if((CanMsg18FD7C00.Data[6].bbyte&0x1C)==0x04)
    {
      bDSTable[ID_HOUTPUTTEMP]|=DS0_MASK;
      bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));
      bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));
    }
    else
    {
      bDSTable[ID_HOUTPUTTEMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      bDSTable[ID_HOUTPUTTEMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      bDSTable[ID_HOUTPUTTEMPRed]&=(~(DS0_MASK|DS1_MASK));
    }
    //
    if((CanMsg18FD7C00.Data[0].bbyte&0x07)!=0x07)//DPF
    {
      if((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x01)
      {
        bDSTable[ID_DPFLAMP]|=DS0_MASK;
        bDSTable[ID_DPFLAMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
      else if((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x04)
      {
        bDSTable[ID_DPFLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_DPFLAMPBlink]|=DS0_MASK;
      }
      else
      {
        bDSTable[ID_DPFLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
        bDSTable[ID_DPFLAMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }      
    }
    else
    {
      bDSTable[ID_DPFLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      bDSTable[ID_DPFLAMPBlink]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
    //lzs--gai--
    if((CanMsg18FD7C00.Data[0].bbyte&0x07)!=0x07)//DPF 红
    {
      if((CanMsg18FD7C00.Data[0].bbyte&0x07)==0x02)
      {
        bDSTable[ID_DPFRLAMP]|=DS0_MASK;
      }
      else
      {
        bDSTable[ID_DPFRLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }      
    }
    else
    {
      bDSTable[ID_DPFRLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
    //lzs--gai--
    if((CanMsg18FD7C00.Data[2].bbyte&0x03)==0x01)//((CanMsg18FD7C00.Data[2].bbyte&0x03)==0x01)
    {
      bDSTable[ID_DPFForbit]|=DS0_MASK;
    }
    else if((CanMsg18FD7C00.Data[2].bbyte&0x0C)==0x04)//((CanMsg18FD7C00.Data[2].bbyte&0x0c)==0x04)
    {
      bDSTable[ID_DPFForbit]|=DS0_MASK;  //这个和上面那个是DPF禁止再生
    }
    else if((CanMsg18E0FF00.Data[5].bbyte&0x03)==0x01) //新报文18E0FF00
    {
      bDSTable[ID_DPFForbit]|=DS0_MASK; 
    } 
    else
    {
      bDSTable[ID_DPFForbit]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }  
    CanMsg18FD7C00.ProceF = Disable;
    CanMsg18E0FF00.ProceF = Disable;
  }
  //
   /*if(CanMsg18E0FF00.ProceF)
  {
    if((CanMsg18E0FF00.Data[5].bbyte&0x03)==0x01) //新报文18E0FF00
    {
      bDSTable[ID_DPFForbit]|=DS0_MASK; 
    }
    else
    {
      bDSTable[ID_DPFForbit]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }  
    CanMsg18E0FF00.ProceF = Disable;
  }*/
  //
  if(CanMsgFEE4.ProceF)//预热
  {
    if(CanMsgFEE4.Data[3].bbib.bib0!=3 )
    {
      if(1==CanMsgFEE4.Data[3].bbib.bib0 )
      {
        bDSTable[ID_HEAT]|=DS0_MASK;
        bDSTable[ID_HEAT]&=(~DS1_MASK);
      }
      else
      {
        bDSTable[ID_HEAT]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
    }
    else
    {
      bDSTable[ID_HEAT]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
    CanMsgFEE4.ProceF = Disable;
  }
  //
  if(CanMsgFE40.ProceF)
  {
    if(CanMsgFE40.Data[1].bbib.bib3!=3 ) //左转向
    {
      bLtrnFlag=1;
      if(1==CanMsgFE40.Data[1].bbib.bib3 )
      {
        bDSTable[ID_LTRN]|=DS0_MASK;
        bDSTable[ID_LTRN]&=(~DS1_MASK);
      }
      else
      {
        bDSTable[ID_LTRN	]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
    }
    else
    {
      bDSTable[ID_LTRN	]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      bLtrnFlag=0;
    }
    //右转向
    if(CanMsgFE40.Data[1].bbib.bib2!=3 )
    {
      bRtrnFlag=1;
      if(1==CanMsgFE40.Data[1].bbib.bib2 )
      {
        bDSTable[ID_RTRN]|=DS0_MASK;
        bDSTable[ID_RTRN]&=(~DS1_MASK);       
      }
      else
      {
        bDSTable[ID_RTRN]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1     
      }
    }
    else
    {
      bRtrnFlag=0;
      bDSTable[ID_RTRN]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
    // 后雾灯
    if(CanMsgFE40.Data[4].bbib.bib0!=3 )
    {
      bFFogFlag=1;
      if(1==CanMsgFE40.Data[4].bbib.bib0 )
      {        
        bDSTable[ID_FFOG]|=DS0_MASK;
        bDSTable[ID_FFOG]&=(~DS1_MASK);
      }
      else
      {
        bDSTable[ID_FFOG]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1          
      }
    }
    else
    {
      bFFogFlag=0;
      bDSTable[ID_FFOG]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    }
    CanMsgFE40.ProceF = Disable;
  }
  //
  if(CanMsgF001.ProceF)//ABS
  {
    if(CanMsgF001.Data[5].bbib.bib2!=3 )
    {
      bAbsFlag=1;
      if(1==CanMsgF001.Data[5].bbib.bib2 )
      {
        bDSTable[ID_ABS]|=DS0_MASK;
        bDSTable[ID_ABS	]&=(~DS1_MASK);
      }
      else
      {
        bDSTable[ID_ABS]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
      }
    }
    else
    {
      bAbsFlag=0;
      bDSTable[ID_ABS]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
    } 
    CanMsgF001.ProceF = Disable;
  }  
  //天蓝液---区分00 3D
  if(CanMsgFE5600.ProceF)
  {
    bAdBlueFlag=1;      
    CanMsgFE5600.ProceF = Disable;
  }
  //-----------------
  if(CanMsgFE563D.ProceF)
  {      
    CanMsgFE563D.ProceF = Disable;
  }
  if(CanClk.Signal.ExistFE563D==Enable)
  {
    if(InitAdblueTime>=T_2s)
    {
      bCatalystLevel =  (INT8U)((INT16U)CanMsgFE563D.Data[0].bbyte*2/5);
    }
  }
  else
  {
    if(InitAdblueTime>=T_2s)
    {
      bCatalystLevel =  (INT8U)((INT16U)CanMsgFE5600.Data[0].bbyte*2/5);
    }
  }
  //glz--20170519  油门开度
  if(CanMsg0CF00300.ProceF)
  {
    b0CF00300Flag = 1;
    OilScale = (INT8U)CanMsg0CF00300.Data[1].bbyte;      
    CanMsg0CF00300.ProceF = Disable;
  }
  //油耗
  if(CanMsg18FEF200.ProceF)
  {
    bFEF200Flag = 1;      
    //瞬时油耗
    temp1 = (INT8U)CanMsg18FEF200.Data[3].bbyte;
    temp1 = temp1 << 8;
    temp1 |= (INT8U)CanMsg18FEF200.Data[2].bbyte;
    if(temp1>0)
    {
      InstFuelConsump = 512000 / temp1;
    }
    else
    {
      InstFuelConsump = 0;
    }
    //平均油耗
    temp1 = (INT8U)CanMsg18FEF200.Data[5].bbyte;
    temp1 = temp1 << 8;
    temp1 |= (INT8U)CanMsg18FEF200.Data[4].bbyte;
    if(temp1>0)
    {
      AvgFuelConsump = 512000 / temp1;
    }
    else
    {
      AvgFuelConsump = 0;
    }  
    CanMsg18FEF200.ProceF = Disable;
  }
  //机油压力
  if(CanMsgFEEF.ProceF)
  {
    bFEEFlag = 1;
    OilPressure = ((INT16U)CanMsgFEEF.Data[3].bbyte*4);  
    CanMsgFEEF.ProceF = Disable;
  }
  //多包广播
  /*if(CanMsg18ECFF00.ProceF)
  {
    GetConnectInfo(&MulCanMsg_ECM18EBFF00,CanMsg18ECFF00.Data);
    CanMsg18ECFF00.ProceF=EMPTY;
  }
  //多包广播数据
  if(CanMsg18EBFF00.ProceF)
  {
    if(GetMulDTC(&MulCanMsg_ECM18EBFF00,CanMsg18EBFF00.Data))
      UpdateDtcTbl(&MulCanMsg_ECM18EBFF00,EcmDtcTbl,&bEcmDtcCnt);
    CanMsg18EBFF00.ProceF=EMPTY;
  }
  //                                     
  if(((MulCanMsg_ECM18EBFF00.bBuf[0]&0x03)==0x01)&&(CanClk.Signal.Exist18ECFF00==1))
  {
    Engine21_18EBFF00 = 1;
  }
  else
  {
    Engine21_18EBFF00 = 0;     
  }     
  //                   
  if(((MulCanMsg_ECM18EBFF00.bBuf[0]&0xC0)==0x40)&&(CanClk.Signal.Exist18ECFF00==1))
  {
    OBDLamp87_18EBFF00=1;
  }
  else
  {
    OBDLamp87_18EBFF00=0;     
  } */
  //
  if(CanMsgEECA00.ProceF)
  {     
    CanMsgEECA00.ProceF = Disable;
  }
  //
  if(CanMsgFD0700.ProceF)
  {     
    CanMsgFD0700.ProceF = Disable;
  }    
  //
 /* if(CanMsgEECA3D.ProceF)
  {   
    CanMsgEECA3D.ProceF = Disable;
  } */
  //OBD红
  /*if((CanMsgEECA00.Data[0].bbyte&0x30)==0x10)
  {
    bDSTable[ID_ESLAMP]|=DS0_MASK;			
    bDSTable[ID_ESLAMP]&=(~DS1_MASK);
  } 
  else   */
  if((CanMsgFD0700.Data[0].bbyte&0x03)==0x01)
  {
    bDSTable[ID_ESLAMP]|=DS0_MASK;			
    bDSTable[ID_ESLAMP]&=(~DS1_MASK);
  }              
  else
  {
    bDSTable[ID_ESLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
  }        
  //        
  if(CanMsgFF08.ProceF)
  {
    CanMsgFF08.ProceF = Disable;
  }     
  //发动机故障(OBD黄)(单包多包或)
  if(Engine21_18EBFF00 == 1)
  {
    bDSTable[ID_EWLAMP]|=DS0_MASK;			
    bDSTable[ID_EWLAMP]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMPBlink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
  }
  else if((CanMsgEECA00.Data[0].bbyte&0x03)==0x01)
  {
    bDSTable[ID_EWLAMP]|=DS0_MASK;			
    bDSTable[ID_EWLAMP]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMPBlink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }
 /* else if(((CanMsgEECA00.Data[1].bbyte&0x30)==0x00)&&((CanMsgEECA00.Data[0].bbyte&0x30)==0x10))//1hz
  {
    bDSTable[ID_EWLAMPBlink1]|=DS0_MASK;			
    bDSTable[ID_EWLAMPBlink1]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }
  else if(((CanMsgEECA00.Data[1].bbyte&0x30)==0x10)&&((CanMsgEECA00.Data[0].bbyte&0x30)==0x10))//2hz
  {
    bDSTable[ID_EWLAMPBlink2]|=DS0_MASK;			
    bDSTable[ID_EWLAMPBlink2]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }//lzs--*/
  else if((CanMsgEECA00.Data[0].bbyte&0x30)==0x10)
  {
    bDSTable[ID_EWLAMP]|=DS0_MASK;			
    bDSTable[ID_EWLAMP]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMPBlink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }   
  else
  {
    bDSTable[ID_EWLAMP]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMPBlink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
  }   
     
  //OBD
  if(OBDLamp87_18EBFF00 == 1)  
  {
    bDSTable[ID_EWLAMP1]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1]&=(~DS1_MASK);
    // 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }
  else if(CanClk.Signal.ExistFF08&&(CanMsgFF08.Data[3].bbyte&0x03)==0x01)   //lzs--jia--
  {
    bDSTable[ID_EWLAMP1]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1]&=(~DS1_MASK);
    // 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }
  else if(CanClk.Signal.ExistFF08&&(CanMsgFF08.Data[3].bbyte&0x03)==0x02) //2hz
  {
    bDSTable[ID_EWLAMP1Blink2]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1Blink2]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMP1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1      
  }
 /* else if(CanClk.Signal.ExistFECA00&&((CanMsgEECA00.Data[1].bbyte&0xC0)==0x00)&&((CanMsgEECA00.Data[0].bbyte&0xC0)==0x40)) //1hz
  {
    bDSTable[ID_EWLAMP1Blink1]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1Blink1]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMP1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1  
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
  }   
  else if(CanClk.Signal.ExistFECA00&&((CanMsgEECA00.Data[1].bbyte&0xC0)==0x40)&&((CanMsgEECA00.Data[0].bbyte&0xC0)==0x40)) //2hz
  {
    bDSTable[ID_EWLAMP1Blink2]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1Blink2]&=(~DS1_MASK);
    //
    bDSTable[ID_EWLAMP1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1  
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
  } 
  else if(CanClk.Signal.ExistFECA00&&((CanMsgEECA00.Data[0].bbyte&0xC0)==0x40))
  {
    bDSTable[ID_EWLAMP1]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1]&=(~DS1_MASK);
    // 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1
  }  */     
  else if(CanClk.Signal.ExistFD0700&&((CanMsgFD0700.Data[0].bbyte&0xC0)==0x40)) 
  {
    bDSTable[ID_EWLAMP1]|=DS0_MASK;			
    bDSTable[ID_EWLAMP1]&=(~DS1_MASK);
    // 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
  } 
  else
  {
    bDSTable[ID_EWLAMP1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink1]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
    bDSTable[ID_EWLAMP1Blink2]&=(~(DS0_MASK|DS1_MASK));	//clear DS0 & DS1 
  }
  //        
  if(CanMsgFEBF0B.ProceF)
  {
    VehMeter.CurBoardVal = CanMsgFEBF0B.Data[1].bbyte; 
    CanMsgFEBF0B.ProceF = Disable;
  }  
  //-----驾驶员警告灯--潍柴报文----
  if(CanMsg18FEFF00.ProceF)
  {
    CanMsg18FEFF00.ProceF = Disable;
  }  
  //-----驾驶员警告灯--玉柴报文----
 /* if(CanMsg18FECA10.ProceF)
  {
    CanMsg18FECA10.ProceF = Disable;
  }    */   
  //-----T-BOX----
  if(CanMsg1CFFBE18.ProceF)
  {
    CanMsg1CFFBE18.ProceF = Disable;
  }
  //变更加远程清零报文
  if (CanMsg5F2.ProceF == msg_full)
  {
    if (CanMsg5F2.Data[7].bbyte == 0x11)
    {
        if (ClearOdoCanTimes < 10)
        {
            ClearOdoCanTimes++;
        }
    } 
    else
    {
        ClearOdoCanTimes = 0;
    }
    
    CanMsg5F2.ProceF = Disable;
  }                     
}          
/*-------------------------------------------------------------------------
* Function Name  : GetConnectInfo                         
* Description    : 
* Input          : 
* Output         : None
* Return         : None
* onther         : 
--------------------------------------------------------------------------*/
 void GetConnectInfo(MULCANMSG *pMulCanMsg,INT8U * pCanBuf)
{
	INT16U wTemp;
	if(!pMulCanMsg->bRcvBusy)
	{
		wTemp=(((INT16U)pCanBuf[2])<<8)|pCanBuf[1];
		if( wTemp <= MAX_MULCANDATALEN )
		{//长度在可处理的范围以内.
			pMulCanMsg->bLength=pCanBuf[1];
			pMulCanMsg->bCtrByte=pCanBuf[0];
			pMulCanMsg->wPGN=(((INT16U)pCanBuf[6])<<8)|pCanBuf[5];
			pMulCanMsg->bPackage=pCanBuf[3];
			pMulCanMsg->bRcvInfoFlg=1;
			pMulCanMsg->bPrePckNum=0;
		}
	}
	else
	{
		//reset MulCanMsg,使其能够重新接收连接信息
		pMulCanMsg->bRcvBusy=0;
		pMulCanMsg->bPrePckNum=0;
		pMulCanMsg->bRcvInfoFlg=0;
	}
}
/*-------------------------------------------------------------------------
* Function Name  : GetMulDTC                         
* Description    : 
* Input          : 
* Output         : None
* Return         : None
* onther         : 
--------------------------------------------------------------------------*/
INT8U GetMulDTC(MULCANMSG *pMulCanMsg,INT8U * pCanBuf)
{
	if(pMulCanMsg->bRcvInfoFlg){//接收到多包数据报文(连接管理)
		if(pMulCanMsg->wPGN==65226){	//接收ECM故障码(多包)
			if(pMulCanMsg->bCtrByte==32){//BAM(广播公告消息)
				if(pMulCanMsg->bPrePckNum+1==pCanBuf[0]){//检查序列号的连续性
					pMulCanMsg->bRcvBusy=1;//开始接收多包消息	
					(void)memmove(&pMulCanMsg->bBuf[pMulCanMsg->bPrePckNum*7],
								  &pCanBuf[1],7);//move myRxData to MulCan.DataBuf.
					pMulCanMsg->bPrePckNum++;
					if(pMulCanMsg->bPrePckNum==pMulCanMsg->bPackage){//最后一包
						pMulCanMsg->bRcvInfoFlg=0;//多包信息接收完成
						pMulCanMsg->bRcvBusy=0;//多包信息接收完成,主机可以接收新的连接信息(pgn60416)
						pMulCanMsg->bPrePckNum=0;
						return 1;	//多包信息接收完成
					}

				}
			}
		}
	}
	return 0;
}
/************************************************************************
Function Name	:	UpdateDtcTbl(MULCANMSG *pMulCanMsg,DTC *pDtcTable,INT8U *pDtcCnt)
Engineer		:	bill	
Date			:	2009 05 03
Parameters		:	None
Returns			:	None
Notes			:	更新故障码队列,仅用于多包故障码的更新 
*************************************************************************/
 void UpdateDtcTbl(MULCANMSG *pMulCanMsg,DTC *pDtcTable,INT8U *pDtcCnt)
{
	INT8U i;
  INT32U tmp32u_Can;
	*pDtcCnt=(INT8U)((pMulCanMsg->bLength-2)>>2);
	if(*pDtcCnt>DTCTBLLEN)
		*pDtcCnt=DTCTBLLEN;
	for(i=0;i<*pDtcCnt;i++){
	  pDtcTable[0].Err=pMulCanMsg->bBuf[0];
		pDtcTable[i].bFMI=pMulCanMsg->bBuf[4+i*4]&0x1f;
		tmp32u_Can=0;
		//GET SPN
		tmp32u_Can|=(pMulCanMsg->bBuf[4+i*4]>>5);
		tmp32u_Can<<=8;
		tmp32u_Can|=pMulCanMsg->bBuf[3+i*4];  
		tmp32u_Can<<=8;
		tmp32u_Can|=pMulCanMsg->bBuf[2+i*4];  
		pDtcTable[i].dwSPN=tmp32u_Can;

	}
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_CANSendExtFrame                        glz--20170518
* Description    :
* Input          :
* Output         : None
* Return         : dwPGN
* onther         :
--------------------------------------------------------------------------*/
INT8U bsp_CANSendExtFrame (INT32U id,INT8U priority,INT8U length,INT8U *txdata)
{
    INT8U txbuffer,index;
    INT16U cn = null;
    if (!CANTFLG) //Is Transmit Buffer full ? Full ( TXEx=0;)
        return   failt;
    if(id == null)
        return   failt;
    CANTBSEL = CANTFLG; /* Select lowest empty buffer */
    txbuffer = CANTBSEL; // Backup selected buffer
    //====
    CANTXIDR0 = (INT8U)((id & 0x1fe00000)>>21);
    CANTXIDR1 = (INT8U)((id & 0x001c0000)>>13);
    CANTXIDR1 |= (INT8U)((id & 0x00038000)>>15);
    CANTXIDR1 |= 0x18;
    CANTXIDR2 = (INT8U)((id & 0x00007f80)>>7);
    CANTXIDR3 = (INT8U)((id & 0x0000007f)<<1);
    
    if(length>8)
        length=8;
    for ( index=0; index < length; index++) {
        *(&CANTXDSR0 + index) = txdata[index]; //Load data to Tx buffer Data Segment Registers
    }
    
    CANTXDLR = length; /* Set Data Length Code */
    CANTXTBPR = priority; /* Set Priority */
    CANTFLG = txbuffer; /* Start transmission */
    
    ////////////////glz--20170519  busoff  ////////////////////
    if((CANTFLG & txbuffer) != txbuffer)
    {
        return  2; //failt;     lzs--gai
    }
    else
    {
        CanClk.BusOffTime = T_100ms;
        CanClk.BusOffCn = null;
        
        return  success;
    }
    ///////////////////////////////////////////////////////////////
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_CANSendStdFrame                        clb--20231115
* Description    :
* Input          :
* Output         : None
* Return         : dwPGN
* onther         :
--------------------------------------------------------------------------*/
INT8U bsp_CANSendStdFrame (INT32U id, INT8U priority, INT8U length, INT8U *txdata)
{
    INT8U txbuffer, index;
        
    if (!CANTFLG) //Is Transmit Buffer full ? Full ( TXEx=0;)
        return   failt;
    
    if (id == null)
        return   failt;
    
    CANTBSEL = CANTFLG; /* Select lowest empty buffer */
    txbuffer = CANTBSEL; // Backup selected buffer
    //====
    CANTXIDR0 = (INT8U)((id & 0x07F8) >> 3);
    CANTXIDR1 = (INT8U)((id & 0x0007) << 5);
    
    if (length>8)
        length=8;
    for ( index=0; index < length; index++) 
    {
        *(&CANTXDSR0 + index) = txdata[index]; //Load data to Tx buffer Data Segment Registers
    }
    
    CANTXDLR  = length; /* Set Data Length Code */
    CANTXTBPR = priority; /* Set Priority */
    CANTFLG   = txbuffer; /* Start transmission */
    
    ////////////////glz--20170519  busoff  ////////////////////
    if ((CANTFLG & txbuffer) != 0)
    {
        return  failt;
    }
    else
    {
        CanClk.BusOffTime = T_100ms;
        CanClk.BusOffCn   = null;
        
        return  success;
    }
}

/*-------------------------------------------------------------------------
函数名称：App_SendCANMsg
功    能：
参    数：None
返回数值：None
使用说明：
--------------------------------------------------------------------------*/
void App_SendCANMsg(void)
{
  INT32U wTemp = null;
    
  if (Curkeyinput == KeyON)
  {
    //--------------------------------
    if (CanClk.Can18FFB317Time == null)
    {
      wTemp = AccKm.ShortAccKm/10;
      g_txCanMsg.id = 0x18FFB317;
      g_txCanMsg.msg[0] = (INT8U)wTemp; 
      g_txCanMsg.msg[1] = (INT8U)(wTemp>>8); 
      
      wTemp = AccKm.LongAccKm/10;
      g_txCanMsg.msg[2] = (INT8U)wTemp;
      g_txCanMsg.msg[3] = (INT8U)(wTemp>>8);
      g_txCanMsg.msg[4] = (INT8U)(wTemp>>16);
      g_txCanMsg.msg[5] = (INT8U)(wTemp>>24);
      g_txCanMsg.msg[6] = 0x00;
      g_txCanMsg.msg[7] = 0x00;
      g_txCanMsg.dlc = 8;
      bReturn = bsp_CANSendExtFrame(g_txCanMsg.id,3,g_txCanMsg.dlc,g_txCanMsg.msg);
      if (bReturn != 0)
        CanClk.Can18FFB317Time = 488;//2.048mS中断计时
    }   
    //燃油外发液位
    wTemp = FuelMeter.CurPosition;
    wTemp = (wTemp*100) / FuelMeterParamer.DashStep[FuelMeterParamer.bVirtualVal - 1];
    if (CanClk.Can18FEF117Time == null)
    {
      g_txCanMsg.id = 0x18FEFC17; //1000mS
      g_txCanMsg.msg[0] = 0x00;
      g_txCanMsg.msg[1] = (INT8U)(wTemp*5/2);
      g_txCanMsg.msg[2] = 0x00;
      g_txCanMsg.msg[3] = 0x00;
      g_txCanMsg.msg[4] = 0x00;
      g_txCanMsg.msg[5] = 0x00;
      g_txCanMsg.msg[6] = 0x00;
      g_txCanMsg.msg[7] = 0x00;
      g_txCanMsg.dlc = 8;
      bReturn = bsp_CANSendExtFrame(g_txCanMsg.id,3,g_txCanMsg.dlc,g_txCanMsg.msg);
      if (bReturn != 0)
        CanClk.Can18FEF117Time = 488; //T,1000ms/2.048
    } 
    //------------------------------
    if(CanClk.Can18FF0D17Time == null)
    {
      g_txCanMsg.id = 0x18FF0D17;
      g_txCanMsg.msg[0] = 0x00;
      //机油压力低。
      if(OilPressure<60)    
      {
        g_txCanMsg.msg[0] |= 0x01;
      }
      //驻车 
      if((bDSTable[ID_ABS]&STATEMASK) == 0x01)
      {
        //ABS_LED_P=1;
        g_txCanMsg.msg[0] |= 0x02;
      }
      //安全带
      if(AQD_LED_IN==0)
      {
        g_txCanMsg.msg[0] |= 0x04;
      }
      //巡航状态。
      if(1==CanMsg18FEF100.Data[3].bbib.bib0 )
      {
        g_txCanMsg.msg[0] |= 0x08;
      }
      g_txCanMsg.msg[1] = (INT8U)QY1Meter.CurPosition;
      g_txCanMsg.msg[2] = (INT8U)QY2Meter.CurPosition;
      g_txCanMsg.msg[3] = 0x00;
      g_txCanMsg.msg[4] = (INT8U)wTemp;
      g_txCanMsg.msg[5] = (INT8U)RevMeter.CurBoardVal;
      g_txCanMsg.msg[6] = (INT8U)(RevMeter.CurBoardVal>>8);
      g_txCanMsg.msg[7] = 0x00;
      if((CanMsgEECA00.Data[0].bbyte&0x30)==0x10)
      {
        //bDSTable[ID_ESLAMP]|=DS0_MASK;			
        //bDSTable[ID_ESLAMP]&=(~DS1_MASK);
        g_txCanMsg.msg[7] |= 0x02;
      } 
      else if((CanMsgFD0700.Data[0].bbyte&0x03)==0x01)
      {
        //bDSTable[ID_ESLAMP]|=DS0_MASK;			
        //bDSTable[ID_ESLAMP]&=(~DS1_MASK);
        g_txCanMsg.msg[7] |= 0x01;
      }
      g_txCanMsg.dlc = 8;
      bReturn = bsp_CANSendExtFrame(g_txCanMsg.id,3,g_txCanMsg.dlc,g_txCanMsg.msg);
      if (bReturn != 0)
        CanClk.Can18FF0D17Time = 49; //100mS
    }  
    //车速
    if(CanClk.CanCFE6CEETime == null)
    {
      g_txCanMsg.id = 0xCFE6CEE;
      g_txCanMsg.msg[0] = 0x00;
      g_txCanMsg.msg[1] = 0x00;
      g_txCanMsg.msg[2] = 0x00;
      g_txCanMsg.msg[3] = 0x00;
      g_txCanMsg.msg[4] = 0x00;
      g_txCanMsg.msg[5] = 0x00;
      g_txCanMsg.msg[6] = (INT8U)(CansendVeh % 256);
      g_txCanMsg.msg[7] = (INT8U)(CansendVeh / 256);
      g_txCanMsg.dlc = 8;
      bReturn = bsp_CANSendExtFrame(g_txCanMsg.id,3,g_txCanMsg.dlc,g_txCanMsg.msg);
      if (bReturn != 0)     
        CanClk.CanCFE6CEETime = 25; //50mS
    }
    
    //清零外发
    if (CanClk.Can49ETime == null)
    {
      g_txCanMsg.id = 0x49E;
      
      g_txCanMsg.msg[0] = 0;
      g_txCanMsg.msg[1] = 0;
      g_txCanMsg.msg[2] = 0;
      g_txCanMsg.msg[3] = 0;
      g_txCanMsg.msg[4] = 0;
      g_txCanMsg.msg[5] = 0;
      g_txCanMsg.msg[6] = 0;
      g_txCanMsg.msg[7] = 0;
                      
      if (AccKm.LongAccKm < 20000)
      {
        if (OUT_2000km_Clear != one)
        {
          ;
        } 
        else
        {
          if (ClearOdoCanOut)
          {
            ClearOdoCanOutCn = ClearOdoCanOut;
            ClearOdoCanOut--;
            g_txCanMsg.msg[7] |= 0x90;
          }
          else
          {
            ClearOdoCanOutCn = 0;
            g_txCanMsg.msg[7] |= 0x50;
          }
        }
      } 
      else
      {
        if (OUT_2000km_Clear != one)
        {
          g_txCanMsg.msg[7] |= 0x40;
        } 
        else
        {
          g_txCanMsg.msg[7] |= 0x50;
        }
      }
      g_txCanMsg.dlc = 8;
      bReturn = bsp_CANSendStdFrame(g_txCanMsg.id, 0x80, g_txCanMsg.dlc, g_txCanMsg.msg);
      if (bReturn != 0)
      {
        CanClk.Can49ETime = 488; //1000mS
      } 
      else
      {
        if (g_txCanMsg.msg[7] == 0x90)
        {
          ClearOdoCanOut = ClearOdoCanOutCn;
        }
      }
    }
  }
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_CAN_BusOff                             glz--20170519
* Description    : can bus off
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void bsp_CAN_BusOff(void)
{
    CANMISC_BOHOLD = ClearFlag;
    CANTARQ_ABTRQ = CANTBSEL;
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_CAN_Sleep
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void bsp_CAN_Sleep(void)
{    
  bsp_tx_msgbuf_abort();
  CANCTL0_SLPRQ = Enable;
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_tx_msgbuf_abort
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void bsp_tx_msgbuf_abort(void)
{
  CANTARQ_ABTRQ0 = Enable;
  CANTARQ_ABTRQ1 = Enable;
  CANTARQ_ABTRQ2 = Enable;
}
/*-------------------------------------------------------------------------
* Function Name  : bsp_CAN_SleepRelease
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void bsp_CAN_SleepRelease(void)
{
    CANCTL0_SLPRQ = Disable;
}
/*-------------------------------------------------------------------------
* Function Name  : App_ChcekSleep
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void App_ChcekSleep(void)
{    
  if((CANCTL0_SLPRQ) && (CANCTL1_SLPAK))
  {
    bcanbussleep = 1;
  }
  else
  {
    bcanbussleep = 0;
  }
}
#pragma CODE_SEG DEFAULT
