[python-win32] how do I sink Mscomm32 events?

duane voth duanev@io.com
Tue Apr 8 17:26:39 EDT 2003


After studying everything I can find via google on python-win32,
mscomm32, and DispatchWithEvents, I've pieced together the following
test code:

    >>> from win32com.client import DispatchWithEvents
    >>> class CommEvents:
	def OnComm(self):
	    print self

	    
    >>> com1 = DispatchWithEvents('MSCOMMLib.MSComm.1', CommEvents)
    >>> com1.CommPort = 1
    >>> com1.Settings = "115200,N,8,1"
    >>> com1.PortOpen = 1
    >>> com1.InputLen = 0
    >>> com1.Handshaking = 2
    >>> com1.RTSEnable = 1
    >>> com1.Output = "ATDT555-1234" + chr(13)+'\n\n'
    >>> print 'Event:', com1.CommEvent
    Event: 0
    >>> com1.InBufferCount
    3
    >>> 

There are no errors, and "ATDT555-1234" is sent to device attached
to my COM1 port, but I don't get any events.  I'm expecting to see
some kind of output from the print in OnComm whenever a character
is received by the COM1 serial port.  Must I do something to get the
dispatcher to run? (I'm quite COM illiterate)  Are threads assumed
to exist or must I create them, enabled them, or unblock them?

Duane




More information about the Python-win32 mailing list