Python Forum

Full Version: No Data Transmission with Python / COM
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using Python 2.7 to communicate with an eye movement system over USB. The device came with an ActiveXControl-- I have used makepy to create a python wrapper to access the methods. This is the script which creates the instance of the COM object and attempts to collect data (I excluded the serial number of the device):

Instantation Code

Quote:# this code creates an instance of priCS681Comm.ocx
import win32com.client
import win32com.client.dynamic
from win32com.client import gencache
gencache.EnsureModule('{35F923BD-6F0F-477D-A07C-E33C53FB692B}', 0, 3, 0)
cs = win32com.client.Dispatch("PRICS681.priCS681Comm")

cs.ConnectionConnect('xxxxxx')

print cs.Connected
print cs.InconsistentPacketNumber
print cs.InconsistentTimeStamp
print cs.PacketsReceived

cs.GetDataAngular()

Traceback

Quote:C:\Python27\Lib\site-packages\win32com\client>python LateAndEarly.py
True
0
0
0
Traceback (most recent call last):
File "LateAndEarly.py", line 16, in <module>
cs.GetDataAngular()
File "C:\Python27\lib\site-packages\win32com\gen_py\35F923BD-6F0F-477D-A07C-E3
3C53FB692Bx0x3x0.py", line 415, in GetDataAngular
return self._ApplyTypes_(1610809374, 1, (12, 0), (), u'GetDataAngular', None
,)
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 467, in
_ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'PRICS681', u'Su
bscript out of range', None, 1000009, -2146828279), None)

The Connected Boolean returns True; however, reports there are no packets received. Calling the GetDataAngular method also creates an error I cannot interpret. The manual says data can only be collected once the ReceiveData event is fired-- this may be the problem. I see a function definition for an OnReceiveData event handler in the generated makepy file; however, I'm unsure what to do next...