Pointers and arrays in Python ctypes
You can cast the result, but ctypes
allows you to use an array in place of a pointer, directly. The issue is the byref
in your code (which would be the equivalent of a pointer to a pointer):
So instead of:
cresult = (c_ulong * num)()err = self.c_read_block(addr, byref(cresult), num)
try:
cresult = (c_ulong * num)()err = self.c_read_block(addr, cresult, num)