01-12-2012 02:04 PM
i want to call a function in a dll. one of the parameters is a pointer to a structure where some of the fields are arrays. see below.
i've seen several suggestions on how to do this. i was wondering which is the best way to handle this particular case.
i need my vi to support version 8 and later. 32 and 64 bit.
thanks.
#define MAXCHANNEL 0x6 // Maximum number of channels on a card
typedef struct _D2S_OUTPUT_STATUS
{
BOOLEAN bPowerActive; /* True - Power Active; FALSE - Power Inactive */
BOOLEAN bS1Active[MAXCHANNEL]; /* True - Active; FALSE - inactive */
BOOLEAN bS3Active[MAXCHANNEL];
BOOLEAN bS2Active[MAXCHANNEL];
BOOLEAN bS4Active[MAXCHANNEL];
}D2S_OUTPUT_STATUS, * PD2S_OUTPUT_STATUS;
S16 _DECL Get_D2rsOutputsStatus(S16 s16DevNum, PD2S_OUTPUT_STATUS pOutputsStatus);
01-12-2012 02:33 PM
What are the methods you are considering?
There's only one good way to do this that I know of: create a LabVIEW cluster that matches the struct, replacing the fixed-size arrays with clusters containing the correct number of elements. Pass this cluster to a call library function node with the type set to "Adapt to Type." Clusters are passed by reference (pointer). Your cluster should use a numeric of an appropriate integer size instead of BOOLEAN (if I remember correctly that's a U32, but you should confirm this) - LabVIEW's boolean will not necessarily have the same numeric representation.
01-12-2012 02:42 PM
My preferred approach: Ask the manufacturer of the device for a LabVIEW driver. Do they have one? Do they have plans for a LabVIEW driver?
Next best approach: You create a set of VIs that run the according call library nodes.
01-12-2012 02:53 PM
i have seen the cluster approach as well as creating a wrapper dll.
01-12-2012 02:55 PM
ah, that we be us.
i am creating wrapper vi's to the function calls into our library and sample apps.
01-12-2012 03:00 PM
I would prefer creating the wrapper VIs, too.
Writing a wrapper.DLL would involve that you have to maintain the DLL for 32bit and 64bit.
01-12-2012 03:21 PM
we currently have wrapper dlls for some other products and we maintain 32/64 bit dlls.
i had to create a wrapper anyway for this product. so i might add this. i'll see how i feel.
01-12-2012 03:35 PM
If you already maintain wrapper DLLs then I would add this function to the wrapper and give it a "LabVIEW friendly" interface.