Cfsetospeed and cfsetispeed functions in Linux-supplement to serial programming in Linux

Source: Internet
Author: User

The cfsetospeed and cfsetispeed functions are usually used to set the baud rate. The cfgetispeed and cfgetospeed functions are used to obtain the baud rate information.

Cfsetospeed Function

Header file:

# Include <termios. h>

Function prototype:

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

Parameters:

Struct termios * termptr-pointer to the termios Structure

Speed_t speed-output baud rate to be set

Return Value:

If the request is successful, 0 is returned. Otherwise,-1 is returned.

Cfsetispeed Function

Header file:

# Include <termios. h>

Function prototype:

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

Parameters:

Struct termios * termptr-pointer to the termios Structure

Speed_t speed-the input baud rate to be set

Return Value:

If the request is successful, 0 is returned. Otherwise,-1 is returned.

Cfgetospeed Function

Header file:

# Include <termios. h>

Function prototype:

Speed_t cfgetospeed (const struct termios * termptr );

Parameters:

Const struct termios-pointer to the termios Structure

Return Value:

Returns the output baud rate.

Cfgetispeed Function

Header file:

# Include <termios. h>

Function prototype:

Speed_t cfgetispeed (const struct termios * termptr );

Parameters:

Const struct termios * termptr-pointer to the termios Structure

Return Value:

Returns the input baud rate.

Baud Rate Constant:

Cbaud mask

B0 0 Port

B50 50 Port

B75 75 Port

B110 100 Port

B134 134 Port

B150 150 Port

B200 200 Port

B300 300 Port

B600 600 Port

B1200 1200 Port

B1800 1800 Port

B2400 2400 Port

B9600 9600 Port

B19200 19200 Port

B38400 38400 Port

B57600 57600 Port

B115200 115200 Port

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.