Time measurement in Python between transmitted and received CAN frame
Posted: Wed 20. May 2020, 18:14
Hi,
I would like to measure the time between the transmission of a CAN frame and the next received CAN frame in Python (I am aware that PCAN does not provide a timestamp for transmitted frames). Therefore I use the uptime() function (https://pythonhosted.org/uptime/), which returns a timestamp measured relative to the boot time of the operating system - comparable to the PCAN timestamp. The difference between read- and writeTime is the time window.
The response is sent back from the CAN slave to the PCAN within 1-2 ms. This time is displayed in the PCAN View. If the time is measured with the API in Python, the time window is sometimes 150 ms or 2 s, which varies depending on whether the operating system (Windows 10) is restarted. So there is a significant difference between the timestamps. I expect that the measurement is not accurate to one millisecond, but there is a significant time difference.
How can I achieve a more precise measurement?
For the development I use the PCAN-Basic API: https://www.peak-system.com/PCAN-Basic.239.0.html
Best regards,
Martin
I would like to measure the time between the transmission of a CAN frame and the next received CAN frame in Python (I am aware that PCAN does not provide a timestamp for transmitted frames). Therefore I use the uptime() function (https://pythonhosted.org/uptime/), which returns a timestamp measured relative to the boot time of the operating system - comparable to the PCAN timestamp. The difference between read- and writeTime is the time window.
The response is sent back from the CAN slave to the PCAN within 1-2 ms. This time is displayed in the PCAN View. If the time is measured with the API in Python, the time window is sometimes 150 ms or 2 s, which varies depending on whether the operating system (Windows 10) is restarted. So there is a significant difference between the timestamps. I expect that the measurement is not accurate to one millisecond, but there is a significant time difference.
How can I achieve a more precise measurement?
For the development I use the PCAN-Basic API: https://www.peak-system.com/PCAN-Basic.239.0.html
Best regards,
Martin