Automotive and Embedded Networks

Showing results for 
Search instead for 
Did you mean: 

Does NI-CAN (USB-8473) support programming in C#

Hi there, I am developing software in C#, which supposed to test electronic devices (production of electronic manufacturing company), to ensure quality and functionality.

My system consist of many NI devices, mainly Digital and Analog I/O, of them belong to DAQmx-group, and support programming in C#.

Recently I added to the system CAN device USB-8473, which belong to NI-CAN-group (using my own terminology).


Question is: Does NI-CAN provide support (classes, libraries, dll's, etc) for programming in C#?


Thank you in advance

Message 1 of 8



Please see section starting on pg 5-1:  This will describe all the languages that are supported with the NI CAN drivers that will be used to control the 8473.  It also mentions that other languages can call the nican.dll



0 Kudos
Message 2 of 8

Hi Chris, thanks for fast reply,

yes, sure, I read this section of manual, just was thinking, this manual is from mid-2010, and meanwhile updated version of NI-CAN might be available, compatible with last generation of .NET, but it seems it is not.

One more question: your Nican.dll is C++, unmanaged code library. To use it in .NET, particularly in C#, there must be some code which describe functions and variables packaged in this dll, to  provide translation (conversion) of functions and variables types, from C++ types to C# types, which would be very helpful for .NET programmers in using this dll. Something like:


        [DllImport("Nican.dll" , CallingConvention = CallingConvention.Cdecl)]
        public static extern int ncGetHardwareInfo(uint CardIndex, uint PortIndex, uint AttrId, uint AttrSize, ref uint  Attr);

        //instead of NCTYPE_STATUS _NCFUNC_ ncGetHardwareInfo(NCTYPE_UINT32 CardIndex, NCTYPE_UINT32 PortIndex, NCTYPE_ATTRID AttrId, .......
        public const int NICAN_ERROR_BASE   =        (int)(0xBFF62000);    // instead of #define  NICAN_ERROR_BASE (NCTYPE_STATUS)(0xBFF62000)
        public const int CanErrFunctionTimeout = (NICAN_ERROR_BASE | 0x001); // instead of #define  CanErrFunctionTimeout (NICAN_ERROR_BASE | 0x001)

If you have code with this kind of conversion, would be very nice to have a link to that.

Thank you for your help.

0 Kudos
Message 3 of 8

Hi Serge,


We do not have a wrapper written, but it looks like others in the community have written some: and
Also, this looks like it might be useful for automating the process of creating a wrapper:



0 Kudos
Message 4 of 8

Hi there, spent few days working on C# wrapper and now share it with you guys.

So, attached project is NI-CAN wrapper in C#, Visual Studio 2010, for Frame API only, device: USB-8473(no sync)

Have a nice day

0 Kudos
Message 5 of 8

Thanks so much for this. Is there a way to save your project to VS 2005 and repost?


Thanks again.

0 Kudos
Message 6 of 8

Thank you very much for the CANTest1.


I have also made some converion to C# (by this tool: Link, was little bit tricky).

(see attached file, but be careful with the arguments !  compare to TestCAN1)


The best way to develop such a C# library is:

1. Create C# dll with the interop / PInvoke code

2. Compare with LabView sample code from (e.g) "C:\Programme\National Instruments\LabVIEW 2012\examples\nican\Frame - Basic.llb"

3. develop library step by step



Eugen Wiebe



Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
0 Kudos
Message 7 of 8
Hello, Thanks for the TestCAN1. I am able to Config,Open,Write but unable to Read the transmitted message.Instead,am getting other messages.Kindly guide me regarding this. Thanks in Advance
0 Kudos
Message 8 of 8