Xon\xoff principle of Serial-Port handshake protocol

Source: Internet
Author: User

The Xon\xoff principle of serial-port handshake protocol Some people may not understand, look at the following example you should be able to understand.

Suppose pc A and PC B communicate via RS232 serial port

A and B are negotiated using the Software Handshake Protocol (DCB.FOUTX = TRUE), defining XonChar \ XoffChar such as XonChar = 1,

XoffChar = 2.

Now, a sends the character 2 to B, and B sends the string "HelloWorld" to a. A can you get the string "HelloWorld"? No, I can't.

After B sends the character 1 to a, a will receive the string "HelloWorld".

Question: is a to B hair xoffchar? or b to a hair XoffChar?

For example, Li Four has a lot of books, now a laptop to Zhang San, Zhang San suddenly to go to the toilet, want to Li four pause a while, so

Zhang San said to John Doe: "Pause." When John Doe heard, he stopped to pass the book to Zhang San.
"Zhang San" is the receiving end of the communication, "John Doe" is the transmitting end of the communication.

The transmission direction of the XoffChar is the receive-to-send

When Zhang San came back from the toilet, he said to John Doe, "I'm back, let's go." So, John Doe to the rest of the book a copy of a copy of the pass to Zhang San

In the same way, the transmission direction of the XonChar is also receive-and-send.


Issue: After the sender receives the XoffChar, who has not yet sent the successful characters to be kept.
Answer: Operating system.

The serial port sends the message to use WriteFile (), if is the overlap way, after the sender receives the XoffChar, WriteFile () will return Faile,
GetLastError () = = error_io_pending.

If the non-overlap way, the program will stop at WriteFile (), wait for the send to succeed, and of course, take into account the timeout setting.

The next step is to go deep into the WriteFile overlap principle.

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.