'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.'

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):
            for (fd, event) in poll.poll((self._timeout * 1000)):
                if (event & ((select.POLLERR | select.POLLHUP) | select.POLLNVAL)):
                    raise SerialException('device    reports    error    (poll)')
            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
    return bytes(read)
