Linux下cfsetospeed和cfsetispeed函數——對linux下串口編程的補充

來源:互聯網
上載者:User

對于波特率的設定通常使用cfsetospeed和cfsetispeed函數來完成。擷取傳輸速率資訊是通過cfgetispeed和cfgetospeed函數來完成的。

cfsetospeed函數

    標頭檔:

        #include <termios.h>

    函數原型:

        int cfsetospeed(struct termios *termptr, speed_t speed);

    參數:

        struct termios *termptr - 指向termios結構的指標

        speed_t speed - 需要設定的輸出傳輸速率

    傳回值:

        如果成功返回0,否則返回-1

cfsetispeed函數

    標頭檔:

        #include <termios.h>

    函數原型:

        int cfsetispeed(struct termios *termptr, speed_t speed);

    參數:

        struct termios *termptr - 指向termios結構的指標

        speed_t speed - 需要設定的輸入傳輸速率

    傳回值:

        如果成功返回0,否則返回-1

cfgetospeed函數

    標頭檔:

        #include <termios.h>

    函數原型:

        speed_t cfgetospeed(const struct termios *termptr);

    參數:

        const struct termios - 指向termios結構的指標

    傳回值:

        返回輸出傳輸速率

        cfgetispeed函數

    標頭檔:

        #include <termios.h>

    函數原型:

        speed_t cfgetispeed(const struct termios *termptr);

    參數:

        const struct termios *termptr - 指向termios結構的指標

    傳回值:

        返回輸入傳輸速率

        傳輸速率常量:

CBAUD 掩碼

B0 0傳輸速率

B50 50傳輸速率

B75 75傳輸速率

B110 100傳輸速率

B134 134傳輸速率

B150 150傳輸速率

B200 200傳輸速率

B300 300傳輸速率

B600 600傳輸速率

B1200 1200傳輸速率

B1800 1800傳輸速率

B2400 2400傳輸速率

B9600 9600傳輸速率

B19200 19200傳輸速率

B38400 38400傳輸速率

B57600 57600傳輸速率

B115200 115200傳輸速率

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.