title: How to pass a python list to C function (dll) using ctypes
body: <p><strong>Background</strong></p>
  
  <p>I have some analysis software in Python I must pass a list of 4096 bytes (<em>which looks like this</em> <code>[80, 56, 49, 50, 229, 55, 55, 0, 77, ......]</code>) to a dll, so that the dll writes it to a device.</p>
  
  <ol>
  <li>The bytes to be written are stored in variable name data</li>
  <li><p>The c function (in dll) which has to be called from python is </p>
  
  <p><code>int _DLL_BUILD_ IO_DataWrite(HANDLE hDevice, unsigned char* p_pBuff, unsigned char p_nByteCntInBuff);</code></p></li>
  <li><p>I have no access to the dll code</p></li>
  </ol>
  
  <p><strong>Method tried</strong></p>
  
  <p>I tried to declare a data type </p>
  
  <pre><code>data_tx = (ctypes.c_uint8 * len(data))(*data)
  </code></pre>
  
  <p>and called the function </p>
  
  <pre><code>ret = self.sisdll.IO_DataWrite(self.handle, ctypes.byref(data_tx), ctypes.c_uint8(pending_bytes))
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>There seems to be no error but its not working. The API call works with C and C++.</p>
  
  <p>Am I doing this correct. Could anyone please kindly point the mistake for me? </p>