TPCANTimestamp into readable time
Posted: Thu 22. Feb 2024, 15:01
Hello!
For a current project, I need to read data from CAN using Labview. I am using the kdi_labview_api_for_pcan_basic_fd-1.0.0.10 1 and Labview Version Q3 2023 (32-bit).
So far, I've established a connection and am able to read CAN Data via the Function "CAN Read". The Code returns the CAN messages, but also the TPCANTimestamp out.
The question is, how do I convert the type TPCANTimestamp (e.g. 30F0000 06F4 7D60) into UTC time (with Labview)?
From the following entries in the form we figured out one could use the following formula to convert the timestamp into milliseconds:
viewtopic.php?f=119&t=2529&p=7503&hilit=timestamp#p7503
viewtopic.php?t=3223
{
int32 millis: --> 30F0000
int16 millis_overflow; --> 06F4
int16 micros; -->7D60
}
time_milliseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
Using this formula, we get weird results (e.g. negative numbers), and we don't know how to convert these milliseconds into a readable time, e.g. UTC.
Any help would be great!
Best regards,
Kirsten
PS: In the attachment an Output of the Example PCAN_BASIC_READ_EXAMPLE from the APi.
For a current project, I need to read data from CAN using Labview. I am using the kdi_labview_api_for_pcan_basic_fd-1.0.0.10 1 and Labview Version Q3 2023 (32-bit).
So far, I've established a connection and am able to read CAN Data via the Function "CAN Read". The Code returns the CAN messages, but also the TPCANTimestamp out.
The question is, how do I convert the type TPCANTimestamp (e.g. 30F0000 06F4 7D60) into UTC time (with Labview)?
From the following entries in the form we figured out one could use the following formula to convert the timestamp into milliseconds:
viewtopic.php?f=119&t=2529&p=7503&hilit=timestamp#p7503
viewtopic.php?t=3223
{
int32 millis: --> 30F0000
int16 millis_overflow; --> 06F4
int16 micros; -->7D60
}
time_milliseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
Using this formula, we get weird results (e.g. negative numbers), and we don't know how to convert these milliseconds into a readable time, e.g. UTC.
Any help would be great!
Best regards,
Kirsten
PS: In the attachment an Output of the Example PCAN_BASIC_READ_EXAMPLE from the APi.