Jump to content

Using Variants in a Call Library Function, using Interface to Data


Recommended Posts

Hi,

I am working in a DLL to create a Labview component that runs some C code. I was using the Call Library Function, and I see it works to write external functions that get and set Labview data in/from the C code. But now, I would like to make it work with Variants, since I want to allow to wire any kind of data into my CLF Node.

I have been using the Adapt to Type - Interface to Data option to be able to introspect the LabVIEW Data from my C code and get or set its value. I have been told that Variants are structured very similar to any other LabVIEW Type, so I should be able to use the Interface to Data option as well (with some minor changes in the code and maybe some casts). But the truth is that I cannot even try it since when I connect a Variant to the CLF Node, LabVIEW tells me:

The data type wired cannot be passed into a Call Library Function Node parameter that is configured to use Adapt to Type with data format of Interface to Data.

I guess this means that it is not going to be as easy as expected, probably having to do some tricks, workarounds, etc. but right now I do not have any idea on what to try or where to start with. I have been trying to look in the documentation, help and posts anything useful but I did not find anything. So, any help will be greatly appreciated.

Thank you very much.

Link to comment

Hi,

I am working in a DLL to create a Labview component that runs some C code. I was using the Call Library Function, and I see it works to write external functions that get and set Labview data in/from the C code. But now, I would like to make it work with Variants, since I want to allow to wire any kind of data into my CLF Node.

I have been using the Adapt to Type - Interface to Data option to be able to introspect the LabVIEW Data from my C code and get or set its value. I have been told that Variants are structured very similar to any other LabVIEW Type, so I should be able to use the Interface to Data option as well (with some minor changes in the code and maybe some casts). But the truth is that I cannot even try it since when I connect a Variant to the CLF Node, LabVIEW tells me:

I guess this means that it is not going to be as easy as expected, probably having to do some tricks, workarounds, etc. but right now I do not have any idea on what to try or where to start with. I have been trying to look in the documentation, help and posts anything useful but I did not find anything. So, any help will be greatly appreciated.

Thank you very much.

In order to deal with LabVIEW Variants on the C side of the fence you need an API that exists but is undocumented so far for people not working at NI. LabVIEW Variants are really C++ type objects so with just flattening or whatever you won't get far.

And the way to pass variants to the Call Library Node is not as Interface To Data but simply as LabVIEW data. So any of the other three options though it won't really make any difference which you chose as they don't apply to data other than arrays or handles.

Link to comment
And the way to pass variants to the Call Library Node is not as Interface To Data but simply as LabVIEW data. So any of the other three options though it won't really make any difference which you chose as they don't apply to data other than arrays or handles.

Sorry, but I do not understand if you mean that any other option inside the Adapt to Type is valid or if none of them will work. Would it be possible to get an example on how to pass a variant to a Call Library Function Node (how to configure the parameter options) and how to use the Variant in the C code. I have found the LvVariant class defined in extcode.h but since you says there is no documentation, I do not know how to use it :$

Thank you very much.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.