'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
    if ((self._timeout is not None) and (self._timeout != 0)):
        timeout = (time.time() + self._timeout)
    else:
        timeout = None
    data = bytearray()
    while ((size > 0) and self.is_open):
        try:
            b = self.queue.get(timeout=self._timeout)
        except queue.Empty:
            if (self._timeout == 0):
                break
        else:
            if (b is not None):
                data += b
                size -= 1
            else:
                break
        if (timeout and (time.time() > timeout)):
            if self.logger:
                self.logger.info('read    timeout')
            break
    return bytes(data)
