NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass an array of structs to a C function using the dll flexible prototype adapter?

I've got something working, well kind of. I've used the following settings in TestStand:

In the Custom Data Types:
For the array of struct:
In C Struct Passing:
Checked "Allow Objects..."
Packing: 8 byte
For the Properties of the Data Type:
Store Array As: Pointer to Array
Store Struct As: Embedded Struct

In the Labwindows Step:
For the properties of the struct array passed to the module:
Category: Array of C Struct
Type: TelnetScript (i.e. not the array of struct, but the struct itself)
Element Pass: Embedded Element
Dimensions: 1
Dim 1 size: 1024


Now in Labwindows the prototype of the parameter passed is:

TelnetScript TestScript[1024]

Now this works when I execute it, all the array elements are accessed, but when I add TestScript to the watch list I can only watch the 1st struct of the array. Is this because I have done something wrong in TestStand or is it a bug in Labwindows?

Thanks!

Louis
0 Kudos
Message 11 of 17
(2,171 Views)
Louis,

It looks like you are passing the struct correctly. I take it you added TestScript as a watch expression in LabWindows. What happens if you add TestScript[1] as a watch expression? Do you see the second element in the array of structs?

Eric
0 Kudos
Message 12 of 17
(2,166 Views)
Yup I see it. Thanks for the workaround.

Louis
0 Kudos
Message 13 of 17
(2,158 Views)
By the way is there any function to get the size of an array in Labwindows? Just to make sure I dont get out of the array.

Louis
0 Kudos
Message 14 of 17
(2,155 Views)
You are welcome!

As far as the size of the array, you declared the array as having 1024 elements. Now, “For one-dimensional arrays in which the array argument has fewer elements than the temporary array, the C/C++ DLL Adapter fills the remaining elements in the temporary array with zeros” (TestStand Help, Edit C/C++ DLL Call Parameters). What you could do to know how many non-zero elements is to keep a numeric in TestStand that keeps track of how many structs get put in the array. Then, pass this numeric to your LabWindows code. Otherwise, you could search the 1024 elements of the array for the first “zeroed” element.

Eric
0 Kudos
Message 15 of 17
(2,152 Views)
I have a similar requirement. I want to pass an array of Clusters to a Labview DLL. I followed this http://digital.ni.com/public.nsf/allkb/22BF02003B4588808625717F003ECD67 and managed to pass a cluster to labview DLL. But when i try to pass an array of clusters i get this error -17502; System Level Exception. I have attached my sequence. It is calling a DLL which has a simple function to ouput array of clusters. I also tried passing the cluster array as an input parameter to the DLL. But still i get the same error.Thanks
0 Kudos
Message 16 of 17
(1,693 Views)

Hello Sara -

 

Thank you for attaching your files. I spent a little time attempting to get this working, then I decided to look further into our documentation. Unfortunately, this is currently a Known Issue (158938) and limitation in TestStand. Please see the link below for information on this Known Issue. You can use the Known Issue ID to check the Bug Fix List for future versions of TestStand to see if this issue has been resolved or not.

 

TestStand Known Issue 158938

 

I would like to point out that you can accomplish this task by simply calling a VI. Is there a particular reason you prefer calling a LabVIEW built DLL as opposed to a LabVIEW VI?

Manooch H.
National Instruments
0 Kudos
Message 17 of 17
(1,614 Views)