Page 1 of 1

TPCANTimestamp question

Posted: Wed 10. Jul 2019, 22:06
by kieldowdle
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

Re: TPCANTimestamp question

Posted: Thu 11. Jul 2019, 08:22
by K.Wagner
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 9214 times

Re: TPCANTimestamp question

Posted: Thu 11. Jul 2019, 17:43
by kieldowdle
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.

Re: TPCANTimestamp question

Posted: Fri 12. Jul 2019, 08:18
by K.Wagner
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.

Re: TPCANTimestamp question

Posted: Tue 13. Aug 2019, 20:14
by kieldowdle
It's been awhile since I posted this question but you were helpful in me figuring out a solution to my issue. Thank you.

Re: TPCANTimestamp question

Posted: Wed 14. Aug 2019, 08:23
by K.Wagner
Hello,

you're welcome.

Closed