I'm trying to communicate with an oscilloscope using Python via a .dll provided by the manufacturer and Ctypes. I'm a novice to C so I might be missing something obvious, but I can't seem to get the more complicated function calls right.
I have got access to the .dll file and the .h file.
Excerpt from the .h file:
typedef long ScHandle;
...
int ScOpenInstrument(int wire, char* address, ScHandle* rHndl);
My python code:
import ctypes
lib = ctypes.WinDLL("ScAPI.dll")
# Define types
ScHandle = ctypes.c_long
# Define function argument types
lib.ScOpenInstrument.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.POINTER(ScHandle)]
lib.ScStart.argtypes = [ScHandle]
# Init library
ret = lib.ScInit()
# Open instrument
wire = ctypes.c_int(7)
addr = ctypes.c_char_p("91SB21329".encode("utf-8"))
handle = ScHandle(0)
ret = lib.ScOpenInstrument(wire, addr, ctypes.byref(handle))
The function is supposed to return a handle to the oscilloscope but instead I get the error:
ValueError: Procedure probably called with too many arguments (12 bytes in excess)