serial_exec
Send a command to a serial shell session and wait for its output, using automatic completion detection. Enables reliable interactive control of remote embedded devices via serial console.
Instructions
Send a command to a serial shell session and wait for the output. Combines write + read in one call, with automatic completion detection (marker/prompt). 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 | |
| command | Yes | The command to send to the shell | |
| timeoutMs | No | Execution cap in ms — MANDATORY on every call: estimate the command's expected runtime and pass it; omit it ONLY when the user explicitly says not to pass a timeout. Suggested estimates: basic instant commands (ls/pwd/echo/cat small files/ip addr/uname) 3000-5000, never above 10000; output-heavy commands (cat large files, dmesg/journalctl with long output, log dumps) 20000-30000; medium tasks (apt install, dd, service restart) 30000-120000; reboot/reset/power-cycle up to 120000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). Do NOT pass 300000 — the 5-minute value is the internal safety-valve fallback only, not a suggested estimate; if a command genuinely needs longer than ~2min, pass an explicit larger value. 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. | |
| session_id | Yes | The session ID returned by serial_open |