A data transmission method and device for a ring buffer and related equipment

CN122654034APending Publication Date: 2026-08-28SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510237527.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0004]本发明实施例的目的是提供一种环形缓冲区的数据传输方法、装置及相关设备,以解决相关技术中一旦环形缓冲区中某个数据包中的长度信息填充错误时,会导致环形缓冲区中的所有数据包均不可用的技术问题

Benefits of technology

[0037] Beneficial effects: In this invention, when the software side stores the updated tail pointer's actual position in the target circular buffer to the cache unit, the hardware side reads the tail pointer's actual position in the target circular buffer from the cache unit to obtain the first position. Then, the hardware side determines the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer to obtain the second position. If the hardware side determines that the second position and the first position are consistent, the target data packet is transmitted, and the head pointer is updated. If the hardware side determines that the second position and the first position are inconsistent, the target data packet is discarded, and the head pointer is updated. Finally, the hardware side stores the updated head pointer in a register so that the software side can determine the data filling state of the target circular buffer based on the head pointer and the tail pointer, and perform corresponding operation processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122654034A_ABST
    Figure CN122654034A_ABST
Patent Text Reader

Abstract

The application provides a data transmission method and device of a ring buffer and related equipment, and belongs to the technical field of computers. The method comprises the following steps: when a software side stores an actual pointing position of an updated tail pointer in a target ring buffer in a cache unit, a hardware side reads the actual pointing position of the tail pointer in the target ring buffer from the cache unit to obtain a first position, and determines an expected pointing position of the tail pointer in the target ring buffer to obtain a second position; if the two positions are consistent, a target data packet is transmitted, and a head pointer is updated; if the two positions are inconsistent, the target data packet is discarded, and the head pointer is updated; and a software side performs corresponding operation processing according to a data filling state of the target ring buffer. Through the method, the technical problem that, in related technologies, once the length information in a certain data packet in the ring buffer is filled with errors, all data packets in the ring buffer become unusable can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a data transmission method, apparatus, and related equipment using a circular buffer. Background Technology

[0002] A circular buffer is a fixed-size, contiguous buffer data structure commonly used to cache data streams. In computer applications, the software and hardware typically use a tail pointer and a head pointer, respectively, to update and maintain the circular buffer. The tail pointer manages data read operations, while the head pointer manages data write operations.

[0003] In related technologies, the hardware determines the specific information of a data packet in the circular buffer solely based on the positions of the head and tail pointers within the buffer. However, this approach is problematic because if the data length information of a data packet is incorrectly filled, it can disrupt the normal operation of other data packets in the circular buffer, potentially rendering all data packets in the buffer unusable. Currently, there is no effective solution to this technical problem. Summary of the Invention

[0004] The purpose of this invention is to provide a data transmission method, apparatus, and related equipment for a circular buffer, so as to solve the technical problem in the related art that if the length information of a data packet in a circular buffer is filled incorrectly, all data packets in the circular buffer will become unusable.

[0005] To address the aforementioned technical problems, this invention provides a data transmission method using a circular buffer, applied on the hardware side; comprising:

[0006] When the software stores the updated tail pointer's actual position in the target circular buffer into the cache unit, the actual position of the tail pointer in the target circular buffer is read from the cache unit to obtain the first position;

[0007] The expected position of the tail pointer in the target circular buffer is determined based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, thus obtaining the second position;

[0008] If the second position matches the first position, then the target data packet is transmitted and the header pointer is updated;

[0009] If the second position is inconsistent with the first position, the target data packet is discarded and the header pointer is updated;

[0010] The updated head pointer is stored in a register so that the software side can determine the data filling state of the target circular buffer based on the head pointer and the tail pointer, and perform the corresponding operation processing.

[0011] On the one hand, the length of the target data packet can be adjusted according to user needs.

[0012] On the other hand, after discarding the target data packet, the method further includes:

[0013] The error information of the target data packet is reported, and the header information of the target data packet is stored in the log.

[0014] On the other hand, the cache unit is specifically a first-in-first-out queue.

[0015] To address the aforementioned technical problems, this invention also provides a data transmission method using a circular buffer, applied on the software side, comprising:

[0016] The updated tail pointer's actual position in the target circular buffer is stored in a cache unit. The hardware then reads the actual position of the tail pointer in the target circular buffer from the cache unit to obtain a first position. Based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, the expected position of the tail pointer in the target circular buffer is determined to obtain a second position. If the hardware determines that the second position matches the first position, the target data packet is transmitted, and the head pointer is updated. If the hardware determines that the second position does not match the first position, the target data packet is discarded, and the head pointer is updated.

[0017] When the hardware stores the updated head pointer into the register, it determines the data filling state of the target circular buffer based on the head pointer and the tail pointer, and performs the corresponding operation processing.

[0018] On one hand, storing the updated tail pointer at its actual location in the target circular buffer into the cache unit includes:

[0019] The target circular buffer is initialized.

[0020] Data packets are generated based on the remaining space in the target circular buffer, and the generated data packets are then filled into the target circular buffer.

[0021] The tail pointer is updated, and the updated tail pointer is stored in the cache unit at the actual position it points to in the target circular buffer.

[0022] On the other hand, the step of determining the data filling state of the target circular buffer based on the head pointer and the tail pointer, and performing the corresponding operation processing, includes:

[0023] If the target circular buffer is determined to be full based on the positions of the head pointer and the tail pointer in the target circular buffer, then the data filling process for the target circular buffer is stopped.

[0024] If the target circular buffer is determined to be in a state of incomplete data based on the position pointed to by the head pointer and the position pointed to by the tail pointer in the target circular buffer, then the step of generating a data packet based on the remaining space of the target circular buffer and filling the target circular buffer with the generated data packet continues.

[0025] On the other hand, it also includes:

[0026] Determine whether the position following the position pointed to by the tail pointer in the target circular buffer is consistent with the position pointed to by the head pointer in the target circular buffer;

[0027] If the position following the position pointed to by the tail pointer in the target circular buffer is inconsistent with the position pointed to by the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be in a state where the data is not filled.

[0028] If the position following the position pointed to by the tail pointer in the target circular buffer is the same as the position pointed to by the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be full, and the available storage space on the software side is determined according to user needs. An expanded circular buffer; ;

[0029] The target circular buffer and The expanded circular buffer is determined to be a set of circular buffers;

[0030] Determine the number of circular buffers in the set that are not yet filled with data to obtain the target number;

[0031] If the target number is greater than 1, then the release of data from the circular buffers in the circular buffer set is prohibited.

[0032] If the target quantity is equal to 1, then release the ring buffers in the ring buffer set that have empty storage space.

[0033] To address the aforementioned technical problems, the present invention also provides a data transmission device with a circular buffer, comprising:

[0034] Memory, used to store computer programs;

[0035] A processor for executing the computer program to implement the steps of a data transfer method for a circular buffer as disclosed above.

[0036] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of a data transmission method for a circular buffer as disclosed above.

[0037] Beneficial effects: In this invention, when the software side stores the updated tail pointer's actual position in the target circular buffer to the cache unit, the hardware side reads the tail pointer's actual position in the target circular buffer from the cache unit to obtain the first position. Then, the hardware side determines the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer to obtain the second position. If the hardware side determines that the second position and the first position are consistent, the target data packet is transmitted, and the head pointer is updated. If the hardware side determines that the second position and the first position are inconsistent, the target data packet is discarded, and the head pointer is updated. Finally, the hardware side stores the updated head pointer in a register so that the software side can determine the data filling state of the target circular buffer based on the head pointer and the tail pointer, and perform corresponding operation processing.

[0038] In the data transmission method described in this invention, the hardware side can determine the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer. Furthermore, it stores the actual position of the tail pointer in the target circular buffer using a buffer unit. This allows the hardware side to verify the expected position of the tail pointer in the target circular buffer using the actual position of the tail pointer. If the verification passes, it indicates that the length information of the target data packet is correctly filled, and the hardware side can continue transmitting the target data packet. If the verification fails, it indicates that the length information of the target data packet is incorrectly filled, and the hardware side can discard the target data packet. This configuration allows for automatic error correction of data packets in the circular buffer, enhancing the robustness of data interaction between the software and hardware sides, and preventing the problem that an incorrect length information filling of a data packet in the circular buffer would render all data packets in the circular buffer unusable.

[0039] Correspondingly, the other data transmission method for a circular buffer, as well as the data transmission device, equipment, medium, and computer program product for a circular buffer provided by the present invention, also have the above-mentioned beneficial effects. Attached Figure Description

[0040] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 A flowchart illustrating a data transmission method using a circular buffer, as provided in an embodiment of the present invention;

[0042] Figure 2 The structure diagram of the target circular buffer;

[0043] Figure 3 This is a diagram illustrating how the head and tail pointers are managed via registers on both the software and hardware sides.

[0044] Figure 4 A schematic diagram of the target data packet in the target circular buffer;

[0045] Figure 5 A flowchart illustrating another data transmission method using a circular buffer provided in an embodiment of the present invention;

[0046] Figure 6 A flowchart illustrating data interaction between the software and hardware sides within a circular buffer.

[0047] Figure 7 A schematic diagram illustrating the principle of data interaction between the software and hardware sides in a circular buffer, provided as an embodiment of the present invention.

[0048] Figure 8 This is a structural diagram of a data transmission device with a circular buffer provided in an embodiment of the present invention;

[0049] Figure 9 A structural diagram of another data transmission device with a circular buffer provided in an embodiment of the present invention;

[0050] Figure 10 This is a structural diagram of a data transmission device with a circular buffer provided in an embodiment of the present invention. Detailed Implementation

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

[0052] The terms "comprising" and "having," and any variations thereof, in the specification and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may include steps or units not listed.

[0053] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0054] Please see Figure 1 , Figure 1 A flowchart of a data transmission method using a circular buffer provided in an embodiment of the present invention, the method being applied to the hardware side, including:

[0055] Step S11: When the software stores the updated tail pointer's actual position in the target circular buffer into the cache unit, the actual position of the tail pointer in the target circular buffer is read from the cache unit to obtain the first position;

[0056] Step S12: Determine the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, and obtain the second position;

[0057] Step S13: If the second position matches the first position, then transmit the target data packet and update the header pointer;

[0058] Step S14: If the second position is inconsistent with the first position, discard the target data packet and update the header pointer;

[0059] Step S15: Store the updated head pointer in the register so that the software side can determine the data filling status of the target circular buffer based on the head pointer and tail pointer, and perform the corresponding operation processing.

[0060] This embodiment provides a data transmission method for a circular buffer. This method can automatically correct data packets in the circular buffer, enhancing the robustness of data interaction between the software and hardware sides, and preventing the problem that an incorrect length information filling error in a single data packet in the circular buffer would render all data packets in the buffer unusable. This data transmission method is described with the hardware side as the execution entity.

[0061] In this data transmission method, a buffer unit is pre-added on the hardware side. After the software side adds a data packet to the target circular buffer, it updates the tail pointer. At this time, the software side stores the updated tail pointer's actual position in the target circular buffer into the buffer unit.

[0062] Please see Figure 2 , Figure 2 This is a structural diagram of the target circular buffer. Figure 2 In this context, the effective portion of the internal storage space of the target circular buffer is described using head and tail pointers. The base address represents the first storage location of the target circular buffer, and the depth represents the size or storage capacity of the target circular buffer. After updating the tail pointer, the software stores the updated tail pointer at its actual location within the target circular buffer into the cache unit.

[0063] In practical applications, both the head pointer and the tail pointer are... The unit is depth. If the head pointer and tail pointer point to the same location in the target circular buffer, it means that the location pointed to by the head pointer and tail pointer in the target circular buffer is empty. The tail pointer will always point to an empty location in the target circular buffer. Therefore, the maximum amount of data that the target circular buffer can actually hold is: depth minus one. The valid data in the target circular buffer is between the location pointed to by the head pointer and the previous location pointed to by the tail pointer.

[0064] In the target circular buffer, if the head pointer's position in the buffer is read, the head pointer will move one position forward. If the head and tail pointers point to the same position in the target circular buffer, the buffer is empty, and the head pointer cannot be moved further. If new data is written to the position pointed to by the tail pointer, the tail pointer will move one position forward. If the head pointer points to the position following the tail pointer, the buffer is full, and no data can be written to the tail pointer's position, nor can the tail pointer move further.

[0065] Please see Figure 3 , Figure 3 This diagram illustrates the management of the head and tail pointers via registers by both the software and hardware sides. In practical applications, the head and tail pointers of the target circular buffer exchange data between the software and hardware sides via registers. The tail pointer is maintained and updated by the software side. Each time the software side fills a data packet into the target circular buffer, it updates the tail pointer and stores the updated tail pointer's actual pointing position in the target circular buffer into the cache unit. The head pointer, on the other hand, is maintained and updated by the hardware side. When the hardware side passes the updated head pointer to the software side via a register, the software side can execute subsequent operations based on the information carried by the head pointer.

[0066] Specifically, after the software side stores the updated tail pointer's actual position in the target circular buffer into the cache unit, the hardware side reads the tail pointer's actual position in the target circular buffer from the cache unit to obtain the first position, and determines the expected position of the tail pointer in the target circular buffer based on the head pointer and the header information of the target data packet pointed to by the head pointer in the target circular buffer to obtain the second position.

[0067] Then, the hardware compares the second position with the first position to verify the length information of the target data packet. If the second position and the first position match, it means that the length information of the target data packet pointed to by the header pointer is correctly filled. At this point, the hardware can continue to transmit the target data packet according to the expected destination address and update the header pointer. The hardware can determine the expected destination address of the target data packet by parsing it.

[0068] If the second position and the first position are inconsistent, it indicates that the length information of the target data packet pointed to by the head pointer in the target circular buffer is incorrectly filled. In this case, the hardware side does not need to continue transmitting the target data packet, but needs to discard the target data packet and update the head pointer. After the hardware side has finished updating the head pointer, it will store the updated head pointer in a register.

[0069] After the hardware stores the updated head pointer into the register, the software determines the data fill status of the target circular buffer based on the head and tail pointers. That is, the software determines whether the storage space in the target circular buffer is full based on the head and tail pointers. Finally, the software performs the corresponding operation based on the data fill status of the target circular buffer.

[0070] Compared to related technologies, in the data transmission method described in this embodiment, the hardware side can determine the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer. Furthermore, a buffer unit stores the actual position of the tail pointer in the target circular buffer. Thus, the hardware side can use the actual position of the tail pointer in the target circular buffer to verify the expected position of the tail pointer in the target circular buffer. If the verification passes, it indicates that the length information of the target data packet is correctly filled, and the hardware side can continue transmitting the target data packet. If the verification fails, it indicates that the length information of the target data packet is incorrectly filled, and the hardware side can discard the target data packet. With this configuration, automatic error correction can be performed on the data packets in the circular buffer, enhancing the robustness of data interaction between the software and hardware sides, and avoiding the problem that if the length information of a certain data packet in the circular buffer is incorrectly filled, all data packets in the circular buffer will become unusable.

[0071] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. As a preferred implementation method, the length of the target data packet can be adjusted according to user needs.

[0072] In this embodiment, since the hardware can use the actual position of the tail pointer in the target circular buffer to verify the expected position of the tail pointer in the target circular buffer, the length of the data packets in the target circular buffer can be adaptively adjusted based on this setting mechanism. In other words, there is no need to fix the length of the target data packets in the target circular buffer; data packet configurations of arbitrary lengths can be supported within the allowable range of the target circular buffer.

[0073] In practical applications, the target circular buffer is based on... Data is stored in units; therefore, when the data packets that need to be exchanged between the software and hardware sides are not... When the value is a multiple of an integer, the last data in the data packet needs to be padded with zeros to ensure that the last data in the data packet is aligned to the specified value. .

[0074] Please see Figure 4 , Figure 4 This is a schematic diagram of the target data packet within the target circular buffer. Figure 4 The target data packet shown is configured with There are 1 data point, and the space occupied by each data point is 1. (i.e., ).this This data includes: packet header, data payload, and reserved space, etc. The packet header further specifies: packet type, packet length, etc.

[0075] Clearly, the technical solution provided in this embodiment enables the circular buffer to support the storage of data packets of different lengths.

[0076] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. As a preferred implementation, after discarding the target data packet, the above step further includes:

[0077] Error information of the target data packet is reported, and the header information of the target data packet is stored in the log.

[0078] In this embodiment, when the hardware side determines that the second position and the first position are inconsistent, in addition to discarding the target data packet, the hardware side will also report the error information of the target data packet to the interrupt program or terminal device such as the processor on the software side, and store the header information of the target data packet in the log.

[0079] This configuration not only enables the software to process erroneous data packets in the circular buffer in a timely manner, but also allows it to parse the header information of the target data packet based on the information recorded in the log, find the root cause of the error, and prevent similar phenomena from occurring in subsequent processes.

[0080] Clearly, the technical solution provided in this embodiment can further ensure the robustness of the software and hardware sides when interacting with each other through the circular buffer.

[0081] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. As a preferred implementation method, the cache unit is specifically a first-in-first-out queue.

[0082] In digital circuits, First-In-First-Out (FIFO) queues offer simpler control logic. Data writing and reading operations can be controlled via read / write enable signals, eliminating the need for complex address signal management like buffer units. Furthermore, FIFO queues strictly adhere to the first-in-first-out principle, with data written and read in a fixed order, requiring no external logic to manage data storage location. These characteristics make FIFO queues easier to implement and maintain in hardware design. Therefore, in this embodiment, the hardware-side buffer unit is configured as a FIFO queue.

[0083] Obviously, the technical solution provided in this embodiment can relatively reduce the logical complexity of data interaction between the software and hardware sides in the circular buffer.

[0084] Please see Figure 5 , Figure 5 A flowchart of another data transmission method using a circular buffer provided in an embodiment of the present invention, the method being applied on the software side, including:

[0085] Step S21: Store the updated actual position of the tail pointer in the target circular buffer into the buffer unit, so that the hardware side can read the actual position of the tail pointer in the target circular buffer from the buffer unit to obtain the first position, and determine the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer to obtain the second position; if the hardware side determines that the second position is consistent with the first position, then transmit the target data packet and update the head pointer; if the hardware side determines that the second position is inconsistent with the first position, then discard the target data packet and update the head pointer.

[0086] Step S22: When the hardware stores the updated head pointer into the register, the data filling status of the target circular buffer is determined based on the head pointer and the tail pointer, and the corresponding operation is performed.

[0087] In this embodiment, the software side is the execution entity, and the aforementioned data transmission method for a circular buffer is specifically described. For a detailed description of this method, please refer to the technical content of the aforementioned data transmission method for a circular buffer, which will not be repeated here.

[0088] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. As a preferred implementation, the above step of storing the updated tail pointer at the actual position pointed to by the target circular buffer into the cache unit includes:

[0089] Initialize the target circular buffer;

[0090] Generate data packets based on the remaining space in the target circular buffer, and then fill the target circular buffer with the generated data packets;

[0091] Update the tail pointer and store the updated tail pointer at the actual location it points to in the target circular buffer into the cache unit.

[0092] In practical applications, when the software and hardware sides interact with each other through a circular buffer, the software side first initializes the target circular buffer. At this time, the head pointer and the tail pointer will point to the same position in the target circular buffer, and the storage space of the target circular buffer is empty.

[0093] Then, the software generates a data packet of appropriate length based on the remaining space in the target circular buffer and fills the target circular buffer with the generated data packet. When the software fills the target circular buffer with the generated data packet, it updates the tail pointer and stores the updated tail pointer's actual position in the target circular buffer into the cache unit, thus allowing the hardware to begin the subsequent verification process.

[0094] Clearly, the technical solution provided in this embodiment can ensure the accuracy of data interaction between the software and hardware sides in the circular buffer.

[0095] In a preferred embodiment, the above steps include: determining the data filling state of the target circular buffer based on the head pointer and tail pointer, and performing corresponding operation processing, including:

[0096] If the target circular buffer is determined to be full based on the positions of the head pointer and the tail pointer in the target circular buffer, then stop filling the target circular buffer with data.

[0097] If the target circular buffer is determined to be in a state where it is not full of data based on the positions of the head pointer and the tail pointer in the target circular buffer, then the steps of generating data packets based on the remaining space in the target circular buffer and filling the target circular buffer with the generated data packets continue.

[0098] In this embodiment, when the software determines that the target circular buffer is already full based on the positions of the head pointer and the tail pointer in the target circular buffer, the software can end the operation and stop filling data in the target circular buffer.

[0099] When the software determines that the target circular buffer is not full based on the positions of the head pointer and the tail pointer in the target circular buffer, the software will continue to execute the steps of generating data packets based on the remaining space in the target circular buffer and filling the target circular buffer with the generated data packets.

[0100] Please see Figure 6 , Figure 6 This is a flowchart illustrating data interaction between the software and hardware sides within a circular buffer. The method includes:

[0101] Step S101: The software side initializes the target circular buffer;

[0102] Step S102: The hardware side determines that the head pointer and the tail pointer point to the same position in the target circular buffer. At this time, the target circular buffer is empty.

[0103] Step S103: The software generates a data packet of appropriate length based on the remaining space of the target circular buffer, and fills the target circular buffer with the generated data packet;

[0104] Step S104: The software updates the tail pointer and stores the updated tail pointer in the target circular buffer at its actual position in the first-in-first-out queue;

[0105] Step S105: The hardware side determines that the target circular buffer is not full of data, and reads the actual storage position of the tail pointer in the target circular buffer from the first-in-first-out queue to obtain the first position;

[0106] Step S106: The hardware side determines the expected position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, and obtains the second position;

[0107] Step S107: The hardware side determines whether the second position is consistent with the first position; if the second position is consistent with the first position, then proceed to step S08; if the second position is inconsistent with the first position, then proceed to step S09.

[0108] Step S108: Transmit the target data packet and update the header pointer;

[0109] Step S109: Discard the target data packet and update the header pointer;

[0110] Step S110: The software reads the head pointer and determines whether the target circular buffer is in a data-filled state based on the head pointer and the tail pointer; if the target circular buffer is in a data-filled state, then execute step S111; if the target circular buffer is in a data-incomplete state, then jump to step S103.

[0111] Step S111: Stop filling the target circular buffer with data.

[0112] Clearly, the technical solution provided in this embodiment can ensure the overall reliability of data interaction operations between the software and hardware sides in the target circular buffer.

[0113] Based on the above embodiments, this embodiment further explains and optimizes the technical solution. As a preferred implementation, the above data transmission method further includes:

[0114] Determine if the position following the position pointed to by the tail pointer in the target circular buffer is the same as the position pointed to by the head pointer in the target circular buffer;

[0115] If the position following the position pointed to by the tail pointer in the target circular buffer is inconsistent with the position pointed to by the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be in a state where the data is not filled.

[0116] If the next position of the tail pointer in the target circular buffer is the same as the position of the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be full, and the available storage space on the software side is determined according to user requirements. An expanded circular buffer; ;

[0117] Target circular buffer and The expanded circular buffer is determined to be a set of circular buffers;

[0118] Determine the number of circular buffers in the set that are not yet filled with data, and obtain the target number;

[0119] If the target number is greater than 1, then the release of data from the circular buffers in the circular buffer set is prohibited.

[0120] If the target quantity is equal to 1, then release the ring buffers in the ring buffer set that have empty storage space.

[0121] In practical applications, during data exchange between the software and hardware sides within the target circular buffer, the software can also determine in real time whether the next position of the tail pointer in the target circular buffer matches the position of the head pointer. If the next position of the tail pointer in the target circular buffer does not match the position of the head pointer, it indicates that the storage space of the target circular buffer is not full.

[0122] If the next position of the tail pointer in the target circular buffer matches the position of the head pointer in the target circular buffer, it indicates that the storage space of the target circular buffer is full. At this point, the software can expand the target circular buffer and determine the available storage space based on user needs. An expanded circular buffer.

[0123] Then, the software side will then add the target circular buffer and The expanded circular buffer is determined to be a set of circular buffers. During the maintenance of the circular buffers in the set of circular buffers, the software side will determine the number of circular buffers in the set that are not yet filled with data, and obtain the target number.

[0124] If the target number is greater than 1, to avoid errors in the stored data within the circular buffers of the circular buffer set, the software side will not allow the circular buffer expansion enable to be disabled. In this case, the software side will prevent the release of data from the circular buffers in the circular buffer set. If the target number is equal to 1, to improve the system's storage efficiency, the software side can configure the circular buffer enable to be disabled. In this case, the software side will release the circular buffers in the circular buffer set that have empty storage space.

[0125] Obviously, through the technical solution provided in this embodiment, the software side can also flexibly adjust the number of circular buffers according to user needs.

[0126] Please see Figure 7 , Figure 7 This is a schematic diagram illustrating the principle of data interaction between the software and hardware sides in a circular buffer, as provided in an embodiment of the present invention. When the software and hardware sides interact in the target circular buffer, they first manage the head and tail pointers in the target circular buffer using registers. When the software side stores the updated tail pointer's actual position in the target circular buffer in a first-in-first-out (FIFO) queue, the hardware side uses the actual position of the tail pointer in the target circular buffer stored in the FIFO queue to perform length verification on the data packet pointed to by the head pointer in the target circular buffer. If the verification passes, the hardware side continues to transmit the data packet pointed to by the head pointer in the target circular buffer; if the verification fails, the hardware side performs error processing on the data packet pointed to by the head pointer in the target circular buffer.

[0127] Furthermore, when the software and hardware sides interact with each other in the target circular buffer, the software side will also expand the circular buffer according to user needs and the data filling status in the target circular buffer, thereby achieving the purpose of dynamically adjusting the number of circular buffers.

[0128] Additionally, it should be noted that throughout the entire process described above, the software side remains largely unchanged compared to the current operating procedure, except for reading and writing operations on the head and tail pointers in the registers. This ensures the simplicity of the technical solution in actual use.

[0129] Furthermore, in practical applications, the software side can maintain and manage the tail pointer through either a fixed interface or multiple interfaces. When the software side maintains and manages the tail pointer jointly through multiple interfaces, the hardware side can perform one-to-many data interaction with the multiple interfaces on the software side. This allows the technical solution provided in this application to be applied to a wider range of application scenarios.

[0130] Please see Figure 8 , Figure 8 This is a structural diagram of a data transmission device with a circular buffer provided in an embodiment of the present invention, applied on the hardware side; including:

[0131] The position reading module 11 is used to read the actual position of the tail pointer in the target circular buffer from the cache unit when the software side stores the updated tail pointer's actual position in the target circular buffer into the cache unit, and obtain the first position.

[0132] The position calculation module 12 is used to determine the expected pointing position of the tail pointer in the target circular buffer based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, so as to obtain the second position;

[0133] The data transmission module 13 is used to transmit the target data packet and update the header pointer if the second position is consistent with the first position.

[0134] The data discarding module 14 is used to discard the target data packet and update the header pointer if the second position is inconsistent with the first position.

[0135] The operation execution module 15 is used to store the updated head pointer into a register so that the software side can determine the data filling state of the target circular buffer based on the head pointer and the tail pointer, and perform corresponding operation processing.

[0136] On the one hand, it also includes:

[0137] The information reporting module is used to report the error information of the target data packet after the target data packet is discarded, and to store the header information of the target data packet in the log.

[0138] The data transmission apparatus for a circular buffer provided in this embodiment of the invention has the beneficial effects of the data transmission method for a circular buffer disclosed above.

[0139] Please see Figure 9 , Figure 9 This is a structural diagram of another data transmission device with a circular buffer provided in an embodiment of the present invention, applied to the software side, including:

[0140] The tail pointer update module 21 is used to store the updated actual position of the tail pointer in the target circular buffer to a cache unit, so that the hardware side reads the actual position of the tail pointer in the target circular buffer from the cache unit to obtain a first position, and determines the expected position of the tail pointer in the target circular buffer according to the head pointer and the target data packet pointed to by the head pointer in the target circular buffer to obtain a second position; if the hardware side determines that the second position is consistent with the first position, the target data packet is transmitted to update the head pointer; if the hardware side determines that the second position is inconsistent with the first position, the target data packet is discarded and the head pointer is updated.

[0141] The operation processing module 22 is used to determine the data filling state of the target circular buffer based on the head pointer and the tail pointer when the hardware side stores the updated head pointer into the register, and to perform the corresponding operation processing.

[0142] On one hand, the tail pointer update module 21 includes:

[0143] An initialization unit is used to initialize the target circular buffer.

[0144] A data filling unit is used to generate data packets based on the remaining space of the target circular buffer and fill the generated data packets into the target circular buffer.

[0145] The tail pointer update unit is used to update the tail pointer and store the updated tail pointer at the actual position it points to in the target circular buffer into the cache unit.

[0146] On the other hand, the operation processing module 22 includes:

[0147] The first execution unit is configured to stop filling the target circular buffer with data if it is determined from the position of the head pointer and the position of the tail pointer in the target circular buffer that the target circular buffer is already filled with data.

[0148] The second execution unit is configured to, if it is determined from the position of the head pointer and the position of the tail pointer in the target circular buffer that the target circular buffer is in a state where the data is not filled, continue to execute the step of generating a data packet based on the remaining space of the target circular buffer and filling the target circular buffer with the generated data packet.

[0149] On the other hand, it also includes:

[0150] The position determination module is used to determine whether the next position of the tail pointer in the target circular buffer is consistent with the position of the head pointer in the target circular buffer;

[0151] The first determination module is used to determine that the storage space of the target circular buffer is in a state where the data is not filled when the determination result of the position determination module is negative.

[0152] The second determination module is used to determine that the storage space of the target circular buffer is in a data-filled state when the determination result of the position determination module is yes, and to determine the available storage space in the software side according to user needs. An expanded circular buffer; ;

[0153] The set determination module is used to combine the target circular buffer and The expanded circular buffer is determined to be a set of circular buffers;

[0154] The quantity determination module is used to determine the number of circular buffers in the set of circular buffers that are not yet filled with data, and to obtain the target quantity;

[0155] The first operation module is used to prevent the release of data from the circular buffers in the circular buffer set if the target number is greater than 1.

[0156] The second operation module is used to release the ring buffers with empty storage space in the ring buffer set if the target quantity is equal to 1.

[0157] The data transmission apparatus for a circular buffer provided in this embodiment of the invention has the beneficial effects of the data transmission method for a circular buffer disclosed above.

[0158] Please see Figure 10 , Figure 10 This is a structural diagram of a data transmission device with a circular buffer provided in an embodiment of the present invention. The device includes:

[0159] Memory 31 is used to store computer programs;

[0160] Processor 32 is configured to execute the computer program to implement the steps of a data transfer method for a circular buffer as disclosed above.

[0161] The data transmission device for the circular buffer provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.

[0162] The processor 32 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 32 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 32 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 32 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 32 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.

[0163] The memory 31 may include one or more computer-readable storage media, which may be non-transitory. The memory 31 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 31 is used to store at least the following computer program 301, which, after being loaded and executed by the processor 32, is capable of implementing the relevant steps of the circular buffer data transfer method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 31 may also include an operating system 302 and data 303, and the storage method may be temporary or permanent storage. The operating system 302 may include Windows, Unix, Linux, etc. The data 303 may include, but is not limited to, the data involved in the circular buffer data transfer method.

[0164] In some embodiments, the data transmission device of the ring buffer may further include a display screen 33, an input / output interface 34, a communication interface 35, a power supply 36, and a communication bus 37.

[0165] Those skilled in the art will understand that Figure 10 The structure shown does not constitute a limitation on the data transmission device of the circular buffer and may include more or fewer components than illustrated.

[0166] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical disks, and other media capable of storing program code.

[0167] The data transmission device with a circular buffer provided in this embodiment of the invention has the beneficial effects of the data transmission method with a circular buffer disclosed above.

[0168] Accordingly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a data transmission method for a circular buffer as disclosed above.

[0169] The computer-readable storage medium provided in this embodiment of the invention has the beneficial effects of the aforementioned data transmission method using a circular buffer.

[0170] In the above embodiments, a data transmission method for a circular buffer has been described in detail. The present invention also provides a computer program product. The computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of a data transmission method for a circular buffer in any of the above embodiments.

[0171] 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 the method section.

[0172] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0173] The present invention has provided a detailed description of a data transmission method, apparatus, and related equipment for a circular buffer. Specific examples have been used to illustrate the principles and implementation methods of the invention. The descriptions of these embodiments are merely illustrative of the method and its core concepts. It should be noted that those skilled in the art can make various improvements and modifications to the invention without departing from its principles, and these improvements and modifications also fall within the scope of protection of the claims.

Claims

1. A data transmission method using a circular buffer, characterized in that, Applied to the hardware side; including: When the software stores the updated tail pointer's actual position in the target circular buffer into the cache unit, the actual position of the tail pointer in the target circular buffer is read from the cache unit to obtain the first position; The expected position of the tail pointer in the target circular buffer is determined based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, thus obtaining the second position; If the second position matches the first position, then the target data packet is transmitted and the header pointer is updated; If the second position is inconsistent with the first position, the target data packet is discarded and the header pointer is updated; The updated head pointer is stored in a register so that the software side can determine the data filling state of the target circular buffer based on the head pointer and the tail pointer, and perform the corresponding operation processing.

2. The data transmission method using a circular buffer according to claim 1, characterized in that, The length of the target data packet can be adjusted according to user needs.

3. The data transmission method for a circular buffer according to claim 1, characterized in that, After discarding the target data packet, the method further includes: The error information of the target data packet is reported, and the header information of the target data packet is stored in the log.

4. The data transmission method for a circular buffer according to claim 1, characterized in that, The cache unit is specifically a first-in-first-out queue.

5. A data transmission method using a circular buffer, characterized in that, Applied to the software side, including: The updated tail pointer's actual position in the target circular buffer is stored in a cache unit. The hardware then reads the actual position of the tail pointer in the target circular buffer from the cache unit to obtain a first position. Based on the head pointer and the target data packet pointed to by the head pointer in the target circular buffer, the expected position of the tail pointer in the target circular buffer is determined to obtain a second position. If the hardware determines that the second position matches the first position, the target data packet is transmitted, and the head pointer is updated. If the hardware determines that the second position does not match the first position, the target data packet is discarded, and the head pointer is updated. When the hardware stores the updated head pointer into the register, it determines the data filling state of the target circular buffer based on the head pointer and the tail pointer, and performs the corresponding operation processing.

6. The data transmission method for a circular buffer according to claim 5, characterized in that, The step of storing the updated tail pointer at its actual location in the target circular buffer into the cache unit includes: The target circular buffer is initialized. Data packets are generated based on the remaining space in the target circular buffer, and the generated data packets are then filled into the target circular buffer. The tail pointer is updated, and the updated tail pointer is stored in the cache unit at the actual position it points to in the target circular buffer.

7. The data transmission method for a circular buffer according to claim 6, characterized in that, The step of determining the data filling state of the target circular buffer based on the head pointer and the tail pointer, and performing corresponding operation processing, includes: If the target circular buffer is determined to be full based on the positions of the head pointer and the tail pointer in the target circular buffer, then the data filling process for the target circular buffer is stopped. If the target circular buffer is determined to be in a state of incomplete data based on the position pointed to by the head pointer and the position pointed to by the tail pointer in the target circular buffer, then the step of generating a data packet based on the remaining space of the target circular buffer and filling the target circular buffer with the generated data packet continues.

8. The data transmission method for a circular buffer according to claim 5, characterized in that, Also includes: Determine whether the position following the position pointed to by the tail pointer in the target circular buffer is consistent with the position pointed to by the head pointer in the target circular buffer; If the position following the position pointed to by the tail pointer in the target circular buffer is inconsistent with the position pointed to by the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be in a state where the data is not filled. If the position following the position pointed to by the tail pointer in the target circular buffer is the same as the position pointed to by the head pointer in the target circular buffer, then the storage space of the target circular buffer is determined to be full, and the available storage space on the software side is determined according to user needs. An expanded circular buffer; ; The target circular buffer and The expanded circular buffer is determined to be a set of circular buffers; Determine the number of circular buffers in the set that are not yet filled with data to obtain the target number; If the target number is greater than 1, then the release of data from the circular buffers in the circular buffer set is prohibited. If the target quantity is equal to 1, then release the ring buffers in the ring buffer set that have empty storage space.

9. A data transmission device with a circular buffer, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of a data transmission method for a circular buffer as described in any one of claims 1 to 4 or a data transmission method for a circular buffer as described in any one of claims 5 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of a data transmission method for a circular buffer as described in any one of claims 1 to 4 or a data transmission method for a circular buffer as described in any one of claims 5 to 8.