From 042c36ee1be844be1a77fc882dffba60a6095520 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 19 Feb 2016 17:44:25 +0100 Subject: [PATCH] soc/tools/litex_term: continue cleanup --- litex/soc/tools/litex_term.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/litex/soc/tools/litex_term.py b/litex/soc/tools/litex_term.py index 06d8843c..97fb0579 100644 --- a/litex/soc/tools/litex_term.py +++ b/litex/soc/tools/litex_term.py @@ -116,7 +116,7 @@ class LiteXTerm: self.reader_alive = False self.writer_alive = False - self.promp_detect_buffer = bytes(len(sfl_prompt_req)) + self.prompt_detect_buffer = bytes(len(sfl_prompt_req)) self.magic_detect_buffer = bytes(len(sfl_magic_req)) def open(self, port, baudrate): @@ -182,8 +182,8 @@ class LiteXTerm: def detect_prompt(self, data): if len(data): - self.promp_detect_buffer = self.promp_detect_buffer[1:] + data - return self.promp_detect_buffer == sfl_prompt_req + self.prompt_detect_buffer = self.prompt_detect_buffer[1:] + data + return self.prompt_detect_buffer == sfl_prompt_req else: return False @@ -213,11 +213,7 @@ class LiteXTerm: if c == b"\r": sys.stdout.write(b"\n") else: - try: - # TODO: cleanup - sys.stdout.write(c.decode()) - except: - pass + sys.stdout.buffer.write(c) sys.stdout.flush() if self.kernel_image is not None: @@ -243,10 +239,7 @@ class LiteXTerm: def writer(self): try: while self.writer_alive: - try: - b = getkey() - except KeyboardInterrupt: - b = b"\x03" + b = getkey() if b == b"\x03": self.stop() elif b == b"\n": @@ -296,13 +289,12 @@ def _get_args(): def main(): args = _get_args() term = LiteXTerm(args.serial_boot, args.kernel, args.kernel_adr) - term.open(args.port, args.speed) - term.start() try: + term.open(args.port, args.speed) + term.start() term.join(True) - except KeyboardInterrupt: - pass - term.close() + finally: + term.close() if __name__ == "__main__": -- 2.30.2