LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use returned memory pointers

Dear All !

 

I create a 2d array with initialise array. I wire this array to a dll call, so the dll gets the Array Data Pointer. My dll writes some data into the memory area, and returns a pointer to somewhere inside that area. I would like to use this memory area in labview as an array. The only solution i found is to have the dll return an offset relative to the beginning of the array, and pass this offset to "array subset" VI. But this seems very slow. Is there a VI to which i pass a memory pointer, and some dimension sizes, and it gives me an array handle i can use later on as a regular LV array ? Thank you

0 Kudos
Message 1 of 4
(2,864 Views)

Do you have access to the DLL source code?

 

If so, then pass LabVIEW array HANDLES, not pointers to it.  dereference them properly in the DLL and you're all set.

 

Remember that a LabVIEW array is NOT just a pointer to the first element, as it is in C.  It is a HANDLE, and the first thing in the data storage is an I32 for each dimension, telling how many items are in that dimension at the moment.

 

 

There are no VIs that deal with memory pointers.  That's antithetical to the LabVIEW way, and dangerous in the hands of beginners.

 

 

There's a HELP topic somewhere about "using External Code with LabVIEW"  or something like that. That should explain all you need to know.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 4
(2,855 Views)

I understand the difference between array data<->handle pointers

Just a little bit more detail please. I have 2d labview array, i pass it as handle to the dll.

Suppose i want this labview array to begin with the 15th element when the dll returns.

I think this is what you refer to as "dereferencing". This should be something like array = &array[14].

I thought i could simply overwrite the address of the handle to make it point to a different memory location, but this crashed labview, even if correctly changing the dimension values.

How is this done ? Thank you

0 Kudos
Message 3 of 4
(2,850 Views)

dzac wrote:

Dear All !

 

I create a 2d array with initialise array. I wire this array to a dll call, so the dll gets the Array Data Pointer. My dll writes some data into the memory area, and returns a pointer to somewhere inside that area.


OK. I understand so far (ignoring the incorrect terminology).

 


I would like to use this memory area in labview as an array.

Haven't a clue what this means, or what you're trying to do. 

 

Message 4 of 4
(2,832 Views)