I'm trying to use PCANBasic within LabWindowsCVI.
CAN_Initialize, CAN_Write and CAN_Read work fine. But how to get a timestamp for CAN_Write ???
I found some trick - before CAN_Write to perform one dummy CAN_Read and then to take a timestamp. But I'm not sure that thimestamp is correct when can message is not read ???
Generally speaking - how to get timestamp out of CAN_Read function.
Thank you in advance
the PCANBasic and the PCAN-Light API do not offer that timestamp feature for the CAN_write. Only with the canapi2 API from the PCAN-Developer package you will get an API called CAN_GetSystemTime() to get the timestamp. As a workaround you can use the Windows Systemtime and synchronize with the Read() function, however, the timestamp of the CAN message will be set when the message was received by the CAN-Controller, so there could be a small gap between the timestamp of CAN_Read() and the Windows time. When there is no message in the queue, no timestamp will be available in CAN_Read().
What actually mean "timestamp of write"?
My understanding is:
1. "timestamp of read message" : timestamp set in PEAK HW (USB or any) on receive frame, but receive from CAN bus not receive by API what may be much much later than receive in HW (few milliseconds depend windows delay or architecture of application)
2. "timestamp of write": analogy to above: set in HW form PEAK in time of "successfully send" frame to CAN bus, not when queued using API.
Am I understanding correct?
1) The timestamp is set by the hardware, upon reception and the driver will promptly foward this message to the receive-queue, the timestamp is already set at this point, it will not change when actively read from the queue by a application.
2) Getting a timestamp upon transmission is possible using the PCAN-Developer 4 package (CAN API 4) which allows for self-receive frames, which do have proper timestamps written to them upon reception.
This feature is not available in PCANBasic.
Thank you. My intention was actually to get to know how timestamp are give: hardware or in API (host).
My understanding is that send and receive timestamp are in HW, which only makes sense to me but I had to ask about it.
I hope last question regarding this issue:
I do understand that logging to TRC file by PCANasic API using correct timestamp from HW. So indirect option to get proper send timestamp is read TRC file. Correct?
not correct.I do understand that logging to TRC file by PCANasic API using correct timestamp from HW. So indirect option to get proper send timestamp is read TRC file. Correct?
The receive-timestamps are the actual HW-timestamps whereas the transmit-timestamps shown in the trace-file are the time that a transmit-message was given to the driver, that does not equate to a "proper" hardware timestamp.
If you want to have proper hardware-timestamps for your application have another channel on the same bus get the timestamps for those messages on reception.