From 29e214e4d5af153283f81143fa8ee1157187449b Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 26 Sep 2003 17:33:59 +0000 Subject: [PATCH] 2003-09-26 Cedric Aubert PR 501/rtems_misc * console.c: console_open disables ICANON on non-console port, which should be ok for the first open but not for subsequent ones. If you open one serial port, you will configure it, when you reopen it you will lost the ICANON parameters if you had put it. Should be done by console only at first open. --- c/src/lib/libbsp/shared/ChangeLog | 9 ++++++++ c/src/lib/libbsp/shared/console.c | 36 ++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog index 5d8514fbf6..02c7fd0320 100644 --- a/c/src/lib/libbsp/shared/ChangeLog +++ b/c/src/lib/libbsp/shared/ChangeLog @@ -1,3 +1,12 @@ +2003-09-26 Cedric Aubert + + PR 501/rtems_misc + * console.c: console_open disables ICANON on non-console port, which + should be ok for the first open but not for subsequent ones. If you + open one serial port, you will configure it, when you reopen it you + will lost the ICANON parameters if you had put it. Should be done by + console only at first open. + 2003-09-04 Joel Sherrill * bootcard.c, bspclean.c, clockdrv_shell.c, console-polled.c, diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c index 7623b7c628..0f59a17231 100644 --- a/c/src/lib/libbsp/shared/console.c +++ b/c/src/lib/libbsp/shared/console.c @@ -20,6 +20,7 @@ #include #include +#include #include /* @@ -50,6 +51,7 @@ rtems_device_driver console_open( struct termios Termios; rtems_termios_callbacks Callbacks; console_tbl *cptr; + struct rtems_termios_tty *current_tty; /* * Verify the port number is valid. @@ -79,19 +81,27 @@ rtems_device_driver console_open( status = rtems_termios_open ( major, minor, arg, &Callbacks ); Console_Port_Data[minor].termios_data = args->iop->data1; - - if (minor!=Console_Port_Minor) { - /* - * If this is not the console we do not want ECHO and - * so forth - */ - IoctlArgs.iop=args->iop; - IoctlArgs.command=RTEMS_IO_GET_ATTRIBUTES; - IoctlArgs.buffer=&Termios; - rtems_termios_ioctl(&IoctlArgs); - Termios.c_lflag=ICANON; - IoctlArgs.command=RTEMS_IO_SET_ATTRIBUTES; - rtems_termios_ioctl(&IoctlArgs); + + /* Get tty pointeur from the Console_Port_Data */ + current_tty = Console_Port_Data[minor].termios_data; + + if ( (current_tty->refcount == 1) ) { + /* + * If it's the first open, modified, if need, the port parameters + */ + if (minor!=Console_Port_Minor) { + /* + * If this is not the console we do not want ECHO and + * so forth + */ + IoctlArgs.iop=args->iop; + IoctlArgs.command=RTEMS_IO_GET_ATTRIBUTES; + IoctlArgs.buffer=&Termios; + rtems_termios_ioctl(&IoctlArgs); + Termios.c_lflag=ICANON; + IoctlArgs.command=RTEMS_IO_SET_ATTRIBUTES; + rtems_termios_ioctl(&IoctlArgs); + } } if ( (args->iop->flags&LIBIO_FLAGS_READ) &&