LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array from C function

Hallo everybody!
I have a shared library on my linux system I like to use from labview. To
exchange simple integers and strings between there are no problems.

Now I like to get an array of integers from my library which I like to treat
as an array in my VI.

Has anybody an idea how to do this in the "best" way?

Thanx for any hints!

Helmut Halfmann
0 Kudos
Message 1 of 5
(3,131 Views)
Hello Helmut

Problems with arrays is that you must reserve some space in memory for them. You can do it from CINs using the "memory manager" from CIN tools, but the easier way is to build the array in LabVIEW and pass the pointer top the dll. Inside DLL use this pointer to load the data to it and return back. In this way dll does not have to make a memory space for array.
The disadvantage of this is that you need to know what the size of the array is in order to initialize the array before calling the dll.

If you need some more of it try looking into: "lvexcode.pdf"

hope it helps.
Pawel
0 Kudos
Message 2 of 5
(3,131 Views)
On Tue, 24 Feb 2004 09:18:42 +0100, Helmut Halfmann wrote:
> I have a shared library on my linux system I like to use from labview. To
> exchange simple integers and strings between there are no problems.
>
> Now I like to get an array of integers from my library which I like to treat
> as an array in my VI.
>
In the 'Call Library Function' dialogue, have you tried changing 'Type' to
array? Sorry, if I'm stating the obvious. BTW, don't forget to
initialize the buffer for the output, e.g. if you have an array of 10
elements (I32), write an array with ten dummy values it's input.

Check out the Linux-GPIB library for LabVIEW for some examples:
http://openg.org/tiki/tiki-index.php?page=Linux-GPIB%20Library

Don't think there are any arrays being returned
but maybe it will give you
some ideas.
Message 3 of 5
(3,131 Views)
Hi Helmut,

Using an 'array' data type as a parameter to your 'Call Library Function' node would be the recommended way to pass an array to and from your shared library. One thing to note, however, is if you choose this method, you will have a choice of Formats: either Array Data Pointer, Array Handle, or Array Handle Pointer (in Labview 7.0). If you use an Array Data Pointer, be sure to also pass the array dimension as a separate parameter.

Good Luck!

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 4 of 5
(3,131 Views)
pawel wrote:

> Hello Helmut
>
> Problems with arrays is that you must reserve some space in memory for
> them. You can do it from CINs using the "memory manager" from CIN
> tools, but the easier way is to build the array in LabVIEW and pass
> the pointer top the dll. Inside DLL use this pointer to load the data
> to it and return back. In this way dll does not have to make a memory
> space for array.
> The disadvantage of this is that you need to know what the size of the
> array is in order to initialize the array before calling the dll.
>
> If you need some more of it try looking into: "lvexcode.pdf"
>
> hope it helps.
> Pawel

Thanks for your advice! I will do it like this.

Thanx
Helmut
0 Kudos
Message 5 of 5
(3,131 Views)