Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set the CAN time attribute at run time

In order to correct at run time for an offset relative to a time server, I have tried to set the CAN timestamp atribute (x80000008) using DLL ncSetAttr, but LabVIEW crashed when calling this function. There is any available example showing how this operation can be corectly performed?
Thanks
GN
0 Kudos
Message 1 of 4
(4,656 Views)
Unfortunately that attribute is no longer supported on the current version of the driver.  As a work around, you can set the card to use relative time and then compare that with the time server to track the difference.
Robert Mortensen
Software Engineer
National Instruments
Message 2 of 4
(4,622 Views)

Robert,

Thank you for your reply. I am not sure, however, if I understood what you meant by setting the CAN to use relative time instead of absolute time.

Meantime I think that I found a workable solution. Since I have noticed that the CAN absolute clock is ajusted to the system time every time the network is initialized, I am using now a set of ncCLOSE-ncConfigCANNET-ncOPEN commands to priodically adjust the CAN clock to the system time, which in parallel I take care to be synchronized with a time server using a service running in the background. I am not sure, however, if this method is safe enough to avoid loosing some CAN frames sent over the network just before or during this procedure.

I would greatly appreciate your opinion regrading this approach.

Many thanks,

GN

0 Kudos
Message 3 of 4
(4,589 Views)
The ncClose will flush the queue of all frames so you will lose whatever is in the queue plus whatever is put on the bus before the ncOpen.

If you have any DAQ hardware you can sync it with your CAN to use the same timebase.

There is also an unsupported trick you can pull with the frame API to accomplish this.  If you are interested I could email you the code.
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,570 Views)