Kvaser Linux CANLIB

Time Measurement

CAN messages are time stamped as they arrive. This time stamping is, depending on your hardware platform, done either by the CAN interface hardware or by CANLIB.

In the former case, the accuracy is pretty good, in the order of 1 - 10 microseconds; when CANLIB does the job, the accuracy is more like 100 microseconds to 10 milliseconds and you may experience a rather large jitter. This is because Windows is not a real-time operating system.

The resolution of the time stamps is, by default, 1 ms. It can be changed to a better resolution if desired.

Use canReadTimer() to read the current time. You must pass the handle of an open channel to this API call; the return value is the current time using the clock of that channel.

Use canIoCtl() with a function code of canIOCTL_SET_TIMER_SCALE to change the resolution of the time stamps, if desired. This will not affect the accuracy of the time stamps.