[Previous]
[Contents]
[Next]

cfsetispeed()

set the input baud rate in a termios structure

Synopsis:

#include <termios.h>
int cfsetispeed( struct termios *termios_p,
                 speed_t speed );

Description:

The cfsetispeed() function sets the input baud rate within the termios structure pointed to by termios_p to be speed. Valid values for speed are defined in <termios.h>.

A valid termios control structure for an opened device can be obtained using the tcgetattr() function.


Note:
  • The new baud rate isn't effective until tcsetattr() is called with this modified termios structure.
  • Attempts to set baud rates to values not supported by the hardware are ignored, and cause tcsetattr() to return an error, but cfsetispeed() doesn't indicate an error.
  • Attempts to set input baud rates to a value that's different from the output baud rate, when the hardware doesn't support split baud rates, cause the input baud rate to be ignored, but no error is generated.

Returns:

0
success
-1
an error occurred; errno is set.

Errors:

EINVAL
One of the arguments is invalid.
ENOTTY
This function is not supported by the system.

Examples:

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

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

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

    /* Set input baud rate */
    speed = 9600;
    cfsetispeed( &termios_p, speed );
    tcsetattr( fd, TCSADRAIN, &termios_p);

    close( fd );
    return (EXIT_SUCCESS);
  }

Classification:

POSIX 1003.1

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

cfgetispeed(), cfgetospeed(), cfsetospeed(), errno, tcgetattr(), tcsetattr()


[Previous]
[Contents]
[Next]