Chapter Contents |
Previous |
Next |
cfsetispeed |
Portability: | POSIX.1 conforming |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
PORTABILITY | |
EXAMPLE | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <termios.h> int cfsetispeed(struct termios *terminal, speed_t speed);
DESCRIPTION |
cfsetispeed
is used to set a new input baud rate in the
termios
structure pointed to by
terminal
. This structure is defined in
<termios.h>
and contains terminal
attribute information.
The
tcgetattr
function must be used to obtain a copy of the
termios
structure before you can use the
cfsetispeed
function to set the
input baud rate. The
cfsetispeed
function changes the baud rate in this copy and the
tcsetattr
functions can then be used to update
the
termios
control structure.
The defined type,
speed_t
, specifies the baud rate. Each value is associated with an
asynchronous line speed as follows:
RETURN VALUE |
If successful,
cfsetispeed
returns
0
.
A
-1
is returned if unsuccessful.
PORTABILITY |
The
cfsetispeed
function is defined by the POSIX.1 standard and provides
portability between operating environments. Note that USS only supports pseudoterminals
and that baud rate does not affect the operation of a pseudoterminal.
EXAMPLE |
The following example illustrates the
use of
cfsetispeed
to set
a new output baud rate:
#include <sys/types.h> #include <termios.h> #include <unistd.h> main() { struct termios termAttr; speed_t baudRate; /* Make a copy of the termios structure. */ tcgetattr(STDIN_FILENO, &termattr); /* Get the input speed. */ baudRate = cfgetispeed(&termattr); /* Set output speed if not 9600 baud. */ if (baudRate != B9600) { cfsetispeed(&termattr, B9600); tcsetattr(STDIN_FILENO, TCSANOW, &termattr); } }
RELATED FUNCTIONS |
cfgetispeed
,
cfsetospeed
,
tcsetattr
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.