Skip to content

Commit

Permalink
src: add argument -B to send a break just before starting the terminal
Browse files Browse the repository at this point in the history
This can be useful for pseudo-automated sequences which require a reset
before operating. With -B, the terminal is reset just before starting.
  • Loading branch information
wtarreau committed Dec 19, 2020
1 parent 84dcde1 commit 8584f2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bootterm is a simple, reliable and powerful terminal designed to ease connection
- enumeration of available ports with detected drivers and descriptions
- wait for a specific, a new, or any port to appear (convenient with USB ports)
- support for non-standard baud rates (e.g. 74880 bauds for ESP8266)
- can send a Break sequence and toggling RTS/DTR for various reset sequences
- can send a Break sequence and toggling RTS/DTR for various reset sequences, even on startup
- fixed/timed captures to files (may be enabled at run time)
- optionally time-stamped captures (relative/absolute dates)
- reliable with proper error handling
Expand Down Expand Up @@ -197,7 +197,7 @@ fi

The current port status (name, speed, pins) is reported when pressing `p` after the escape sequence. Pin names in lower cases are in the low state, those in upper case are in the high state. When pin toggling is required, it is wise to check the real pin's polarity, as most circuits invert it multiple times along the chain. The reported status here is the one seen by the serial port driver.

A break sequence can be used to trigger the SysRq feature in Linux, or to reboot some boards. The break happens by pressing `b` after the escape key. E.g. `Ctrl-] b`.
A break sequence can be used to trigger the SysRq feature in Linux, or to reboot some boards. The break happens by pressing `b` after the escape key. E.g. `Ctrl-] b`. It is also possible to send a break sequence just before starting the terminal by passing `-B` on the command line.

The DTR pin can be toggled by pressing `D` after the escape character, and the RTS pin can be toggled by pressing `R`. Both pins can be toggled together (for example to reset an ESP8266 in flashing mode) by pressing `F`.

Expand Down
9 changes: 9 additions & 0 deletions src/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const char usage_msg[] =
" -e <escape> escape character or ASCII code (default: 29 = Ctrl-])\n"
" -f <fmt> capture file name (default: 'bootterm-%%Y%%m%%d-%%H%%M%%S.log')\n"
" -V show version and license\n"
" -B send a break sequence before starting the terminal\n"
"\n"
"Ports are sorted in reverse registration order so that port 0 is the most\n"
"recently added one. A number may be set instead of the port. With no name nor\n"
Expand Down Expand Up @@ -1658,6 +1659,7 @@ int main(int argc, char **argv)
int do_wait_new = 0;
int do_wait_any = 0;
int do_print = 0;
int do_send_break = 0;
int forced = 0;
int usepath = 0;
int retries = 0;
Expand Down Expand Up @@ -1725,6 +1727,10 @@ int main(int argc, char **argv)
die(0, version_str);
break;

case 'B':
do_send_break = 1;
break;

case 'l':
do_list = 1;
break;
Expand Down Expand Up @@ -2073,6 +2079,9 @@ int main(int argc, char **argv)
printf("Escape character is '%s'. Use escape followed by '?' for help.\n", esc);
}

if (do_send_break)
tcsendbreak(fd, 0);

/* set start time of capture just before forwarding */
gettimeofday(&start_ts, NULL);

Expand Down

0 comments on commit 8584f2e

Please sign in to comment.