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

FreeBSD: Fixed initial sw-side state of RTS and DTR

This commit is contained in:
Joe Merten
2018-01-02 15:58:58 +01:00
parent cc8d142e2c
commit de631d4c58
2 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,10 @@ the port is used without hardware handshake.
This behavior cannot be avoided without patching the linux kernel This behavior cannot be avoided without patching the linux kernel
driver (see also http://stackoverflow.com/a/21753723/2880699). 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 Work-around using the user-space API
------------------------------------ ------------------------------------

View File

@ -252,7 +252,7 @@ int tty_fd = -1;
int log_fd = -1; int log_fd = -1;
/* RTS and DTR are usually raised upon opening the serial port (at /* 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 rts_up = 1;
int dtr_up = 1; int dtr_up = 1;
@ -1197,6 +1197,8 @@ do_command (unsigned char c)
fd_printf(STO, "\r\n*** pulse DTR ***\r\n"); fd_printf(STO, "\r\n*** pulse DTR ***\r\n");
if ( term_pulse_dtr(tty_fd) < 0 ) if ( term_pulse_dtr(tty_fd) < 0 )
fd_printf(STO, "*** FAILED\r\n"); fd_printf(STO, "*** FAILED\r\n");
else
dtr_up = 1;
break; break;
case KEY_TOG_DTR: case KEY_TOG_DTR:
if ( dtr_up ) if ( dtr_up )
@ -2007,6 +2009,12 @@ main (int argc, char *argv[])
fatal("failed to config port: %s", fatal("failed to config port: %s",
term_strerror(term_errno, errno)); 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)); set_tty_write_sz(term_get_baudrate(tty_fd, NULL));
if ( ! opts.exit ) { if ( ! opts.exit ) {