LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Address of array changed by for loop

Hi

 

I am creating a VI that initialises an array in a for loop. The array is used by a DLL and I am finding that the address of the array is different outside the loop. The attached example illustrates this. The GetAddress function simply displays the address of the array passed to it in a message box.

 

Does anyone know how I can ensure that the address is not changed?

 

Thanks

 

Robin 

 

ArrayAddress.jpg 

0 Kudos
Message 1 of 6
(3,311 Views)
Because LabVIEW is data flow oriented, it makes copies of arrays, because it doesn't know how they are going to be modified. Because you have a wire branch, it's probably making a copy. Turn on Show Buffer Allocations in the Profile menu. The copies contain the same data, so no worries about that.
Message 2 of 6
(3,305 Views)

RobinM2 wrote: 

Does anyone know how I can ensure that the address is not changed?

ArrayAddress.jpg 


 

LabVIEW MUST make a datacopy of the array at the wire branch, because it need to ensure that the loop output tunnel, which is wired directly from initialize array (!), does not contain data updated from inside the first dll. If the dll were allowed to step on the data of the output tunnel, all bets are off.
 
If both instances of the dll should operate on the same array, you need to wire it differently. For example you could try and delete the wire branch and wire from the output of the first dll to the input of the second dll.
 
What are you actually trying to do? 
Message 3 of 6
(3,280 Views)

Hi 

 

Thanks for the replies.

 

I should have realised that it is the branch causing the data copy.

 

I have a DLL that assigns a set of data buffers using one function and populates them using another function.  The assign buffer function is called once for each buffer and the populate function is called once only.

 

If I assign all of my buffers in a for loop, I get a 2D array by using an auto-indexed tunnel. However, when I call my populate function, the arrays remain unchanged. This appears to be because the location of the arrays has changed since the call to assign the buffer.

 

Does the auto-indexing tunnel move the locations of arrays so that they are contiguous? Is there a way to preserve the address that was allocated by the initialise array block and still combine them into a 2D array?

 

Thanks

 

Robin 

0 Kudos
Message 4 of 6
(3,244 Views)

RobinM2 wrote: 

I have a DLL that assigns a set of data buffers using one function and populates them using another function.  The assign buffer function is called once for each buffer and the populate function is called once only.

 

If I assign all of my buffers in a for loop, I get a 2D array by using an auto-indexed tunnel. However, when I call my populate function, the arrays remain unchanged. This appears to be because the location of the arrays has changed since the call to assign the buffer.

 

Does the auto-indexing tunnel move the locations of arrays so that they are contiguous? Is there a way to preserve the address that was allocated by the initialise array block and still combine them into a 2D array?


 

In LabVIEW, all arrays are contiguous in memory.
 
I am sure your problem can be solved. Could you provide a bit more details or example code?
0 Kudos
Message 5 of 6
(3,231 Views)

altenbach wrote:

RobinM2 wrote: 

I have a DLL that assigns a set of data buffers using one function and populates them using another function.  The assign buffer function is called once for each buffer and the populate function is called once only.

 

If I assign all of my buffers in a for loop, I get a 2D array by using an auto-indexed tunnel. However, when I call my populate function, the arrays remain unchanged. This appears to be because the location of the arrays has changed since the call to assign the buffer.

 

Does the auto-indexing tunnel move the locations of arrays so that they are contiguous? Is there a way to preserve the address that was allocated by the initialise array block and still combine them into a 2D array?


 

In LabVIEW, all arrays are contiguous in memory.
I am sure your problem can be solved. Could you provide a bit more details or example code?

 

Wrapping the dll call in an Action Engine wrapper, I believe will met your req's.

 

The Shift Register will "hold" the data when the dll is not being called.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(3,227 Views)