01-24-2017 12:41 AM
02-06-2017 11:29 PM
It is possible to use NI-CAN board in Measurement Studio C# (C Sharp). However, it is not officially supported by National Instruments.
To call functions from ni-can.dll you need to create wrapper functions. For example to wrap the following NI-CAN function:
nctTypeStatus NCT_FUNC nctInitStart (
cstr ChannelList,
i32 Interface,
i32 Mode,
f64 SampleRate,
nctTypeTaskRef *TaskRef);
you need to create the following prototype in C# (C Sharp):
[DllImport("C:\\WINDOWS\\system32\\Nican.dll")]
public static unsafe extern int nctInitStart(string ChannelList, int Interface, int Mode, double SampleRate, int* TaskRef);
You need to use keyword unsafe in the prototype to be able to call external functions from dlls. Also, you cannot use char* type, instead you use string datatype. Also, to instead nctTypeTimestamp datatype use the following structure:
public struct CanTimestamp
{
public int LowPart, HighPart;
}