From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Library Function Node, DLL large array passing

Solved!
Go to solution

Hi,

I have successfully interfaced to most of the functions in a DLL but one is causing me problems...

header file declaration:
CORRTABLE * pDestCorrectionTable ;

Fundamental data type:
struct {
 long[65*65];
 long[65*65];
 long[65*65];
}*;


Call Library Functio Node prototype:
unsigned long  MC_get_corrtable(unsigned short int wSourceIndex, void *pDestCorrectionTable);


The automatically generated wrapper from Tools|Import|Shared Library creates a 3x65 cluster of longs. Shouldn't it have created a 3x65x65 cluster? (but 256 is the maximum cluster size). This and every method I've tried cause the Call Library Function Node to crash.
What's the workaround?
Thanks

Al

0 Kudos
Message 1 of 18
(4,245 Views)

Hi Al,

 

Can you post the DLL and header file so I can try to replicate your crash?

 

Kind regards

Sheela Sujeeun

Applications Engineer
National Instruments UK
0 Kudos
Message 2 of 18
(4,210 Views)

Hi Sheela,

Thanks for your help - I've attached the DLL and header file...

Al

0 Kudos
Message 3 of 18
(4,197 Views)

Hi Al,

 

Sorry for the delay in getting back to you.  I have been trying various methods to use your dll, but have not been able to replicate the crash you were getting.  If you could post the steps you took that caused the crash I will try again, and file a CAR (Corrective Action Request) for the issue to so that R&D are aware of it.  Also, what version of LabVIEW are you using?

 

I have however gotten the same result as you from that one function, an output of 3x65, not the 3x65x65 that one would expect.  I want to do some more digging into why this is the case and will post back with an explanation as soon as I can.

 

kind regards

Sheela Sujeeun

Applications Engineer
National Instruments UK
Message 4 of 18
(4,169 Views)

Hi,

The "MC_get_corrtable" function is the only one causing a crash - I assume because the import wizard incorrectly connects a cluster input of size 3x65 to the DLL due to a parsing error from "long[65*65]".

How do I force LabVIEW to reserve the correct memory? I can't connect a cluster of 3x4225 to the DLL input (too large!)

thanks for your help

Al

0 Kudos
Message 5 of 18
(4,165 Views)

Al,

 

Actually, looking back at the VI you posted, you have a cluster of 195 elements, 65 X elements, 65 Y elements, and 65 Z elements.  I have instead a VI that has three separate 1D arrays for X, Y and Z data.  See the attached vi.  Still, a 1D array is of no use when the function specifies a 2D array of 65 elements in each direction.  One option is to create a custom control, perhaps a cluster with 3 2D arrays, and on the last page of the import wizard select custom control.

Sheela Sujeeun

Applications Engineer
National Instruments UK
0 Kudos
Message 6 of 18
(4,156 Views)

Hi,

that's correct a cluster of 195 (I wrote size 65x3 to make it clear where this number had come from).

The original function doesn't specify a 2D array - The internal 65x65 2D array is stored end to end as a 4225 element 1D array and it is this that is exposed to the LabVIEW code.

I have tried clusters of arrays i.e. a cluster of 3 arrays of size 4225 and several other methods but they all cause the DLL to crash.

please could you attach your vi as version 8.5.

Many thanks

Al

0 Kudos
Message 7 of 18
(4,152 Views)
Sorry about that, this should be an 8.5 version.  If the internal data is a 1D array, then perhaps this will suffice?
Sheela Sujeeun

Applications Engineer
National Instruments UK
0 Kudos
Message 8 of 18
(4,149 Views)

Hi,

I don't have access to the DLL to change the input parameters so three separate 1D arrays as in your VI can't work for me. I'll have to admit defeat with this function unless anyone has any other ideas?

Is there any reason why a pointer to a structure of 3 arrays of  4225 element long integers can't be passed?

Thanks

Al

0 Kudos
Message 9 of 18
(4,139 Views)

Hi Al,

 

Good afternoon and I hope your well today. Sheela is going to be out of the office for awhile and she has asked me to continue your support.

 

There seems to be a bit of confusion in what your expecting, what errors/crash you saw and what expecting this dll is generating at an output. 

 

So can we start again, slightly, ?

 

1) Did you have an error or a crash? If it was an error could you please provide the details, if it was a crash - how did LabVIEW crash, could you close LabVIEW in taskmachine or did the entire OS crash?

 

2) could you please provide the steps to replicate your issue.. I see you have code and the dll (function) so if you could me the steps and how your configuring your Call Library Node then that would be a great start! 

 

3) LabVIEW handles arrays differently to other languages.. pointers for starters aren't used.  In the call library node you have three options, which are explained in the following knowledgebase article, please take a read.

 

What are the Differences Between "Array Data Pointer", "Array Handle", and "Array Handle Pointer"?

http://digital.ni.com/public.nsf/allkb/862567530005F09C8625649700587C37?OpenDocument

 

I look forward to working with on this issue from Monday - but please provide the information above. 
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 10 of 18
(4,110 Views)