简体   繁体   English

CAPL脚本-CAN C通信(停止从DBC发送一条消息)

[英]CAPL Scripting - CAN C communication (Stop transmitting one message from DBC)

I am working on a CAPL script that has to allow all messages to transmit on a CAN C channel and stop transmitting one particular message from the database file. 我正在使用CAPL脚本,该脚本必须允许所有消息在CAN C通道上传输,并停止从数据库文件传输一条特定消息。 Can anyone help with the method/function/code I can use? 任何人都可以提供有关我可以使用的方法/功能/代码的帮助吗?

AFAIK, the only way to accomplish this is to disable any automatic transmission of messages (eg via the IG or Network IL) and transmit all messages manually from your CAPL script in timer callbacks. AFAIK,完成此操作的唯一方法是禁用消息的任何自动传输(例如,通过IG或网络IL),并在计时器回调中从CAPL脚本手动传输所有消息。 Transmission can be done using the output function and based on whichever criteria you define, you can choose not to call output for any messages which should be blocked. 可以使用output功能来完成传输,并且可以根据您定义的任何标准,选择不为任何应阻止的消息调用output

Your question is vague, but I'm assuming you are going from one CAN channel to another. 您的问题含糊不清,但我假设您是从一个CAN通道转到另一个。 For instance, CAN C to CAN D (or CAN 3 to CAN 4), than you could do: 例如,从CAN C到CAN D(或从CAN 3到CAN 4),比您可以做的多:

on message CAN3.0x7FF  // This would be that one ID that stops at some point
{
  message CAN4.0x7FF msg;
  msg = this;

  // Assuming you are receiving on CAN 3, and looking to transmit on CAN 4
  if(this.dir == rx)
  {
      // Declare a global variable that sets to 1 when you want it to stop
    if(MSG_STOP == 0)
       output(msg);
  }
}

on message CAN3.*
{

  message CAN4.* msg;
  msg = this;
  if (this.dir == rx)
  {
    output (msg);
  } 
}

If you are using the Interaction Layer (IL) in your simulation, and the DBC file cyclic times are correctly configured there are some CAPL functions that can be used for fault injection which will allow you to selectively start/stop transmitting certain messages: 如果在仿真中使用交互层(IL),并且正确配置了DBC文件的循环时间,则可以使用一些CAPL函数进行故障注入,这将使您可以有选择地启动/停止传输某些消息:

on sysvar Sys_m0x461_Send {
/**********************************************************
 * FAULT INJECTION Enable/Disable Msg Sending
 **********************************************************/
  if (@this) {
    ILFaultInjectionEnableMsg(Message0x461fromDBC);
  }
  else {
    ILFaultInjectionDisableMsg(Message0x461fromDBC);
  }
}

In the example if the system variable (could be linked to a panel control, eg checkbox) equals '1' the message will transmit as defined in the DBC, otherwise the message sending is stopped. 在示例中,如果系统变量(可以链接到面板控件,例如复选框)等于“ 1”,则消息将按照DBC中的定义进行发送,否则消息发送将停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM