cfgetispeed()

Return the input baud rate that's stored in a termios structure

Synopsis:

#include <termios.h>

speed_t cfgetispeed( 
            const struct termios* termios_p );

Arguments:

termios_p
A pointer to a termios structure that describes the terminal's control attributes.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The cfgetispeed() function returns the input baud rate that's stored in the termios structure pointed to by termios_p.

You can get a valid termios control structure for an opened device by calling tcgetattr().

Returns:

The input baud rate stored in *termios_p, or -1 if an error occurs (errno is set).

Errors:

EINVAL
One of the arguments is invalid.
ENOTTY
This function isn't supported by the system.

Examples:

#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main( void )
  {
    int fd;
    struct termios termios_p;
    speed_t speed;

    fd = open( "/dev/ser1", O_RDWR );
    tcgetattr( fd, &termios_p);

    /*
     *  Get input baud rate
     */
    speed = cfgetispeed( &termios_p);
    printf( "Input baud: %ld\n", speed );

    close( fd );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, cfgetospeed(), cfsetispeed(), cfsetospeed(), tcgetattr(), tcsetattr(), termios