termios raw question
Fernando RUIZ CASAS
correo at fernando-ruiz.com
Fri Feb 17 08:04:55 UTC 2006
HI jennifer,
here
http://www.rtems.com/cgi-bin/viewcvs.cgi/rtems/cpukit/libmisc/shell/shell.c?rev=1.14&content-type=text/vnd.viewcvs-markup
You have availiable a raw stream.
-----------------------------------
setvbuf(stdin,NULL,_IONBF,0); /* Not buffered*/
/* make a raw terminal,Linux MANuals */
if (tcgetattr (fileno(stdin), &term)>=0) {
term.c_iflag &=
~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
term.c_oflag &= ~OPOST;
term.c_oflag |= (OPOST|ONLCR); /* But with cr+nl on
output */
term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
term.c_cflag = CLOCAL | CREAD |(shell_env->tcflag);
term.c_cc[VMIN] = 1;
term.c_cc[VTIME] = 0;
if (tcsetattr (fileno(stdin), TCSADRAIN, &term) < 0) {
fprintf(stderr,"shell:cannot set terminal
attributes(%s)\n",devname);
};
----------------------------------
A lot of RTEMS people use it in telnetd and shell serial
console without problems.
Maybe in the output better set to no CR+LF.
See you.
On Tue, 14 Feb 2006 18:03:13 -0600 (CST)
"Jennifer Averett" <jennifer.averett at oarcorp.com> wrote:
> I'm trying to use termios for reading/writing a raw data
>stream.
> I am using tcgetattr to get the attributes then setting:
>
> termios_attr.c_iflag &= ~(IXON|IXANY|IXOFF);
> termios_attr.c_oflag &= ~OPOST;
> termios_attr.c_lflag &=
>~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
> termios_attr.c_cflag = CREAD;
> termios_attr.c_cflag &= ~(CSIZE|PARENB);
>
> Setting Baud rate in c_cflag based upon a table value
> Setting bits per charachter in c_cflag based upon a
>table value
> Setting parity in c_cflag based upon a table value
> Setting number in c_cflag of stop bits based upon a
>table value
> Settiing flow control in c_iflag based upon a table
>value
>
> Then I use tcsetattr to set the attribute. I found a
>problem where 0xd
> was being changed to a 0xa with this code and replaced
>the first c_iflag
> setting with:
>
> termios_attr.c_iflag &= ~(IXON|IXANY|IXOFF|ICRNL);
>
> However this causes a queue overflow when reading the
>device. Does anyone
> know if clearing ICRNL, would have the effect of
>hoarding input characters
> and if so how to keep this from happening? Any other
>suggestions would be
> appreciated.
>
> Jennifer
More information about the users
mailing list