A serial communication big data packet transmission and processing method, device and medium

By splitting data packets and setting buffer arrays in serial communication, identifying and checking data packets, the problem of insufficient data packet carrying capacity and packet loss and adhesion in serial communication is solved, and the stability and security of big data transmission are achieved.

CN116112581BActive Publication Date: 2024-10-29CASCO SIGNAL LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211690743.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-27
Publication Date
2024-10-29
Estimated Expiration
2042-12-27

AI Technical Summary

Technical Problem

Serial communication is limited by the transmission speed and the size of the receiver's buffer during the data transmission process, and cannot meet the needs of big data transmission. Moreover, when data is sent frequently, packet loss and adhesion problems are prone to occur, resulting in data loss.

Method used

By splitting the sender's data packet into sub-packets whose length is no larger than the receiver's buffer size, and setting up two buffer arrays on the receiver, the complete serial port layer data packet is identified and checked to ensure the integrity and continuity of the data packet. properties to avoid packet loss and adhesion.

Benefits of technology

It effectively solves the problem of insufficient data packet carrying capacity and packet loss and adhesion in serial communication, improves the stability and security of data transmission, and meets the needs of big data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116112581B_ABST
    Figure CN116112581B_ABST
Patent Text Reader

Abstract

The present invention relates to a serial communication big data packet transmission and processing method, device and medium, the method comprising: S1, splitting the communication data packet of the sender into sub-packets whose length is not greater than the buffer size; S2, defining the sub-packets or the data after the sub-packets are spliced ​​as application layer data packets; S3, according to the size and number of the serial port receiving side buffer, setting two buffer arrays A and B of the same size on the receiving side; S4, storing the serial port layer data in a buffer into the buffer array A; S5, checking the identified complete serial port layer data packet, only when all the checks are passed can the sub-packet data therein be accepted, and preparing to store it in the buffer array B; S6, the buffer array B may contain multiple application layer data packets, further segmenting them to obtain a single application layer data packet. Compared with the prior art, the present invention has the advantages of effectively solving the problem that the amount of data carried by a single data packet is limited and cannot meet the user's demand for large data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a train signal control system, and in particular to a serial communication big data packet transmission and processing method, equipment and medium. Background Art

[0002] Serial communication is a serial communication method widely used in embedded and industrial control fields. It has the characteristics of low cost and simple communication line implementation, but slow data transmission speed. Limited by the transmission speed and the size of the receiver's buffer, the amount of application layer data that can be carried by a data packet cannot meet the user's demand for large data transmission. Moreover, when the serial port sends data frequently, a large number of packet loss and adhesion problems will occur, making it impossible for the receiver to receive data stably, resulting in data loss. Summary of the invention

[0003] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a serial communication big data packet transmission and processing method, equipment and medium.

[0004] The purpose of the present invention can be achieved by the following technical solutions:

[0005] According to a first aspect of the present invention, a method for serial communication big data packet transmission and processing is provided, comprising the following steps:

[0006] Step S1, according to the buffer size of the serial communication receiver, split the communication data packet of the sender into sub-packets whose length is not greater than the buffer size;

[0007] Step S2, defining the sub-packet or the data after the sub-packets are spliced ​​as the application layer data packet;

[0008] Step S3, according to the size and number of the serial port receiving side buffer, set two buffer arrays A and B of the same size on the receiving side;

[0009] Step S4, storing the serial port layer data in a buffer into the buffer array A, and performing the processing of step S5 after a complete serial port layer data packet is identified from the buffer array;

[0010] Step S5, check the identified complete serial port layer data packet, and only accept the sub-packet data therein after all checks are passed, and prepare to store it in the buffer array B;

[0011] Step S6: The buffer array B may contain multiple application layer data packets, which are further segmented to obtain a single application layer data packet, and then step S4 is executed again to read the data in the next buffer.

[0012] As a preferred technical solution, the sub-packet in step S1 contains the following fields: sub-packet protocol frame header, packet length, total number of packets, sub-packet sequence number and sub-packet data.

[0013] As a preferred technical solution, the data with the subpacketization protocol frame header is defined as a serial port layer data packet. When subpacketization is not required, the total number of packets is fixed to 1 and the subpacket sequence number is fixed to 0. When subpacketization is required, the initial value of the subpacket sequence number is 0.

[0014] As a preferred technical solution, the application layer data packet in step S2 includes the following fields: application data frame header, frame type, packet length and application data, wherein the frame header of the application data packet and the frame header of the serial port data packet have different values.

[0015] As a preferred technical solution, in step S4, if the length of the newly added serial port layer data plus the existing data in the buffer array A exceeds the maximum length of the buffer data, the buffer array A is cleared first, and then the new data is put in.

[0016] As a preferred technical solution, the step S4 of identifying a complete serial port layer data packet is specifically as follows:

[0017] Step S41, read the data in the buffer array A in a loop, and when the packet protocol frame header is identified, continue to identify the packet length and perform a packet length check. Only when all the checks are passed, it is considered that a complete serial port layer data packet is identified, and the data of this packet is removed from the buffer array A, ready for subsequent processing, and the data after this packet is moved to the beginning of the buffer array A;

[0018] Step S42: If the data packet fails the check, it means that the serial port layer data packet is incomplete and is a broken packet. Try to splice the serial port data in the next buffer with it and execute step S4 again.

[0019] As a preferred technical solution, in step S4, when step 4 is executed again, the next Buffer that has not stored data in the buffer array A is selected in sequence, and when all Buffers are read, the method ends.

[0020] As a preferred technical solution, in step S5, if the length of the sub-packet data after checking plus the length of the existing data in the buffer array B exceeds the maximum length of the buffer data, the buffer array B is cleared first, and then the new sub-packet data is put in.

[0021] As a preferred technical solution, in step S5, the identified complete serial port layer data packet is checked, specifically:

[0022] Step S51, check that the sub-packet number should be less than the total number of packets;

[0023] Step S52: If the total number of packets is 1, the sub-packet number is 0;

[0024] Step S53: If the total number of packets is greater than 1, the sub-packet numbers must be continuous;

[0025] Step S54: When any one of the above checks fails, all saved sub-packets are cleared, that is, the buffer array B is cleared, and step S4 is executed again.

[0026] As a preferred technical solution, the step S6 may read a plurality of application layer data packets, specifically:

[0027] Step S61, cyclically reading multiple application data packets that may be contained in the buffer array B until the end of the buffer array B is read, and after identifying the application data frame header in the byte stream, continue to identify the subsequent frame type and packet length, and perform a data packet length check;

[0028] Step S62, when the packet length check passes, a complete and correct application layer data packet is found, which is deleted from the buffer array B and allocated to the module that needs to use this data. The data that does not pass the check will be cleared, and step S61 is repeated.

[0029] According to a second aspect of the present invention, there is provided an electronic device, comprising a memory and a processor, wherein a computer program is stored in the memory, and the method described above is implemented when the processor executes the program.

[0030] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the program implements the method described above when executed by a processor.

[0031] Compared with the prior art, the present invention has the following advantages:

[0032] 1) The present invention can effectively solve the problem that a single data packet has a limited amount of data and cannot meet the user's demand for large data transmission by setting a serial port layer data packet and an application layer data packet.

[0033] 2) The present invention can effectively solve the packet disconnection and sticking problems that frequently occur in serial communication by setting a buffer array, and avoids data loss caused by directly discarding the disconnected packets and stuck packets.

[0034] 3) The present invention improves data security by verifying the packet length and packet sequence number of the serial port data. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a schematic diagram of data interaction between a train control onboard system and the communication management module.

[0036] Figure 2 It is a schematic diagram of format definition of serial layer data packet and application layer data packet of the present invention.

[0037] Figure 3 The present invention is a flow chart of the vehicle-mounted main control software processing serial port data using the present invention.

[0038] Figure 4 The present invention is a flow chart for identifying a complete serial port layer data packet.

[0039] Figure 5 The present invention is a flow chart of checking a serial port layer data packet.

[0040] Figure 6 The present invention is a flow chart of reading a data packet that may contain multiple application layers. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0042] refer to Figure 1 , describing the system structure of a train control vehicle-mounted system that uses the technical solution of the present invention to interact with a communication management module for serial port data.

[0043] The train control vehicle system and the communication management module exchange data through the RS422 serial port. The maximum length of the data packet to be transmitted is 1500 bytes, while the number of buffers in the serial port receiving FIFO of the train control vehicle system is 10, and the maximum number of bytes that can be stored in each buffer is 200. There will be packet breakage problems when transmitting data through the serial port, that is, half of a complete data packet is received in the first buffer, and the other half is received in the next buffer. There is also a problem of adhesion, that is, under normal circumstances, there should be only one serial port layer data packet in each buffer, but when the adhesion problem occurs, there are multiple serial port layer data packets in one buffer. Considering that the communication management module needs to forward the data received from 4 radio stations to the train control vehicle system, the amount of data interaction is large, and packet breakage and adhesion problems occur frequently. The use of the technical solution of the present invention can solve this problem well.

[0044] refer to Figure 2 , explaining the format definition of the serial layer data packet and application layer data packet used by this system.

[0045] The serial layer data packet contains the packetization protocol frame header, total number of packets, sub-packet sequence number, packet length, sub-packet data and CRC (cyclic redundancy check code). The application layer data packet contains the application data frame header, frame type, packet length, application data and CRC. Due to the buffer limitation of the train control vehicle system, the length of the data packet that can pass through the serial port is no more than 200 bytes. Therefore, when sending large data, the application data packet is first split into sub-packets with a length of no more than 200 bytes, and then the sub-packets are encapsulated as serial layer data according to the packetization protocol, and then sent to the train control vehicle system.

[0046] refer to Figure 3 , which explains how the vehicle-mounted main control software uses this method to process serial port data.

[0047] Step 301, according to the number and size of buffers, set the size of buffer arrays A and B to 2000 bytes.

[0048] Step 302, read data from a Buffer, determine whether the length of the existing data in the buffer array A plus the length of the read data exceeds 2000 bytes, if so, clear the buffer array A and store new data.

[0049] Step 303: Search the buffer array A for complete serial port layer data.

[0050] Step 304, checking the identified serial port layer data.

[0051] Step 305, determine whether the length of the checked serial port layer data plus the length of the data in the buffer data B exceeds 2000 bytes. If so, clear the buffer array B and store new data.

[0052] Step 306: Search the buffer array B for complete application layer data.

[0053] Step 307, determine whether all buffers have been read, if not, repeat steps 302-307 until all are read and the program ends.

[0054] refer to Figure 4 , explaining the process of this method to identify a complete serial port layer data packet.

[0055] Step 401, sequentially search for the frame header 0x77AA from the buffer array A, and execute step 402 if the frame header is found. If the frame header is not found, try to concatenate the serial port data in the next buffer with the frame header, and execute step 302.

[0056] Step 402, after finding the frame header 0x77AA, check the packet length of the data packet. If it passes the check, take the data packet out of array A and move the subsequent data to the beginning of array A. If it fails, try to splice the serial port data in the next buffer with it and execute step 302.

[0057] refer to Figure 5 , which explains the process of checking the serial port layer data packet by this method.

[0058] Step 501, perform the following judgments in sequence: check that the sub-packet number should be less than the total number of packets; if the total number of packets is 1, the sub-packet number is 0; if the total number of packets is greater than 1, the sub-packet numbers must be continuous. When all the above checks are passed, prepare to store the sub-packets that have passed the check in the buffer array B. If any check fails, clear the buffer array B and execute step 302.

[0059] refer to Figure 6 , describing the process of this method for reading a data packet that may contain multiple application layer packets.

[0060] Step 601, sequentially search for the frame header 0x55AA from the buffer array B, and execute step 602.

[0061] Step 602, check the packet length of the found application data packet, and if the check passes, take the data packet out of array B and distribute it to the required module. If it fails, search for the frame header 0x55AA in sequence backward until all possible application data packets are found.

[0062] Step 603: When the buffer array B has been searched to the end, execute step 302.

[0063] The above is an introduction to the method embodiment. The following is a further explanation of the scheme of the present invention through electronic equipment and storage medium embodiments.

[0064] The electronic device of the present invention includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for device operation can also be stored. The CPU, ROM and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0065] Multiple components in the device are connected to the I / O interface, including: input units, such as keyboards, mice, etc.; output units, such as various types of displays, speakers, etc.; storage units, such as disks, optical disks, etc.; and communication units, such as network cards, modems, wireless communication transceivers, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunication networks.

[0066] The processing unit performs the various methods and processes described above, such as the method of the present invention. For example, in some embodiments, the method of the present invention can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program can be loaded and / or installed on the device via a ROM and / or a communication unit. When the computer program is loaded into RAM and executed by the CPU, one or more steps of the method of the present invention described above can be performed. Alternatively, in other embodiments, the CPU can be configured to perform the method of the present invention by any other appropriate means (e.g., by means of firmware).

[0067] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0068] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0069] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0070] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A serial communication big data packet transmission and processing method, characterized in that: The following steps are involved: Step S1, according to the buffer size of the serial communication receiver, split the communication data packet of the sender into sub-packets whose length is not greater than the buffer size; Step S2, defining the sub-packet or the data after the sub-packets are spliced ​​as the application layer data packet; Step S3, according to the size and number of the serial port receiving side buffer, set two buffer arrays A and B of the same size on the receiving side; Step S4, storing the serial port layer data in a buffer into the buffer array A, and performing the processing of step S5 after a complete serial port layer data packet is identified from the buffer array; Step S5, check the identified complete serial port layer data packet, and only accept the sub-packet data therein after all checks are passed, and prepare to store it in the buffer array B; Step S6: The buffer array B may contain multiple application layer data packets, which are further segmented to obtain a single application layer data packet, and then step S4 is executed again to read the data in the next buffer; The subpacket in step S1 includes the following fields: subpacket protocol frame header, packet length, total number of packets, subpacket sequence number and subpacket data; the data with the subpacket protocol frame header is defined as a serial port layer data packet. When subpacketing is not required, the total number of packets is fixed to 1 and the subpacket sequence number is fixed to 0. When subpacketing is required, the initial value of the subpacket sequence number is 0; The step S6 of reading a data packet that may contain multiple application layer packets is as follows: Step S61, cyclically reading multiple application data packets that may be contained in the buffer array B until the end of the buffer array B is read, and after identifying the application data frame header in the byte stream, continue to identify the subsequent frame type and packet length, and perform a data packet length check; Step S62, when the packet length check passes, a complete and correct application layer data packet is found, which is deleted from the buffer array B and allocated to the module that needs to use this data. The data that does not pass the check will be cleared, and step S61 is repeated.

2. According to claim 1, a serial communication big data packet transmission and processing method is characterized in that: The application layer data packet in step S2 includes the following fields: application data frame header, frame type, packet length and application data, wherein the frame header of the application data packet and the frame header of the serial port data packet have different values.

3. A serial communication big data packet transmission and processing method according to claim 1, characterized in that: In the step S4, if the length of the newly added serial port layer data plus the existing data in the buffer array A exceeds the maximum length of the buffer data, the buffer array A is cleared first, and then the new data is put in.

4. A serial communication big data packet transmission and processing method according to claim 1, characterized in that: The step S4 of identifying a complete serial port layer data packet is specifically as follows: Step S41, read the data in the buffer array A in a loop, and when the packet protocol frame header is identified, continue to identify the packet length and perform a packet length check. Only when all the checks are passed, it is considered that a complete serial port layer data packet is identified, and the data of this packet is removed from the buffer array A, ready for subsequent processing, and the data after this packet is moved to the beginning of the buffer array A; Step S42: If the data packet fails the check, it means that the serial port layer data packet is incomplete and is a broken packet. Try to splice the serial port data in the next buffer with it and execute step S4 again.

5. A serial communication big data packet transmission and processing method according to claim 4, characterized in that: In the step S4, when the step 4 is executed again, the next Buffer which has not stored data in the buffer array A is selected in sequence, and when all the Buffers are read, the method ends.

6. A serial communication big data packet transmission and processing method according to claim 1, characterized in that: In step S5, if the length of the sub-packet data after the check plus the length of the existing data in the buffer array B exceeds the maximum length of the buffer data, the buffer array B is cleared first, and then the new sub-packet data is put in.

7. A serial communication big data packet transmission and processing method according to claim 1, characterized in that: In step S5, the identified complete serial port layer data packet is checked, specifically: Step S51, check that the sub-packet number should be less than the total number of packets; Step S52: If the total number of packets is 1, the sub-packet number is 0; Step S53: If the total number of packets is greater than 1, the sub-packet numbers must be continuous; Step S54: When any one of the above checks fails, all saved sub-packets are cleared, that is, the buffer array B is cleared, and step S4 is executed again.

8. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Embedded processor serial port communication method and software development kit

    CN113778920A

  • Flow control method, device and equipment for serial port data transmission and storage medium

    CN114138700A