LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resizing an array of clusters for a DLL?

Hi,

If I pass an array of a cluster of 2 floats and one int into a DLL function for manipulation. Do I just resize and allocate memory for the array, or do I need to allocate memory for both the resized array and the cluster it contains.

If I resize the array, will the Labview memory manager create the neccessary memory for the cluster elements in the array as well?

How do I do this using CVI? I have allocated the cluster memory, and I can successfully populate the cluster, but when I copy the cluster (struct) into the resized array Labview either crashes or doesn't show the data.

Here are the data structures..

// The cluster...
typedef struct
{
uInt32 Wavelength;
float64 Power;
f
loat64 OSNR;
} Data;

// The array..
typedef struct
{
int32 dimSize;
Data peakData[1];
} DataArray;

// The handle..
typedef DataArray **DataArrayHandle;
0 Kudos
Message 1 of 3
(2,776 Views)
LabVIEW passes an array of clusters as an array of pointers to the clusters. Each cluster must be valid in LabVIEW's data space. Becuase of this, I think you would have to actually define a new cluster in the C code using the LabVIEW memory management tools and then resize the array of clusters by adding a pointer to your new cluster, again using LabVIEW memory management tools. This can get particularly tricky. Here's an example program that might help you.

http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&443CB374ADF0B1D1862569880064C658&cat=D0A775F79852010F862567AC00583FA7
0 Kudos
Message 2 of 3
(2,776 Views)
Hi codeman,

Thanks for the great examples. I'm still having trouble getting this to work w/o crashing. I have attached my LV file with a LV generated basic C file. I'm starting to wonder (after looking at your example code) if I am doing this correctly and LV is just crashing.

Could you try to write to the two data types in the array for an array size greater than 2 and see what happens? I'd love to see how you implement this !!

Kindest,
Warren
0 Kudos
Message 3 of 3
(2,777 Views)