improve error messages

This commit is contained in:
Davide Alberani 2017-04-15 16:32:53 +02:00
parent d44217542c
commit f8d06a7849

View file

@ -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