Commit 9f57498
committed
feat!: serial expect/send automation with monitor mode
Rework the serial module from a single read-only expect into a
non-interactive automation engine driven entirely by up-front arguments,
suitable for scripts and machines.
Modes:
- Monitor (no steps): stream the serial output to the client until the
session is cancelled or -t elapses (a success).
- Sequence (one or more steps): run expect / send / send-raw steps in
order; the run fails on the first expect that times out.
Grammar: [-t <dur>] [-eol cr|lf|crlf|none] [-keep-escapes] [--] <step>... where
a step is expect <regex> / send <data> / send-raw <data>. send payloads support
the escapes \r \n \t \\ and \xNN (e.g. \x03 for Ctrl-C). Per-step progress is
reported to the client as "--- [n/total] matched/sent ... ---" markers. If the
last step is a send, output is shown briefly afterwards so the DUT's reply is
visible.
A 'delay' module option (with: delay, default 50ms; "0s" disables) paces input
by pausing before each send, for consoles that present a prompt before the tty
is ready to read.
By default terminal escape sequences (cursor moves, colour, queries) are
stripped from the output before it is shown or matched, so they don't break
expect patterns; pass -keep-escapes to forward the raw stream (e.g. binary
data).
Internals: a port interface plus a per-run engine with a 64 KiB rolling
match buffer (matches across reads, never newline-reset) and a tee that
forwards serial output to the client. Structured so an interactive
session.Console mode can be added later.
Also migrate the serial backend from the unmaintained tarm/serial to
go.bug.st/serial, and update the module README and example config.
BREAKING CHANGE: The serial module's invocation changed. It no longer accepts
a single optional expect regex; callers must pass an explicit step sequence.
For example, `serial "(?i)hello"` becomes `serial -- expect "(?i)hello"`.
Existing configs/scripts using the old form must be updated.
Signed-off-by: Jens Topp <jens.topp@blindspot.software>1 parent 282989f commit 9f57498
11 files changed
Lines changed: 1692 additions & 133 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | | - | |
| 22 | + | |
20 | 23 | | |
21 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
24 | 33 | | |
25 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
26 | 76 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
31 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
32 | 109 | | |
| 110 | + | |
0 commit comments