Analysis of PC serial communication flow control

xiaoxiao2021-03-06  39

Analysis of PC serial communication flow control Gong Jianwei 2001.8.23 We often see two options of RTS / CTS and XON / XOFF in serial communication, this is the two stream control options, and the current flow control is mainly applied. In the data communication of the modem, it is good for the knowledge of ordinary RS232 to understand the knowledge of this. So, what is the role of streaming in serial communication? What is the application of serial communication programs? Here we will talk about this problem. 1. Flow Control The role in serial communication This "stream", of course, is a data stream. When the data is transmitted between two serial ports, there is often a phenomenon of loss of data, or the processing speed of the two computers is different, such as communication between the desktop and the microcontroller, the receiving end data buffer is full, then continue to send The data coming will be lost. Now we have data transmission through MODEM on the network, this problem is particularly highlighted. Flow control can solve this problem, when the receiving end data processing is not, "no longer receiving" signal is issued, the sending end stops transmission until the "can continue" signal will be sent again. Therefore, stream control can control the process of data transmission to prevent data from loss. Two stream controls commonly used in the PC are hardware flow controls (including RTS / CTS, DTR / CTS, etc.) and software flow control XON / XOn / XOn / XONFF (continued / stop), which will be described below. 2. Hardware flow controls hardware flow control commonly used RTS / CTS stream control and DTR / DSR (Data Term Read Read Read Read Ready) Flow Control. Hardware flow control must connect the corresponding cable, and use RTS / CTS (request send / clear transmission) stream to control the RTS, CTS lines on both ends of the communication, and the data terminal device (such as a computer) uses RTS. Start the data stream of the demodulator or other data communication device, and the data communication device (such as a modem) is started with CTS to start and suspend traffic from the computer. The process of this hardware handshake mode is: We set a high-level flag according to the receiving end buffer size when programming (75% of the buffer size) and a low mark (25% of the buffer size), when buffer When the data volume in the zone reaches a high position, we set a low level (send logic 0) at the receiving end. When the sender's program detects that the CTS is low, the transmission data is stopped until the data amount of the receiving end buffer is low. The CTS is high at a low position. RTS is used to indicate whether the receiving device is ready to receive data. Common stream controls have DTR / DSR (Data Terminal Ready / Data Setting Ready). We will not be detailed here. Due to the diversity of stream control, I personally think that when using flow control in the software, you should do a detailed description, how to connect, how to apply. 3. Software flow control Due to the limitations of the cable, we generally do not have hardware flow control in ordinary control communication, and use software flow control. Software flow control is generally achieved by XON / XOFF. The common method is: When the amount of data in the input buffer in the receiving end exceeds the set high position, the xoff character (decimal 19 or control-s, the device programming manual should be described in detail), the transmitting end is received After the Xoff characters, the XOF characters immediately stop sending data; when the amount of data in the input buffer in the receiving end is lower than the set low position, the XON character (decimal 17 or control-q) is sent to the data sender, and the sender receives Xon characters. I started to send data immediately.

转载请注明原文地址:https://www.9cbs.com/read-51635.html

New Post(0)