perhaps the pi leaves the serial line down for short periods of time?.
I might suggest just wrapping the block in try/except and retrying. If that works okay, probably best you can do.
I might suggest just wrapping the block in try/except and retrying. If that works okay, probably best you can do.
try: if (ser.inWaiting()>0): data_str = ser.read(ser.inWaiting()) print(data_str) except OSError: # ignore or log... Let the loop retry. pass