cfsetispeed()

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

Прототип:

#include <termios.h>
int cfsetispeed( 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 cfsetispeed() function sets the input 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 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.

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

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 input baud rate
*/
speed = 9600;
cfsetispeed( &termios_p, speed );
tcsetattr( fd, TCSADRAIN, &termios_p );
close( fd );
return (EXIT_SUCCESS);
}

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

POSIX 1003.1

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

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

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




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