From f8d06a7849e96a271132e51a36d6180362d9c40c Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sat, 15 Apr 2017 16:32:53 +0200 Subject: [PATCH] improve error messages --- tools/qrcode_reader.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/qrcode_reader.py b/tools/qrcode_reader.py index b52287c..6234648 100755 --- a/tools/qrcode_reader.py +++ b/tools/qrcode_reader.py @@ -119,6 +119,7 @@ class Connector(): def scan(port): retry = 1 + logger.info('trying to connect to %s, please wait...' % port) while True: logger.debug('waiting for connection on port %s...' % port) try: @@ -133,7 +134,11 @@ def scan(port): logger.info('connected to %s' % port) ser_io = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), newline='\r', line_buffering=True) while True: - line = ser_io.readline().strip() + try: + line = ser_io.readline().strip() + except serial.serialutil.SerialException as ex: + logger.error('disconnected: %s' % ex) + sys.exit(3) if not line: continue yield line