【问题标题】:CAPL Canoe wait for a specific can messageCAPL Canoe 等待特定的 can 消息
【发布时间】:2018-06-15 02:09:25
【问题描述】:

我目前正在尝试测试控制器的自动生成代码。

测试将在带有 Capl 的 CANoe 中完成。

我已经尝试了很多东西并且效果很好,但现在我想 测试“消息丢失”。

我需要这样的东西。

CAN 1 正在发送 10 次测试消息。消息会丢失 3 次。

接收信号的 CAN 2 必须以特定值对此作出反应。

我需要类似 WaitForMessage(int aTimeOut, Message yourMessage) 的东西,例如 0 表示成功访问消息或 -1 表示超时。

    on timer sendMessage
  {
    if(anzahlAnBotschaften > 0) // amount of sent Messages
    {
      if(anzahlAnBotschaften % 3 == 0) // 3 times message lost
      {
        botschaftWirdGesendet = 0;  
        lRet = ???? here is the part where i want to wait for a an answer from CAN2 
        if(lRet != 0)
        {
          TestStepPass("010.1", "SNA was triggered");
        }
        else
        {
          TestStepFail("010.1", "Timeout was triggered, but no SNA was found");
         }
      }
      else
      {
        botschaftWirdGesendet = 1;
        output(sendingCan_BrkSys);
        lRet = TestGetWaitEventMsgData(receivingCan_aMessage);
        if(lRet == 0) 
        {
          // same for the positive case
        }
      }
      anzahlAnBotschaften -- ;
      setTimer(botschaftsAusfall,20);
    }
  }

【问题讨论】:

    标签: testing can-bus capl canoe


    【解决方案1】:

    有什么问题?只需按照帮助中的说明使用 CAPL 函数 testWaitForMessage

    您正在使用测试节点,因为您的代码中有 TestStepFail/Pass 调用,因此您在控制测试序列方面所需的一切都以 test 开头。 ..

    附言别的东西,我怀疑用这段代码你可以检测到评论中描述的内容

    if(anzahlAnBotschaften % 3 == 0) // 3 times message lost
    

    anzahlAnBotschaften = in german 这意味着接收到的消息的计数。因此,如上所述,当您将收到 10 条消息中的 7 条消息 (anzahlAnBotschaften == 7) 时,此条件为 false

    【讨论】:

    • 您好,我使用了 testWaitForMessage,它可以工作,谢谢。我搜索了这样一个函数,但不知道确切的函数名称。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-20
    • 2021-09-27
    • 2020-08-22
    • 2016-12-23
    • 2021-05-27
    • 2021-10-29
    • 2018-08-19
    相关资源
    最近更新 更多