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.is_open:
              raise portNotOpenError
          read = bytearray()
          poll = select.poll()
          poll.register(self.fd, select.POLLIN | select.POLLERR | select.POLLHUP | select.POLLNVAL)
          if size > 0:
              while len(read) < size:
                  # print "\tread(): size",size, "have", len(read)    #debug
                  # wait until device becomes ready to read (or something fails)
                  for fd, event in poll.poll(self._timeout * 1000):
                      if event & (select.POLLERR | select.POLLHUP | select.POLLNVAL):
                          raise SerialException('device reports error (poll)')
                      #  we don't care if it is select.POLLIN or timeout, that's
                      #  handled below
                  buf = os.read(self.fd, size - len(read))
                  read.extend(buf)
                  if ((self._timeout is not None and self._timeout >= 0) or
                          (self._inter_byte_timeout is not None and self._inter_byte_timeout > 0)) and not buf:
                      break   # early abort on timeout
          return bytes(read)
function_tokens: def read ( self , size = 1 ) : if not self . is_open : raise portNotOpenError read = bytearray ( ) poll = select . poll ( ) poll . register ( self . fd , select . POLLIN | select . POLLERR | select . POLLHUP | select . POLLNVAL ) if size > 0 : while len ( read ) < size : # print "\tread(): size",size, "have", len(read)    #debug # wait until device becomes ready to read (or something fails) for fd , event in poll . poll ( self . _timeout * 1000 ) : if event & ( select . POLLERR | select . POLLHUP | select . POLLNVAL ) : raise SerialException ( 'device reports error (poll)' ) #  we don't care if it is select.POLLIN or timeout, that's #  handled below buf = os . read ( self . fd , size - len ( read ) ) read . extend ( buf ) if ( ( self . _timeout is not None and self . _timeout >= 0 ) or ( self . _inter_byte_timeout is not None and self . _inter_byte_timeout > 0 ) ) and not buf : break # early abort on timeout return bytes ( read )