Some hints on setting up the termios flags when using a serial device
that you've opened yourself (as opposed to using your existing control
You probably want to set all the bits in
c_iflag to 0,
unless you want to use software flow control (ick) in which case you set
Most of the bits of
c_oflag are hacks of one sort or another to
make output to slow terminals work, and as such some newer systems have
dropped almost all of them as obsolete (especially all the gory
output-padding options). As with
c_iflag, setting everything to 0
is reasonable for most applications.
When setting the character size, remember to mask using
first; e.g. to set 8-bit characters, use:
attr.c_cflag &= ~CSIZE;
attr.c_cflag |= CS8;
Other important flags found in
c_cflag that you probably want to
turn on and
If you need to generate even parity, then set
PARENB and clear
PARODD; if you need to generate odd parity then set both
PARODD. If you don't want parity at all, then
PARENB is clear.
CSTOPB unless you actually need to generate two stop bits.
Flags for enabling hardware flow control may also be found in
c_cflag, but they aren't standardised (pity).
Most applications will probably want to turn off
(canonical, i.e. line-based, input processing),
IEXTEN is a more complex issue. If you don't turn it off, the
implementation is allowed to do nonstandard things (like define
additional control characters in
c_cc) that might cause
unexpected results, but you might need to leave
on some systems to get useful features like hardware flow control.
This is an array of characters that have special meanings on input.
These characters are given names like
the names are indexes into the array.
(Two of these "characters" are not really characters at all, but control
the behaviour of
ICANON is disabled; these are
The indexes are often referred to as though they were actual variables,
e.g. "set VMIN to 1" actually means "set c_cc[VMIN] to 1". The shorthand
is useful and only occasionally confusing.
Many of the slots in
c_cc are only used if some other combination
of flags is set:
VWERASEif defined and
ICANONis not set
Implementations may define additional entries in
c_cc. It may
be prudent to initialise all the entries to
NCCS gives the array size) before setting the
specific values you wish to use.
VTIME (which may share slots with
VEOL respectively, depending on the implementation) have the
following meaning. The value of
VTIME is (if not 0) always
interpreted as a timer in tenths of seconds.
c_cc[VMIN] > 0, c_cc[VTIME] > 0
read()will return when either VMIN bytes of input are available,
c_cc[VMIN] > 0, c_cc[VTIME] == 0
read()will return when VMIN bytes of input are available, or if
c_cc[VMIN] == 0, c_cc[VTIME] > 0
read()will return as soon as any input is available; if VTIME
select()for a timeout avoids this particular problem.)
c_cc[VMIN] == 0, c_cc[VTIME] == 0
read()will always return immediately; if no data is available
English to Visayan Cebuano Dictionary
Suggest a Site
Visayan Cebuano to English Dictionary