problems with python: pywintypes.com_error

Discussion in 'Python' started by Matt Smith, Aug 8, 2003.

  1. Matt Smith

    Matt Smith Guest

    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
     
    Matt Smith, Aug 8, 2003
    #1
    1. Advertising

  2. Matt Smith

    Mark Hammond Guest

    Matt Smith wrote:

    > 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.
     
    Mark Hammond, Aug 9, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. x-herbert
    Replies:
    2
    Views:
    1,949
    x-herbert
    Aug 8, 2003
  2. Lucas Machado

    handling pywintypes.error exceptions

    Lucas Machado, Mar 5, 2005, in forum: Python
    Replies:
    1
    Views:
    3,698
    Roger Upole
    Mar 5, 2005
  3. g.franzkowiak

    Python win32com com_error: (-2147418113

    g.franzkowiak, Sep 21, 2005, in forum: Python
    Replies:
    1
    Views:
    2,383
    Roger Upole
    Sep 22, 2005
  4. Replies:
    8
    Views:
    1,005
  5. Alexander Eisenhuth
    Replies:
    2
    Views:
    1,158
    Alexander Eisenhuth
    Nov 25, 2009
Loading...

Share This Page