Data processing method and device and electronic equipment
Through the data cropping and unpacking methods, combined with ring buffers and DMA technology, the problem of sticking and losing packets in the communication system is solved, and efficient data processing and flexible system configuration are realized.
Patent Information
- Application Number
- CN202510886727.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2045-06-30
AI Technical Summary
In the prior art, communication systems are prone to packet sticking and packet loss when high-frequency or multiplexed data are concurrent, resulting in incomplete data processing and inefficient efficiency.
Through the data cropping and unpacking method, the data packet is cropped according to the packet length value, and the single frame data length is determined through the fixed frame length value, the data frame length description and characteristic value, so as to realize the unpacking and analysis of data, and combine the ring buffer and DMA technology for data processing.
It effectively reduces the data sticking and packet loss situation, improves the flexibility and processing efficiency of the communication system, and ensures data integrity and stability of the communication system.
Smart Images

Figure CN120390045A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of communication data processing, and particularly relates to a data processing method, apparatus and electronic device. Background Art
[0002] Communication data processing involves collecting, transmitting, storing, analyzing and applying the data generated in a communication system. In the photovoltaic field, the electronic control system of a tracking bracket is mainly divided into two parts: a control end (TCU) and a communication end (NCU). Among them, as an important node for data convergence and information upload in the entire bracket electronic control system, there are multiple communication nodes for both the upstream and downstream of the data in the communication end, which belongs to the communication bottleneck of the entire intelligent bracket system. Therefore, the immediacy and integrity of data processing by the NCU determine the stability and efficiency of data update and synchronization of the entire system.
[0003] Currently, the data processing method of NCU devices mainly receives and sends through an ordinary foreground-background mechanism. When a new packet of data arrives, the processor stores the data in the background interrupt, and then calls out the foreground task for parsing and data reply. When the total communication frequency is higher than a certain level or multiple data are concurrent, since the TCP protocol cannot distinguish the partition relationship between data, a packet sticking phenomenon may occur, that is, two data packets are stuck together in sequence. For an ordinary protocol parsing system, usually only the frontmost frame of data will be processed, and the subsequent data will be discarded entirely, which will result in packet loss. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a data processing method, apparatus and electronic device, which reduce the requirements for data sources and reduce the situation of data packet sticking and packet loss.
[0005] To solve the above technical problem, in a first aspect, the present invention provides a data processing method, including: a first processing unit performs data clipping and data unpacking on the data to be processed; wherein, the data clipping includes: according to the length value indicating a single data packet, clipping a plurality of bytes of data with the corresponding length value as a data packet; the data unpacking includes: determining the length of a single-frame data; unpacking the data packet according to the length of the single-frame data to obtain a plurality of single-frame data; wherein, the length of the single-frame data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
[0006] Optionally, the step of cropping a number of bytes of data corresponding to the length value as a data packet according to the length value indicating a single data packet includes: defining a frame buffer pointer and a frame length pointer. In an initial state, the frame buffer pointer points to the starting position of the data storage area, and the frame length pointer points to the starting position in the data length array; according to the length value stored at the position pointed to by the frame length pointer, starting from the current position pointed to by the frame buffer pointer, crop a number of bytes of subsequent data with the length value as a data packet.
[0007] Optionally, the method further includes: performing frame data parsing by the first processing unit; in response to being unable to perform data parsing on the current frame data, indicating that there is a packet adhesion in the current frame data.
[0008] Optionally, the data to be processed is extracted from a second processing unit, and the parsed data is saved back to the second processing unit.
[0009] Optionally, the second processing unit stores data in a circular buffer manner, and the second processing unit receives external communication data and / or sends communication data to an external unit.
[0010] Optionally, the method further includes: the second processing unit defines a task stack number, the task stack number corresponds to the number of unparsed data packets in the storage area, and the task stack number indicates whether to start the data processing process of the first processing unit.
[0011] Optionally, the method further includes: in the second processing unit, initializing the task stack number to zero; for each received external communication data packet, the task stack number is incremented by 1, and for each data packet transmitted to the first processing unit, the task stack number is decremented by 1; in response to the task stack number not being zero, starting the data processing process of the first processing unit.
[0012] In a second aspect, the present invention provides a data processing device, including: a first processing unit, which performs data cropping and data unpacking on the data to be processed by the first processing unit; the first processing unit includes a cropping module, and the cropping module is configured to: crop a number of bytes of data corresponding to the length value as a data packet according to the length value indicating a single data packet; the first processing unit includes an unpacking module, and the unpacking module is configured to: determine the length of a single frame of data; unpack the data packet according to the length of the single frame of data to obtain a plurality of single frames of data; wherein, the length of the single frame of data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
[0013] Optionally, it further includes a second processing unit, which is configured to: store data, transmit data to be processed to the first processing unit, receive external communication data, and / or send communication data to an external unit.
[0014] In a third aspect, the present invention provides an electronic device, including: a processor and a memory, where the memory stores a program or instruction that can run on the processor, and when the program or instruction is executed by the processor, it implements the steps of the data processing method as described in the first aspect.
[0015] In a fourth aspect, the present invention provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, it implements the steps of the data processing method as described in the first aspect.
[0016] Compared with the prior art, the present invention has the following advantages: according to the length value indicating a single data packet, several bytes of data corresponding to the length value are cropped as a data packet, and the length of a single-frame data is also determined. The data packet is unpacked according to the length of the single-frame data to obtain multiple single-frame data. Therefore, the received data can be effectively sorted and unpacked, the requirements for the data source are reduced, the configuration of the communication system is made more flexible, and the packet loss rate is reduced at the same time. Description of the Drawings
[0017] The accompanying drawings are provided to further understand the present application. They are incorporated and constitute a part of the present application. The accompanying drawings illustrate the embodiments of the present application and, together with this specification, serve to explain the principle of the present application. In the accompanying drawings: Figure 1 is a schematic flowchart of a data processing method according to an embodiment of the present invention; Figure 2 is a schematic flowchart of a data processing method according to another embodiment of the present invention; Figure 3 is a schematic flowchart of a data processing method according to another embodiment of the present invention; Figure 4 is a schematic structural diagram of a data processing device according to an embodiment of the present invention; Figure 5 is a schematic structural diagram of a data processing device according to another embodiment of the present invention; Figure 6 is a schematic diagram of an electronic device shown according to an embodiment of the present invention. Detailed Embodiments
[0018] To more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required for the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application. For those of ordinary skill in the art, without creative efforts, the present application can also be applied to other similar scenarios based on these drawings. Unless obvious from the language context or otherwise stated, the same reference numerals in the figures represent the same structure or operation.
[0019] As shown in the present application and the claims, unless the context clearly indicates an exception, words such as "a", "an", "one", and / or "the" are not specifically singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of the clearly identified steps and elements, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.
[0020] In addition, it should be noted that the use of words such as "first" and "second" to limit components is only for the convenience of distinguishing the corresponding components. Without further statement, the above words have no special meaning, so it cannot be understood as a limitation on the protection scope of the present application. In addition, although the terms used in the present application are selected from well-known and commonly used terms, some of the terms mentioned in the specification of the present application may be selected by the applicant according to his or her judgment, and their detailed meanings are described in the relevant parts of this description. In addition, it is required to understand the present application not only through the actual terms used, but also through the meaning implied by each term.
[0021] Flowcharts are used in the present application to illustrate the operations performed according to the embodiments of the present application. It should be understood that the previous or following operations are not necessarily executed precisely in sequence. On the contrary, they can be executed in reverse order or simultaneously. At the same time, other operations can be added to these processes, or one or more operations can be removed from these processes.
[0022] Refer to Figure 1 as shown, Figure 1 is a schematic flowchart of a data processing method according to an embodiment of the present invention. The first processing unit performs data clipping and data unpacking on the data to be processed, including: S110, the data clipping includes: according to the length value indicating a single data packet, clipping several bytes of data with the corresponding length value as a data packet; S120, the data unpacking includes: determining the length of a single-frame data; unpacking the data packet according to the length of the single-frame data to obtain multiple single-frame data; wherein, the length of the single-frame data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
[0023] When the total communication frequency is higher than a certain level or multiple data are concurrent, due to the TCP protocol's inability to distinguish the segmentation relationship between data, a packet adhesion phenomenon may occur, that is, two data packets are adhesively connected in sequence front and back. For ordinary protocol parsing systems, usually only the frontmost frame of data is processed, and the subsequent data is all discarded, which will lead to packet loss.
[0024] In this embodiment, when processing network traffic data, in order to ensure that the packet length meets some requirements, the data packets can be trimmed. In some communication protocols, the length information of the data packet is stored in a specific field of the packet header. A decoder can be used to parse these length fields and trim the data packets according to the specified length. Trimming is to extract the next complete received data packet to be processed. Then, the data is unpacked. Since there may be a situation where two packets are adhesively connected in a complete data packet trimmed, unpacking is needed to separate them. Exemplarily, according to the different protocols loaded, the data packets can be separated in one or more of the following ways: 1. In some protocols, the frame length is a fixed value, and a classification and screening can be performed according to the length value; 2. The content describes its own length. In some protocols, the length description of its own data frame is stored at a fixed position, and a classification and screening can be performed on this; 3. In some protocols, the fixed position is the protocol identification code, function code, etc., and a classification and screening can be performed according to this. In summary, through one round or multiple rounds of screening in the above ways, several lengths of data are judged and trimmed and defined as a data frame conforming to the corresponding protocol.
[0025] The method of this embodiment performs integrity analysis on a data packet, and through one round or multiple rounds of screening by various types of different protocols loaded in the system, it is judged whether there is packet adhesion, and the data frames of multiple different protocols are independently segmented and data parsing is performed in sequence.
[0026] In an example, trimming a number of bytes of data corresponding to the length value as a data packet according to the length value indicating a single data packet includes: defining a frame buffer pointer and a frame length pointer. Initially, the frame buffer pointer points to the starting position of the data storage area, and the frame length pointer points to the starting position in the data length array; according to the length value saved at the position pointed to by the frame length pointer, using the current position pointed to by the frame buffer pointer as the starting point, trimming a number of subsequent bytes of data with the length value as a data packet.
[0027] Frame buffer pointers are often used to point to a certain position in the frame buffer (Frame Buffer). Through the frame buffer pointer, pixel data in the frame buffer can be quickly accessed. Frame length pointers are often used to point to a field or memory location storing frame length information. Frame length information is used to identify the size of a data frame and is usually used in network communication to parse and process data frames. The main function of the frame length pointer is that through the frame length pointer, the length information of the data frame can be quickly obtained, so as to correctly parse and process the data frame. For example, in an Ethernet frame, the frame length field is used to identify the length of the data field. Frame buffer pointers are mainly used to manage the receive and transmit buffers in a network interface card (NIC) to ensure that data can be correctly stored and transmitted. By reasonably using frame buffer pointers and frame length pointers, the efficiency and reliability of network communication can be improved, and at the same time, the data processing logic can be simplified.
[0028] Exemplarily, first define a frame buffer pointer and a frame length pointer. In the initial state, the former points to the starting position of the circular buffer, and the latter points to the starting position in the aforementioned data length array. According to the length value saved at the position pointed to by the frame length pointer, the relevant function will use the position pointed to by the frame buffer pointer as the starting point and cut out several bytes of data with subsequent length values as the data packet to be processed currently.
[0029] In one example, refer to Figure 2 As shown, the data processing method further includes: S210, parsing the frame data by the first processing unit; in response to being unable to perform the data parsing of the current frame data, indicating that there is a packet adhesion in the current frame data.
[0030] In this embodiment, if there is no packet adhesion, the data parsing task can be directly performed on the current data; if there is packet adhesion, the data parsing of the current frame data cannot be performed. Therefore, the first frame in the current packet can be disassembled according to the packet adhesion separation algorithm and input into the data parsing task for processing. The above processes of disassembling and parsing are executed until the data in the packet is processed completely.
[0031] In one example, the data to be processed is extracted from the second processing unit, and the parsed data is stored back in the second processing unit. Refer to Figure 3 As shown, in this embodiment, the second processing unit stores data, transmits the data to be processed to the first processing unit, receives external communication data and / or sends communication data to an external unit. Based on this, the general process of processing data by the first processing unit includes: 310, the data to be processed is extracted from the second processing unit; S110, performing data clipping, including: according to the length value indicating a single data packet, clipping several bytes of data with the corresponding length value as a data packet; S120, performing data unpacking, including: determining the length of a single-frame data; unpacking the data packet according to the length of the single-frame data to obtain multiple single-frame data; S320, and the parsed data is stored back in the second processing unit.
[0032] The complete data processing cycle occupies too much of the MCU processor. For data reception, parsing, and sending, the MCU needs to participate in the operations, resulting in low efficiency. Moreover, when the total communication frequency is higher than the processor's processing frequency, it will cause congestion in the communication link, leading to packet loss or slow response. Even, due to the excessive occupation of the MCU for communication task processing, it will affect the normal operation of other functions in the device. Especially when the total communication frequency is higher than a certain level or multiple data are concurrent, data congestion is bound to occur. The ordinary foreground / background processing mechanism belongs to a blocking process that only instantaneously processes the current data packet and cannot receive or process new data during operation, resulting in packet loss.
[0033] In this embodiment, the first processing unit processes data, while the second processing unit stores data and data transmission. Exemplarily, data is first received and sent through DMA (Direct Memory Access), thus saving the occupation of the MCU. That is, only the parsing process truly requires the MCU to participate, shortening the data processing cycle, improving the operating efficiency of the NCU itself, and the communication timeliness and synchronization of the overall communication system. Using DMA to send and receive data makes this process no longer occupy the MCU, realizing the dual-thread operation of the system and greatly improving the processing efficiency. Especially for high-frequency and concurrent data, it has extremely high processing flexibility, ensuring the integrity of data reception and reducing the packet loss rate.
[0034] In one example, the second processing unit stores data in a circular buffer manner, and the second processing unit receives external communication data and / or sends communication data to external units.
[0035] A circular buffer is a buffer with a fixed size. Its characteristic is that the head and tail are connected to form a circular structure. When data is written to the end of the buffer, it will automatically wrap around to the beginning of the buffer to continue writing. The size of the buffer is pre-allocated and cannot be dynamically expanded. When the buffer is full, new data will overwrite the oldest data (configurable to block or discard). The writing and reading of data are managed by read and write pointers. By adding a circular buffer for data sending and receiving and queuing and processing according to the FIFO principle, it ensures the complete reception and proper processing of all data in high-frequency and concurrent situations. Generally speaking, normal functions require the CPU to process and execute, but DMA can perform the sending / receiving function by itself, equivalent to dual-line operation.
[0036] The method of this embodiment adds a circular buffer for data sending and receiving, which is queued and processed according to the FIFO principle to ensure the complete reception and reliable processing of all data in high-frequency and concurrent situations. During operation, the DMA will transfer all received data to the circular buffer in sequence. If the packet data has reached the tail of the circular buffer, the remaining data content will be anchored to the head of the circular buffer for continued storage, thus ensuring the integrity of the data packet. The DMA channel in the MCU can directly transfer the data of the specified interface to the inside of the CPU without the participation of the CPU, and the transmission efficiency is much higher than the conventional foreground and background methods.
[0037] In one example, the method of this embodiment further includes: the second processing unit defines the task stack number, which corresponds to the number of unparsed data packets in the storage area, and the task stack number indicates whether to start the data processing process of the first processing unit. In one implementation, in the second processing unit, the task stack number is initialized to zero; for each received external communication data packet, the task stack number is incremented by 1, and for each data packet transmitted to the first processing unit, the task stack number is decremented by 1; in response to the task stack number not being zero, the data processing process of the first processing unit is started.
[0038] Each time a new packet of data is received, the length of the packet will be stored in an array to distinguish each packet of data in the buffer, and the task stack number will be incremented by one. When the processing system detects that the task stack is not 0, it means that there are currently unparsed data packets. As described above, according to the length value saved at the position pointed to by the frame length pointer, the relevant function will use the frame buffer pointer as the starting point and cut out several bytes of data with the subsequent length value as the data packet to be processed currently. At the same time, the frame buffer pointer moves backward by the position of the length value, the frame length pointer moves backward by one position, and the task stack number is decremented by 1. If the task stack number is still not 0, the above loop will continue, and the data packets will be processed according to the first-in-first-out processing principle.
[0039] Exemplarily, if two packets of data are received within a short period of time, FF 00 01 02 03, FF 01 02 03 04 FF 02 03 04 05, the former is normal data and the latter has packet sticking. At this time, both packets of data will be sequentially stored in the circular buffer for analysis. The data in the circular buffer is {FF 00 01 02 03 FF 01 02 03 04 FF 02 03 04 05}, both the frame buffer pointer and the frame length pointer are 0, and at the same time, the received data lengths will be sequentially stored in the frame length array as {05, 10}, and the task stack count is 2. When the CPU is idle and it detects that the task stack count is not equal to 0, it starts to clip data from the circular buffer. First, since the frame length pointer is 0, it obtains the frame length 5 at the 0 position of the frame length array, and updates the frame length pointer to 0 + 1. Since the frame buffer pointer is 0, it takes 5 bytes of data from the 0 position of the circular buffer, and updates the frame buffer pointer to 0 + 5, which is FF 00 01 02 03. Assume that only protocol A is loaded at this time, and the packet frame header is fixed as FF, so the data inside the packet does not need to be separated, and the data is sent to the next data parsing task, and then the reply data is sent to the DMA for automatic transmission, and the task stack count is -1. It detects again that the task stack count is not 0 and repeats the above steps. At this time, the frame length pointer is 1, so it obtains the frame length 10 at the 1 position of the frame length array, and the frame buffer pointer is 5, that is, it starts to clip 10 bytes of data from the 5 position of the circular buffer, which is FF 01 02 03 04 FF 02 03 04 05. If the frame header is correct, it passes through the in-packet data separation task and proceeds to the next data parsing. However, it is found that the parsing cannot be executed (because the two packets of data are stuck together and the data format is incorrect), so the data of this packet is re-executed for the in-packet data separation task. By screening the frame header, it is found that there is another frame header in the data packet. The data packet is disassembled into two packets, FF 01 02 03 04 and FF 02 03 04 05, and then the data parsing task is executed.
[0040] In the data processing method of this embodiment, the first processing unit performs data clipping and data unpacking on the data to be processed. Among them, data clipping includes: according to the length value indicating a single data packet, clipping several bytes of data with the corresponding length value as a data packet; data unpacking includes: determining the length of a single-frame data, and unpacking the data packet according to the length of the single-frame data to obtain multiple single-frame data; among them, the length of the single-frame data is determined by one or more of the following methods, according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol. Furthermore, the requirements for the data source can be reduced, the configuration of the communication system can be made more flexible, the situation of data packet sticking and packet loss can be reduced, and the effective processing of data can be achieved. In addition, through the second processing unit, data is separately stored or data transmission and data communication are performed, realizing the dual-thread operation of the processing system and greatly improving the processing efficiency.
[0041] Reference Figure 4 As shown, this embodiment provides a data processing device, including: a first processing unit 410, which performs data clipping and data unpacking on the data to be processed; the first processing unit 410 includes a clipping module 401, and the clipping module 401 is configured to: according to the length value indicating a single data packet, clip a plurality of bytes of data with the corresponding length value as a data packet; the first processing unit 410 includes an unpacking module 402, and the unpacking module 402 is configured to: determine the length of a single-frame data; unpack the data packet according to the length of the single-frame data to obtain a plurality of single-frame data; wherein, the length of the single-frame data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
[0042] In one example, according to the length value indicating a single data packet, clipping a plurality of bytes of data with the corresponding length value as a data packet includes: defining a frame buffer pointer and a frame length pointer, in the initial state, the frame buffer pointer points to the starting position of the data storage area, and the frame length pointer points to the starting position in the data length array; according to the length value saved at the position pointed to by the frame length pointer, starting from the current position pointed to by the frame buffer pointer, clip a plurality of bytes of data with the subsequent length value as a data packet.
[0043] In one example, the first processing unit performs frame data parsing; in response to being unable to execute the data parsing of the current frame data, it indicates that there is a sticky packet in the current frame data.
[0044] In one example, reference Figure 5 As shown, the device further includes a second processing unit 510, and the second processing unit 510 is configured to: store data, transmit the data to be processed to the first processing unit, receive external communication data and / or send communication data to an external unit.
[0045] In one example, the data to be processed is extracted from the second processing unit 510, and the parsed data is stored back in the second processing unit 510.
[0046] In one example, the second processing unit stores data in a circular buffer manner, and the second processing unit receives external communication data and / or sends communication data to an external unit.
[0047] In one example, the second processing unit defines the number of task stacks, and the number of task stacks corresponds to the number of unparsed data packets in the storage area, and the number of task stacks indicates whether to start the data processing process of the first processing unit.
[0048] In one example, in the second processing unit, the initialized task stack count is zero; for each received external communication data packet, the task stack count is incremented by 1, and for each data packet transmitted to the first processing unit, the task stack count is decremented by 1; in response to the task stack count not being zero, the data processing process of the first processing unit is started.
[0049] Details of other operations performed by each module or unit in this embodiment can be referred to the foregoing embodiments and will not be elaborated here.
[0050] In the data processing device of this embodiment, the first processing unit performs data clipping and data unpacking on the data to be processed. Among them, data clipping includes: according to the length value indicating a single data packet, clipping a certain number of bytes of data with the corresponding length value as a data packet; data unpacking includes: determining the length of a single-frame data, and unpacking the data packet according to the length of the single-frame data to obtain multiple single-frame data; the length of the single-frame data is determined by one or more of the following methods: according to the fixed frame length value in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol, thereby reducing the requirements for the data source, making the configuration of the communication system more flexible, reducing the situation of data packet adhesion and packet loss, and realizing the effective processing of data. In addition, by separately storing data or performing data transmission and data communication through the second processing unit, the dual-thread operation of the processing system is realized, greatly improving the processing efficiency.
[0051] A data processing device in an embodiment of the present application can be a device, or a component, an integrated circuit, or a chip in a terminal. A data processing device in an embodiment of the present application can be a device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
[0052] The present application also provides an electronic device, including: a memory for storing programs or instructions executable by a processor; and a processor for executing the above programs or instructions to implement each process of the data processing method embodiment described above, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0053] Figure 6Schematic diagram of an electronic device shown according to an embodiment of the present invention. The electronic device 600 may include an internal communication bus 601, a processor 602, a read-only memory (ROM) 603, a random access memory (RAM) 604, and a communication port 605. When the application is on a personal computer, the electronic device 600 may further include a hard disk 606. The internal communication bus 601 may enable data communication between components of the electronic device 600. The processor 602 may make judgments and issue prompts. In some embodiments, the processor 602 may be composed of one or more processors. The communication port 605 may enable data communication between the electronic device 600 and the outside. In some embodiments, the electronic device 600 may send and receive information and data from a network through the communication port 605. The electronic device 600 may also include different forms of program storage units and data storage units, such as the hard disk 606, the read-only memory (ROM) 603, and the random access memory (RAM) 604, which can store various data files used for computer processing and / or communication, as well as possible programs or instructions executed by the processor 602. The result processed by the processor 602 is transmitted to the user device through the communication port 605 and displayed on the user interface.
[0054] The above data processing method may be implemented as a computer program, stored in the hard disk 606, and recorded in the processor 602 for execution to implement any of the data processing methods in this application.
[0055] An embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it realizes each process of the above data processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0056] For those skilled in the art, the above invention disclosure is only an example and does not constitute a limitation to this application. Although not explicitly stated here, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are proposed in this application, so such modifications, improvements, and corrections still belong to the spirit and scope of the exemplary embodiments of this application.
[0057] Although this application has been described with reference to current specific embodiments, those of ordinary skill in the art in this technical field should recognize that the above embodiments are only used to illustrate this application, and various equivalent changes or substitutions can be made without departing from the spirit of this application. Therefore, as long as the changes and variations of the above embodiments are within the scope of the spirit of this application, they will fall within the scope of the claims of this application.
Claims
1. A data processing method, characterized in that, including: The first processing unit performs data clipping and data unpacking on the data to be processed; wherein, the data clipping includes: according to the length value indicating a single data packet, clipping a plurality of bytes of data with the corresponding length value as a data packet; the data unpacking includes: determining the length of a single-frame data; unpacking the data packet according to the length of the single-frame data to obtain a plurality of single-frame data; wherein, the length of the single-frame data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
2. The data processing method according to claim 1, wherein The step of clipping a plurality of bytes of data with the corresponding length value as a data packet according to the length value indicating a single data packet includes: defining a frame buffer pointer and a frame length pointer, in the initial state, the frame buffer pointer points to the starting position of the data storage area, and the frame length pointer points to the starting position in the data length array; according to the length value stored at the position pointed to by the frame length pointer, starting from the current position pointed to by the frame buffer pointer, clipping a plurality of subsequent bytes of data with the length value as a data packet.
3. The data processing method according to claim 1, wherein: The method further includes: the first processing unit performs frame data parsing; in response to being unable to perform data parsing on the current frame data, indicating that there is a packet adhesion in the current frame data.
4. The data processing method according to any one of claims 1 to 3, characterized in that The data to be processed is extracted from the second processing unit, and the parsed data is saved back to the second processing unit.
5. The data processing method according to claim 4, wherein, The second processing unit stores data in a circular buffer manner, and the second processing unit receives external communication data and / or sends communication data to an external unit.
6. The data processing method according to claim 4, wherein The method further includes: the second processing unit defines a task stack number, the task stack number corresponds to the number of unparsed data packets in the storage area, and the task stack number indicates whether to start the data processing process of the first processing unit.
7. The data processing method according to claim 6, characterized in that, The method further includes: in the second processing unit, initializing the task stack number to zero; for each received external communication data packet, the task stack number is incremented by 1, and for each data packet transmitted to the first processing unit, the task stack number is decremented by 1; in response to the task stack number not being zero, starting the data processing process of the first processing unit.
8. A data processing device, characterized in that, including: a first processing unit, the first processing unit performs data clipping and data unpacking on the data to be processed; the first processing unit includes a clipping module, and the clipping module is configured to: according to the length value indicating a single data packet, clip a plurality of bytes of data with the corresponding length value as a data packet; the first processing unit includes an unpacking module, and the unpacking module is configured to: determine the length of a single-frame data; unpack the data packet according to the length of the single-frame data to obtain a plurality of single-frame data; wherein, the length of the single-frame data is determined by one or more of the following methods, including: according to the fixed value of the frame length in the data protocol, the description of the data frame length recorded in the data protocol, and the characteristic value in the data protocol.
9. The data processing device according to claim 8, wherein It further includes a second processing unit, and the second processing unit is configured to: store data, transmit the data to be processed to the first processing unit, receive external communication data and / or send communication data to an external unit.
10. An electronic device, characterized in that, including: A processor and a memory, wherein the memory stores a program or instructions that can run on the processor, and when the program or instructions are executed by the processor, the steps of the data processing method according to any one of claims 1-7 are implemented.
11. A readable storage medium, characterized in that, A program or instructions are stored on the readable storage medium, and when the program or instructions are executed by a processor, the steps of the data processing method according to any one of claims 1-7 are implemented.
Citation Information
Patent Citations
Transmission control protocol packet adhesion processing method and device
CN105306355A
TCP packet splicing handling method, server and system
CN107040549A
Data transmission method and device and storage medium
CN112398698A
Data transmission method and device, equipment, storage medium and program product
CN118803093A
Data transmission method and device, equipment, storage medium and computer program product
CN119561989A