Hi, Does anyone have anything else I can try to fix my problem? I know that events are being fired because of their side effects on the COM object state. However I never see my little print messages from the event handler. I feel like it is just something small that I am missing. Thank you in advance.
-Seth ------msrtest.py------- from win32com import client import pythoncom import time class OPOSEventSink: def OnDirectIOEvent(self, EventNumber, pData, pString): """method DirectIOEvent""" print "direct io" def OnDataEvent(self, Status): """method DataEvent""" print "data" def OnStatusUpdateEvent(self, Data): """method StatusUpdateEvent""" print "status update" def OnErrorEvent(self, ResultCode, ResultCodeExtended, ErrorLocus, pErrorResponse): """method ErrorEvent""" print "error" if __name__ == '__main__': msr = client.DispatchWithEvents("OPOS.MSR", OPOSEventSink) #Ready the device status = msr.Open("Ing6XXX") if status <> 0: print "failed to open msr" quit() status = msr.ClaimDevice(-1) if status <> 0: print "failed to claim msr" quit() #setup the magnetic stripe reader msr.AutoDisable = True #tell the device to turn its self off when a swipe is read msr.DataEventEnabled = True msr.TracksToRead = 0xf #read all 4 tracks msr.FreezeEvents = True #hold events till I say to send them #turn the device on msr.DeviceEnabled = True print "please swipe a card" #when this loop finishes there has been a successful swipe of a card #and a data event is waiting to be released in the com object while msr.DataCount < 1: time.sleep(0.5) #by the OPOS specification these attributes are set as blank strings #until a data event is fired print 'before unfreezing events should be blank' print 'Account number:', msr.AccountNumber, '\nName:', msr.Surname, '\n' #release the events msr.FreezeEvents = False print 'events thawed should still be blank' print 'Account number:', msr.AccountNumber, '\nName:', msr.Surname, '\n' pythoncom.PumpWaitingMessages() print 'after pump waiting messages now the values should be there' print 'Account number:', msr.AccountNumber, '\nName:', msr.Surname, '\n' timeout = time.time() + 30 while time.time() <= timeout: print 'pumping messages' pythoncom.PumpWaitingMessages() time.sleep(0.5) msr.ReleaseDevice() msr.Close() ---output--- please swipe a card before unfreezing events should be blank Account number: Name: events thawed should still be blank Account number: Name: after pump waiting messages now the values should be there Account number: <card number> Name: <name> pumping messages pumping messages pumping messages .... _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32