www.LinuxHowtos.org
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 speedLIBRARY
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
-
- B76800
- B153600 B307200 B614400
-
- B2500000
- B3000000 B3500000 B4000000
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)