Python ctypes. How to pass IN LPVOID to C++ function -
i trying use ctypes pass string c++ function, , 1 in return. function declaration is:
bool performaxcom_api _stdcall sendreceive(in handle phandle, in lpvoid wbuffer, in dword dwnumbytestowrite, in dword dwnumbytestoread, out lpvoid rbuffer)
i happy enough handle
, dword
variables, , achieved out lpvoid
in similar function following setup:
szreplybuffer = create_string_buffer(64) replybuffer = c_char_p(addressof(szreplybuffer))
which when used similar out lpvoid
got string back.
my current method @ creating in lpvoid
inputted string cmdstr
(for example "e0=1") is:
szsendstr = c_char * 64 sendstr = szsendstr() in range(len(cmdstr)): sendstr[i] = cmdstr[i]
i pass function using following declaration: status = sendreceive(byref(husbdevice), c_void_p(addressof(sendstr)), 64, 64, replybuffer)
i have tried lots of different permutations of passing sendstr
function, never empty string in replybuffer
. there way of passing string missing?
thanks
laurence
Comments
Post a Comment