Chapter Contents |
Previous |
Next |
cfsetospeed |
Portability: | POSIX.1 conforming |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
PORTABILITY | |
EXAMPLE | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <termios.h> int cfsetospeed(struct termios *terminal, speed_t speed);
DESCRIPTION |
cfsetospeed
is used to set a new output baud rate in the
termios
structure. (
terminal
points to a copy of this structure.) This structure is defined
in
<termios.h>
and contains
terminal attribute information.
The
tcgetattr
function must be used to make a copy of the
termios
structure before you can use the
cfsetospeed
function to set the
output baud rate. The
cfsetospeed
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,
cfsetospeed
returns
0
.
A
-1
is returned if unsuccessful.
PORTABILITY |
The
cfsetospeed
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
cfsetospeed
to set
a new output baud rate:
#include <sys/types.h> #include <termios.h> #include <unistd.h> #include <stdio.h> main() { struct termios termAttr; speed_t baudRate; /* Obtain a copy of the termios structure for stdout. */ tcgetattr(STDOUT_FILENO, &termAttr); /* Get the output speed. */ baudRate = cfgetospeed(&termAttr); /* Set output speed if not 9600 baud. */ if (baudRate != B9600) { cfsetospeed(&termAttr, B9600); tcsetattr(STDOUT_FILENO, TCSADRAIN, &termAttr); } }
RELATED FUNCTIONS |
cfgetospeed
,
cfsetispeed
,
tcsetattr
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.