CAPL Programming usage of Timer as a delay

delay function in capl script
programming with capl pdf download
capl programming diagnosis testing
can capl programming diagnosis testing
capl script for diagnostics
capl scripting training
capl scripting interview questions
canoe capl scripting for test automation

I have been writing a CAPL script that would send message on each channel (2 no's) after a certain delay. The following delay i want to generate using SetTimer() and mstimer::isRunning function. I can use setTimer function but I dont know how to use mstimer::isRunning. The code is shown below:

    Variables{
          message * temp = {DLC=8};
          mstimer timer1;
    }
    on timer timer1{
        //Do nothing
    }
    onstart{

    for(noofChannel=1;noofChannel<=2;noofChannel++){
        settimer(timer1,100);
        temp.CAN = noofChannel;
        temp.ID = 0xAA;
        While (mstimer::isrunning)==0 // I need to write this right.
        { //wait for timer to expire}
        Output(temp);

    }

Instead of mstimer::isrunning use isTimerActive() method. isTimerActive() returns 1 if timers is running and 0 if it is expired. So your code will look like:

on start{

    for(noofChannel=1;noofChannel<=2;noofChannel++){
        settimer(timer1,100);
        temp.CAN = noofChannel;
        temp.ID = 0xAA;
        While (isTimerActive(timer1) == 1)  
        { //wait for timer to expire}
        }
        Output(temp);

      }
    }

But I would not recommend doing this. Instead of looping in on start, you can ouput 2nd message through onTimer

on start{
            temp.CAN = 1;
            temp.ID = 0xAA;
            Output(temp);
            settimer(timer1,100);
        }

on timer timer1{
    temp.CAN = 2;
    Output(temp);
}

If you want to keep it generic i.e. not restricting to 2 channels, you can take a variable and increment it in timer.

CAPL Programming usage of Timer as a delay - can, I can use setTimer function but I dont know how to use mstimer::isRunning. The code is shown below: Variables{ message * temp = {DLC=8}; mstimer timer1; }  CAPL Programming usage of Timer as a delay can , capl Instead of mstimer::isrunning use isTimerActive() method. isTimerActive() returns 1 if timers is running and 0 if it is expired.

I asked Vector for the same question and they answered it something like this: "msTimer.isRunning" gives us status of Timer, whether timer running or not The usability is mentioned below:

      on timer myTimer
      {
         write("Running Status %d",myTimer.isRunning());
      }

" timeToElapse() " function can also be used for the following case. Syntax:

      timer t;
      setTimer(t,5);
      write("Time to elapse: %d",timeToElapse(t)); // Writes 5

The 7 CAPL Events you should know about, CAPL - Communication Access Protocol Language is used by Vector tools like CANoe and CANalyzer. This is useful for initting variables, setting delays etc. For Timer variable, on timer event takes place after the seconds  can - CAPL Programming usage of Timer as a delay. I have been writing a CAPL script that would send message on each channel (2 no's) after a certain delay. The following delay i want to generate using SetTimer() and mstimer::isRunning function.

/*Solution on how timer works*/

variables
{
mstimer t1,t2;/*millisec timer*/
timer t3;/*sec timer*/
}
on timer t1
{
settimer(t2, 10);/*wait in timer t1 for 10ms and then goes to timer t2*/
}
on timer t2
{
settimer(t3, 10);/*wait in timer t2 for 10ms and then goes to timer t3*/
}
on timer t3
{
settimer(t4, 10);/*wait in timer t3 for 10sec and then goes to timer t4*/
}
on timer t4
{
settimer(t1, 10);/*wait in timer t4 for 10sec and then goes to timer t1*/
}

on start()
{
settimer(t1,10);/*waits here for 10ms and then goes to timer t1*/
}

Delay function in CAPL apart from testwaitfortimeout() - capl - html, Delay function in CAPL apart from testwaitfortimeout() - capl. One idea could be to use a timer: variables { msTimer myTimer; } testcase wavGenerator() I know the answer but just try to program it to show how vxWorks does it. I am still not  setTimer(randomTimer, delay); The timer event procedure is where most of the work happens. The event procedure must first decide which input to change, then change the input, and then reset the timer to a random value.

CAPL Basics, which allows you to program CANoe for individual applications. n Introduction to Timers can also be used to respond to an event after a delay. The setTimer()  Timers can also be used to respond to an event after a delay. The setTimer() function takes two parameters, the name of the timer and the length of time to setthe timer. The length of time parameter has different units depending on what kind of timer youare using.

[PDF] Programming with CAPL, Program Development Uses the Database Tool – CANdb++. CANalyzer – CAPL Programming Environment . Stopping a Timer Before It Expires. Gets delay time value of current node (CANoe's Simulation Setup  Quick Introduction To CAPL Application Note AN-AND-1-113 5 It is important to note that the use of each message must include a definition within the global variables. In this example we have defined the message msg1 as having a CAN identifier of 555 hex and data length code (dlc) or data size of one byte.

[PDF] CAPL Function Reference Manual, Obsolete functions can still be used in CAPL programming; however, they are not If a timer is no longer running or it has been expired, this function has no effect. to start after a delay either within the CANoe tool or using the setStartDelay()  Examining a CAPL program Brief Introduction to CAPL Additional CAPL files that contain generic code that can be reused in other programs Variables defined here are accessible throughout the CAPL program Multiple pre-defined event handlers exist for your use within CAPL. The code in this handler will only be executed when the event occurs.

Comments
  • When asking stuff about CAPL, it is important to specify if you're in "Simulation" or "Test" mode. Some functionalities are made available/disabled depending on what kind of script you're writing.
  • Thanks for the advice! I was using Simulation mode, But I needed a solution compatible to both simulation and Realtime.