NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

export custom data type to C code

Solved!
Go to solution

Hi,

 

I wonder, in TestStand, is there a way I can export a custom data type to C struct type definition?

 

I am using TestStand 4.2

 

Thanks.

 

Peggy

0 Kudos
Message 1 of 5
(4,021 Views)
Solution
Accepted by topic author PeggyC

You will have to do a series of API calls, I think.

 

I assume that you have a container type with C struct passing enabled, otherwise you will have no correspondence of subproperties to C data types. Then the following API functions should help you:

  • GetNumSubProperties gives you the number of subproperties in the container type. Then you can do a loop over these. For each
    • GetNthSubPropertyName to get the member name in the container type. 
    • GetStructMemberType gives you the C type, a subproperty maps to;
    • GetStructMemberStringBufferSize, GetStructMemberStorage and GetStructMemberArrayStorage tell you, how structs and arrays are stored inside the container (inline, pointers ...)
  • GetStructPacking gives you the byte padding used for passing the struct. For Visual C++, e. g., this can be translated into a #pragma pack surrounding the type.

 

I think that you will have to use standard Win32 file operations to actually write the information to a header file, since the built-in WriteFile functions of TestStand afaik write TestStand file formats.

 

Perhaps someone knows an easier way. Hope that helps, anyway.

 

Regards

 

Peter

 

0 Kudos
Message 2 of 5
(4,008 Views)

I am using LabWindows/CVI and I can't finding any resemble methods for "GetStructMemberStringBufferSize", "GetStructMemberStorage", and "GetStructMemberArrayStorage".  Do you know how to implement in LabWindows/CVI?

 

Thanks.

 

Peggy

0 Kudos
Message 3 of 5
(3,935 Views)

To reply the access to Common C Adapter class methods, I found the answer.  

 

I am using TS_PropertyGetTypeDefinition, TS_EngineGetAdapterByKeyName, and TS_CVIAdapterAsCommonCAdapter to get the CVI Adapter interface and the variable type interface.  After that, I can call the Common C Adapter functions.

 

Thanks.

 

Peggy

 

 

0 Kudos
Message 4 of 5
(3,928 Views)

And, Thank you Peter.  It works.

 

Peggy

0 Kudos
Message 5 of 5
(3,927 Views)