Trying to Call a LabVIEW dll into python that invokes a CAN protocol

2

I was wondering if anybody could help me make sense of this error. I am calling a LabVIEW generated dll in python that communicates to a DCM via a CAN protocol.

The structure and input parameters of the LabVIEW function called in Python is as follows:

int32_t func_1(CStr version_number, int32_t Verbose, CStr SetupFileName);

I know that the dll is imported into Python, and that the parameters are being input correctly because other functions with the same structure have the same input parameters and they don't return an error.

import ctypes as c

mydll = c.windll.LoadLibrary('intcan.dll') #'C:/Users/PycharmProjects/impdll/intcan.dll')

mydll.func_1(c.c_char_p('15.1.1.1'), c.c_int(0), c.c_char_p('CanDevice.xml'))

When I run the code I get the following error.

Traceback (most recent call last):
  File "C:/Users/PycharmProjects/impdll/venv/tester.py", line 22, in <module>
    mydll.func_1(c.c_wchar_p('15.1.1.1'), c.c_int(0), c.c_wchar_p('CanDevice.xml'))
OSError: [WinError -529697949] Windows Error 0xe06d7363

Process finished with exit code 1
python
dll
labview
asked on Stack Overflow Jun 3, 2019 by user11594041 • edited Jun 12, 2019 by user11594041

1 Answer

0

There are a number of ways in which you can configure a string to be passed into a function in a LabVIEW DLL.

If the string is just an input, the easiest way is to set:

  • Param Type: Input
  • Pass By: C String Pointer

which would yield this function prototype:

void func_1(char MyString[])

you can then call in Python as:

import ctypes as c

mydll = c.windll.LoadLibrary('mydll.dll')
mydll.func_1("myValue".encode("ascii"))
answered on Stack Overflow Nov 18, 2020 by phil_rawlings

User contributions licensed under CC BY-SA 3.0