termios raw question
Eric Norum
norume at aps.anl.gov
Tue Feb 14 16:10:28 UTC 2006
If your code is looking for '\n' to terminate the read, and the
device is actually sending a '\r' then you'll never see an 'end-of-
line' unless ICRNL is set.
i.e. if your code looks something like:
for(;;) {
read(fd,&c,1);
if (c == '\n')
break;
buf[i++] = c;
}
then you must have IRCNL set.....
On Feb 14, 2006, at 6:03 PM, Jennifer Averett 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
--
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793
More information about the users
mailing list