From 2fa4ad38333aea64c09c9dbaa511b0acc90980ae Mon Sep 17 00:00:00 2001
From: Antonio Galea <antonio.galea@gmail.com>
Date: Thu, 12 Jan 2017 19:15:05 +0100
Subject: [PATCH] reconnecting a USB-serial dongle under Linux might give
 permission errors until udev scripts complete

---
 dist/tools/pyterm/pyterm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dist/tools/pyterm/pyterm b/dist/tools/pyterm/pyterm
index 16c167e1a3..9a49f94d0f 100755
--- a/dist/tools/pyterm/pyterm
+++ b/dist/tools/pyterm/pyterm
@@ -601,7 +601,11 @@ class SerCmd(cmd.Cmd):
                 if os.path.exists(self.port):
                     self.logger.warn("Try to reconnect to %s again..."
                                      % (self.port))
-                    self.serial_connect()
+                    try:
+                        self.serial_connect()
+                        self.logger.info("Reconnected to serial port %s" % self.port)
+                    except serial.SerialException as se:
+                        pass
                 continue
             if c == '\r':
                 if (self.newline == "LFCR" and nlreceived) or (self.newline == "CR"):
-- 
GitLab