Every one second, Arduino prints (in serial) 'current time in milliseconds and Hello world'. On serial monitor, the output looks fine.
But in pySerial, sometimes there is line break at the middle of string.
313113 Hel
lo world
314114 Hello world
315114 Hello world
My python code is as:
import serial
import time
ser = serial.Serial(port='COM4',
baudrate=115200,
timeout=0)
while True:
str = ser.readline() # read complete line
str = str.decode() # decode byte str into Unicode
str = str.rstrip()
if str != "":
print(str)
time.sleep(0.01)
What am I doing wrong?
My configuration:
Python 3.7
pySerial 3.4
Board Arduino Mega