termios configuration/read question

jennifer averett jennifer.averett at oarcorp.com
Fri Oct 6 18:25:02 UTC 2000


Thanks for the response,

That works but looking at termios description I think it is incorrect
behavior. The iproc (termios.c) method changes the CR character
regardless of the  setting of  ICANON setting.  The following patch
should fix the problem, but I'd like to verify the functionality against the
POSIX specification before it is applied.

"CR    Special character on input, which is recognized if the ICANON
          flag is set; it is the carriage return character. When ICANON and ICRNL are
          set and IGNCR is not set, this character is translated into an NL,
          and has the same effect as an NL character. "


Index: termios.c
===================================================================
RCS file:
/cavsl/AirVehicle/tools/sw_repository/rtems-451-beta1b-c4x/c/src/lib/libc/termios.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 termios.c
*** termios.c 2000/03/08 21:39:49 1.1.1.1
--- termios.c 2000/10/06 18:05:23
***************
*** 720,736 ****
    c &= 0x7f;
   if (tty->termios.c_iflag & IUCLC)
    c = tolower (c);
-  if (c == '\r') {
-   if (tty->termios.c_iflag & IGNCR)
-    return 0;
-   if (tty->termios.c_iflag & ICRNL)
-    c = '\n';
-  }
-  else if ((c == '\n') && (tty->termios.c_iflag & INLCR)) {
-   c = '\r';
-  }
   if ((c != '\0') && (tty->termios.c_lflag & ICANON)) {
!   if (c == tty->termios.c_cc[VERASE]) {
     erase (tty, 0);
     return 0;
    }
--- 720,736 ----
    c &= 0x7f;
   if (tty->termios.c_iflag & IUCLC)
    c = tolower (c);
   if ((c != '\0') && (tty->termios.c_lflag & ICANON)) {
!   if (c == '\r') {
!    if (tty->termios.c_iflag & IGNCR)
!     return 0;
!    if ( (tty->termios.c_iflag & ICRNL) )
!     c = '\n';
!   }
!   else if ((c == '\n') && (tty->termios.c_iflag & INLCR)) {
!    c = '\r';
!   }
!   else if (c == tty->termios.c_cc[VERASE]) {
     erase (tty, 0);
     return 0;
    }


Jennifer

Thomas Doerfler wrote:

> Hello,
>
> >
> > Is this a bug in termios or am I setting attributes incorrectly?
> > I do not want any data in the stream modified by termios and
> > am setting the attributes as below.  However '\r' is being changed
> > to a '\n' from my input stream.  I
> >
> >   termios_attr.c_lflag &= ~(ICANON|ECHO|ECHONL|ECHOK|ECHOE|ECHOPRT|ECHOCTL);
> >   termios_attr.c_iflag &= ~(IXON|IXANY|IXOFF);
>
> Maybe you should also clear at least "ICRNL" in c_iflag. Have a look
> at ".../sys/termios.h", there is a whole bunch of further iflag bits,
> maybe you can check, which are set in your system by default...
>
> Bye,
>         Thomas.
>
> >
> >
> > Thanks
> >
> > Jennifer
>
> --------------------------------------------
> IMD Ingenieurbuero fuer Microcomputertechnik
> Thomas Doerfler           Herbststrasse 8
> D-82178 Puchheim          Germany
> email:    Thomas.Doerfler at imd-systems.de




More information about the users mailing list