parameters: (self, size=1)
return_statement: return bytes(read)
docstring: Read size bytes from the serial port. If a timeout is set it may
             return less characters as requested. With no timeout it will block
             until the requested number of bytes is read.
docstring_summary: Read size bytes from the serial port. If a timeout is set it may
             return less characters as requested. With no timeout it will block
             until the requested number of bytes is read.
docstring_tokens: Read size bytes from the serial port . If a timeout is set it may return less characters as requested . With no timeout it will block until the requested number of bytes is read .
function: def read(self, size=1):
          """Read size bytes from the serial port. If a timeout is set it may
             return less characters as requested. With no timeout it will block
             until the requested number of bytes is read."""
          if not self.hComPort: raise portNotOpenError
          if size > 0:
              win32.ResetEvent(self._overlappedRead.hEvent)
              flags = win32.DWORD()
              comstat = win32.COMSTAT()
              if not win32.ClearCommError(self.hComPort, ctypes.byref(flags), ctypes.byref(comstat)):
                  raise SerialException('call to ClearCommError failed')
              if self.timeout == 0:
                  n = min(comstat.cbInQue, size)
                  if n > 0:
                      buf = ctypes.create_string_buffer(n)
                      rc = win32.DWORD()
                      err = win32.ReadFile(self.hComPort, buf, n, ctypes.byref(rc), ctypes.byref(self._overlappedRead))
                      if not err and win32.GetLastError() != win32.ERROR_IO_PENDING:
                          raise SerialException("ReadFile failed (%r)" % ctypes.WinError())
                      err = win32.WaitForSingleObject(self._overlappedRead.hEvent, win32.INFINITE)
                      read = buf.raw[:rc.value]
                  else:
                      read = bytes()
              else:
                  buf = ctypes.create_string_buffer(size)
                  rc = win32.DWORD()
                  err = win32.ReadFile(self.hComPort, buf, size, ctypes.byref(rc), ctypes.byref(self._overlappedRead))
                  if not err and win32.GetLastError() != win32.ERROR_IO_PENDING:
                      raise SerialException("ReadFile failed (%r)" % ctypes.WinError())
                  err = win32.GetOverlappedResult(self.hComPort, ctypes.byref(self._overlappedRead), ctypes.byref(rc), True)
                  read = buf.raw[:rc.value]
          else:
              read = bytes()
          return bytes(read)
function_tokens: def read ( self , size = 1 ) : if not self . hComPort : raise portNotOpenError if size > 0 : win32 . ResetEvent ( self . _overlappedRead . hEvent ) flags = win32 . DWORD ( ) comstat = win32 . COMSTAT ( ) if not win32 . ClearCommError ( self . hComPort , ctypes . byref ( flags ) , ctypes . byref ( comstat ) ) : raise SerialException ( 'call to ClearCommError failed' ) if self . timeout == 0 : n = min ( comstat . cbInQue , size ) if n > 0 : buf = ctypes . create_string_buffer ( n ) rc = win32 . DWORD ( ) err = win32 . ReadFile ( self . hComPort , buf , n , ctypes . byref ( rc ) , ctypes . byref ( self . _overlappedRead ) ) if not err and win32 . GetLastError ( ) != win32 . ERROR_IO_PENDING : raise SerialException ( "ReadFile failed (%r)" % ctypes . WinError ( ) ) err = win32 . WaitForSingleObject ( self . _overlappedRead . hEvent , win32 . INFINITE ) read = buf . raw [ : rc . value ] else : read = bytes ( ) else : buf = ctypes . create_string_buffer ( size ) rc = win32 . DWORD ( ) err = win32 . ReadFile ( self . hComPort , buf , size , ctypes . byref ( rc ) , ctypes . byref ( self . _overlappedRead ) ) if not err and win32 . GetLastError ( ) != win32 . ERROR_IO_PENDING : raise SerialException ( "ReadFile failed (%r)" % ctypes . WinError ( ) ) err = win32 . GetOverlappedResult ( self . hComPort , ctypes . byref ( self . _overlappedRead ) , ctypes . byref ( rc ) , True ) read = buf . raw [ : rc . value ] else : read = bytes ( ) return bytes ( read )