![]() |
![]() |
![]() |
Set the input baud rate in a termios structure
#include <termios.h> int cfsetispeed( struct termios* termios_p, speed_t speed );
libc
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.
![]() |
|
#include <termios.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.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; }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
errno, cfgetispeed(), cfgetospeed(), cfsetospeed(), tcgetattr(), tcsetattr()
![]() |
![]() |
![]() |