Hi guys, this is my first share.
I think a C # wrapper functions for CAN may be useful to many.
To link the CAN API with C # I have used the C++ language and the /CLI extensions.
The system used to test the project was composef from
NI PXI-1033 Chassis
NI PXI 8512 Board
The software installed was
NI-XNET 1.4 (version 1.4.0.f0)
NI-CAN 2.7.3 (version 2.7.3f2)
In order to use the CAN functions with the NI PXI-1033 and XNET CAN boards it's required the
Compatibility Layer installation. This options must be checked in the NI-XNET driver.
If all the hardware and software was installed correctly MAX should show this informations
Under Devices and Interfaces
Please notice that the CAN number is different from CAN and XINET-CAN
The first port address is CAN0 for CAN API and CAN1 for XNET API
The project was develope with Visual Studio 2010.
The soultion has two projects, NICanProxy is the Class Library which realize the
NI-CAN proxy and TestNICanProxy is a console application which explains some
functionality of the proxy.
The NICanProxy file contains the following class:
Channel API wrapper for .NET
Channel configuration for Channel API CreateMessage functions
Hardware info details
Message configuration for Channel API CreateMessage functions
Service Utilities
Timestamp returned from Channel API Read functions
and the following enumerations;
Message Arbitration Id enumeration
Defines the properties available with NI-CAN
Defines the channel data type
Defines I/O mode
Defines the byte order
Defines GetName functionality
19-01-2012
Added log4net management to proxy. Some comment are swiched to XML comment.
Have a nice day
Roberto Guerzoni
Tecnologic s.r.l.
Campogalliano (MO)
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hello
First, excellent work/development here... I dont know why NI does not give you sample project that do that automatically. Afterall, we are buying their hardware. Just make it easier for us to develop/use... maybe for another topic 🙂
There seems to be a warning when compiling; and continue starting the project throws the build error message.
Warning
Severity Code Description Project File Line Suppression State
Warning The primary reference "NICanProxy" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0". TestNICanProxy
Build Error
Visual studio cannnot start debugging because the debug target.. c:\.... is missing. Please build the project and retry...
I know I have correct path as I am setting the path, and remove reference NiCanProxy reference and then readding it.
What is the issue here and if anyone has found the solution.. thanks in advance.. Leo
Hello, I'd like to ask where the driver of PXI-8512 is downloaded. Do you have a download address? I can't find it on the official website
I'm supporting and old USB-8472 device using the NI-CAN. Im'm trying to use your wrapper and I tested using your TestNICanProxy. Configure a CAN Channel from MAX called WheelBasedVehicleSpeed and when I exexute your code and debug from MessageConfigTest1 where you read the value from this channel configured you the console lof this:
Testing GetPropertyValue
ChannelAPI.InitStart(ChannelList, VCAN1, IoMode.Output, 0, out wTaskRef)
NI-CAN: (Hex 0xBFF6210D) Your application uses a feature that is not supported by your NI CAN or LIN hardware. Solutions: Contact NI to upgrade your CAN hardware; Consult the Programmer Reference to avoid the new feature (typically related to RTSI or SJA1000); Do not use the Channel API on USB-847x hardware.
My question is do you implement th Message API? is this the API that my device only implement?
Regards