Is there a better place to post such questions?

Anyway, in the hope it is something simple, I would appreciate some help.

I am adding some C++ code to Python.  From Python I want to be able to read 
data from a target device, over USB.  My software does all the hard work and 
I have a class:

class ViperUsbC
    {
    public:
    // snip snip
        ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16 
Length);
    // Snip,snip
    };

I use swigwin-1.3.34 to wrap it into a module called SHIP.

In Python, I have:

import SHIP
ViperUsb = SHIP.ViperUsbC()
Slave =7
Offset = 0
Length = 64
Buffer = 'a' * Length
print "type(Buffer)=%s" % type(Buffer)
print "len(Buffer)=%s" % len(Buffer)
Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length);

That fails with:

type(Buffer)=<type 'str'>
len(Buffer)=64

Traceback (most recent call last):
  File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel-
    ViperTests()
  File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests
    Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length);
  File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in 
ReadSlaveMemory
    def ReadSlaveMemory(*args): return 
_SHIP.ViperUsbC_ReadSlaveMemory(*args)
TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 *'


How do I provide a buffer into which to read the data?  It would not be 
intolerable to provide another layer using %extend, but I feel sure this 
should be automagic.

Thanks in advance
    Bill

PS This is a very small part of a much larger project so I cannot supply 
complete source code. 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to