I am new in python and recently using python to program CCD camera to taking pictures. I want to call a function in a .so file using ctypes. The prototype of the function is:
INT is_ImageFile (HIDS hCam, UINT nCommand, void* pParam, UINT cbSizeOfParam)
HIDS is uint type. An example given officially with c code is :
is_ImageFile(m_hCam, IS_IMAGE_FILE_CMD_SAVE, (void*)&ImageFileParams,
sizeof(ImageFileParams));
where ImageFileParams is a struct type:
typedef struct{
wchar_t* pwchFileName;
UINT nFileType;
UINT nQuality;
char** ppcImageMem;
UINT* pnImageID;
BYTE reserved[32];}IMAGE_FILE_PARAMS;
In my .py file, I tried to define the struct in this way:
class IMAGE_FILE_PARAMS(Structure):
_fields_=[("pwchFileNmae",c_wchar_p),("nFileType",c_uint),("nQuality",c_uint),("ppcImageMem",POINTER(c_char_p)),("pnImageID",POINTER(c_char_p)),("reserved",c_byte*32)]
and define some of the members in this way:
ImageFileParams.pwchFileName = c_wchar_p("/home/user/aa.jpg")
ImageFileParams.nQuality=c_uint(80)
ImageFileParams.nFileType=c_uint(1)
then call the function:
is_ImageFile(hCam, IS_IMAGE_FILE_CMD_SAVE, cast(pointer(ImageFileParams),c_void_p),c_uint(sizeof(ImageFileParams)))
But I always get an error indicating invalid parameter. What's the problem?