Serial Communication Flow Control

Source: Internet
Author: User
Serial Communication Flow Control

 

In serial communication processing, we often see the two options, namely, RTS/CTS and Xon/xoff, which are two traffic control options. Currently, traffic control is mainly used in modem data communication, but for general RS-232 programming, understanding this knowledge is good. so what is the role of Stream Control in serial communication and how to apply it in the preparation of serial communication programs? Here we will talk about this issue.
The role of Stream Control in serial communication:
The "stream" mentioned here, of course, refers to data streams. when data is transmitted between two serial ports, data loss often occurs, or the processing speed of the two computers is different, such as the communication between the desktop and the single chip microcomputer, the data buffer at the receiving end is full, in this case, the sent data will be lost. now we can transmit data through modem on the network, which is particularly prominent. stream Control can solve this problem. When the receiving end cannot process data, it sends a "no longer received" signal, and the sending end stops sending until it receives a "can continue sending" signal and then sends data. therefore, flow control can control the data transmission process to prevent data loss. two common traffic control methods in PC are hardware traffic control (including RTS/CTS, DTR/CTS, etc.) and software traffic control Xon/xoff (continue/Stop.
Hardware Flow Control:
Hardware traffic control is commonly used, including RTS/CTS traffic control and DTR/DSR (Data Terminal ready/data set ready) Traffic Control.
The hardware traffic control must be connected to the corresponding cable. When you use the RTS/CTS (request sending/clearing sending) traffic control, the RTS and CTS lines at both ends of the communication should be connected accordingly, data Terminal devices (such as computers) Use RTS to start data streams from modem or other data communication devices, while data communication devices (such as modem) Use CTS to start and pause data streams from computers. the hardware handshaking process is: we set a high flag (75% of the buffer size) and a low flag (25% of the buffer size) based on the buffer size at the receiver end during programming ), when the data volume in the buffer reaches a high level, we set the CTS line to a low level (send logic 0) at the receiving end. When the sending end detects that the CTS is low, it stops sending data, until the data volume in the receiver buffer is lower than the low value, the CTS is set to a high level. RTS indicates whether the receiving device is ready to receive data.
Common traffic control methods include DTR/DSR (Data Terminal ready/Data ready ). we will not detail it here. due to the diversity of flow control, I personally think that when the software uses flow control, we should give a detailed description of how to connect and how to apply it. In serial communication processing, we often see the two options, namely, RTS/CTS and Xon/xoff, which are two traffic control options. Currently, traffic control is mainly used in modem data communication, but for general RS-232 programming, understanding this knowledge is good. so what is the role of Stream Control in serial communication and how to apply it in the preparation of serial communication programs? Here we will talk about this issue.
The role of Stream Control in serial communication:
The "stream" mentioned here, of course, refers to data streams. when data is transmitted between two serial ports, data loss often occurs, or the processing speed of the two computers is different, such as the communication between the desktop and the single chip microcomputer, the data buffer at the receiving end is full, in this case, the sent data will be lost. now we can transmit data through modem on the network, which is particularly prominent. stream Control can solve this problem. When the receiving end cannot process data, it sends a "no longer received" signal, and the sending end stops sending until it receives a "can continue sending" signal and then sends data. therefore, flow control can control the data transmission process to prevent data loss. two common traffic control methods in PC are hardware traffic control (including RTS/CTS, DTR/CTS, etc.) and software traffic control Xon/xoff (continue/Stop.
Hardware Flow Control:
Hardware traffic control is commonly used, including RTS/CTS traffic control and DTR/DSR (Data Terminal ready/data set ready) Traffic Control.
The hardware traffic control must be connected to the corresponding cable. When you use the RTS/CTS (request sending/clearing sending) traffic control, the RTS and CTS lines at both ends of the communication should be connected accordingly, data Terminal devices (such as computers) Use RTS to start data streams from modem or other data communication devices, while data communication devices (such as modem) Use CTS to start and pause data streams from computers. the hardware handshaking process is: we set a high flag (75% of the buffer size) and a low flag (25% of the buffer size) based on the buffer size at the receiver end during programming ), when the data volume in the buffer reaches a high level, we set the CTS line to a low level (send logic 0) at the receiving end. When the sending end detects that the CTS is low, it stops sending data, until the data volume in the receiver buffer is lower than the low value, the CTS is set to a high level. RTS indicates whether the receiving device is ready to receive data.
Common traffic control methods include DTR/DSR (Data Terminal ready/Data ready ). we will not detail it here. due to the diversity of flow control, I personally think that when the software uses flow control, we should give a detailed description of how to connect and how to apply it.
Software flow control:
Due to the limitation of cables, we usually use software flow control instead of hardware flow control in general control communication. generally, Xon/xoff is used to implement software flow control. the common method is: when the data volume in the input buffer of the receiving end exceeds the set high, xoff (19 in decimal or control-s in decimal format) is sent to the data sending end, the device programming specification should be described in detail). After receiving the xoff character, the sender immediately stops sending data. When the data volume in the input buffer of the receiver is less than the set low level, send the Xon character (17 or control-Q in decimal format) to the data sender. The sender starts sending the data immediately after receiving the Xon character. generally, you can find the characters sent from the source program of the device.
It should be noted that if binary data is transmitted, the flag characters may also occur in the data stream and cause misoperations. This is a defect in software flow control, and hardware flow control will not have this problem.

Software flow control:
Due to the limitation of cables, we usually use software flow control instead of hardware flow control in general control communication. generally, Xon/xoff is used to implement software flow control. the common method is: when the data volume in the input buffer of the receiving end exceeds the set high, xoff (19 in decimal or control-s in decimal format) is sent to the data sending end, the device programming specification should be described in detail). After receiving the xoff character, the sender immediately stops sending data. When the data volume in the input buffer of the receiver is less than the set low level, send the Xon character (17 or control-Q in decimal format) to the data sender. The sender starts sending the data immediately after receiving the Xon character. generally, you can find the characters sent from the source program of the device.
It should be noted that if binary data is transmitted, the flag characters may also occur in the data stream and cause misoperations. This is a defect in software flow control, and hardware flow control will not have this problem.

Note: In embedded development, serial communication between the PC and the Board does not require Serial Data Flow Control. Therefore, when the serial port is set, traffic control: None, data bit: 8, stop bit: 1, and parity: None

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.