나는 python으로 c dll을 통해 HV-Supply와 통신을 시도합니다. 가장 단순한 기능이 작동합니다. 하지만 더 복잡한 함수 CAENHVInitSystem을 호출하면 오류가 발생합니다 : OSError : 예외 : 액세스 위반이 0x00000001을 읽습니다. 나는 파이썬에서 ctypes에 대해 아주 새로운 것이다. 내가 아는 한,이 오류는 아마도 내 인자 중 일부가 잘못된 유형이기 때문에 나타날 수 있습니다. 하지만 어떻게 더 잘못된 인수가 정확하게 알고 디버깅 할 수 있습니까? 누구든지 내 실수를 봤어? 미리ctypes : OSError : 예외 : 읽기 액세스 위반 0x00000001
import os
from ctypes import *
bib = CDLL("CAENHVWrapper")
ret = bib.CAENHVLibSwRel() # This call works
print(c_char_p(ret))
sysType = c_int(1) #SY2527
link = c_int(0) #TCP/IP
#arg = c_char_p(b'149.217.10.241') #i change it for test to c_void_p but later the arg should be the ip adress
arg = c_void_p()
user = c_char_p(b'admin')
passwd = c_char_p(b'admin')
sysHndl = c_int()
# c function definition in the header file
#CAENHVLIB_API CAENHVRESULT CAENHV_InitSystem(
# CAENHV_SYSTEM_TYPE_t system,
# int LinkType,
# void *Arg,
# const char *UserName,
# const char *Passwd,
# int *handle);
# definition of the enum of the first argument
#typedef enum {
# SY1527 = 0,
# SY2527 = 1
#} CAENHV_SYSTEM_TYPE_t;
bib.CAENHVInitSystem.argtypes = [c_int, c_int, c_void_p, c_char_p, c_char_p, POINTER(c_int)]
ret = bib.CAENHVInitSystem(sysType, link, arg, user, passwd, byref(sysHndl))
print(ret)
print(bib.CAENHV_GetError(sysHndl))