Bug: message delimiter misinterpreted when multiple escape bytes preceed a message delimiter
im mmcu_uart.py the method find_unescaped_stop(self, buffer, start_index) evaluates all escape bytes as actual escapes. Escape bytes, preceeded by another escape byte should not escape the next byte.
def find_unescaped_stop(self, buffer, start_index):
"""Find the next unescaped UART_STOP_CMD (\n) in the buffer starting from start_index"""
while True:
stop_index = buffer.find(self.UART_STOP_CMD, start_index)
if stop_index == -1:
return -1 # No stop found
# Check if the stop is escaped
if stop_index > 0 and buffer[stop_index - 1] == self.UART_ESCAPE:
# Escaped stop, look for the next one
start_index = stop_index + 1
else:
return stop_index # Unescaped stop found
Edited by joknob001