termios raw question

Ian Caddy ianc at goanna.iinet.net.au
Tue Feb 14 16:12:53 UTC 2006


Hi Jennifer,

We use raw data streams a lot with RTEMS, and what you are shown looks OK.

On the c_iflags we normally use:

c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);

The only other thing is what values do you use for:

term.c_cc[VMIN]
term.c_cc[VTIME]

These values depend very much on how you want your serial port to work.

If you set VMIN to anything other than 0, your call to receive will wait 
forever until the VMIN number of characters have appeared.  In our 
systems we normally use VMIN = 0 and VTIME = 1 so the driver will return 
after 100ms if no character has appeared, or as soon as the character 
arrives.

I hope this helps.

regards,

Ian Caddy



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
> 
> 


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.7/259 - Release Date: 13/02/2006



More information about the users mailing list