Passing large array (4Mbytes) between PyQt and C language .dll

  • Hi guys,

    I'm in a bind. I have a C language .dll running for 32-bit Windows 7 that I absolutely cannot change. The .dll function require a pointer (unsigned long int or uint32) to a large 4Mbyte buffer space for input and fills that same space for its output. My problem is that although I can send the buffer to the .dll function successfully, when the function returns, the data in that buffer does not get sent back to the calling python routine...I get all zeroes coming back. I know the function in the .dll works because I can call it from a C program and it gets the data perfectly, but it isn't received by my calling pyqt4 routine.

    Here is how I am setting up and calling:

    indVideoBuffer = (c_ulong * 4194304)()

    bfretrv = ctypes.c_ulong(0)
    pvdPixelBGR8 = 37
    convert_formatted_type = ctypes.c_uint32(pvdPixelBGR8)
    formatted_buffer_size = ctypes.c_ulong(4194304)

    cvtresult = convertFormattedBuffer(bfretrv, byref(indVideoBuffer), formatted_buffer_size, convert_formatted_type)

    Yes, I am using ctypes which works very well for the functions in the .dll library, except for this one case of the large buffer....the only function in the .dll library that uses this size buffer.

    I've found examples on the internet for passing arrays between C and python functions, but they only pass maybe 10 items at most.....not very helpful in my case where I am trying to pass 4Mbyte items.

    One final note, the .dll library requires a 1d array of uint32 numbers x 4Mbytes. I cannot change what has to be sent or returned by the C .dll library, so numpy arrays will not work (and I've tried them already). If numpy arrays would work, please let me know testing at a minimum has the numpy library telling me that the 4Mbyte array is too large.

    Anyboday have any ideas or suggestions?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.