while True:
    buffer_string = buffer_string + ser.read(ser.inWaiting())
if '\n' in buffer_string:
    lines = buffer_string.split('\n')
last_received = lines[-2]
buffer_string = lines[-1]
pyserial - How to read the last line sent from a serial device