CAPL Script

SetTimerCyclic

This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.

Syntax

void setTimerCyclic(msTimer t, long firstDuration, long period);
void setTimerCyclic(msTimer t, long period);

Both durations use milliseconds. The three-argument overload separates the initial delay from the recurring period. The two-argument overload uses the period for the first delay as well. These functions do not return a value.

Example: first after 10 ms, then every 20 ms

variables
{
  msTimer tick;
}
on start
{
  setTimerCyclic(tick, 10, 20);
}
on timer tick
{
  write("Cyclic timer event");
}
on key 'x'
{
  cancelTimer(tick);
}
on preStop
{
  cancelTimer(tick);
}

Relative to the initial scheduling call, the requested sequence is 10, 30, 50, 70 ms and so on. This describes the requested schedule, not measured execution timestamps. There is no setTimer call inside the handler because this example already uses cyclic scheduling.

Do not mix this pattern with the explicit rearming pattern in setTimer without checking the intended semantics. To verify, record several event times in your configuration, inspect the initial delay separately from later differences, then cancel and confirm no further scheduled actions. If the handler transmits CAN frames, measure the received frames separately with the interval analyzer.

Source and validation

API signatures and behavior follow the authorized Vector reference. The explanations and inspection examples are site guidance, not recorded CANoe test results. Check the installed help for your tool version and node type. See sources and validation limits.