NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

import c struct from dll header file into TestStand?

Hi,

I'm writing a TestStand sequence to call some CVI functions I have compiled into a dll. One header file in the CVI code is the interface to the dll and declares some functions and some C structs which are to be passed into the functions as pointers. These structs are populated with test results as the CVI code executes. I want to import these structs into TestStand.

TestStand seems to have properly imported my function calls because I can select them from a drop-down list. But it doesn't seem to recognize my struct definitions, because it just says "unknown __struct 617*" -- it knows it's a C struct pointer but doesn't know what fields exist in the struct.

How do I get TestStand to recognize the fields that are in my structs?

The C functions and structs are declared with DLLEXPORT in the header file. I compile the CVI code into a dll, with the target settings set to export marked header files and symbols. The only header file marked in the target settings dialog is the header file declaring these functions and structs. So I think they're being exported properly into the dll.

Any ideas to help?

Thanks!
0 Kudos
Message 1 of 5
(5,633 Views)
You have to define a sruct in the teststand (container) similar to the one at the cvi, make sure the size of the variables inside the
teststand struct are the same as in the cvi one.
 
Also as far as I can remember there are examples in the teststand which you can use & try typing "struct" at the search option (there some good answers there).

Message Edited by ch.zohar on 09-12-2007 04:49 PM

0 Kudos
Message 2 of 5
(5,617 Views)
TestStand cannot import the struct definition from the DLL or from a header file.

The name of the struct will be __unknown_NNN if you use a typedef without a name as in the following example:

typedef struct { int a; } MyStruct;

Instead, you should give the struct a name in its declaration:

struct MyStruct { int a; };


0 Kudos
Message 3 of 5
(5,594 Views)
I'm using typedef struct {...} MyStruct; to make life easier in CVI world, so rather than changing that throughout my CVI code I think I'll just live with the fact that TestStand doesn't know what struct type it is.

But typedef or not, is it ever possible for TestStand to import the struct definitions (ie so that it knows what fields and types exist within the struct)? Or do I have to make containers in TestStand that match the format of the structs I'm using in CVI, and pass those container pointers into my CVI function calls?

Thanks!
0 Kudos
Message 4 of 5
(5,588 Views)
You have to define a container in TestStand that matches the struct in CVI.

With respect to typedef, because the struct name and typedef name are in different namespaces, you can declare the struct as follows without errors:

 typedef struct MyStruct {...} MyStruct;
Message 5 of 5
(5,557 Views)