problems with python: pywintypes.com_error

M

Matt Smith

Hi all,

I am VERY new to python , 3 days to be exact, but as I have been
programming competently in Perl and C/C++ for a while now, I thought
it would be a simple case of relearning the syntax, and in many ways
it has been just that.

However last night as I was just about to leave work, when I came
across an error message I had never seen before. Not only that but it
appears that there is very little in the way of help in all the usual
sources of information on the internet (i.e. newsgroups and forums
and the like) So to the problem at hand...

I am calling a program called v2wreg (its a program for interfacing
with the registers/parallel port, used, unfortunatly i think
exclusivly, by the company I work for), I can load the program fine,
but when I come to use any of its advanced featurs i.e.
SetDeviceAddress or ReadRegister I get the same type of error message.

i.e.
File "<COMObject v2wreg.Application>", line 2, in MakeConnection
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)

When I commented out the first line I knew was giving an error, I got
the another pywintypes.com_error from the next line in my code to use
a feature of v2wreg?

Are these errors connected? I have looked about abit and there has
been some mention of programs not being registered properly
generating pywintypes.com_error errors is there anyway I can check
what is meant to be registered?

Any light anyone could spread on this subject would be very helpful

Thanks in advance,

Matt Smith,
2nd year Electronic & Electrical Engineer at Edinburgh University.

p.s. here is part of my code with the affected area

serialBusToolv2wReg = win32com.client.Dispatch
("v2wreg.Application") ##this line works and calls the app
minimumDesiredVersion = 142
appVersion = serialBusToolv2wReg.QueryVersion ##this line
also works and it calls a feature of the program
serialBusToolv2wReg.Maximize = 10 ##this line works also
if((appVersion) < minimumDesiredVersion):print"error"
else: print "app version is working well....'yaaay'"
serialTransportParameters = []
PciCardId = 0
if(self.transpor == 'pci'):serialTransportParameters=["VPCI"
(65536+PciCardId), 0]
elif( self.transpor == 'parallel'):serialTransportParameters=
["VPLL",1,0]
else: print "eeek..error"
if(self.protocol == 'i2c'):serialTransportParameters.insert
(0, 0)
elif(self.protocol == 'cci'):serialTransportParameters.insert
(0, 1)
elif(self.protocol == 'v2w'):serialTransportParameters.insert
(0, 0)
else: print "error......."
print "serialTransportParameters->", serialTransportParameters
success = serialBusToolv2wReg.MakeConnection
(serialTransportParameters)###this line is where the error appears
if not (self.deviceAddress == -1):
serialBusToolv2wReg.SetDeviceAddress = self.deviceAddress
##this line also returns a pywintypes.com_error error
serialIndex = win32com.client.pythoncom.VT_VARIANT = 0
serialValue = win32com.client.pythoncom.VT_VARIANT = 0
serialAutoInc = win32com.client.pythoncom.VT_VARIANT = 0
success = serialBusToolv2wReg.ReadRegisterNoWrite
(self.deviceAddress, serialIndex, serialValue, serialAutoInc)
if ((success == 0) or (serialValue = 'read failed') :
print "read error booo \n"
break
else: print "\n error"
print success
 
M

Mark Hammond

Matt said:
I am calling a program called v2wreg (its a program for interfacing
with the registers/parallel port, used, unfortunatly i think
exclusivly, by the company I work for), I can load the program fine,
but when I come to use any of its advanced featurs i.e.
SetDeviceAddress or ReadRegister I get the same type of error message.

i.e.
File "<COMObject v2wreg.Application>", line 2, in MakeConnection
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)

These generally mean you are passing the incorrect param types to the
object. It is the object complaining, not Python.

Some things look a little suspect - eg:

serialBusToolv2wReg.SetDeviceAddress = self.deviceAddress

It is likely this should be written as:

serialBusToolv2wReg.DeviceAddress = self.deviceAddress

or

serialBusToolv2wReg.SetDeviceAddress(self.deviceAddress)

If you still have trouble, you should try reducing it down to no more
than 5 lines of Python that demonstrates the problem, and the equivilent
VB/Anything code that works.

Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top