serial_wait_for
Block until a regex pattern appears in serial output, then optionally send a response to trigger time-sensitive actions like interrupting bootloaders or waiting for login prompts.
Instructions
Wait for a specific pattern to appear in the serial output. Blocks until the regex pattern matches in incoming data, or until timeout.
If respond or respond_hex is provided, that data is sent immediately
when the pattern matches — before this tool returns. This enables
sub-millisecond triggered responses for time-sensitive sequences like
interrupting a bootloader autoboot. The respond string is sent as-is
(no newline appended).
Useful for waiting for boot messages, login prompts, or specific device states before interacting.
Examples: - Wait for login: serial_wait_for(pattern="login:") - Wait for U-Boot: serial_wait_for(pattern="U-Boot", timeout=30) - Wait for prompt: serial_wait_for(pattern="[$#>]\s*$") - Wait for ready: serial_wait_for(pattern="System ready", timeout=60) - Interrupt autoboot: serial_wait_for(pattern="Hit any key to stop autoboot", respond=" ", timeout=60) - Bootloader handshake: serial_wait_for(pattern="Bootloader v", respond_hex="7F")
Args: pattern: Regex pattern to wait for timeout: Max seconds to wait (default 10) session_id: Port name of the session. Optional if only one session is open. encoding: Character encoding (default utf-8) respond: Text to send immediately when pattern matches (sent as-is, no newline) respond_hex: Hex bytes to send when pattern matches (e.g. "7F", "AA 55")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | ||
| respond | No | ||
| timeout | No | ||
| encoding | No | utf-8 | |
| session_id | No | ||
| respond_hex | No |