I am having trouble sending an argument to an active X object that is an array 
of integers or doubles.  I am trying to control an instrument called a "DPG".  
It is a data pattern generator that drives a digital-to-analog converter, but 
that is not important.

This much code works:

# This module will communicate with the DPG2
import win32com.client as win32client
import math

# This code follows the MatLab example from the manual
h = win32client.Dispatch('AnalogDevices.DPG2')
devices = h.AttachedDevices
dpg = devices[0]

# This statement works OK, though, so we are talking to the DPG
dpg.StartPlayback

Now, I get hung up when I try to send it an array.  It has methods like:

bool DownloadDataVectorInt1D(int[] data, bool ShowProgress)

Downloads an array of integers. Setting ShowProgress to true will show a pop-up 
progress bar during the download. This method will not return until the 
download is complete (blocking call).


If I attempt that with something like:

waveform = [int(28000 * math.cos(2*math.pi*t/32)) for t in range(128)]
dpg.DownloadDataVectorInt1D(waveform, True)

I get this error:
Traceback (most recent call last):
  File "<pyshell#233>", line 1, in <module>
    dpg.DownloadDataVectorInt1D(wavei,True)
  File "<COMObject <unknown>>", line 2, in DownloadDataVectorInt1D
com_error: (-2147352571, 'Type mismatch.', None, 1)

If I do exactly the same thing from MatLab, it works fine.

Calling dpg methods that only take scalar arguments work fine, so it seems that 
the issue is getting the array passed with the right type.

What can I do to get past this 'Type mismatch' error when passing an array?

Tim Daughters
The MITRE Corporation
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to