-1

I want check in CAPL if the message is receiving or not in the simulation and if it is not coming in the trace, i want send new message. I have tried using functions like. I want to check particular message is receving or not? TestWaitForPDU();TestWaitFormessage(msg,2000) etc but in simple configuration these are not working.

I have also tried using istimerActive() or istimerunning(), but these function will not check if message has stopped receiving or transmitting.

I am working in generic node.and i have tried something like this

on timer tslpack
{
  int sleepack;
   long Systemtime[9];
  sleepack= isTimerActive(tslpack);
   //write("Bus Active");
    
 // write("Running Status %d",tslpack.isRunning());
 

 

        if(sleepack==1)
          {
            write("timer cancelled");
            cancelTimer(tslpack);
            Settimer(tslpack,100);
          }
          else
          {
            result=1;
        if(result ==1)
        {
         
        write("Bus Sleep");
          sleeptime=timeNow();
    
    
      
       result = 0;
       }

}
Anurag
  • 7
  • 1
  • 3
  • Hello, welcome to SO. Please take your time to properly format your question, and maybe add an example script you tried and is not working. Are you working in a test case, or in a generic node? – Daemon Painter Sep 25 '20 at 08:29
  • Hi, i am working in generic node not testcase – Anurag Sep 25 '20 at 11:56
  • I have written some thing like this,but it is not working – Anurag Sep 25 '20 at 12:13
  • on timer tslpack { int sleepack; long Systemtime[9]; sleepack= isTimerActive(tslpack); //write("Bus Active"); // write("Running Status %d",tslpack.isRunning()); if(sleepack==1) { write("timer cancelled"); cancelTimer(tslpack); Settimer(tslpack,100); } else{ result=1; if(result ==1) { write("Bus Sleep"); sleeptime=timeNow(); result = 0; } – Anurag Sep 25 '20 at 12:13
  • 1
    the code makes little sense...you are setting timers, a large part of the implementation isn't shown. Please read this on [MCVE](https://stackoverflow.com/help/minimal-reproducible-example) and maybe a basic tutorial on CAPL. I can't see any effort in reaching the desired goal, I see random spaghetti – Daemon Painter Sep 25 '20 at 12:40

1 Answers1

0

You have mentioned that you are not writing the code in Test Node and you want to do it in Simulation Node. Clearly the functions TestWaitForPDU();TestWaitFormessage(msg,2000) are supposed to be used in tests as the name of the function shows.
I suppose you are waiting for a CAN message and so I am giving you a sample code for it.

variables
{
  msTimer TimerToCheckMessage;
  message CAN1.0x123 TxMsg;    //Message which you want to send
}

on start
{
  setTimer(TimerToCheckMessage,103);
  TxMsg.dlc = 4;
}

on message CAN1.0x1            //Message which you want to check
{
  setTimer(TimerToCheckMessage,103);
}

on timer TimerToCheckMessage
{
  output(TxMsg);
  setTimer(TimerToCheckMessage,103);
}
Shyam
  • 649
  • 1
  • 5
  • 20