How to get Timestamp of CAN_Write ?

The free CAN Software API (Application Programming Interface) for Windows®
Locked
Petko Goranov
Posts: 2
Joined: Mon 4. Apr 2011, 19:43

How to get Timestamp of CAN_Write ?

Post by Petko Goranov » Mon 4. Apr 2011, 20:04

Hi everybody,

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

M.Maidhof
Support
Support
Posts: 1303
Joined: Wed 22. Sep 2010, 14:00

Re: How to get Timestamp of CAN_Write ?

Post by M.Maidhof » Tue 5. Apr 2011, 13:57

Hi,

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().

best regards

Michael

Petko Goranov
Posts: 2
Joined: Mon 4. Apr 2011, 19:43

Re: How to get Timestamp of CAN_Write ?

Post by Petko Goranov » Tue 5. Apr 2011, 17:15

Hi,

I solved the problem with Windows SDK GetLocalTime(...).

Thanks

GregK
Posts: 3
Joined: Tue 18. Aug 2020, 12:03

Re: How to get Timestamp of CAN_Write ?

Post by GregK » Tue 18. Aug 2020, 12:12

Dear Michael

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?

/Greg

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: How to get Timestamp of CAN_Write ?

Post by M.Heidemann » Wed 19. Aug 2020, 13:36

Hello Greg,

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.

Best Regards

Marvin

GregK
Posts: 3
Joined: Tue 18. Aug 2020, 12:03

Re: How to get Timestamp of CAN_Write ?

Post by GregK » Thu 20. Aug 2020, 13:33

Dear Marvin

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?

/Best Regards
/Greg

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: How to get Timestamp of CAN_Write ?

Post by M.Heidemann » Thu 20. Aug 2020, 13:58

Hello Greg,
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.

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.


Best Regards

Marvin

GregK
Posts: 3
Joined: Tue 18. Aug 2020, 12:03

Re: How to get Timestamp of CAN_Write ?

Post by GregK » Thu 20. Aug 2020, 17:44

Ok, make sense

summarize:
proper timestamp for transmition:
- second hw
or
- PCAN-Developer 4 package

Best Regards
/Greg

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: How to get Timestamp of CAN_Write ?

Post by M.Heidemann » Fri 21. Aug 2020, 08:45

Hello Greg,

Yes, exactly.

Best Regards

Marvin

-closed-

Locked