查询 id名 长度等

发布时间 2023-12-11 13:24:59作者: 韩昊
variables
{
  dword contextCAN = 0x00010000;//报文名字
  dword contextLIN = 0x00050000;//固定的
  dword contextMOST = 0x00060000;
  dword contextFLEXRAY = 0x00070000;
  dword contextBEAN = 0x00080000;
  dword contextJ1708 = 0x00090000;
  dword id; //报文ID
  int message_len;  //字节长度
  msTimer Timer1;//定义时间
  int Busload = 0;
  long time[9];
  char timeBuffer[64];
}

on start
{
  setTimer(Timer1,1000);
}
on timer Timer1
{
  {setTimer(Timer1,1000);}
  write("CAN1:BUS Load:%f",@sysvar::_Statistics::CAN1::Busload);//输出负载率
  getLocalTime(time);
  write("busload time on %02d/%02d/%02d %02d:%02d:%02d.%-3d",
	  time[5]-100, time[4]+1, time[3], time[3], time[2], time[1], time[0]);//输出当前时间
  write("      ");
}//输出负载率

  
on message CAN1.*   //可以修改为全部报文或某条报文 如*、BCM1_1、CAN1.* 
{
  char buffer[64];
//  id = GetMessageID("LowBeamSt");
//    write( "Message:", id);
  if(this.id == 0x230)
  {
    message_len = canGetDataLength(this); //字节长度
    write("Message 0x230 length is %d", message_len); 
  }
  if (getMessageName( this.ID, contextCAN | this.CAN, buffer, elcount( buffer))) //elCount 结果是数组的定义长度
  {
    write( "Message: %s", buffer);
  }
  // check reaction of signal “LockState” after crash
  
   
}