Double-buffer data communication method
By employing a double-buffered data communication method and dynamic switching between the master and slave communication buses, the problem of resource access conflicts in multi-bus communication systems is resolved, achieving efficient and reliable data transmission.
Patent Information
- Application Number
- CN202511847990.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-02-06
AI Technical Summary
In multi-bus communication systems, when data processing devices are simultaneously receiving and forwarding data, resource access conflicts can easily lead to decreased data transmission efficiency or even data errors, affecting system performance and reliability.
A dual-buffer data communication method is adopted, which ensures the integrity and reliability of data transmission by coordinating the control of the receive buffer and the transmit buffer and dynamically switching the master and slave communication buses.
It effectively solves the access conflict problem in the data reception and transmission process, and ensures highly reliable and conflict-free continuous data communication in complex network environments.
Smart Images

Figure CN121486447A_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to the field of computer technology, and specifically to a double-buffered data communication method. Background Technology
[0002] In applications requiring high-reliability communication, such as airborne equipment, a multi-bus architecture combining a primary communication channel and an auxiliary channel is typically used to improve system robustness. When the primary communication channel fails, the system can switch to the auxiliary channel to continue data transmission, ensuring that the communication link is not interrupted.
[0003] However, in the actual operation of such multi-bus communication systems, when data processing devices simultaneously perform data reception and forwarding operations, data transmission efficiency can easily decrease or even become corrupted due to resource access conflicts. This concurrent access conflict problem restricts the performance and reliability of the system in continuous data transmission scenarios and is a key deficiency that urgently needs to be addressed in existing technologies. Summary of the Invention
[0004] In view of the above-mentioned defects or deficiencies in the prior art, it is desirable to provide a double-buffered data communication method to solve the above problems.
[0005] This application provides a double-buffered data communication method, including: Receive data blocks from the data sending device and verify each received data block; Based on the verification results, control information is fed back to the data sending device to manage the retransmission of data blocks or the switching of communication channels; The verified data blocks are stored in the receive buffer, and the status of the completion flag is updated based on the integrity of the data blocks in the receive buffer; the completion flag is used to indicate whether all data blocks from the data transmitting device have been completely and correctly stored in the receive buffer. Based on the coordinated state of the collection flag and the transmission flag, the process of copying data from the receive buffer to the transmission buffer is controlled; the transmission flag is used to indicate whether data is being transmitted to the data receiving device. Sending data blocks in the transmit buffer to the data receiving device; and processing feedback information from the data receiving device to manage the retransmission of data blocks sent to the device or the switching of communication channels.
[0006] According to the technical solution provided in the embodiments of this application, the verification of each received data block includes: Parse the header area of the data packet, calculate the checksum based on the header content using the XOR sum method, and compare the calculated checksum with the checksum in the header area. At the same time, compare whether the length of the received data packet is consistent with the length of the data packet declared in the header area.
[0007] According to the technical solution provided in the embodiments of this application, the step of feeding back control information to the data sending device based on the verification result includes: If the verification is successful and the data packet length is consistent, a verification success message will be returned. If a verification error occurs or the data packet length is inconsistent, a resend request message will be sent. If the number of resend requests for the same data block exceeds a preset threshold, a channel switching request will be sent.
[0008] According to the technical solution provided in the embodiments of this application, controlling the data copying process based on the coordinated state of the collection flag and the transmission flag includes: When the data collection flag indicates that the data has been collected and the transmission flag indicates that the data is not in the transmission state, the operation of copying the data in the receive buffer to the transmission buffer is performed, and the transmission flag is updated to the transmission state after the copying is completed.
[0009] According to the technical solution provided in the embodiments of this application, if the receive buffer is updated due to the receipt of a new data block while waiting for the send flag to become an unsent state, the collection flag is reset to an uncollected state.
[0010] According to the technical solution provided in the embodiments of this application, the processing of feedback information from the data receiving device includes: If a valid verification message is received, continue sending the next data block; If a retransmission request is received, the current data block will be retransmitted. If the number of retransmission requests for the same data block exceeds a preset threshold, a channel switching request is sent to the data receiving device 300, and the current data block is retransmitted through the auxiliary communication channel.
[0011] According to the technical solution provided in the embodiments of this application, during the process of receiving data blocks and sending data blocks, the communication status of the main communication bus is periodically determined, and when the main communication bus is abnormal, the corresponding auxiliary communication bus is switched to transmit data.
[0012] According to the technical solution provided in the embodiments of this application, during the process of storing the verified data block into the receiving buffer, if the sending flag indicates that it is not in the sending state, the process waits until the data collection flag indicates that the data has been collected before starting the operation of copying the data in the receiving buffer to the sending buffer.
[0013] According to the technical solution provided in the embodiments of this application, the state of updating the completion flag based on the integrity of the data blocks in the receiving buffer includes: Count the number of data blocks that have been correctly received and stored in the receive buffer; Compare the number of data blocks with the total number of packets declared in the data packet header area; When both are consistent, the collection flag is updated to indicate that the data has been collected.
[0014] Compared with the prior art, the beneficial effects of this application are as follows: by setting up a receive buffer and a transmit buffer, and by using the coordinated state of the receive flag and the transmit flag to control the timing of data copying from the receive buffer to the transmit buffer, the access conflict problem in the data receiving and transmitting process is effectively solved; by verifying data block by block and using a feedback mechanism based on the verification result, the integrity of data transmission is ensured; and by combining the dynamic switching capability of the master and slave communication buses, communication is guaranteed to be uninterrupted when a single channel is abnormal, thereby achieving highly reliable and conflict-free continuous data communication in complex network environments. Attached Figure Description
[0015] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 A flowchart illustrating the steps of the double-buffered data communication method provided in this application; Figure 2 This is a schematic diagram of a multi-bus data transmission system. Figure 3 This is a software architecture diagram of a data processing device. Figure 4 This is a schematic diagram of the data packet structure for the calculation results; Figure 5 To verify the data packet structure of the results; Figure 6 This is a schematic diagram of a dual data buffer structure.
[0016] Reference numerals: 100, Data transmitting device; 200, Data processing device; 210, Bus communication module; 220, Data processing module; 221, System management submodule; 222, Data processing submodule; 223, Buffer management submodule; 224, Receive buffer; 225, Transmit buffer; 300, Data receiving device; 410, First main communication bus; 420, Second main communication bus; 510, First auxiliary communication bus; 520, Second auxiliary communication bus. Detailed Implementation
[0017] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0018] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0019] Please refer to Figure 1 This application provides a double-buffered data communication method for use in multi-bus data transmission systems.
[0020] The structure of the system is as follows Figure 2 As shown in the figure. The system includes a data transmitting device 100, a data processing device 200, and a data receiving device 300. The data processing device 200 serves as the execution entity for the double-buffered data communication method. The data processing device 200 is communicatively connected to the data transmitting device 100 via a first main communication bus 410 and a first auxiliary communication bus 510, and is communicatively connected to the data receiving device 300 via a second main communication bus 420 and a second auxiliary communication bus 520. In this embodiment, the data transmitting device 100 is a general-purpose computing device, and the data receiving device 300 is a comprehensive display device. The software architecture of the system is as follows: Figure 3 As shown, the system software runs on the data processing device 200 and mainly includes a bus communication module 210 and a data processing module 220. The data processing module 220 further includes a system management submodule 221, a buffer management submodule 223, and a data processing submodule 222.
[0021] The double-buffer data communication method includes: S1: Receive data blocks from data transmitting device 100 and verify each received data block.
[0022] Specifically, step S1 is executed collaboratively by the bus communication module 210 and the data processing submodule 222. In this step, the data transmitting device 100 generates the calculation result data and divides the data into N data blocks. The structure of each data block is as follows: Figure 4 As shown, it includes a header area and a data area. The header area includes a header flag, data sequence number, total number of packets, data length of this packet, and checksum, while the data area includes the data content. The bus communication module 210 is responsible for receiving data blocks sent by the data sending device 100 through the first main communication bus 410 or the first auxiliary communication bus 510; then, the data processing submodule 222 verifies each received data block.
[0023] S2: Based on the verification result, control information is fed back to the data sending device 100 to manage the retransmission of data blocks or the switching of communication channels.
[0024] Specifically, step S2 is executed collaboratively by the data processing submodule 222 and the bus communication module 210. In this step, the data processing submodule 222 verifies each received data block and generates corresponding control information; the bus communication module 210 is responsible for sending a verification result data packet containing control information to the data generating device through the first main communication bus 410 or the first auxiliary communication bus 510, thereby managing the retransmission of data blocks or the switching of communication channels. The verification result data packet is as follows: Figure 5 As shown, it includes packet header information, data sequence number, total number of packets, channel type, and verification results.
[0025] S3: Store the correctly verified data blocks into the receive buffer 224, and update the status of the completion flag based on the integrity of the data blocks in the receive buffer 224; the completion flag is used to indicate whether all data blocks from the data transmitting device 100 have been completely and correctly stored into the receive buffer 224.
[0026] Specifically, step S3 is executed by the buffer management submodule 223, which manages the dual data buffers. The dual data buffers include a receive buffer 224 and a transmit buffer 225, and the structures of the receive buffer 224 and the transmit buffer 225 are as follows: Figure 6 As shown. In this step, the correctly verified data blocks are stored in the receive buffer 224; the buffer management submodule 223 maintains a collection flag, which indicates whether all data blocks from the data transmitting device 100 have been completely and correctly stored in the receive buffer 224. When the total number of received data blocks matches the total number of packets in the data packet header area and each data packet is correctly verified, it is determined that all data has been collected, and the status of the collection flag is updated.
[0027] S4: Based on the coordinated state of the collection flag and the transmission flag, control the copying process of data in the receive buffer 224 to the transmission buffer 225; the transmission flag is used to indicate whether data is being transmitted to the data receiving device 300.
[0028] Specifically, step S4 is executed by the buffer management submodule 223. The buffer management submodule 223 also maintains a transmit flag to indicate whether data is being transmitted to the data receiving device 300. In this step, the buffer management submodule 223 detects the coordination state of the receive flag and the transmit flag in real time, and based on this coordination state, decides and executes the process of copying the data in the receive buffer to the transmit buffer 225.
[0029] S5: Send the data block in the transmission buffer 225 to the data receiving device 300; and process the feedback information from the data receiving device 300 to manage the retransmission of data blocks sent to the device or the switching of communication channels.
[0030] Specifically, step S5 is executed collaboratively by the bus communication module 210 and the data processing submodule 222. In this step, the bus communication module 210 is responsible for sending the data blocks in the transmit buffer 225 to the data receiving device 300 via the second main communication bus 420 or the second auxiliary communication bus 520; at the same time, the bus communication module 210 receives feedback information from the data receiving device 300, which is then processed by the data processing submodule 222 to manage the retransmission of data blocks destined for that device or the switching of communication channels.
[0031] Furthermore, the verification of each received data block in step S1 includes: Parse the header area of the data packet, calculate the checksum based on the header content using the XOR sum method, and compare the calculated checksum with the checksum in the header area. At the same time, compare whether the length of the received data packet is consistent with the length of the data packet declared in the header area.
[0032] Specifically, after receiving a data block, the data processing submodule 222 first parses the header area of the data packet. The header area contains a pre-calculated checksum and a declared data length for this packet. Next, the data processing submodule 222 recalculates the checksum based on the contents of the header area using an XOR summation method. The specific calculation process is as follows: starting from the beginning of the header area, each byte in the header area and the data area is XORed bitwise, accumulating to obtain a final checksum value. Then, the data processing submodule 222 compares the calculated checksum with the original checksum parsed from the header area, and compares the actual received data packet length with the declared data length in the header area. Only when the results of the two comparisons are completely consistent is the data block considered to be correctly checked.
[0033] Furthermore, the step of feeding back control information to the data sending device 100 based on the verification result includes: If the verification is successful and the data packet length is consistent, a verification success message will be returned. If a verification error occurs or the data packet length is inconsistent, a resend request message will be sent. If the number of resend requests for the same data block exceeds a preset threshold, a channel switching request will be sent.
[0034] Specifically, the data processing submodule 222 generates the following three types of control information based on the verification results of each data block, and encapsulates them through the bus communication module 210 as follows: Figure 5 The verification result data packet shown is sent back to the data sending device 100: When the data processing submodule 222 determines that the data block verification is correct and the length of the received data packet matches the declared value, it generates a verification success message. After receiving this message, the data sending device 100 will continue to send the next data block; When the data processing submodule 222 determines that there is a data block verification error or that the length of the received data packet is inconsistent with the declared value, it generates a retransmission request message. Upon receiving this message, the data sending device will retransmit the current data block. To ensure transmission reliability, the system presets a retransmission threshold, which is 3 times in this embodiment. If the number of retransmission requests for the same data block exceeds this preset threshold, it indicates that the quality of the current communication channel may be severely degraded, and the data processing submodule 222 generates a channel switching request message. After receiving this message, the data transmitting device 100 will immediately switch from the currently used first main communication bus 410 to the first auxiliary communication bus 510 and retransmit the currently blocked data block.
[0035] Furthermore, controlling the data copying process based on the coordinated state of the collection flag and the transmission flag includes: When the data collection flag indicates that the data has been collected and the transmission flag indicates that the data is not in the transmission state, the operation of copying the data in the receive buffer 224 to the transmission buffer 225 is performed, and the transmission flag is updated to the transmission state after the copying is completed.
[0036] Specifically, the buffer management submodule 223 continuously monitors the status of its maintained collection flag and transmission flag, and precisely controls the timing of data copying from the receive buffer 224 to the transmit buffer 225 based on their coordinated status. The buffer management submodule 223 immediately initiates the copying operation when both of the following conditions are met: The data collection flag indicates that all data blocks from the data transmitting device 100 have been completely and correctly stored in the receive buffer 224.
[0037] The transmit flag indicates that the device is not in a transmit state: This means that no data is currently being transmitted to the data receiving device 300, and the transmit buffer 225 is idle.
[0038] After the copy operation is completed, the buffer management submodule 223 updates the send flag to the send status. This flag update indicates that the send buffer 225 has been loaded with complete data to be sent, and the system enters the data forwarding stage. At the same time, it effectively locks the receive buffer 224 to prevent new data write operations from overwriting data that has not yet been sent during the process of sending data 100 to downstream devices, thereby fundamentally avoiding data transmission and reception conflicts.
[0039] Furthermore, while waiting for the transmit flag to become untransmitted, if the receive buffer 224 is updated due to the receipt of a new data block, the completeness flag is reset to the uncompleted state.
[0040] Specifically, when the data processing device 200 is preparing to copy the data from the receiving buffer 224 to the sending buffer 225, if the buffer management submodule 223 detects that the data collection flag indicates that the data has been collected, but the sending flag indicates that the data is in the sending state, the system enters a waiting state and suspends the copying operation. During the process of the waiting-to-send flag changing to the non-send state, if the data sending device 100 receives a new data block, verifies it, and stores it in the receive buffer 224, the data in the receive buffer 224 will be updated. At this time, the buffer management submodule 223 will immediately reset the collection flag to the non-collection state.
[0041] Furthermore, the processing of feedback information from the data receiving device 300 includes: If a valid verification message is received, continue sending the next data block; If a retransmission request is received, the current data block will be retransmitted. If the number of retransmission requests for the same data block exceeds a preset threshold, a channel switching request is sent to the data receiving device 300, and the current data block is retransmitted through the auxiliary communication channel.
[0042] Specifically, the data processing submodule 222 parses the verification result data packet from the data receiving device 300 and executes the following three processing strategies based on the feedback content: If a normal verification message is received, it indicates that the current data block has been correctly received by the data receiving device 300. The data processing submodule 222 then instructs the bus communication module 210 to continue sending the next data block in the transmission buffer 225.
[0043] If a retransmission request is received, it indicates that the data receiving device 300 has failed to verify the current data block. The data processing submodule 222 then instructs the bus communication module 210 to retransmit the same data block.
[0044] If the number of retransmission requests for the same data block exceeds a preset threshold (3 times in this embodiment), it indicates that the communication quality of the second main communication bus 420 may be severely degraded. At this time, the data processing submodule 222 executes a channel switching procedure: first, it sends a channel switching request data packet to the data receiving device 300 via the bus communication module 210; after receiving the switching confirmation from the data receiving device 300, it immediately switches to the second auxiliary communication bus 520 to retransmit the currently blocked data block.
[0045] Furthermore, during the process of receiving data blocks and sending data blocks, the communication status of the main communication bus is periodically determined, and when the main communication bus is abnormal, the system switches to the corresponding auxiliary communication bus for data transmission.
[0046] Specifically, the system management submodule 221 periodically triggers a diagnostic check of the main communication bus status through a preset timing mechanism. This diagnostic process is performed separately for the communication links in both directions: in the receiving direction, the status of the first main communication bus 410 is diagnosed; in the transmitting direction, the status of the second main communication bus 420 is diagnosed.
[0047] According to the instructions, the bus communication module 210 performs a channel switching operation. If the first main communication bus 410 is abnormal, it will switch the channel that receives data from the data sending device 100 to the first auxiliary communication bus 510. If the second main communication bus 420 is abnormal, it will switch the channel that sends data to the data receiving device 300 to the second auxiliary communication bus 520.
[0048] Furthermore, during the process of storing the correctly verified data block into the receive buffer 224, if the send flag indicates that it is not in the send state, it waits until the data collection flag indicates that the data has been collected before starting the operation of copying the data in the receive buffer 224 to the send buffer 225.
[0049] Specifically, when the buffer management submodule 223 stores the correctly verified data block into the receive buffer 224, it monitors the status of the transmit flag in real time. If the transmit flag indicates that it is not in the transmit state, but the data completion flag does not indicate that the data has been fully received, it means that the data in the current batch has not been fully received. In this case, the buffer management submodule 223 will not immediately start the copying operation, but will enter a waiting state. It will continuously monitor the status change of the data completion flag and wait until the data completion flag indicates that all data blocks from the data transmitting device have been completely and correctly stored in the receive buffer 224. Once the data completion flag changes to indicate that the data has been fully received, the buffer management submodule 223 will immediately start the operation of copying all the data in the receive buffer 224 to the transmit buffer 225. This control logic ensures that in scenarios where the transmit channel is idle but the received data is not yet complete, the system can wait for the data to be fully received before performing batch forwarding, avoiding invalid or erroneous data transmission due to incomplete data, and further optimizing the efficiency and accuracy of data processing.
[0050] Furthermore, the update of the completion flag based on the integrity of the data blocks in the receive buffer 224 includes: Count the number of data blocks that have been correctly received and stored in the receive buffer 224; Compare the number of data blocks with the total number of packets declared in the data packet header area; When both are consistent, the collection flag is updated to indicate that the data has been collected.
[0051] Specifically, this process is executed by the buffer management submodule 223: The buffer management submodule 223 accurately determines data integrity and updates the collection flag through three consecutive steps. First, it counts the number of data blocks that have been correctly received and stored in the receive buffer 224, accumulating the count each time a data block is successfully stored. Then, it compares this count with the total number of packets declared in the data packet header area, parsing the total number of packets in each data packet header as the comparison benchmark. Only when the count is completely consistent with the declared total number of packets will the buffer management submodule 223 update the collection flag to indicate that the data has been collected. This strict determination mechanism provides a key guarantee for ensuring the integrity of data transmission.
[0052] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.
Claims
1. A double-buffered data communication method, characterized in that, include: Receive data blocks from the data transmitting device (100) and verify each received data block; Based on the verification results, control information is fed back to the data sending device (100) to manage the retransmission of data blocks or the switching of communication channels; The data blocks that have been verified are stored in the receive buffer (224), and the status of the collection flag is updated based on the integrity of the data blocks in the receive buffer (224); the collection flag is used to indicate whether all data blocks from the data transmitting device (100) have been completely and correctly stored in the receive buffer (224). Based on the coordinated state of the collection flag and the transmission flag, the process of copying data from the receive buffer (224) to the transmission buffer (225) is controlled; the transmission flag is used to indicate whether data is being transmitted to the data receiving device (300); Sending data blocks in the transmit buffer (225) to the data receiving device (300); and processing feedback information from the data receiving device (300) to manage the retransmission of data blocks sent to the device or the switching of communication channels.
2. The double-buffered data communication method according to claim 1, characterized in that, The verification of each received data block includes: Parse the header area of the data packet, calculate the checksum based on the header content using the XOR sum method, and compare the calculated checksum with the checksum in the header area. At the same time, compare whether the length of the received data packet is consistent with the length of the data packet declared in the header area.
3. The double-buffered data communication method according to claim 1, characterized in that, The control information fed back to the data sending device (100) based on the verification result includes: If the verification is successful and the data packet length is consistent, a verification success message will be returned. If a verification error occurs or the data packet length is inconsistent, a resend request message will be sent. If the number of resend requests for the same data block exceeds a preset threshold, a channel switching request will be sent.
4. The double-buffered data communication method according to claim 1, characterized in that, The control of the data copying process based on the coordinated state of the collection flag and the transmission flag includes: When the data collection flag indicates that the data has been collected and the sending flag indicates that the data is not in the sending state, the operation of copying the data in the receiving buffer (224) to the sending buffer (225) is performed, and the sending flag is updated to the sending state after the copying is completed.
5. The double-buffer data communication method according to claim 4, characterized in that, While waiting for the send flag to become unsendable, if the receive buffer 224 is updated due to the receipt of a new data block, the completeness flag is reset to the uncompleted state.
6. The double-buffered data communication method according to claim 1, characterized in that, The processing of feedback information from the data receiving device (300) includes: If a valid verification message is received, continue sending the next data block; If a retransmission request is received, the current data block will be retransmitted. If the number of retransmission requests for the same data block exceeds a preset threshold, a channel switching request is sent to the data receiving device 300, and the current data block is retransmitted through the auxiliary communication channel.
7. The double-buffered data communication method according to claim 1, characterized in that, During the process of receiving and sending data blocks, the communication status of the main communication bus is periodically determined, and when the main communication bus is abnormal, the system switches to the corresponding auxiliary communication bus for data transmission.
8. The double-buffered data communication method according to claim 4 or 5, characterized in that, During the process of storing the verified data block into the receive buffer (224), if the send flag indicates that it is not in the send state, it waits until the data collection flag indicates that the data has been collected before starting the operation of copying the data in the receive buffer 224 to the send buffer (225).
9. As described in claim 9, characterized in that, The state of updating the completion flag based on the integrity of the data blocks in the receive buffer (224) includes: Count the number of data blocks that have been correctly received and stored in the receive buffer (224); Compare the number of data blocks with the total number of packets declared in the data packet header area; When both are consistent, the collection flag is updated to indicate that the data has been collected.