NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing SAFEARRAY Pointer from CVI

Hi,



I am having problem in importing IVI-COM dll to C wrapper dll in Labwindows/CVI. I have to do that for my TestStand application to call the functions of the dll. After registering the COM dll, I have used �Create Activex Controller� option to create .c, .fp and .h files. With this, I was able to create dll but without any prototype info. So, I included the fp file to include prototype info. But while I create my dll with the type lib info, odl file gave error to use SAFEARRAY pointer. So I have declared a structure mySAFEARRAY (same parameters as that of SAFEARRAY) and has replaced all the (SAFEARRAY *) to (mySAFEARRAY *). After doing this, I have created the dll successfully.



Now in TestStand when I have called the dl
l with �Flexible Prototype Adapter�, few of the data types (structures) are not applicable to TestStand. So it is taking all the unknown data types to �long�. When I check the prototype with my C file, it is telling mismatch prototype.



Now, please help me what do we do for the C wrapper dll to work proper. Is the procedure (which I have described above) proper?



I have got one info from NI site, that the functions using the structure parameters should not be exported directly. Instead a wrapper function should be created, with each and every element of the structure as it parameter. Now do we create a wrapper function for each and every function which has the structure parameter in it? I am eagerly waiting for your information. Actually i am new to both CVI and TestStand.
Thank you in advance for your help.




Thank you,

Sasi.
0 Kudos
Message 1 of 3
(3,504 Views)
Hello Sasi -

I am uncertain what your situation is, but it sounds like you are trying to pass the SafeArray as a parameter of your DLL back to TestStand? TestStand only recognizes certain known types when it comes to creating new memory to hold variables. A SafeArray is fundamentally an array of objects, so passing it directly to TestStand is unlikely to work. Your best bet is to look into the LabWindows/CVI examples and functions for converting SafeArrays to one-dimensional arrays of numbers, and passing that array back to TestStand via a parameter or some API call.

As an additional note, there are generic examples of how to successfully pass structures back and forth between TestStand and code modules, but it requires both environments having a definition o
f the structure as well as agreeing upon the byte-packing of the data. The best resource I can provide is to point you to the TestStand shipping example located in the /Examples/Struct Passing/ directory. However depending on how you are attempting to extract that SafeArray, this may not be an issue (as far as writing a numeric array vs. writing a structure).

If this doesn't help answer your question, maybe you can give me a little more information, maybe a function declaration for your code, to try and see what you are doing in more detail?

--Regards
Elaine R.
National Instruments
http://www.ni.com/ask
0 Kudos
Message 2 of 3
(3,504 Views)
The easiest way to do this is to pass your SAFEARRAY as a VARIANT and then take it appart in TestStand.
0 Kudos
Message 3 of 3
(3,504 Views)