03-15-2018 06:28 AM
In the LabVIEW , I am passing this structure as a input to 'Call Library Function'.
03-15-2018 07:17 AM - edited 03-15-2018 07:18 AM
Hi ,
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.
03-15-2018 07:23 AM
03-15-2018 07:24 AM
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.
03-15-2018 07:37 AM
@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.
03-15-2018 07:40 AM
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.
03-15-2018 07:45 AM
GerdW,
Your solution worked. I have VI snippet now. Thanks a lot
03-15-2018 07:48 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord