I'm trying to use an ActiveX object to read data from hardware. Certain methods do not appear to work, specifically ones that expect a pointer to an array of 32-bit floats as one of the variables. One method is *ReadTag*.
The C prototype is *long ReadTag(LPCTSTR name, float* pBuf, long nOS, long nWords);* Using MakePy, the signature is *def ReadTag(self, Name=defaultNamedNotOptArg, pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, nWords=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), (16388,0), (3, 0), (3, 0)),Name, pBuf, nOS, nWords)* When I attempt to pass an array to it via: *x = numpy.zeros(100) obj.ReadTag('microphone', x, 0, 100)* I get the following error: *only length-1 arrays can be converted to Python scalars* Alternatively: *x = numpy.zeros(100) obj.ReadTag('microphone', x.ctypes.data, 0, 100) *returns a tuple and no error is raised: *(1, 4.28, 0, 100)* However, x is not updated with the new data from the hardware buffer. The following does not work either: *x = numpy.zeros(100)* *ptr = x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)) obj.ReadTag('microphone', ptr, 0, 100)* Nor does:* ptr = x.ctypes.data_as(ctypes.c_voidp).value obj.ReadTag('microphone', ptr, 0, 100)* Although no error is raised for the above two examples where I am attempting to pass a pointer to the array, x remains an array of zeros (the microphone is reading a 1 kHz sinusoid so x should be a sine wave). I'm a bit confused and not sure what the best way to proceed at this point is. How do a pass a pointer to my array into the ActiveX method? Thanks! Orest
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32