Skip to content

UART — read message between tags (uart_detect_message)

What it does: Searches the incoming data for a message between the start and end tags and returns the content between them.

uart_detect_message

Inputs

  • start_char: start mark (text).
  • end_char: end tag (text).
  • timeout: maximum wait in milliseconds.

Output

  • Message text without tags.
  • None if the report fails to compile in time.

When to use it

  • For framed logs of type <payload> or #DATA;.
  • When you need to extract a complete frame from a data stream.

Tips and pitfalls

  • Start/end tags must be unique, otherwise incorrect parsing may occur.
  • After successful loading, the internal buffer is emptied.

Generated Python example

message = wait_for_message(uart1, "<", ">", 2000)