CAPL Script

TimeDiff

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

long timeDiff(message m1, NOW);

long timeDiff(message m1, message m2);

Function

Time difference between messages or between a message and the current time in ms (msg2 - msg1 or now - msg1). Starting withCANalyzer2.xx this difference can be calculated directly (Units of 10 microseconds).

Parameters

Variable of typemessage

Variable of typenow

Return Values

Time difference in ms.

Reference example from the CANoe 12 help. Check the required configuration, database objects and API availability in your installed version; this is not a recorded compiler or runtime test.

diff = timeDiff(m100, now); // CANalyzer 1.x & 2.x
diff = this.time - m100.time; // CANalyzer 2.xx

timeNow | timeNowFloat

These historical expressions have different units: timeDiff returns milliseconds, while subtracting .time values yields 10-microsecond ticks. For example, 5,000 ticks represent 50 ms. The second expression also compares two message times, whereas the first compares a message with NOW. Keep operand meaning, unit conversion and wraparound handling explicit rather than treating them as interchangeable assignments.