termios結構體之tcsetattr函式

2021-08-21 23:31:45 字數 547 閱讀 2219

tcsetattr是用於設定終端引數的函式

int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
tcsetattr函式用於設定終端引數。函式在成功的時候返回0,失敗的時候返回-1,並設定errno的值。引數fd為開啟的終端檔案描述符,引數optional_actions用於控制修改起作用的時間,而結構體termios_p中儲存了要修改的引數。optional_actions可以取如下的值。

tcsanow:不等資料傳輸完畢就立即改變屬性。

tcsadrain:等待所有資料傳輸結束才改變屬性。

tcsaflush:等待所有資料傳輸結束,清空輸入輸出緩衝區才改變屬性。

錯誤資訊:

ebadf:非法的檔案描述符。

eintr:tcsetattr函式呼叫被訊號中斷。

einval:引數optional_actions使用了非法值,或引數termios中使用了非法值。

enotty:非終端的檔案描述符。

termios結構體之tcflush函式

unix終端i o函式。作用 清空終端未完成的輸入 輸出請求及資料。include gt int tcflush int fd,int queue selector fd 終端i o開啟的控制代碼 queue selector 控制tcflush的操作,取值為下面三個常數中的乙個 tciflush ...

termios結構體說明

termios結構體中,該結構體一般包括如下的成員 tcflag t c iflag tcflag t c oflag tcflag t c cflag tcflag t c lflag cc t c cc nccs 其具體意義如下 c iflag 輸入模式標誌,控制終端輸入方式,具體引數如下所示。...

termios結構體各成員

termios結構體內容 成員 描述 c cflag 控制模式標誌 c lflag 本地模式標誌 c iflag 輸入模式標誌 c oflag 輸出模式標誌 c line line discipline c cc nccs 控制字元 c ispeed 輸入波特率 c ospeed 輸出波特率 在te...