0

I'm currently trying to Test Auto-Generated-Code for a Controller.

The test will be done in CANoe with Capl.

I've already tried a lot of things out and it's working good, but now I want to test a "message lost".

I need something like this.

CAN 1 is sending a test message 10 Times. 3 Times there will be a Message lost.

CAN 2 which is receiving the Signals has to react to this with a specific value.

I Need something like WaitForMessage(int aTimeOut, Message yourMessage) which gives for example 0 for succesfully accessing the Message or -1 for timeOut.

    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);
    }
  }

1 Answer 1

1

What's the Problem? Just use CAPL-function testWaitForMessage as described in help.

You are using Test-Node as there is TestStepFail/Pass call in your code, so everything you need in terms of control your test-sequence begins with test...

p.s. something else, I doubt that with this code you can detect what is described in comment

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

anzahlAnBotschaften = in german this means the count of received messages. So when, as described above, you will receive 7 from 10 messages (anzahlAnBotschaften == 7) than this condition is false.

1
  • Hello, I used the testWaitForMessage and it works, thank you. I searched for such a function but didn't knew the excact function Name.
    – gaskraank
    Commented Jan 9, 2018 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.