LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll troubles

Hi

I built a dll with 3 functions embedded:
* The "initialize" one defines a global structure value and sets an
interrupt handler.
* The "write" one sends data.
* The "read" one reads data.

When trying to execute the "init" with a LabVIEW function call, I get
a "LabVIEW.exe caused an error and will be closed by Windows (...)"
failure.

Any idea why ? Ever debugged it ?


Something else about the array argument initialization (for the write
function above). I pass an empty array constant from LabVIEW, while
the array is declared with a defined max lengh in the C source. Does
that mean trouble ? Should I pass an initialized array ?


Thanks - oz
0 Kudos
Message 1 of 3
(2,556 Views)
Hi,

A passed array should be initialised. Assays do not "grow" from within a
library function. It is the same as passing a pointer of an array from one c
function to another. The memory belongs to the caller.

Regards,

Wiebe.


"Olivier Zimmermann" wrote in message
news:3FAB7617.8050404@lpsc.in2p3.fr...
>
> Hi
>
> I built a dll with 3 functions embedded:
> * The "initialize" one defines a global structure value and sets an
> interrupt handler.
> * The "write" one sends data.
> * The "read" one reads data.
>
> When trying to execute the "init" with a LabVIEW function call, I get
> a "LabVIEW.exe caused an error and will be closed by Windows (...)"
> failure.
>
> Any idea why ? Ever debugged it ?
>
>
> Something else about the array argume
nt initialization (for the write
> function above). I pass an empty array constant from LabVIEW, while
> the array is declared with a defined max lengh in the C source. Does
> that mean trouble ? Should I pass an initialized array ?
>
>
> Thanks - oz
>
0 Kudos
Message 2 of 3
(2,556 Views)
> Any idea why ? Ever debugged it ?
>
>
> Something else about the array argument initialization (for the write
> function above). I pass an empty array constant from LabVIEW, while the
> array is declared with a defined max lengh in the C source. Does that
> mean trouble ? Should I pass an initialized array ?
>

I think you need to build a debug version of your DLL and set a
breakpoint in the init. I think you will find that either one of the
calls there is causing the exception, or it is corrupting some memory
that LV tries to access on return. The LV array is a dynamic structure
that can change size in the DLL, but it is not the same as the [] array
in C, which is really just indexing math added to a pointer either
malloced, in a global, or on
the stack. The header file extcode.h has
functions for dealing with LV arrays, and you may want to take a minute
to work through an example to learn a bit about LV datatypes.

In LV, make a DLL node that passes an array and perhaps a few other
types in. Popup on the node and create .c file. The call will show you
some typedefs you can use the manipulate and access the LV arrays. You
can also experiment and see the difference between the choices for
passing arrays as pointer, handle, etc.

Greg McKaskle
0 Kudos
Message 3 of 3
(2,556 Views)