DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

tcgetspeed(3C)


tcgetspeed, tcsetspeed -- get and set baud rate

Synopsis

#include <termios.h>

speed_t tcgetspeed(tcstype_t type, const struct termios *termios_p);

void tcsetspeed(tcstype_t type, struct termios *termios_p, speed_t speed);

Description

The baud rate functions get and set the values of the input and output baud rates in the termios structure. The effects on the terminal device described below do not become effective until the tcsetattr function is successfully called.

The input and output baud rates are stored in the termios structure. The baud rates that can be represented in a termios structure are implementation specific, but include at least the following:

0, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200

A baud rate of zero has a special interpretation. It it used to terminate (hang up) a connection.

tcgetspeed

tcgetspeed gets the baud rate stored in the termios structure pointed to by termios_p. It returns the input or output baud rate, depending on the value of type:

TCS_IN
get/set input baud rate

TCS_OUT
get/set output baud rate

TCS_ALL
get/set all baud rates

The baud rate is returned as an integer (for example, 300 is returned for 300 baud). If tcgetspeed is called with TCS_ALL and the input and output baud rates are not the same, it returns zero.

tcsetspeed

tcsetspeed sets the input and/or output baud rate stored in the termios structure pointed to by termios_p to speed. Both input and output rates will be set if type is TCS_ALL. Otherwise the rate not being set will remain unchanged.

If the output baud rate is set to zero, the modem control lines will be de-asserted. Normally, this disconnects the line. Both baud rates must be set to non-zero values for a useable connection.

Attempts to set baud rates or baud rate combinations not supported by either the termios representation or by the driver are ignored. The previous baud rate setting will remain in effect.

Zeroing all the bytes of a termios structure will have the side effect of setting the output baud rate to zero.

References

termios(3C)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004