From 98413e43af17e860cb7c87e368f99ead0325ad40 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Tue, 27 Nov 2018 16:46:45 +0100
Subject: [PATCH] tools/pyterm: catch serial.Exception when port is busy

This can happen when opening a terminal right after flashing a board that has just been plugged
---
 dist/tools/pyterm/pyterm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/dist/tools/pyterm/pyterm b/dist/tools/pyterm/pyterm
index 72762cfc0c..56bc19d3bc 100755
--- a/dist/tools/pyterm/pyterm
+++ b/dist/tools/pyterm/pyterm
@@ -247,6 +247,9 @@ class SerCmd(cmd.Cmd):
                 self.logger.error("Cannot connect to serial port {}: {}"
                                   .format(self.port, e.strerror))
                 sys.exit(1)
+            except serial.SerialException as e:
+                self.logger.error("%s", e.strerror)
+                sys.exit(1)
 
         # wait until connection is established and fire startup
         # commands to the node
-- 
GitLab