LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: How do I get the memory address of an array?

Solved!
Go to solution

In the LabVIEW , I am passing this structure as a input to 'Call Library Function'.

 

 

0 Kudos
Message 11 of 18
(843 Views)

Hi ,

 

Pointer Demo.png

 

Is it possible to attach VI here for this code you shared? I wanted to know how Call library function is defined and what all parameters are passed to these functions.

0 Kudos
Message 12 of 18
(838 Views)

Hi SNP,

 

you posted a snippet! (All you need to do is written in the LabVIEW help…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 18
(833 Views)

Well, your comment is pretty non-informative. Why do you need this? What API requires this? Do you have control over the source code for this?

All important questions that may make a huge difference in how to best solve this.

Basically if at all possible change the C side of things. Pointers passed back from an API to the caller have all kinds of nasty implications such as how long is this pointer valid (it's pretty nasty if you are trying to read the contents in your app when the underlaying API suddenly decides that this pointer needs to be de/re-allocated), how to make sure it is de-allocated properly after use, and many more such things.

If that is not an option, you will have to start playing a bit of C compiler in the LabVIEW diagram. First your structure must be made to match exactly the memory layout as a C compiler will put it into memory. This includes things like structure element padding as well as creating different structures for 32-bit and 64-bit operation with the use of the conditional compile structure. Basically your pointer has to be a 32-bit integer for use in 32-bit LabVIEW with a 32-bit DLL, and a 64-bit integer for use in 64-bit LabVIEW with a 64-bit DLL. Then you can maybe use the vi.lib\Utility\importsl\GetValueByPointer\GetValueByPointer.xnode to read the contents of the pointer. All of this is without any of the LabVIEW standard belts and supenders that you have when programming with normal VIs. You are responsible to make everything 100% correct or suffer the consequences in form of hard crashes. And unfortunately not crashing is no indication that you got it 100% right. It may seem work for a long time without any visible problems, to suddenly give you the threaded 1097 error when calling this or any other unrelated Call Library Node. Or your application starts to crash when you shut it down, as LabVIEW is trying to cleanup internal resources that your code has overwritten with trash. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 14 of 18
(831 Views)
Solution
Accepted by topic author SNP@25

@GerdW wrote:

Hi SNP,

 

you posted a snippet! (All you need to do is written in the LabVIEW help…)


Well to be fair, the current forum software makes this a bit difficult. You need to right click on the image and open it in a separate window/tab, then remove the trailer "/image-size/large?v=1.0&px=999" from the URL and reload the new URL. When you then drag the image to your desktop, the embedded VI snippet will be maintained, and then you can drag the image into a LabVIEW diagram window.

Rolf Kalbermatter
My Blog
0 Kudos
Message 15 of 18
(825 Views)

Hi GerdW,

 

Its not a VI Snippet its just a screenshot. I found it in the earlier comments. It would be great if you can share VI snippet which I can import in my code.

 

0 Kudos
Message 16 of 18
(825 Views)

GerdW,

 

Your solution worked. I have VI snippet now. Thanks a lot

0 Kudos
Message 17 of 18
(819 Views)
Solution
Accepted by topic author SNP@25

SNP@25

 

Its not a VI Snippet its just a screenshot.

 


No that is actually a snippet and has the executable VI code embedded in the image.  In Chrome I can go to this URL, then drag the picture to my block diagram and bam! There is the code.

0 Kudos
Message 18 of 18
(816 Views)