LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from pointer in LabVIEW

Hi all,

I have a C DLL created by us. This DLL is used in LabVIEW. The DLL can take any datatype as input. It will return the pointer (address) to the output. Note that the output datatype is same as that of the input. Now I have to read the data from the pointer (address) in LabVIEW. How can I read data from pointer ? 

 

Any kind of help is highly appreciated.

Thanks in advance.

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

I would suggest writing another C DLL that take the pointer, figures out the actual data type (for simplicity, I'm going to assume it is numeric, no more than 8 bytes in size, and can be "tagged" with a small set of enumerators (e.g. U8, U16, ... I8, I16, ... Sgl, Dbl, Ext).  You can expand this list if necessary (Complex?).  Your C-to-LV routine would (presumably) be able to "deduce" the native type, and would return a U64 (containing the bits of the data) and an enum (containing the true Type of the data).  With these two pieces, and some clever use of the TypeCast function, you could generate, say, the corresponding Sgl (or I32, or Dbl, or ...) contained in the original C routine and pass it out as a LabVIEW Variant, perhaps also passing out the underlying Type so when you wanted to get the data out of LabVIEW using Variant to Data, you'd know what Data Type to use.  Messy!  I'm sure my colleagues can come out with a better solution ...

 

Bob Schor

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

Hopefully there's no need for all that, but pointers from dll's can be hairy.

 

Try GetValueByPointer.xnode, located at <vi.lib>\Utility\importsl\GetValueByPointer\GetValueByPointer.xnode.

Message 3 of 4
(2,727 Views)

I can think of dozen things that could match your very generic description and each needs a significantly different treatment. So please show use the DLL function definition and what it really does. From what it sounds like that DLL does simply create a reference to whatever memory pointer is passed in, similar to what the & operator in C is doing. If that is the case the whole exercise is basically useless. LabVIEW does not deal with pointers but for variable sized data with handles. This allows it to handle all the data efficiently.

 

Trying to pass in a LabIVIEW handle turned into a C pointer (default option for LabVIEW handle datatypes when passed to a Call Library Node), to then return a reference to that pointer is pure Rube Goldberg and has absolutely no useful purpose in LabVIEW code!

You can not generate references to LabVIEW data that stays valid for longer than a Call Library Node call. All native LabVIEW data passed into a Call Library Node is ONLY guaranteed to be valid during the Call Library Node itself and LabVIEW reserves the right to deallocate, resize, rellocate or overwrite any memory it has created whenever it sees fit except during the actual call to a specifc node including Call Library Nodes.

Rolf Kalbermatter
My Blog
Message 4 of 4
(2,693 Views)