From ae143af728c75a3e4b35cd059631f5d57bbf7e34 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Fri, 16 Nov 2018 23:50:16 +0800 Subject: [PATCH] tools(idf_monitor): Add character filter for Win10 ubuntu subsystem In case of python exception. --- tools/idf_monitor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index a6373926..b43bb39a 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -83,6 +83,11 @@ MATCH_PCADDR = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE) DEFAULT_TOOLCHAIN_PREFIX = "xtensa-esp32-elf-" +def is_ascii(b): + if b > '\x7f': + return False + return True + def get_time_stamp(): ct = time.time() local_time = time.localtime(ct) @@ -309,6 +314,8 @@ class Monitor(object): # this may need to be made more efficient, as it pushes out a byte # at a time to the console for b in data: + if is_ascii(b) == False: + continue if self.enable_time == 'y' and self.next_line == True: self.console.write_bytes(get_time_stamp() + ": ") self.next_line = False