キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Python calling LabVIEW shared Library

Hi Ppl,

 

I'm trying to call a shared library/DLL built from LabVIEW using the application builder from Python. I'm using ctypes to call these DLL's. I was able to pass in simple data types, like Integers, Stings and Booleans. But I was not able to pass in Structures/Clusters. Are there any examples availble for passing in Clusters/Arrays to these DLL. I found few examples in C# and VC++, but a Python example will be really help ful.

 

Thanks,

Sathish

メッセージ1/6
6,695件の閲覧回数

Hasn't anyone done this before. Plz help me out.

 

Thanks,

Sathish

0 件の賞賛
メッセージ2/6
6,650件の閲覧回数

Hi lordsathish, can you please tell me how do you call DLLs with ctypes ?

When I call a Labview compiled library in Python, it always return an error: "Procedure probably called with too many arguments".It seems DLL prototype is not recognized.

Thanks in advance

Angelo1

0 件の賞賛
メッセージ3/6
6,494件の閲覧回数

Hi Angelo,

 

Good to see that someone else is also trying something that I did. Coming to the point. I load the DLL using the cdll.LoadLibrary function. This loadlibrary function will return the handle to the DLL. Now you can use the handle to call the functions within the DLL.

 

dll_handle=cdll.LoadLibrary("<dll_path>")

dll_handle.Add(<parameter_1>,<parameter_2>,<parameter_2>)

 

Add will be the function name that you used in the define prototype window while building the DLL. all the parameters should be ctypes data types. I'm able to pass simple data types like string,int, boolean. I was not successful in passing clusters yet.

 

Hope this helps.

 

BTW I'm curious to know what kind of application you are trying to call the LabVIEW shared library from Python.

 

Thanks,

Sathish

0 件の賞賛
メッセージ4/6
6,483件の閲覧回数

I don't know about ctypes or calling DLLs in Python but LabVIEW clusters are simple C structs too unless they contain variable sized elements such as strings or arrays. Leaving those out of this since that is clearly beyond 99.9% of LabVIEW and Python users ability anyhow you simply would have to do a ctype in Python that matches a given C structure. To get an idea how that C structure looks you can best look into the header file generated by the LabVIEW DLL builder. If Python allows to create structure ctypes then that has to work. You need to be aware that LabVIEW uses byte packing in structures, so no alignement here with fill bytes.

 

Hopefully ctype allows to creat C structures. But looking here for how to do that is not really useful. Either Python has examples for that or you are out of luck.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 件の賞賛
メッセージ5/6
6,440件の閲覧回数

Hey Rolf,

 

Great to see you here. Your LabPython was really very useful. It was great スマイリー ハッピー.

 

BTW we can create structures using ctypes. Here is the link to the documentation. I was successful in passing clusters without arrays and strings. LabVIEW does not expose strings within clusters as C string pointer, instead they are only LabVIEW string handle. That's why I think I was not able to pass in clusters with strings.

 

Thanks,

Sathish

0 件の賞賛
メッセージ6/6
6,437件の閲覧回数