C ++ funtion:
DLLENTRY int VTS_API
SetParamValue( const char *paramName, void *paramValue ) //will return zero(0) in the case of an error
{
rtwCAPI_ModelMappingInfo* mmi = &(rtmGetDataMapInfo(PSA_StandAlone_M).mmi);
int idx = getParamIdx( paramName );
if (idx<0) {
return 0; //Error
}
int retval = capi_ModifyModelParameter( mmi, idx, paramValue );
if (retval == 1 ) {
ParamUpdateConst();
}
return retval;
}
и мой код Python:
import os
from ctypes import *
print(os.getcwd())
os.chdir(r"C:\MY_SECRET_DIR")
print(os.getcwd())
PSAdll=cdll.LoadLibrary(os.getcwd()+"\PSA_StandAlone_1.dll")
setParam=PSAdll.SetParamValue
setParam.restype=c_int
setParam.argtypes=[c_char_p, c_void_p]
z=setParam(b"LDOGenSpdSetpoint", int(20) )
возвращает
z=setParam(b"LDO_PSA_GenSpdSetpoint01", int(20) )
WindowsError: exception: access violation reading 0x00000020
Есть идеи, что может помочь?Я уже пробовал POINTER
и byref()
, но получаю тот же вывод