ESP-IDF monitor eating random newline characters (IDF-6647)
Posted: Mon Jan 09, 2023 11:13 am
Hi,
I observed occasional phenomenon - some (not all) newline characters are lost. Quick debugging with strace proved all data delivered to /dev/ttyACM interface is complete and correct, there is a bug in python code. I made some investigation and found problem in tools/idf_monitor_base/serial_handler.py. Patch below:
diff --git a/tools/idf_monitor_base/serial_handler.py b/tools/idf_monitor_base/serial_handler.py
index b3a71f64a2..394dca021e 100644
--- a/tools/idf_monitor_base/serial_handler.py
+++ b/tools/idf_monitor_base/serial_handler.py
@@ -88,13 +88,8 @@ class SerialHandler:
if self._last_line_part != b'':
# add unprocessed part from previous "data" to the first line
sp[0] = self._last_line_part + sp[0]
- self._last_line_part = b''
- if sp[-1] != b'':
- # last part is not a full line
- self._last_line_part = sp.pop()
+ self._last_line_part = sp.pop()
for line in sp:
- if line == b'':
- continue
if self._serial_check_exit and line == console_parser.exit_key.encode('latin-1'):
raise SerialStopException()
if gdb_helper:
I observed occasional phenomenon - some (not all) newline characters are lost. Quick debugging with strace proved all data delivered to /dev/ttyACM interface is complete and correct, there is a bug in python code. I made some investigation and found problem in tools/idf_monitor_base/serial_handler.py. Patch below:
diff --git a/tools/idf_monitor_base/serial_handler.py b/tools/idf_monitor_base/serial_handler.py
index b3a71f64a2..394dca021e 100644
--- a/tools/idf_monitor_base/serial_handler.py
+++ b/tools/idf_monitor_base/serial_handler.py
@@ -88,13 +88,8 @@ class SerialHandler:
if self._last_line_part != b'':
# add unprocessed part from previous "data" to the first line
sp[0] = self._last_line_part + sp[0]
- self._last_line_part = b''
- if sp[-1] != b'':
- # last part is not a full line
- self._last_line_part = sp.pop()
+ self._last_line_part = sp.pop()
for line in sp:
- if line == b'':
- continue
if self._serial_check_exit and line == console_parser.exit_key.encode('latin-1'):
raise SerialStopException()
if gdb_helper: