cfsetospeed()

Задать скорость вывода данных, хранящуюся в структуре termios

Прототип:

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

Аргументы:

termios_p
A pointer to a struct termios that describes the terminal's control attributes.
speed
The new speed. Valid values for speed are defined in <termios.h>.

Библиотека:

libc

Описание:

The cfsetospeed() function sets the output baud rate within the struct termios pointed to by termios_p to be speed.

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


Note:
  • The new baud rate isn't effective until you call tcsetattr(), with this modified struct termios.

  • Attempts to set baud rates to values that aren't supported by the hardware are ignored, and cause tcsetattr() to return an error, but cfsetospeed() doesn't indicate an error.

Setting the output baud rate to B0 causes the connection to be dropped. If termios_p represents a modem, the modem control lines will be turned off.

Возвращаемое значение:

0
Успешное завершение.
-1
Возникла ошибка. Код ошибки записан в errno.

Коды ошибок:

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

Примеры:

#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 output baud rate
*/
speed = B9600;
cfsetospeed( &termios_p, speed );
tcsetattr( fd, TCSADRAIN, &termios_p );
close( fd );
return (EXIT_SUCCESS);
}

Классификация:

POSIX 1003.1

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Да
В потоке
Да

Тематические ссылки:

errno, cfgetispeed(), cfgetospeed(), cfsetispeed(), tcgetattr(), tcsetattr(), struct termios




Предыдущий раздел: Описание API системной библиотеки