#NEWLINE# def serialReadEvent( self ) : #NEWLINE# #INDENT# n = win32file . GetOverlappedResult ( self . _serial . hComPort , self . _overlappedRead , 0 ) #NEWLINE# if n : #NEWLINE# #INDENT# first = str ( self . read_buf [ : n ] ) #NEWLINE# ( flags , comstat ) = win32file . ClearCommError ( self . _serial . hComPort ) #NEWLINE# if comstat . cbInQue : #NEWLINE# #INDENT# win32event . ResetEvent ( self . _overlappedRead . hEvent ) #NEWLINE# ( rc , buf ) = win32file . ReadFile ( self . _serial . hComPort , win32file . AllocateReadBuffer ( flags . cbInQue ) , self . _overlappedRead ) #NEWLINE# n = win32file . GetOverlappedResult ( self . _serial . hComPort , self . _overlappedRead , 1 ) #NEWLINE# self . protocol . dataReceived ( ( first + str ( buf [ : n ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . protocol . dataReceived ( first ) #NEWLINE# #UNINDENT# #UNINDENT# win32event . ResetEvent ( self . _overlappedRead . hEvent ) #NEWLINE# ( rc , self . read_buf ) = win32file . ReadFile ( self . _serial . hComPort , win32file . AllocateReadBuffer ( 1 ) , self . _overlappedRead )