import serial

s = serial.Serial('tty', 115200, timeout=6)
length = 1

log = open('test.log', 'wb')

while True:
    print(f'Writing {length} bytes')
    s.write(b'b' * length);
    data = s.read(length)
    log.write(data)
    if not data:
        break

    length += 1

print(f'Read back 0 bytes')
