Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-CAN multithreaded?

Applogies if this has already been asked before.

Is the NI-CAN API (specifically Frame API for C) thread safe? For example, is it safe for one thread to read a message from a network object the same time as another thread writing a message to it?
0 Kudos
Message 1 of 7
(4,642 Views)
Hi,
 
Thanks for posting your query on the National Instruments forum.
 
The NI-CAN Channel API is not completly thread safe. But there are some useful rules that one could observe to make NI-CAN function calls thread safe. Please check the following link where you will find examples to show diffeerence in coding:
 
 
I hope this helps!
 
Kind Regards,
 
Kurt
NI Applications Engineer.
0 Kudos
Message 2 of 7
(4,626 Views)
Howerver note that with NI-CAN 2.1 (or later), the Channel API is completely multi-thread safe.
 
Kurt
0 Kudos
Message 3 of 7
(4,619 Views)
HI,
 
The Frame API as well as the Channel API is completely Thread Safe with the 2.3 version or later.
 
DirkW
Message 4 of 7
(4,613 Views)
Hello,

I have an application that uses two PXI 8461/2 : the first one is only dedicated to DiagOnCAN (Frame API) and the second one is used for traditionnal CAN (I load a dbc file and use the Channel API).
Sometimes when I try to read a channel with nctRead the function returns me the following error : 0xBFF62125 : CanErrOverflowFrame which is supposed to be an error generated by the frame API (cf nican.h). At the same time everything works fine with DiagOnCAN ie using the frame API in a different thread.
I currently use NI-CAN 2.2 as the project started about 12 months ago. I presume this problem could be caused by a non thread-safe behavior of NI-CAN 2.2 ? Upgrading to NI-CAN 2.3.2 will stop such errors won't it ?

Thank you.
0 Kudos
Message 5 of 7
(4,601 Views)
Hi,
 
It is usually the case that if problems have been identified and reported to NI about earlier versions of the CAN driver then steps would have been taken to correct the problem in a more uptodate release of the driver. In other words your assumptions are correct. Have a go at installing NI-CAN 2.3.2 and let me know how you get on.
 
All the best!
Kurt
0 Kudos
Message 6 of 7
(4,590 Views)
Thanks for the replies (forgot I posted this thread).

I'm using NICAN.DLL version 2.3.0.12409 at the moment so I should be OK.
0 Kudos
Message 7 of 7
(4,444 Views)