Answer the question
In order to leave comments, you need to log in
How to fix error when connecting Dll python?
Good day, I ran into the following problem: When calling a function from a dll written in C, python gets the following error: argument 1: : wrong type (code below)
import ctypes
from ctypes import *
CanApiDll = cdll.vs_can_api
handle = "12345"
U_Handle = handle.encode('utf-8')
DevHandle = c_char_p(U_Handle)
Mode = c_ulong(0)
PrototypeOpen = WINFUNCTYPE(c_int, c_char_p, c_ulong) # c_char_p -> c_wchar_p
VSCanOpenParam = (1, "DevHandle", 0), (1, "Mode", 0)
VSCanOpen = PrototypeOpen(("VSCAN_Open", CanApiDll), VSCanOpenParam)
VSCanOpen(ctypes.byref(DevHandle), Mode)
N = c_int(1)
PrototypeClose = WINFUNCTYPE(c_int, c_int)
VSCanCloseParam = (1, "DevHandle", 0),
VSCanClose = PrototypeClose(("VSCAN_Close" , CanApiDll), VSCanCloseParam)
VSCanClose(N)
Answer the question
In order to leave comments, you need to log in
def testImportMean():
tmp_dll = cdll.LoadLibrary("/home/nick/python/dllTests/libmean.so")
summ = 0
for i in range(0, 1000):
for j in range(0, 1000):
summ += tmp_dll.mean(c_int(i), c_int(j))
return summ
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question