Setup of Vtime and vmin for Linux under serial port programming

Source: Internet
Author: User
Tags vmin

Vtime defines the amount of time that is required to wait (the value cannot be greater than cc_t).

Vmin defines the minimum number of bytes required to wait.

Options.c_cc[vtime] = X; Sets the time-out period from acquisition to 1 bytes to start a timer

Options.c_cc[vmin] = Y; Set the minimum number of bytes required to wait

Effects on the read () function in the original mode :

1, x=0,y!=0. The function read () returns only if the data of y bytes is read or when a signal is received;

2, x!=0,y=0. Even if no data can be read, the read () function waits for the X time amount to return;

3, x!=0,y!=0. The first byte of data to start, the first to meet the received Y bytes or up to the timeout time x any one condition, read () returns;

4, x=0,y=0. Even if no data is read, the function read returns immediately.

Example:

Through the serial port connection ID card reader, requires that the read serial port at least 6 bytes of data returned immediately, you can set the above two settings of the serial port as follows:

options.c_cc[vtime]=0;

options.c_cc[vmin]=6;

X = = 10 indicates a time-out of 1 seconds

Setup of Vtime and vmin for Linux under serial port programming

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.