Uart software flow control method, device, equipment and medium

CN115687225BActive Publication Date: 2026-10-16FIBOCOM WIRELESS
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211317318.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-26
Publication Date
2026-10-16
Estimated Expiration
2042-10-26

AI Technical Summary

Technical Problem

但标志字符XON/XOFF可能在数据流中出现而引起误操作,因此XON/XOFF的方式至少要等待发送一个字节的时间,此时发送的数据无法确认收到,有可能造成数据丢失

Benefits of technology

[0030] As can be seen, this application receives data frames sent by the sender; if the data buffer is full, it returns an acknowledgment data frame carrying a first preset acknowledgment frame identifier to the sender, so that the sender determines the data frame as an unsuccessfully transmitted data frame and stops sending data frames to the receiver; when the full data buffer has available space, it returns an acknowledgment data frame carrying a second preset acknowledgment frame identifier to the sender, so that the sender retransmits the unsuccessfully transmitted data frame. That is, when receiving data frames, if the data buffer is full, this application returns an acknowledgment data frame carrying identifier information to the sender, so that the sender stops sending data; after the data buffer has available space, it returns an acknowledgment data frame carrying identifier information to the sender, so that the sender retransmits the unsuccessfully transmitted data frame. In this way, by receiving data frames and returning acknowledgment data frames, and retransmitting unsuccessfully transmitted data frames when the buffer has available space, data loss can be avoided, ensuring the real-time performance and reliability of data transmission and reception.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115687225B_ABST
    Figure CN115687225B_ABST
Patent Text Reader

Abstract

The application discloses a UART software flow control method, device, equipment and medium, comprising: receiving a data frame sent by a sender; if a data buffer is full, returning an acknowledgement data frame carrying a first preset acknowledgement frame identifier to the sender, so that the sender determines the data frame as an unsuccessfully sent data frame and stops sending data frames to the receiver; and when the full data buffer has available space, returning an acknowledgement data frame carrying a second preset acknowledgement frame identifier to the sender, so that the sender resends the unsuccessfully sent data frame. In this way, by receiving data frames and returning acknowledgement data frames, the unsuccessfully sent data frame is sent again when the buffer has available space, so that data loss is avoided and the real-time performance and reliability of data transmission and reception are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of UART flow control technology, and in particular to UART software flow control methods, apparatus, equipment and media. Background Technology

[0002] UART (Universal Asynchronous Receiver / Transmitter) is a universal serial data bus used for asynchronous communication. It supports bidirectional communication and can achieve full-duplex transmission and reception. Common UART flow control involves adding hardware pins to notify the sender whether data can be transmitted based on the pin's high or low voltage level. For example, the commonly used CTS and RTS pins are used; CTS notifies the receiver that data can be received, and RTS notifies the sender that data can be transmitted. However, this hardware flow control method requires additional hardware support. Without hardware support, serial port flow control is impossible, increasing design costs. Furthermore, because it's hardware flow control, it cannot be used across platforms; each platform requires an adapted driver layer interface.

[0003] Currently, there is a UART software flow control method that sends XON / XOFF characters. When the amount of data in the receiver's input buffer exceeds a set high bit, it sends an XOFF character to the data sender. Upon receiving the XOFF character, the sender immediately stops transmitting data. Conversely, when the amount of data in the receiver's input buffer falls below a set low bit, it sends an XON character to the data sender. Upon receiving the XON character, the sender immediately begins transmitting data. However, the XON / XOFF flag characters may appear in the data stream, causing erroneous operations. Therefore, the XON / XOFF method requires waiting at least one byte to be sent. During this time, the received data cannot be confirmed, potentially leading to data loss. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a UART software flow control method, apparatus, device, and medium that can avoid data loss and ensure the real-time performance and reliability of data transmission and reception. The specific solution is as follows:

[0005] In a first aspect, this application discloses a UART software flow control method applied to a receiver, comprising:

[0006] Receive data frames sent by the sender;

[0007] If the data buffer is full, an acknowledgment data frame carrying a first preset acknowledgment frame identifier is returned to the sender, so that the sender determines the data frame as a data frame that was not successfully sent and stops sending data frames to the receiver.

[0008] When the full data buffer becomes available, an acknowledgment data frame carrying a second preset acknowledgment frame identifier is returned to the sender so that the sender can resend the unsuccessfully sent data frame.

[0009] Optionally, after receiving the data frame sent by the sender, the method further includes:

[0010] If the data buffer is not full, the payload data carried in the data frame is stored in the data buffer, and an acknowledgment data frame carrying the data frame identifier is returned to the sender; wherein, the data frame identifier is the frame identifier carried in the data frame.

[0011] Optionally, before storing the payload data carried in the data frame into the data buffer, the method further includes:

[0012] The data frame identifier is checked for correctness. If the data frame identifier is correct, the step of storing the payload data carried in the data frame into the data buffer is triggered.

[0013] Optional, also includes:

[0014] Receive a synchronization frame sent by the sender; wherein the synchronization frame carries a start data frame identifier;

[0015] An acknowledgment synchronization frame carrying the starting data frame identifier is returned to the sender, so that the sender can send a starting data frame based on the starting data frame identifier, and determine the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

[0016] Optionally, verifying whether the data frame identifier is correct includes:

[0017] Based on the starting data frame identifier and the preset identifier change rule, verify whether the data frame identifier is correct.

[0018] Optionally, the confirmation data frame, the synchronization frame, the confirmation synchronization frame, and the data frame all carry corresponding frame type information.

[0019] Secondly, this application discloses a UART software flow control method, applied to the sender, including:

[0020] Send data frames to the receiver;

[0021] If an acknowledgment data frame carrying a first preset acknowledgment frame identifier is received from the receiver, the data frame is determined to be a data frame that was not successfully sent, and the sending of data frames to the receiver is stopped; wherein, the first preset acknowledgment frame identifier indicates that the receiver's data buffer is full;

[0022] If a confirmation data frame carrying a second preset confirmation frame identifier is received from the receiver, the unsuccessfully transmitted data frame is retransmitted; wherein, the second preset confirmation frame identifier indicates that the data buffer that was full has free space.

[0023] Thirdly, this application discloses a UART software flow control device applied to a receiver, comprising:

[0024] The frame receiving module is used to receive data frames sent by the sender.

[0025] The frame return module is used to return an acknowledgment data frame carrying a first preset acknowledgment frame identifier to the sender if the data buffer is full, so that the sender determines the data frame as a failed data frame and stops sending data frames to the receiver; when the full data buffer has available space, it returns an acknowledgment data frame carrying a second preset acknowledgment frame identifier to the sender, so that the sender retransmits the failed data frame.

[0026] Fourthly, this application discloses an electronic device, including a memory and a processor, wherein:

[0027] The memory is used to store computer programs;

[0028] The processor is used to execute the computer program to implement the aforementioned UART software flow control method.

[0029] Fifthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned UART software flow control method.

[0030] As can be seen, this application receives data frames sent by the sender; if the data buffer is full, it returns an acknowledgment data frame carrying a first preset acknowledgment frame identifier to the sender, so that the sender determines the data frame as an unsuccessfully transmitted data frame and stops sending data frames to the receiver; when the full data buffer has available space, it returns an acknowledgment data frame carrying a second preset acknowledgment frame identifier to the sender, so that the sender retransmits the unsuccessfully transmitted data frame. That is, when receiving data frames, if the data buffer is full, this application returns an acknowledgment data frame carrying identifier information to the sender, so that the sender stops sending data; after the data buffer has available space, it returns an acknowledgment data frame carrying identifier information to the sender, so that the sender retransmits the unsuccessfully transmitted data frame. In this way, by receiving data frames and returning acknowledgment data frames, and retransmitting unsuccessfully transmitted data frames when the buffer has available space, data loss can be avoided, ensuring the real-time performance and reliability of data transmission and reception. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0032] Figure 1 This is a flowchart of a UART software flow control method disclosed in this application;

[0033] Figure 2 This is a schematic diagram of a specific UART software flow control disclosed in this application;

[0034] Figure 3 This is a flowchart of a UART software flow control method disclosed in this application;

[0035] Figure 4 This is a schematic diagram of the structure of a UART software flow control device disclosed in this application;

[0036] Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0037] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0038] Currently, there is a UART software flow control method that sends XON / XOFF characters. When the amount of data in the receiver's input buffer exceeds a set high bit, an XOFF character is sent to the data sender. Upon receiving the XOFF character, the sender immediately stops transmitting data. Conversely, when the amount of data in the receiver's input buffer falls below a set low bit, an XON character is sent to the data sender. Upon receiving the XON character, the sender immediately begins transmitting data. However, the XON / XOFF flags may appear in the data stream, causing erroneous operations. Furthermore, the XON / XOFF method requires waiting at least one byte to be sent, during which time the received data cannot be confirmed, potentially leading to data loss. Therefore, this application provides a UART software flow control method that can avoid data loss and ensure the real-time performance and reliability of data transmission and reception.

[0039] See Figure 1As shown in the figure, this application discloses a UART software flow control method applied to the receiver, including:

[0040] Step S11: Receive the data frame sent by the sender.

[0041] In a specific implementation, this application embodiment may first receive a synchronization frame sent by the sender; wherein the synchronization frame carries a start data frame identifier; and return an acknowledgment synchronization frame carrying the start data frame identifier to the sender, so that the sender sends a start data frame based on the start data frame identifier, and determines the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

[0042] The preset identifier change rule is to increment within a preset numerical range, and after reaching the maximum value of the preset data range, the data frame identifier starts incrementing from the minimum value of the preset numerical range. For example, the initial data frame identifier is 1, the preset numerical range is from 1 to 127, and if it exceeds 127, it starts again from 1.

[0043] Furthermore, after receiving a data frame sent by the sender, if the data buffer is not full, the payload data carried in the data frame is stored in the data buffer, and an acknowledgment data frame carrying the data frame identifier is returned to the sender; wherein, the data frame identifier is the frame identifier carried in the data frame. The payload data consists of the plain data excluding the header.

[0044] Furthermore, before storing the payload data carried in the data frame into the data buffer, this embodiment of the application can verify whether the data frame identifier is correct. If the data frame identifier is correct, the step of storing the payload data carried in the data frame into the data buffer is triggered.

[0045] In one implementation, the correctness of the data frame identifier can be verified based on the starting data frame identifier and the preset identifier change rule. For example, the receiver starts a counter, with the initial value set to the starting data frame identifier carried in the synchronization frame. After each time the payload data carried in the data frame is stored in the data buffer, the value is incremented according to the preset identifier change rule, for example, by 1. After each data frame is received, the value of the counter is compared with the data frame identifier carried in the data frame. If the value of the counter matches the data frame identifier carried in the data frame, the data frame identifier is determined to be correct.

[0046] Step S12: If the data buffer is full, return an acknowledgment data frame carrying the first preset acknowledgment frame identifier to the sender, so that the sender determines the data frame as a data frame that was not successfully sent and stops sending data frames to the receiver.

[0047] The first preset confirmation frame identifier indicates that the receiver's data buffer is full; for example, the first preset confirmation frame identifier is 0.

[0048] Step S13: When the full data buffer becomes available, an acknowledgment data frame carrying a second preset acknowledgment frame identifier is returned to the sender so that the sender can resend the unsuccessfully sent data frame.

[0049] In one implementation, when the free space in the data buffer is greater than a preset threshold, it is determined that the buffer has available space.

[0050] The second preset confirmed frame identifier indicates that the data buffer that was full has free space. The second preset confirmed frame identifier is a different identifier from the first preset confirmed frame identifier. For example, the second preset confirmed frame identifier is -1.

[0051] Furthermore, in this embodiment of the application, the confirmation data frame, the synchronization frame, the confirmation synchronization frame, and the data frame all carry corresponding frame type information.

[0052] In other words, this application embodiment, based on UART communication, redefines the data format and interaction method. Furthermore, the frame definition can be: |Frame Type|Frame ID|Frame Length|Payload Data. Wherein, Frame Type: one byte; Frame ID: one byte; Frame Length: two bytes (optional, only for data frames); Payload Data: data (optional, only for data frames). The following details each frame type:

[0053] Synchronization frame: The starting frame ID used for synchronizing transmission and reception, for example, |0|frame ID|, where 0 indicates that the frame type is a synchronization frame.

[0054] Confirmation synchronization frame: Used to confirm synchronization frames, for example, |1|frame ID|, where 1 indicates that the frame type is a confirmation synchronization frame.

[0055] Data frame: Used to send data, for example, |2|frame ID|frame length|payload data|, where 2 indicates that the frame type is a data frame. Frame ID: The value ranges from 1 to 127. If it exceeds 127, it restarts from 1. It can only start from 1 again after all frames have been acknowledged.

[0056] Data acknowledgment frame: Used to acknowledge received data frames, for example, |3|frame ID|, where 3 indicates the frame type is a data acknowledgment frame. The frame ID is 1-127, representing the ID of the received frame. A frame ID of -1 indicates that data transmission can continue, while a frame ID of 0 indicates that the buffer is full and transmission should stop.

[0057] For example, see Figure 2 As shown, Figure 2This is a schematic diagram of a specific UART software flow control method disclosed in an embodiment of this application. Before transmitting data, the sender first sends a synchronization frame carrying the start data frame identifier, i.e., frame ID 1, to the receiver. The receiver returns an acknowledgment synchronization frame carrying frame ID 1. The sender then sends data frame 1, carrying frame ID 1. The receiver returns acknowledgment data frame 1, carrying frame ID 1. The sender then sends data frame 2, carrying frame ID 2. The receiver returns acknowledgment data frame 2, carrying frame ID 2. The sender then sends data frame 3, carrying frame ID 3. When the receiver's buffer is full, it returns an acknowledgment data frame, carrying frame ID 0. When the buffer is available, it returns an acknowledgment data frame, carrying frame ID -1. The sender then sends data frame 3, and the receiver returns acknowledgment data frame 3.

[0058] As can be seen, in this embodiment, the system receives data frames sent by the sender. If the data buffer is full, an acknowledgment data frame carrying a first preset acknowledgment frame identifier is returned to the sender, so that the sender determines the data frame as an unsuccessfully sent data frame and stops sending data frames to the receiver. When the full data buffer has available space, an acknowledgment data frame carrying a second preset acknowledgment frame identifier is returned to the sender, so that the sender resends the unsuccessfully sent data frame. That is, in this embodiment, when receiving data frames, if the data buffer is full, an acknowledgment data frame carrying identifier information is returned to the sender, so that the sender stops sending data. After the data buffer has available space, an acknowledgment data frame carrying identifier information is returned to the sender, so that the sender resends the unsuccessfully sent data frame. In this way, by receiving data frames and returning acknowledgment data frames, and resending the unsuccessfully sent data frames when the buffer has available space, data loss can be avoided, and the real-time performance and reliability of data transmission and reception can be guaranteed.

[0059] It should be noted that the flow control scheme of this application can be applied to various UART communication scenarios. For example, when using UART to transfer files, if the flash write speed is slower than the UART speed, this flow control scheme can be used. Similarly, when using UART to transfer TCP data, if the TCP transmission speed is slower than the UART speed, this flow control scheme can be used. This application implements UART flow control at the software layer by designing the communication protocol and interaction process. It does not rely on hardware drivers and can be used across platforms, thus saving hardware and software development costs. Furthermore, in some scenarios, software flow control using XON / XOFF methods requires escaping, but this application does not require escaping and can ensure the real-time performance and reliability of data transmission and reception.

[0060] See Figure 3 As shown in the figure, this application discloses a UART software flow control method, applied to the sender, including:

[0061] Step S21: Send a data frame to the receiver.

[0062] In a specific implementation, a synchronization frame can be sent to the receiver first; wherein the synchronization frame carries a start data frame identifier; an acknowledgment synchronization frame carrying the start data frame identifier is obtained from the receiver, and then a start data frame is sent based on the start data frame identifier, and when sending subsequent data frames, the data frame identifier carried by the data frame is determined based on a preset identifier change rule.

[0063] If an acknowledgment data frame carrying a data frame identifier is received from the sender, wherein the data frame identifier is the frame identifier carried in the sent data frame, then another data frame is sent.

[0064] Step S22: If an acknowledgment data frame carrying a first preset acknowledgment frame identifier is received from the receiver, the data frame is determined to be a data frame that was not successfully sent, and the sending of data frames to the receiver is stopped; wherein, the first preset acknowledgment frame identifier indicates that the receiver's data buffer is full.

[0065] Step S23: If a confirmation data frame carrying a second preset confirmation frame identifier is received from the receiver, the unsuccessfully transmitted data frame is retransmitted; wherein, the second preset confirmation frame identifier indicates that the data buffer that was full has free space.

[0066] As can be seen, in this embodiment, a data frame is sent to the receiver; if an acknowledgment data frame carrying a first preset acknowledgment frame identifier is received from the receiver, the data frame is determined to be a failed data frame, and data frame transmission to the receiver is stopped; wherein, the first preset acknowledgment frame identifier indicates that the receiver's data buffer is full; if an acknowledgment data frame carrying a second preset acknowledgment frame identifier is received from the receiver, the failed data frame is retransmitted; wherein, the second preset acknowledgment frame identifier indicates that the full data buffer has free space. That is, in this embodiment, when the receiver receives a data frame, if the data buffer is full, it returns an acknowledgment data frame carrying identifier information to the sender, and the sender stops sending data. After the data buffer has available space, it returns an acknowledgment data frame carrying identifier information to the sender, and the sender retransmits the failed data frame. In this way, by receiving data frames and returning acknowledgment data frames, the sender retransmits the failed data frame when the buffer has available space, which can avoid data loss and ensure the real-time performance and reliability of data transmission and reception.

[0067] See Figure 4 As shown in the figure, this application discloses a UART software flow control device applied to a receiver, comprising:

[0068] Frame receiving module 11 is used to receive data frames sent by the sender;

[0069] The frame return module 12 is used to return an acknowledgment data frame carrying a first preset acknowledgment frame identifier to the sender if the data buffer is full, so that the sender determines the data frame as a data frame that was not successfully sent and stops sending data frames to the receiver; when the full data buffer has available space, it returns an acknowledgment data frame carrying a second preset acknowledgment frame identifier to the sender, so that the sender retransmits the data frame that was not successfully sent.

[0070] As can be seen, in this embodiment, the system receives data frames sent by the sender. If the data buffer is full, an acknowledgment data frame carrying a first preset acknowledgment frame identifier is returned to the sender, so that the sender determines the data frame as an unsuccessfully sent data frame and stops sending data frames to the receiver. When the full data buffer has available space, an acknowledgment data frame carrying a second preset acknowledgment frame identifier is returned to the sender, so that the sender resends the unsuccessfully sent data frame. That is, in this embodiment, when receiving data frames, if the data buffer is full, an acknowledgment data frame carrying identifier information is returned to the sender, so that the sender stops sending data. After the data buffer has available space, an acknowledgment data frame carrying identifier information is returned to the sender, so that the sender resends the unsuccessfully sent data frame. In this way, by receiving data frames and returning acknowledgment data frames, and resending the unsuccessfully sent data frames when the buffer has available space, data loss can be avoided, and the real-time performance and reliability of data transmission and reception can be guaranteed.

[0071] Furthermore, the device also includes a data buffer module, used to store the payload data carried in the data frame into the data buffer if the data buffer is not full after receiving the data frame sent by the sender. Correspondingly, the frame return module 12 is also used to return an acknowledgment data frame carrying a data frame identifier to the sender; wherein the data frame identifier is the frame identifier carried in the data frame.

[0072] Furthermore, the device also includes a frame identifier verification module, which is used to verify whether the data frame identifier is correct before the data caching module stores the payload data carried in the data frame into the data buffer. If the data frame identifier is correct, the data caching module is triggered to perform the step of storing the payload data carried in the data frame into the data buffer.

[0073] Furthermore, the frame receiving module 11 is also used to receive a synchronization frame sent by the sender; wherein the synchronization frame carries a start data frame identifier.

[0074] Correspondingly, the frame return module 12 is also used to return an acknowledgment synchronization frame carrying the starting data frame identifier to the sender, so that the sender can send a starting data frame based on the starting data frame identifier, and determine the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

[0075] In one implementation, the frame identifier verification module is specifically used to verify whether the data frame identifier is correct based on the starting data frame identifier and the preset identifier change rule.

[0076] Furthermore, in one embodiment, the confirmation data frame, the synchronization frame, the confirmation synchronization frame, and the data frame all carry corresponding frame type information.

[0077] See Figure 5 As shown in the figure, this application discloses an electronic device 20, including a processor 21 and a memory 22; wherein, the memory 22 is used to store a computer program; the processor 21 is used to execute the computer program, the UART software flow control method disclosed in the foregoing embodiments.

[0078] For details regarding the specific process of the above-mentioned UART software flow control method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.

[0079] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, and the storage method can be temporary storage or permanent storage.

[0080] In addition, the electronic device 20 also includes a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26; wherein, the power supply 23 is used to provide operating voltage for the various hardware devices on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0081] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the UART software flow control method disclosed in the foregoing embodiments.

[0082] For details regarding the specific process of the above-mentioned UART software flow control method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.

[0083] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0084] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0085] The above provides a detailed description of the UART software flow control method, apparatus, device, and medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A UART software flow control method, characterized in that, Applied to the recipient, including: Receive data frames sent by the sender; If the data buffer is full, an acknowledgment data frame carrying a first preset acknowledgment frame identifier is returned to the sender, so that the sender determines the data frame as a data frame that was not successfully sent and stops sending data frames to the receiver. When the full data buffer becomes available, an acknowledgment data frame carrying a second preset acknowledgment frame identifier is returned to the sender so that the sender can resend the unsuccessfully sent data frame. The method further includes: receiving a synchronization frame sent by the sender; wherein the synchronization frame carries a start data frame identifier; returning an acknowledgment synchronization frame carrying the start data frame identifier to the sender, so that the sender sends a start data frame based on the start data frame identifier, and determines the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

2. The UART software flow control method according to claim 1, characterized in that, After receiving the data frame sent by the sender, the method further includes: If the data buffer is not full, the payload data carried in the data frame is stored in the data buffer, and an acknowledgment data frame carrying the data frame identifier is returned to the sender; wherein, the data frame identifier is the frame identifier carried in the data frame.

3. The UART software flow control method according to claim 2, characterized in that, Before storing the payload data carried in the data frame into the data buffer, the method further includes: The data frame identifier is checked for correctness. If the data frame identifier is correct, the step of storing the payload data carried in the data frame into the data buffer is triggered.

4. The UART software flow control method according to claim 3, characterized in that, The step of verifying whether the data frame identifier is correct includes: Based on the starting data frame identifier and the preset identifier change rule, verify whether the data frame identifier is correct.

5. The UART software flow control method according to claim 3, characterized in that, The confirmation data frame, the synchronization frame, the confirmation synchronization frame, and the data frame all carry corresponding frame type information.

6. A UART software flow control method, characterized in that, Applied to the sender, including: Send data frames to the receiver; If an acknowledgment data frame carrying a first preset acknowledgment frame identifier is received from the receiver, the data frame is determined to be a data frame that was not successfully sent, and the sending of data frames to the receiver is stopped; wherein, the first preset acknowledgment frame identifier indicates that the receiver's data buffer is full; If a confirmation data frame carrying a second preset confirmation frame identifier is received from the receiver, the unsuccessfully transmitted data frame is retransmitted; wherein, the second preset confirmation frame identifier indicates that the data buffer that was full has free space. The method further includes: sending a synchronization frame to the receiver; wherein the synchronization frame carries a start data frame identifier; obtaining an acknowledgment synchronization frame returned by the receiver carrying the start data frame identifier; sending a start data frame based on the start data frame identifier; and determining the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

7. A UART software flow control device, characterized in that, Applied to the recipient, including: The frame receiving module is used to receive data frames sent by the sender. The frame return module is used to return an acknowledgment data frame carrying a first preset acknowledgment frame identifier to the sender if the data buffer is full, so that the sender determines the data frame as a data frame that was not successfully sent and stops sending data frames to the receiver; when the full data buffer has available space, it returns an acknowledgment data frame carrying a second preset acknowledgment frame identifier to the sender, so that the sender retransmits the data frame that was not successfully sent. The apparatus is further configured to: receive a synchronization frame sent by the sender; wherein the synchronization frame carries a start data frame identifier; and return an acknowledgment synchronization frame carrying the start data frame identifier to the sender, so that the sender sends a start data frame based on the start data frame identifier, and determines the data frame identifier carried by the data frame based on a preset identifier change rule when sending subsequent data frames.

8. An electronic device, characterized in that, Includes memory and processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the UART software flow control method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the UART software flow control method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • High-reliability transmission method for wireless sensor network

    CN103929284A