From 2cbe99783432b29bc303dc2e2cfe6823fe4a6c4f Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Wed, 5 Apr 2017 12:30:39 +0300
Subject: [PATCH] tools/pyboard: ProcessPtyToTerminal: Add workaround for
 PySerial bug.

When working with a "virtual" port, like PTY. The issue described in
http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port
---
 tools/pyboard.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/pyboard.py b/tools/pyboard.py
index b7babdc30..d96ccc328 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -179,7 +179,9 @@ class ProcessPtyToTerminal:
             self.close()
             sys.exit(1)
         pty = m.group()
-        self.ser = serial.Serial(pty, interCharTimeout=1)
+        # rtscts, dsrdtr params are to workaround pyserial bug:
+        # http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port
+        self.ser = serial.Serial(pty, interCharTimeout=1, rtscts=True, dsrdtr=True)
 
     def close(self):
         import signal
-- 
GitLab