TPCANTimestamp question

The free CAN Software API (Application Programming Interface) for Windows®
Locked
kieldowdle
Posts: 4
Joined: Wed 10. Jul 2019, 22:01

TPCANTimestamp question

Post by kieldowdle » Wed 10. Jul 2019, 22:06

Hello

I'm creating a c# application for monitoring CAN messages and also sending them. I have a receive window which also captures the messages I'm sending out. The problems is the messages I'm writing don't have a timestamp when I look at them in my receive window.

I'm fine with making my own timestamp but I feel like I'm missing something in my understanding of the timestamp struct.

I do this => Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow

to get the total microseconds but this is total microseconds from when? I'm hoping to get some more context on what is actually going on with TPCANTimestamp so I can mimic it and also do something more interesting with it in my receive window.

Thanks

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: TPCANTimestamp question

Post by K.Wagner » Thu 11. Jul 2019, 08:22

Hello,

the answer is in the same page of the help documentation from where you have the way for microseconds calculation:
PCAN-Basic Documentation - TPCANTimestamp
PCAN-Basic Documentation - TPCANTimestamp
Timestamp.PNG (12.28 KiB) Viewed 9212 times
Best regards,
Keneth

kieldowdle
Posts: 4
Joined: Wed 10. Jul 2019, 22:01

Re: TPCANTimestamp question

Post by kieldowdle » Thu 11. Jul 2019, 17:43

I can't find any kind of consistency in what TPCANTimestamp is giving me. The number of digits varies from 10 to 6 and comparing it with any other method of creating a time stamp doesn't help either.

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: TPCANTimestamp question

Post by K.Wagner » Fri 12. Jul 2019, 08:18

Hello,

our APIs and drivers work with high-resolution timestamps, with a precision of 1 millisecond. They use QueryPerformanceFrequency and QueryPerformanceCounter for Timestamp generation. As far as I know, C# doesn't offer these functions, but it has a class, StopWatch (System.Diagnostics), that may also be used for timestamps acquisition. You can try using StopWatch or using PInvoke for the funcitons mentioned above.

Note: when getting a timestamp before passing a message to the CAN_Write function is still not the real time of message-sending. The message is first placed in the send-queue of the driver.
Best regards,
Keneth

kieldowdle
Posts: 4
Joined: Wed 10. Jul 2019, 22:01

Re: TPCANTimestamp question

Post by kieldowdle » Tue 13. Aug 2019, 20:14

It's been awhile since I posted this question but you were helpful in me figuring out a solution to my issue. Thank you.

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: TPCANTimestamp question

Post by K.Wagner » Wed 14. Aug 2019, 08:23

Hello,

you're welcome.

Closed
Best regards,
Keneth

Locked