LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Cluster into LabVIEW Generated DLL using __cdecl

I'm using a DLL generated with LabVIEW 7.1 to calculate IIR filter coefficients in a application I'm writing in C++. The DLL contains several different functions. The function prototype in question looks like this:

long __cdecl ButterworthCoefficients(unsigned long filterType,
double samplingFreqFs, long order, double lowCutoffFreqFl,
double highCutoffFreqFh, TD1 *IIRFilterCluster);

where "TD1" is an output that contains the IIR filter coefficients generated by the function. TD1 looks like this:

typedef struct {
unsigned long filterStructure;
TD2Hdl ReverseCoefficients;
TD2Hdl ForwardCoefficients;
} TD1;

TD2Hdl is a handle to a 1-D array containing doubles.

My question relates to how to pass the TD1* parameter into the function. If I simply declare TD1 and leave it uninitialized and pass it's address to the function I get a windows access violation read error. So I assume I have to create and populate the entire TD1 structure in my C++ source file, allocating memory for the arrays, before passing the TD1 address to the function. When I try to do that I get a LabVIEW error "Fatal Internal Error memory.cpp, line 638".

Any ideas on how to make this work?
0 Kudos
Message 1 of 2
(2,648 Views)
Ok, I fixed my problem. I had to set the TD2Hdl elements in the TD1 structure to NULL before passing the TD1 address to the function. I think this makes sense because if you look at the Butterworth Coefficient.vi that I used to generate the DLL, the inputs to the CIN in that VI's block diagram are empty arrays. So I guess by setting the TD2Hdl elements to NULL, it tells LabVIEW that you are giving it an empty array, which is what the CIN was expecting.

Hopefully this helps anyone else who has this same sort of problem.
Message 2 of 2
(2,642 Views)