diff --git a/lowerrts.md b/lowerrts.md index c8c4478..3a0c7e2 100644 --- a/lowerrts.md +++ b/lowerrts.md @@ -24,6 +24,10 @@ the port is used without hardware handshake. This behavior cannot be avoided without patching the linux kernel driver (see also http://stackoverflow.com/a/21753723/2880699). +Note, that in FreeBSD the RTS handshake line is not been changed upon +`open()` but staying left in the state whatever it was before. Tested +with FreeBSD 11, both Ftdi and Prolific adapters, picocom 3.1. + Work-around using the user-space API ------------------------------------ diff --git a/picocom.c b/picocom.c index 1440a4a..58f1120 100644 --- a/picocom.c +++ b/picocom.c @@ -252,7 +252,7 @@ int tty_fd = -1; int log_fd = -1; /* RTS and DTR are usually raised upon opening the serial port (at - least as tested on Linux, FreeBsd and macOS) */ + least as tested on Linux and macOS, but FreeBSD behave different) */ int rts_up = 1; int dtr_up = 1; @@ -1197,6 +1197,8 @@ do_command (unsigned char c) fd_printf(STO, "\r\n*** pulse DTR ***\r\n"); if ( term_pulse_dtr(tty_fd) < 0 ) fd_printf(STO, "*** FAILED\r\n"); + else + dtr_up = 1; break; case KEY_TOG_DTR: if ( dtr_up ) @@ -2007,6 +2009,12 @@ main (int argc, char *argv[]) fatal("failed to config port: %s", term_strerror(term_errno, errno)); + r = term_get_mctl(tty_fd); + if ( r >= 0 && r != MCTL_UNAVAIL ) { + rts_up = (r & MCTL_RTS) != 0; + dtr_up = (r & MCTL_DTR) != 0; + } + set_tty_write_sz(term_get_baudrate(tty_fd, NULL)); if ( ! opts.exit ) {