Jan-23-2017, 06:26 PM
Hi. I'm receiving serial data from an Arduino over USB the data comes at anytime, could be 30 minutes between messages. I have the following while loop that does the job but it prints an empty line ever loop. On the Arduino I can do "while (Serial.available()" How could this be done in Python?
Thanks.
Thanks.
while 1: try: msg = ser.readline() msg=msg.decode('utf-8') print(msg) time.sleep(1) except ser.SerialTimeoutException: print("Data could not be read") time.sleep(1)