'Read until a termination sequence is found (\'
\' by default), the size
is exceeded or until timeout occurs.'

def read_until(self, terminator=LF, size=None):

    lenterm = len(terminator)
    line = bytearray()
    while True:
        c = self.read(1)
        if c:
            line += c
            if (line[(- lenterm):] == terminator):
                break
            if ((size is not None) and (len(line) >= size)):
                break
        else:
            break
    return bytes(line)
