Browse Source

improve error messages

Davide Alberani 7 years ago
parent
commit
f8d06a7849
1 changed files with 6 additions and 1 deletions
  1. 6 1
      tools/qrcode_reader.py

+ 6 - 1
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