From 4519308b9f45a94f54b304071b7bc6d74f0c145d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Mon, 28 Jun 2021 16:27:39 +0200 Subject: [PATCH] tools.flterm: warn and continue after failed TIOCMBIC ioctl. --- lambdasoc/tools/flterm.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lambdasoc/tools/flterm.py b/lambdasoc/tools/flterm.py index 0cdec2a..2348c1f 100755 --- a/lambdasoc/tools/flterm.py +++ b/lambdasoc/tools/flterm.py @@ -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): -- 2.30.2