1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Fix HUPCL handling

Picocom will always set the HUPCL control bit of the serial port,
according to the --noreset option. If --noreset is given, then
HUPCL for the port is cleared, and will remain so after exiting
picocom. If --noreset is *not* given, then HUPCL is set for the
port, and will remain so after exiting picocom. This is true, regardless
of the way picocom terminates (command, read zero-bytes from standard
input, killed by signal, etc), and regardless of the --noinit
option. If picocom exits with the "Quit" command, then --noreset is
assumed given. Almost always this is the most DWIM behavior.

Fixes #72
This commit is contained in:
Nick Patavalis
2017-12-20 05:59:55 +02:00
parent 33c2332c18
commit 82d69071c3
2 changed files with 18 additions and 7 deletions

View File

@ -512,13 +512,16 @@ read_baud (void)
/**********************************************************************/
void cleanup(int drain, int noreset)
void
cleanup (int drain, int noreset)
{
if ( tty_fd >= 0 ) {
/* Print msg if they fail? Can't do anything, anyway... */
if ( drain )
term_drain(tty_fd);
term_flush(tty_fd);
term_set_hupcl(tty_fd, !noreset);
term_apply(tty_fd, 1);
if ( noreset ) {
fd_pinfof(opts.quiet, "Skipping tty reset...\r\n");
term_erase(tty_fd);
@ -564,7 +567,7 @@ fatal (const char *format, ...)
s = "\r\n";
writen_ni(STE, s, strlen(s));
cleanup(0 /* drain*/, 0 /* noreset */);
cleanup(0 /* drain */, opts.noreset);
exit(EXIT_FAILURE);
}
@ -980,8 +983,6 @@ do_command (unsigned char c)
case KEY_EXIT:
return 1;
case KEY_QUIT:
term_set_hupcl(tty_fd, 0);
term_apply(tty_fd, 1);
opts.noreset = 1;
return 1;
case KEY_STATUS:
@ -1728,7 +1729,7 @@ parse_args(int argc, char *argv[])
/**********************************************************************/
int
main(int argc, char *argv[])
main (int argc, char *argv[])
{
int xcode = EXIT_SUCCESS;
int r;
@ -1783,7 +1784,6 @@ main(int argc, char *argv[])
if ( r < 0 )
fatal("failed to add device %s: %s",
opts.port, term_strerror(term_errno, errno));
if ( opts.lower_rts ) {
r = term_lower_rts(tty_fd);
if ( r < 0 )