LINUX serial port c_cc [vtime] And c_cc [Vmin] attribute settings

Source: Internet
Author: User
Tags vmin

In serial programming mode, o_nonblock or o_ndelay is not set for open.

Returns the c_cc [vtime] And c_cc [Vmin] image read functions.

Vtime defines the waiting time, in the unit of hundreds of milliseconds (usually an 8-bit unsigned char variable, the value cannot be greater than cc_t ).

Vmin defines the minimum number of bytes to wait, which may be 0.

If the value of vtime is 0, Vmin defines the minimum number of bytes to be read. Function read () is returned only when Vmin bytes are read or a signal is received.

If the value of Vmin is 0, vtime defines that even if no data is available, the read () function will wait several hundred milliseconds before returning. At this time, the read () function does not need to encounter a file end sign as it normally does to return 0.

If neither vtime nor Vmin is set to 0, vtime defines that the waiting time is calculated after the first byte of data is received. If you can obtain data when calling the READ function, the timer starts timing immediately. If no data is readable when the READ function is called, the timer starts timing after the first byte of data is received. The READ function may return the data of Vmin bytes after reading the data, or return the data after the timing is completed. This mainly depends on which condition is implemented first.However, the function reads at least one byte of data, because the timer starts timing when the first data is read.

If both vtime and Vmin are 0, the function read will return immediately even if no data is read. At the same time, the return value 0 indicates that the READ function does not need to wait for the end mark of the file to return.

Related Article

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.