[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

get_speed, set_speed, or reset_speed Subroutines

Purpose

Set and get the terminal baud rate.

Library

Standard C Library (libc.a)

Syntax

#include <sys/str_tty.h>
int get_speed (FileDescriptor)
int FileDescriptor;
int set_speed (FileDescriptor, Speed)
int FileDescriptor;
int Speed;
int reset_speed (FileDescriptor)
int FileDescriptor;

Description

The baud rate functions set_speed subroutine and get_speed subroutine are provided top allow the user applications to program any value of the baud rate that is supported by the asynchronous adapter, but that cannot be expressed using the termios subroutines cfsetospeed, cfsetispeed, cfgetospeed, and cfsgetispeed. Those subroutines are indeed limited to the set values {BO, B50, ..., B38400} described in <termios.h>.

Interaction with the termios Baud flags:

If the terminal's device driver supports these subroutines, it has two interfaces for baud rate manipulation.

Operation for Baud Rate:

normal mode: This is the default mode, in which a termios supported speed is in use.

speed-extended mode: This mode is entered either by calling set_speed subroutine a non-termios supported speed at the configuration of the line.

In this mode, all the calls to tcgetattr subroutine or TCGETS ioctl subroutine will have B50 in the returned termios structure.

If tcsetatt subroutine or TCSETS, TCSETAF, or TCSETAW ioctl subroutines is called and attempt to set B50, the actual baud rate is not changed. If is attempts to set any other termios-supported speed, the driver will switch back to the normal mode and the requested baud rate is set. Calling reset_speed subroutine is another way to switch back to the normal mode.

Parameters

FileDescriptor Specifies an open file descriptor.
Speed The integer value of the requested speed.

Return Values

Upon successful completion, set_speed and reset_speed return a value of 0, and get_speed returns a positive integer specifying the current speed of the line. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

EINVAL The FileDescriptor parameter does not specify a valid file descriptor for a tty the recognizes the set_speed, get_speed and reset_speed subroutines, or the Speed parameter of set_speed is not supported by the terminal.

Plus all the errno codes that may be set in case of failure in an ioctl subroutine issued to a streams based tty.

Related Information

cfgetospeed, cfsetospeed, cfgetispeed, or cfsetispeed subroutines.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]