From 0328ba7d6c749c9b29f7ef5ed1070c9b1bb0d8eb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 26 Aug 2019 18:17:43 +0200 Subject: [PATCH] tools/litex_term: add automatic check to see if we need to insert LF or not --- litex/tools/litex_term.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) -- 2.30.2