LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call library function node with a pointer to a struct with contains fixed sized arrays

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);

 

0 Kudos
Message 1 of 8
(2,859 Views)

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.

0 Kudos
Message 2 of 8
(2,854 Views)

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.

0 Kudos
Message 3 of 8
(2,849 Views)

i have seen the cluster approach as well as creating a wrapper dll.

0 Kudos
Message 4 of 8
(2,847 Views)

ah, that we be us.

 

i am creating wrapper vi's to the function calls into our library and sample apps.

0 Kudos
Message 5 of 8
(2,846 Views)

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.

0 Kudos
Message 6 of 8
(2,842 Views)

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.Smiley Happy

0 Kudos
Message 7 of 8
(2,838 Views)

If you already maintain wrapper DLLs then I would add this function to the wrapper and give it a "LabVIEW friendly" interface.

0 Kudos
Message 8 of 8
(2,832 Views)