set the output baud rate in a termios structure
#include <termios.h> int cfsetospeed( struct termios *termios_p, speed_t speed );
The cfsetospeed() function sets the output 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.
|
Setting the output baud rate to B0 causes the connection to be dropped by causing the modem control lines to be turned off.
#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 output baud rate */ speed = B9600; cfsetospeed( &termios_p, speed ); tcsetattr( fd, TCSADRAIN, &termios_p); close( fd ); return (EXIT_SUCCESS); }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
cfgetispeed(), cfgetospeed(), cfsetispeed(), errno, tcgetattr(), tcsetattr()