From: Florent Kermarrec Date: Mon, 26 Aug 2019 16:17:43 +0000 (+0200) Subject: tools/litex_term: add automatic check to see if we need to insert LF or not X-Git-Tag: 24jan2021_ls180~1036 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0328ba7d6c749c9b29f7ef5ed1070c9b1bb0d8eb;p=litex.git tools/litex_term: add automatic check to see if we need to insert LF or not --- diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index e96e3e0f..cee989cb 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -152,6 +152,8 @@ class LiteXTerm: signal.signal(signal.SIGINT, self.sigint) self.sigint_time_last = 0 + self.lf_insert = True + def open(self, port, baudrate): if hasattr(self, "port"): return @@ -259,9 +261,16 @@ class LiteXTerm: def reader(self): try: + c_last = 0 while self.reader_alive: c = self.port.read() - if c == b"\r": + if c_last == b"\r": + if c == b"\n": + self.lf_insert = False + else: + self.lf_insert = True + c_last = c + if self.lf_insert and c == b"\r": sys.stdout.buffer.write(b"\n") else: sys.stdout.buffer.write(c)