Sometimes I do not get any data in via the serial interface and I want to catch this case with an exception in the following way:
ser = serial.Serial(3)
ser.baudrate = 115200
timeout = 1
while (some condidion)
try:
dump = ser.read(40)
except ser1.SerialTimeoutException:
print('Data could not be read')
ser.close()
However, when I run this program, the exception is never caught when no data is in the buffer and I am stuck in an endless loop. Anyone an idea what I am doing wrong here?
serial.SerialTimeoutException2. you do not set the condition toFalseafter catching the exception.