termios結構體
阿新 • • 發佈:2019-02-05
關於terimos結構體
在POSIX規範中定義的標準介面,它類似於系統V中的termio介面,通過設定termios型別的資料結構中的值和使用一小組函式呼叫,你就可以對終端介面進行控制。
最小的termios結構的典型定義如下:
struct termios
{
tcflag_t c_iflag; /* 輸入模式 */
tcflag_t c_oflag; /* 輸出模式 */
tcflag_t c_cflag; /* 控制模式 */
tcflag_t c_lflag;/* 本地模式 */
cc_t c_cc[NCCS]; /* 控制字元 */
};
SYNOPSIS
#include <termios.h>#include <unistd.h>
int tcgetattr(int fd, struct termios *termios_p);//用於獲取與終端相關的引數
int tcsetattr(int fd, int optional_actions,//用於設定終端引數
const struct termios *termios_p);
int tcsendbreak(int fd, int duration);
int tcdrain(int fd);//等待直到所有寫入 fd 引用的物件的輸出都被傳輸
int tcflush(int fd, int queue_selector); //刷清(扔掉)輸入快取
int tcflow(int fd, int action); //掛起傳輸或接受
void cfmakeraw(struct termios *termios_p);// 製作新的終端控制屬性
speed_t cfgetispeed(const struct termios *termios_p); //得到輸入速度
speed_t cfgetospeed(const struct termios *termios_p); //得到輸出速度
int cfsetispeed(struct termios *termios_p, speed_t speed); //設定輸入速度
int cfsetospeed(struct termios *termios_p, speed_t speed);//設定輸出速度
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
cfsetspeed(), cfmakeraw(): _BSD_SOURCE
DESCRIPTION 描述
termios 函式族提供了一個常規的終端介面,用於控制非同步通訊埠。 這裡描述的大部分屬性有一個 termios_p 型別的引數,它是指向一個 termios 結構的指標。這個結構包含了至少下列成員: tcflag_t c_iflag; /* 輸入模式 */ tcflag_t c_oflag; /* 輸出模式 */ tcflag_t c_cflag; /* 控制模式 */ tcflag_t c_lflag; /* 本地模式 */ cc_t c_cc[NCCS]; /* 控制字元 */