From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

struct

Hi, I'm trying to figure out how to pass my struct to a dll that I am testing in TestStand 3.1.
 
Here is an example of the code in the dll:
***
typedef short SINT16;
typedef int CONNECT_ID ;
 
typedef struct myStruct
{
    SINT16  partA;
    SINT16  partB;
} myStruct;
 
int myFunction(CONNECT_ID ConnectID, int myInt, void* pData, int dataLen, int param);
***
I have defined SINT16 in TestStand as a Signed 16-bit int with a 2 byte boundary.  I have also defined myStruct as a container type with two SINT16's inside of it with a 4 byte boundry.  It holds the SINT16's as Embedded Structs.
 
I'm trying to send an instance of myStruct to myFunction() as pData but the SINT16's I put in the struct are not being received properly.  Is there a generic trick for dealing with passinf objects to void pointers in TestStand?
 
TIA
 
evard
 
0 Kudos
Message 1 of 2
(2,602 Views)
Hi Evard,

When you define a type in TestStand and try to pass it into your dll, it is basically going to be passed as a Struct.
So by defining your SINT16 type in TestStand as its own type, then creating a container type that holds two of those, you are passing into your dll a Struct containing two structs. Your dll doesn't really know what to do with this.

Instead, I'd recommend simply using Signed 16 bit numerics for your "partA" and "partB", as they are essentially of "short" type in your code, then putting those in your "myType" Custom Type that will be passed into your dll as a struct.


Hope this helps Evard, have a good one.

Dan Weiland
Applications Engineer
National Instruments




Dan Weiland
0 Kudos
Message 2 of 2
(2,579 Views)