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.
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
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.
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.
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.
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.