LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

'Array Data Pointer' in Call Library Node (DLL): Is that a special data-type in LabView?

Hello everybody,
I have a LabView program that accesses a DLL. A function I use requires the "Array Data Pointer" as data-type. For this data type, my input value is a simple numeric array. The program works fine.

 

I tried to execute the same DLL/function with Python (ctypes). The problem was, that it is not possible to build the input parameter same as in LabView with a numeric array. I have tried much data-types but without success. Then I figured out that for the function to be executed, the data type 'Structure' must be declared separately. This is a bit more complex data-type, because it contains different types of data (for more information please refer Wikipedia).

 

Now my question for understanding is: What's up with the 'Array Data Pointer' in LabView? Is that a special data-type in LabView and are there processes take place in the background I can't retrace? Otherwise I can not explain the different behavior of the dll-function.

0 Kudos
Message 1 of 3
(2,296 Views)

@digital_badger wrote:

 

Now my question for understanding is: What's up with the 'Array Data Pointer' in LabView? Is that a special data-type in LabView and are there processes take place in the background I can't retrace?


The Array Data Pointer is just a way to tell the CLFN that a pointer to the data should be passed. No magic happens, or at least both conceptually as in practice it is just that simple.

 


@digital_badger wrote:

 

I tried to execute the same DLL/function with Python (ctypes). The problem was, that it is not possible to build the input parameter same as in LabView with a numeric array. I have tried much data-types but without success.


Well, they need to be the same. That is, Python needs to call the dll with parameters that the dll expects.

 


@digital_badger wrote:

 

Then I figured out that for the function to be executed, the data type 'Structure' must be declared separately. This is a bit more complex data-type, because it contains different types of data (for more information please refer Wikipedia).


Not sure where the "data type 'Structure'" comes from.

 

If this is a Python thing this might not be the place to ask, although somebody might still know and give an answer.

0 Kudos
Message 2 of 3
(2,268 Views)

LabVIEW uses internally for arrays and strings so called handles. That is a LabVIEW specific data type that not only contains the data itself but also the number of elements in the array. And it is not a simple pointer but a pointer to a pointer to the data block that contains that information.

 

Now external code in shared libraries (DLLs) does not work with such array data structures unless it was specifically written to work with LabVIEW. But functions that use such LabVIEW specific data array handles can not be called by non-LabVIEW processes either.

 

So in order to allow to pass such array data to standard external code, you can configure the Call Library Node parameter to pass the pointer to the actual data contained in that data array handle to the shared library. This is the default since most times you call a shared library you are NOT interfacing to one that was specifically written for LabVIEW. And except from National Instruments itself and a few zealots like myself, there is nobody writing such shared libraries either.

 

I'm not very familiar with Python beyond some basic "Hello World" programming and while I know that you can use ctypes to call external code in Python I can't really tell you what you have to do to pass a C array data pointer correctly from Python to a DLL. Some googling would suggest that if you have setup the DLL function in ctypes correctly with the parameter being POINTER(c_float) or POINTER(c_int) declared, you may directly pass the Python array to the function as there will be an implicit conversion. But if that fails you may have to use ctypes.cast() explicitly.

But without showing in more detail what you have done so far that doesn't work we can all only guess. 

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(2,261 Views)