CANoe 杂谈

这篇文章聊聊在工作中遇到的问题和分享一些好玩的函数

 halt();暂停模拟=断点

variables
{
  message InspectMessage gMsgInspect;
  message BreakPointMessage gMsgBreakPoint;
  message BreakPointMessage2 gMsgBreakPoint2;
 
  msTimer tSignalUpdateBreakPoint;
  
  byte gBreakPointMsgByte0 ; 
  byte gBreakPointMsgByte1 ; 
  byte gBreakPointMsgByte2 ; 
  byte gBreakPointMsgByte3 ; 
  byte gBreakPointMsgByte4 ; 
  byte gBreakPointMsgByte5 ; 
  byte gBreakPointMsgByte6 ; 
  byte gBreakPointMsgByte7 ; 

  byte gInspectMsgByte0 ; 
  byte gInspectMsgByte1 ; 
  byte gInspectMsgByte2 ; 
  byte gInspectMsgByte3 ; 
  byte gInspectMsgByte4 ; 
  byte gInspectMsgByte5 ; 
  byte gInspectMsgByte6 ; 
  byte gInspectMsgByte7 ; 
}	

on message InspectMessage
{
  gMsgInspect = this;
  
  gInspectMsgByte0 = gMsgInspect.SigInspect0;
  gInspectMsgByte1 = gMsgInspect.SigInspect1;
  gInspectMsgByte2 = gMsgInspect.SigInspect2;
  gInspectMsgByte3 = gMsgInspect.SigInspect3;
  gInspectMsgByte4 = gMsgInspect.SigInspect4;
  gInspectMsgByte5 = gMsgInspect.SigInspect5;
  gInspectMsgByte6 = gMsgInspect.SigInspect6;
  gInspectMsgByte7 = gMsgInspect.SigInspect7;

  // Inspect() function will update 
  // the variables in the debugger window
  if(@sysvar::Inspect::InspectOnOff)
  {
    inspect();
  }
}

on start
{
  @sysvar::Inspect::InspectOnOff = 0;
  @sysvar::BreakPoint::TimerBreakPoint = 0;
  @sysvar::BreakPoint::MessageBreakPointOnOff = 0;
  @sysvar::BreakPoint::SignalBreakPoint = 0;
  setTimer(tSignalUpdateBreakPoint,2000);
}

on message BreakPointMessage
{
  int CAPLError; 
  int SigPointValue; 

  SigPointValue = this.SigBPoint0; 

  if(@sysvar::BreakPoint::SetError)
  { 
    if(SigPointValue == 0 && @sysvar::BreakPoint::SignalBreakPoint) 
    {
      halt();
    }
    CAPLError = (1.0/this.SigBPoint0);  // Diff through 0
  }
}

on timer tSignalUpdateBreakPoint
{
  if(@sysvar::BreakPoint::TimerBreakPoint) 
  {
    @sysvar::BreakPoint::TimerBreakPoint = 0;
  }
  setTimer(this,2000);
}

on message BreakPointMessage2
{
  gMsgBreakPoint2 = this;
  
  // halt() function will halt the simulation, if the 
  // message comes into the on message handler 
  if(@sysvar::BreakPoint::MessageBreakPointOnOff) 
  {
    @sysvar::BreakPoint::MessageBreakPointOnOff = 0; 
    halt();
  }
  
  saveMessageBytes();
}

void saveMessageBytes()
{
  gBreakPointMsgByte0 = gMsgBreakPoint2.SigBPoint0;
  gBreakPointMsgByte1 = gMsgBreakPoint2.SigBPoint1;
  gBreakPointMsgByte2 = gMsgBreakPoint2.SigBPoint2;
  gBreakPointMsgByte3 = gMsgBreakPoint2.SigBPoint3;
  gBreakPointMsgByte4 = gMsgBreakPoint2.SigBPoint4;
  gBreakPointMsgByte5 = gMsgBreakPoint2.SigBPoint5;
  gBreakPointMsgByte6 = gMsgBreakPoint2.SigBPoint6;
  gBreakPointMsgByte7 = gMsgBreakPoint2.SigBPoint7;
}

stop():停止运行上位机 

if (IsSimulated()) // don't activate tests when running in simulated mode
  {
    WriteLineEx(wrCAPLSink, wrError
      , "This demo cannot run in simulated mode!");     
    stop();
  }

linChangeSchedTable(dword tableIndex, dword slotIndex, dword onSlotIndex)

实现调度表的调度(切换的调度表,切换的调度表的报文,上一个调度表终止调度的报文)

on start
{
  //linStopScheduler();
 linChangeSchedTable(2,2);

  
  
}
on key 'a'
{
  linChangeSchedTable(2,2,4);
}

 

linRunSchedTableNTimes (1, 2, -2, -1);暂时只支持仿真模式,真实节点不确定是否可用

报错1:Start of measurement aborted:复制上位机后添加dbc出现此报错建议,重新新建一个工程环境

  • 15
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yuanyikangkang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值