tools.flterm: warn and continue after failed TIOCMBIC ioctl.
authorJean-François Nguyen <jf@lambdaconcept.com>
Mon, 28 Jun 2021 14:27:39 +0000 (16:27 +0200)
committerJean-François Nguyen <jf@lambdaconcept.com>
Mon, 28 Jun 2021 15:52:58 +0000 (17:52 +0200)
lambdasoc/tools/flterm.py

index 0cdec2abb6a854c0557e6c22beb5a1d328d83d38..2348c1fe7f5a565e43eb23bec49e5829aeb948e6 100755 (executable)
@@ -10,6 +10,7 @@ import asyncio
 import asyncserial
 import serial
 import argparse
+import traceback
 
 
 if sys.platform == "win32":
@@ -134,10 +135,15 @@ class Flterm:
         self.output_only = output_only
 
         self.port = asyncserial.AsyncSerial(port, baudrate=speed)
-        if serial.__version__[0] == "2":
-            self.port.ser.setRTS(False)
-        else:
-            self.port.ser.rts = False
+        try:
+            if serial.__version__[0] == "2":
+                self.port.ser.setRTS(False)
+            else:
+                self.port.ser.rts = False
+        except OSError:
+            # FIXME: The TIOCMBIC ioctl failed. This port is probably a pseudo TTY.
+            traceback.print_exc()
+            print("[FLTERM] Failed to clear RTS bit. Continuing anyway...")
 
     def init(self):
         if not (self.upload_only or self.output_only):