Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining an IVI Driver Session from IVI Logical Name in IVI-COM

Hello everyone,

 

I was wondering if someone can help me understand a few things. I am writing a program in C# using a C DcPwr library. I read that I can use the DllImport function but I'm having some trouble understanding some things.

The function I'm importing is 

ViStatus _VI_FUNC CPX400_init (ViRsrc resourceName, ViBoolean IDQuery, ViBoolean resetDevice, ViSession *newVi)

so I'm confused about two things

The first things is the _VI_FUNC. Can someone explain what that does and how it interacts with the C code.

The second is importing the C function into my C# application. How do I translate the declared types to C# types? I assume I can change ViBoolean to bool, and maybe ViRsrc to string, but how about the others? If I'm wrong, please let me know.

 

0 Kudos
Message 1 of 2
(2,959 Views)

Hello,

 

All of the questions you are asking are about typedefs and definitions. Probably on your computer is a visatype.h file which shows definitions of _VI_Func as well as all of those data types. For example, I have a copy of this located in C:\Program Files\IVI Foundation\VISA\Win64\Include.

 

For example, depending on your processor, if you are running Windows 64 bit, _VI_Func gets defined as a _fastcall function type, but if you are running Windows 32 bit, then _VI_Func gets defined as a _stdcall function. 

 

To go further, this visatype.h file also defines unsigned short as a ViBoolean. So that would show which filetypes you can use when transferring over to C#. You could try using the original data types instead of the custom typedefs, but if you run into issues then it might be easier to create a C wrapper which converts your C# inputs into the typedef parameters.

 

Best,

 

Shamik C

Applications Engineer 

National Instruments 

http://www.ni.com/support 

0 Kudos
Message 2 of 2
(2,915 Views)