Good Day,
I'm trying to implement a device dll to later enable me to automate scanning measurements using a python script. Currently I'm Struggling with calling the required functions from the DLL receiving the error:
OSError: exception: access violation reading 0x00000000571E89E1
The code I am trying to use is:
import ctypes as ct
p517 = ct.cdll.LoadLibrary("PI_GCS2_DLL_x64.dll")
p517.PI_InterfaceSetupDlg.restype = ct.c_int
p517.PI_InterfaceSetupDlg.argtype = ct.c_char_p
p517.PI_InterfaceSetupDlg()
I'm new to working with C in Python but looking at the relevant function in the DLL:
int PI_InterfaceSetupDlg (const char* szRegKeyName)
Open dialog to let user select the interface and create a new PI object. All future calls to control this controller need the ID returned by this call. See Interface Settings (p. 19) for a detailed description of the dialogs shown.
Arguments: szRegKeyName key in the Windows registry in which to store the settings, the key used is "HKEY_LOCAL_MACHINE\SOFTWARE<your keyname>" if keyname is NULL or "" the default key "HKEY_LOCAL_MACHINE\SOFTWARE\PI\PI_GCS2_DLL" is used.
Returns: ID of new object, -1 if user pressed "CANCEL", the interface could not be opened, or no controller is responding.
I thought I had defined the argtype and restype correctly, but most of the problems similar to this seem to have been caused by false type definition. Am I missing something here? Thanks in advance for any advice