Hi,<br><br>The error is generated because you are asking for a u8*, but the buffer is not a u8*, perhaps a char* or even a void*. If you change the method signature to either char* or void*, it may work like you want it to ;)<br>
<br>Matthieu<br><br><div><span class="gmail_quote">2008/4/10, Bill Davy <<a href="mailto:Bill@synectixltd.com">Bill@synectixltd.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Is there a better place to post such questions?<br> <br> Anyway, in the hope it is something simple, I would appreciate some help.<br> <br> I am adding some C++ code to Python.  From Python I want to be able to read<br> data from a target device, over USB.  My software does all the hard work and<br>
 I have a class:<br> <br> class ViperUsbC<br>    {<br>    public:<br>    // snip snip<br>        ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16<br> Length);<br>    // Snip,snip<br>    };<br> <br> I use swigwin-1.3.34 to wrap it into a module called SHIP.<br>
 <br> In Python, I have:<br> <br> import SHIP<br> ViperUsb = SHIP.ViperUsbC()<br> Slave =7<br> Offset = 0<br> Length = 64<br> Buffer = 'a' * Length<br> print "type(Buffer)=%s" % type(Buffer)<br> print "len(Buffer)=%s" % len(Buffer)<br>
 Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length);<br> <br> That fails with:<br> <br> type(Buffer)=<type 'str'><br> len(Buffer)=64<br> <br> Traceback (most recent call last):<br>  File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel-<br>
    ViperTests()<br>  File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests<br>    Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length);<br>  File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in<br>
 ReadSlaveMemory<br>    def ReadSlaveMemory(*args): return<br> _SHIP.ViperUsbC_ReadSlaveMemory(*args)<br> TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 *'<br> <br> <br> How do I provide a buffer into which to read the data?  It would not be<br>
 intolerable to provide another layer using %extend, but I feel sure this<br> should be automagic.<br> <br> Thanks in advance<br>    Bill<br> <br> PS This is a very small part of a much larger project so I cannot supply<br>
 complete source code.<br> <br><br> <br> --<br> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br> </blockquote></div><br><br clear="all"><br>-- <br>French PhD student<br>
Website : <a href="http://matthieu-brucher.developpez.com/">http://matthieu-brucher.developpez.com/</a><br>Blogs : <a href="http://matt.eifelle.com">http://matt.eifelle.com</a> and <a href="http://blog.developpez.com/?blog=92">http://blog.developpez.com/?blog=92</a><br>
LinkedIn : <a href="http://www.linkedin.com/in/matthieubrucher">http://www.linkedin.com/in/matthieubrucher</a>