From fe714f8fe7c3c1a1d31afde39c439b6074211aa8 Mon Sep 17 00:00:00 2001 From: Lasse Dalegaard Date: Tue, 14 Mar 2023 10:48:19 +0100 Subject: [PATCH] litex_term: improve connection setup --- litex/tools/litex_term.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index 7a65caef4..66e3fa502 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -144,11 +144,15 @@ class JTAGUART: self.alive = True self.jtag2tcp_thread = threading.Thread(target=self.jtag2tcp, daemon=True) self.jtag2tcp_thread.start() - time.sleep(0.5) self.pty2tcp_thread = threading.Thread(target=self.pty2tcp, daemon=True) self.tcp2pty_thread = threading.Thread(target=self.tcp2pty, daemon=True) self.tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.tcp.connect(("localhost", self.port)) + for _ in range(0, 50): + try: + self.tcp.connect(("localhost", self.port)) + break + except ConnectionRefusedError: + time.sleep(0.1) self.pty2tcp_thread.start() self.tcp2pty_thread.start()