LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass points to a structure to a function?

Hello,

I'm working with Labview 2016 and I have imported a library of functions through DLL import wizard. There are some functions with parameters pointer to a data structure and with those I cannot figure out how to pass the pointer to the functions correctly. The main function that I really need to use is defined as follow... long AlpDevControlEx (ALP_ID DeviceId, long ControlType, void *UserStructPtr).


Where the parameters of the function should be:

AlpDevControlEx DeviceId: 4-byte integer,
ControlType: 4-byte integer,
UserStructPtr: pointer to a read-able structure according to ControlType


Here is the code of the function as in the header file:

/* AlpDevControlEx */
#define ALP_DEV_DYN_SYNCH_OUT1_GATE 2023L
#define ALP_DEV_DYN_SYNCH_OUT2_GATE 2024L
#define ALP_DEV_DYN_SYNCH_OUT3_GATE 2025L

struct tAlpDynSynchOutGate {
/* For ControlType ALP_DEV_DYN_SYNCH_OUT[1..3]_GATE of function AlpDevControlEx */
/* Configure compiler to not insert padding bytes! (e.g. #pragma pack) */
char unsigned Period; /* #Period=1..16 enables output; 0: tri-state */
char unsigned Polarity; /* 0: active pulse is low, 1: high */
char unsigned Gate[16]; /* #Period number of bytes; each one is 0 or 1
Only the first #Period bytes are used! */
};

 


I do not have any background in programming and so far from reading through the functions description and labview discussion forums I know that I have to make a structure of three values( char unsigned Period, char unsigned Polarity, char unsigned Gate[16]) and then pass the address as pointer to the function, but still I could not find a solution that worked for me. I tried passing the data as a cluster but I got an error (ALP_PARM_INVALID). Could you please help me on how to set a pointer to a data structure for my function correctly.


Thank you in advance,

0 Kudos
Message 1 of 2
(1,815 Views)

The unsigned Gate[16] should point to 16 bytes. The two chars before it are just data. So, I'd use a string filled with 18 characters, or an array of 18 bytes. Depending on how you'd like to fill the Gate. The array and string are passed as pointers by default.

 

You can make this data structure by concatenating the two bytes and the array:

Cluster dll.png

0 Kudos
Message 2 of 2
(1,779 Views)