title: passing a mmap pointer from C to python as a mmap object
body: <p>I am trying to interface a C library (beaglebone PRU driver prussdrv.c) with Python. The particular function I want to access returns a mmap pointer as illustrated below:</p>
  
  <pre><code>int __prussdrv_memmap_init(void) {
        prussdrv.pru0_dataram_base = mmap(0, prussdrv.pruss_map_size, PROT_READ | PROT_WRITE,
           MAP_SHARED, prussdrv.mmap_fd, PRUSS_UIO_MAP_OFFSET_PRUSS);
        ...
  
  int prussdrv_map_prumem(unsigned int pru_ram_id, void **address) {    
       switch (pru_ram_id) {
       case PRUSS0_PRU0_DATARAM:
            *address = prussdrv.pru0_dataram_base;
             break;
  
  prussdrv_map_prumem (DATARAM[PRU_NUM], &amp;pruDataMem);
  pruDataMem_byte = (unsigned char*) pruDataMem;
  </code></pre>
  
  <p>I would like to encapsulate either pruDataMem or pruDataMem_byte and pass it to Python as a mmap object. Is there a straightforward way to do this? I've looked at capsule and ctypes but they do not appear to do what I am looking for?</p>