serial_exec
Send a command to a serial shell session and retrieve the output in a single call, combining write, delay, and read operations for reliable interaction.
Instructions
Send a command to a serial shell session and wait for the output. Combines write + delay + read in one call. IMPORTANT: Do NOT issue concurrent commands to the same session_id — the serial console is a single channel; concurrent calls will interleave output and corrupt results. Always wait for the previous command to finish before sending the next one. If you need parallel execution, open multiple sessions via serial_open.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | Buffer clear flag: 1 (default) = clear buffer before collecting, 0 = append to buffer | |
| delay | No | Minimum polling duration in milliseconds (default: 1000), kept for backward compat | |
| command | Yes | The command to send to the shell | |
| session_id | Yes | The session ID returned by serial_open | |
| maxDuration | No | Execution cap in ms — ALWAYS estimate and pass a timeout matching the command's expected runtime; do not omit it. Suggested ranges: instant info commands (ls/ip addr/cat/echo) 3000-5000; medium tasks (apt install, dd, service restart) 30000-120000; long builds/flashes (make, flash_image) up to 600000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output. |