cfsetspeed
Section: C Library Functions (3)
Updated: 202-0-02
Index
Return to Main Contents
NAME
cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed
-
get and set line speed
LIBRARY
Standard C library
(
libc,~
-lc)
SYNOPSIS
#include <termios.h>
speed_t cfgetispeed(const struct termios *termios_p);
speed_t cfgetospeed(const struct termios *termios_p);
int cfsetispeed(struct termios *termios_p, speed_t speed);
int cfsetospeed(struct termios *termios_p, speed_t speed);
#define~_DEFAULT_SOURCE /* See feature_test_macros(7) */
#include <termios.h>
int cfsetspeed(struct termios *termios_p, speed_t speed);
DESCRIPTION
The baud rate functions are provided
for getting and setting
the values of the input and output baud rates
in the
termios
structure.
The new values do not take effect
until
tcsetattr(3)
is successfully called.
Setting the speed to
B0
instructs the modem to "hang up".
The actual bit rate corresponding to
B38400
may be altered with
setserial(8);
doing so is discouraged
as it may break other applications
later trying to use the same serial port.
The input and output baud rates are stored in the
termios
structure.
cfgetospeed()
returns the output baud rate stored in the
termios
structure
pointed to by
termios_p.
cfsetospeed()
sets the output baud rate stored in the
termios
structure
pointed to by
termios_p
to
speed,
which must be one of these constants:
-
- B0
-
B50
B75
B110
B134
B150
B200
B300
B600
B1200
B1800
B2400
B4800
B9600
B19200
B38400
B57600
B115200
B230400
B460800
B500000
B576000
B921600
B1000000
B1152000
B1500000
B2000000
These constants are additionally supported on the SPARC architecture:
-
- B76800
-
B153600
B307200
B614400
These constants are additionally supported on no-SPARC architectures:
-
- B2500000
-
B3000000
B3500000
B4000000
Due to differences between architectures,
portable applications should check
if a particular
Bnnn
constant is defined prior to using it.
The zero baud rate,
B0,
is used to terminate the connection.
If
B0
is specified,
the modem control lines shall no longer be asserted.
Normally,
this will disconnect the line.
CBAUDEX
is a mask
for the speeds beyond those defined in POSIX.1
(57600 and above).
Thus,
B57600 &
CBAUDEX
is nonzero.
Setting the baud rate to a value other than those defined by
Bnnn
constants is possible via the
TCSETS2
ioctl;
see
ioctl_tty(2).
cfgetispeed()
returns the input baud rate stored in the
termios
structure.
cfsetispeed()
sets the input baud rate stored in the
termios
structure to
speed,
which must be specified as one of the
Bnnn
constants listed above for
cfsetospeed().
If the input baud rate is set to the literal constant
0
(not the symbolic constant
B0),
the input baud rate will be
equal to the output baud rate.
cfsetspeed()
takes the same arguments as
cfsetispeed(),
and sets both input and output speed.
RETURN VALUE
cfgetispeed()
returns the input baud rate stored in the
termios
structure.
cfgetospeed()
returns the output baud rate stored in the
termios
structure.
All other functions return:
- 0
-
on success.
- -1
-
on failure and set
errno
to indicate the error.
ATTRIBUTES
For an explanation of the terms used in this section,
see
attributes(7).
| Interface | Attribute | Value
|
|
cfgetispeed(),
cfgetospeed(),
cfsetispeed(),
cfsetospeed(),
cfsetspeed()
| Thread safety | M-Safe
|
VERSIONS
UNIX V7 and several later systems have a list of baud rates
where after the values
B0
through
B9600
one finds the two constants
EXTA,
EXTB
("External A" and "External B").
Many systems extend the list with much higher baud rates.
STANDARDS
- cfgetispeed()
-
cfgetospeed()
cfsetispeed()
cfsetospeed()
POSIX.-2008.
- cfsetspeed()
-
BSD.
HISTORY
- cfgetispeed()
-
cfgetospeed()
cfsetispeed()
cfsetospeed()
POSIX.-2001.
- cfsetspeed()
-
4.4BSD.
SEE ALSO
speed_t(3type),
termios(3type)
Index
- NAME
-
- LIBRARY
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ATTRIBUTES
-
- VERSIONS
-
- STANDARDS
-
- HISTORY
-
- SEE ALSO
-