Universal analysis method for serial communication protocol containing data length
By obtaining and updating the element parameters of the serial communication protocol and parsing the status flags, the universal parsing of the data length in the electric steering gear is achieved, which solves the problem of protocol parsing complexity and improves versatility and production efficiency.
Patent Information
- Application Number
- CN202310349066.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-04
- Publication Date
- 2024-10-15
AI Technical Summary
Due to the diversified data formats of the existing electric servo serial communication protocols, the protocol parsing process is complicated and it is difficult to achieve universal parsing, especially when the data length is included.
By obtaining the element parameters of the actual serial communication protocol, initialize the parsing status flag, receive the data to be parsed by frame, update the parsing status flag according to the element parameters, until the cache array is full for verification, extract the function code and instruction data, and send them to The main function of the steering gear control software.
It achieves universal analysis of serial communication protocols in different electric servos, improves the versatility and production efficiency of the servos, and reduces production costs.
Smart Images

Figure CN118784752A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of communication protocol analysis, and in particular to a universal analysis method for a serial communication protocol including data length. Background Art
[0002] The electric servo is an important part of the aircraft flight control system. The electric servo receives the control instructions (including self-test, zeroing, and action instructions) sent by the on-board integrated control device, completes the electric servo self-test, zeroing, controls the servo deflection, drives the rudder surface deflection, and realizes the adjustment and control of the missile attitude. At the same time, the action instructions and servo status information (including self-test results, zeroing results, servo angular displacement or linear displacement feedback, voltage, current, temperature and other information) are returned to the on-board integrated control device for servo working status detection, and then the on-board integrated control device sends the received action instructions and servo status information to the telemetry equipment, which realizes the real-time storage and recording of the action instructions and servo status information.
[0003] In the existing electric servo serial communication protocol, there are multiple data formats, the number of frame headers is 1 or 2, some have master station address and slave station address, some do not have master station address and slave station address, and in most cases there is data length, which leads to different protocol parsing processes, bringing great difficulties to the universal parsing design of the electric servo serial communication protocol. How to achieve fast parsing of serial communication protocol in the case of data length is a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of the above analysis, an embodiment of the present invention aims to provide a universal parsing method for serial communication protocols containing data length, so as to solve the problem of difficulty in universal parsing of serial communication protocols containing data length due to the diversity of communication protocol data formats in existing electric servos.
[0005] The present invention discloses a general parsing method for a serial communication protocol including data length, comprising:
[0006] Get the element parameters of the actual serial communication protocol; the mandatory items of the element parameters include frame header 1 and data length identifier, and the optional items include frame header 2, master station address and slave station address; the element parameters in the actual serial communication protocol are arranged in the order of data structure; frame header 1, frame header 2, master station address, slave station address, data length identifier and data cache identifier correspond to the value of the parsing status flag;
[0007] The value of the initialization parsing state flag is the value of the parsing state flag corresponding to frame header 1;
[0008] The data to be parsed is received frame by frame; if the element parameter corresponding to the value of the current parsing status flag is the data length identifier, the data to be parsed is used as the data length of the cache array and stored in the first byte of the cache array, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data cache identifier, and the next frame of data to be parsed is received.
[0009] On the basis of the above scheme, the present invention also makes the following improvements:
[0010] Further, if the element parameter corresponding to the value is frame header 1, frame header 2, master station address or slave station address, and the data to be parsed is the same as the element parameter, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the next element parameter of the element parameter in the data structure, and the next frame of data to be parsed is received.
[0011] Furthermore, the data to be analyzed are obtained by processing the control instructions of the integrated control device on the missile;
[0012] The control instructions of the on-board integrated control device include self-check instructions, zero adjustment instructions and action instructions.
[0013] Furthermore, if the element parameter corresponding to the value is frame header 1, execute:
[0014] Determine whether the data to be parsed is equal to frame header 1,
[0015] If it is not equal to frame header 1, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed;
[0016] If it is equal to frame header 1, determine whether the actual serial communication protocol includes frame header 2.
[0017] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 2, and receive the next frame of data to be parsed;
[0018] If not included, determine whether the actual serial communication protocol includes the master station address.
[0019] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed;
[0020] If not, determine whether the actual serial communication protocol includes the slave address.
[0021] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed;
[0022] If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
[0023] Furthermore, if the element parameter corresponding to the value is frame header 2, execute:
[0024] Determine whether the data to be parsed is equal to frame header 2,
[0025] If it is not equal to frame header 2, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed;
[0026] If it is equal to frame header 2, determine whether the actual serial communication protocol includes the master station address.
[0027] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed;
[0028] If not, determine whether the actual serial communication protocol includes the slave address.
[0029] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed;
[0030] If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
[0031] Furthermore, if the element parameter corresponding to the value is the master station address, execute:
[0032] Determine whether the data to be parsed is equal to the master station address.
[0033] If it is not equal to the master station address, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the frame header 1, and the next frame of data to be parsed is received;
[0034] If it is equal to the master station address, determine whether the actual serial communication protocol includes the slave station address. If it does, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave station address, and receive the next frame of data to be parsed;
[0035] If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
[0036] Further, if the value corresponds to the data cache identifier, the data to be parsed is sequentially stored in the cache array, and the next frame of data to be parsed is received until the cache array is full; and verification is performed based on the full cache array.
[0037] Furthermore, if the value corresponds to the data cache identifier, execute:
[0038] The data to be parsed is stored in the cache array in sequence, and the data receiving counter CountR+1; then, it is determined whether CountR is greater than or equal to the data length PacketRL-1,
[0039] If not, receive the next frame of data to be parsed;
[0040] If yes, check based on the full cache array;
[0041] The initial value of the data receiving counter CountR is 0.
[0042] Further, based on the full cache array, we verify:
[0043] The data of the first PacketRL-1 bytes in the cache array are accumulated and calculated to obtain the cumulative sum; the data of the PacketRL-th byte in the cache array is assigned to the checksum; then, it is determined whether the received checksum is equal to the calculated cumulative sum.
[0044] If not equal, it means that the data verification is wrong, and the data parsing is terminated; the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the frame header 1, and CountR is assigned a value of 0; then, the next frame of data to be parsed is received;
[0045] If they are equal, extract the function code and instruction data from the cache array; update the value of the parsing status flag to the value of the parsing status flag corresponding to the frame header 1, and assign CountR to 0;
[0046] Then, receive the next frame of data to be parsed.
[0047] Further, the function code and the instruction data are extracted from the cache array and sent to the main function of the steering gear control software, so that the main function of the steering gear control software executes the corresponding instruction based on the function code and the instruction data;
[0048] The second byte of data in the cache array is the function code, and the data from the 3rd to PacketRL-1 bytes are the instruction data.
[0049] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0050] The universal parsing method of a serial communication protocol containing data length provided by the present invention has the following beneficial effects: during the use of different electric steering gears, a complete serial communication protocol can be configured and tailored according to actual conditions to obtain an actual serial communication protocol containing data length, and a method for universal parsing of actual serial communication protocols containing data length in various forms is designed, the parsing process is coordinated with the parsing state identification of different element parameters, which is clear and convenient for technical personnel in this field to implement, and effectively solves the problem of difficulty in universalization of electric steering gears in the prior art due to the diversification of communication protocol data formats, and can effectively improve the versatility of steering gears, improve production efficiency, and save production costs.
[0051] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0053] Figure 1 The general data format of the serial communication protocol of the electric servo provided in the embodiment of the present invention;
[0054] Figure 2 A flowchart of a general method for parsing a serial communication protocol including data length provided in Example 1 of the present invention;
[0055] Figure 3 This is a flowchart of a general parsing method for a serial communication protocol including data length provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0056] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0057] The complete data format of the complete serial communication protocol of the electric servo is as follows Figure 1 As shown, it includes the following elements in sequence: frame header 1, frame header 2, master station address, slave station address, data length, function code, instruction data and checksum. Among them,
[0058] Frame header 1 and frame header 2 are start characters, indicating the beginning of a data packet, and each occupies one frame;
[0059] The master station address is the address of the integrated control device on the missile, which occupies one frame;
[0060] The slave address is the address of the electric servo, which occupies one frame;
[0061] The data length is the sum of the data length, function code, instruction data and checksum frame number, occupying one frame;
[0062] Function codes are divided into self-check, zero adjustment, action and other functions, occupying one frame;
[0063] The command data matches the function code and varies according to the function code, carrying specific control information such as self-test, zero adjustment, and action; the number of frames occupied by the command data matches the function code and is not fixed;
[0064] The checksum occupies one frame.
[0065] In the complete data format of the complete serial communication protocol of the electric servo, the solid-line frame represents the necessary elements (frame header 1, function code, instruction data and checksum), and the dotted-line frame represents the optional elements (frame header 2, master station address, slave station address, data length). According to the requirements of different electric servos for the data format of the serial communication protocol during the communication process, the optional elements in the complete data format of the complete serial communication protocol of the electric servo are trimmed to obtain the actual data format of the actual serial communication protocol adapted to the current electric servo. It should be emphasized that when the optional elements are trimmed, the order of the remaining elements in the actual data format remains unchanged.
[0066] When the data structure includes the data length, the checksum is the cumulative sum of the data length, function code and instruction data, and the valid data includes the data length, function code, instruction data and checksum. The data length PacketRL is the sum of the number of frames of each element in the valid data. At the same time, due to the differences in self-test, zero adjustment, action and other functions, the frame length of the instruction data carrying specific information such as self-test, zero adjustment, action and so on is different, which ultimately leads to different data lengths PacketRL.
[0067] Example 1
[0068] Specific embodiment 1 of the present invention discloses a universal parsing method for serial communication protocols including data length, so as to realize universal parsing of actual serial communication protocols of different electric servos. The flowchart of the universal parsing method for serial communication protocols including data length is shown in FIG. Figure 2 As shown, the following steps are included:
[0069] Step S1: Obtain element parameters of the actual serial communication protocol; the mandatory items of the element parameters include frame header 1 and data length identifier, and the optional items include frame header 2, master station address and slave station address; the element parameters in the actual serial communication protocol are arranged in the order of data structure; frame header 1, frame header 2, master station address, slave station address, data length identifier and data cache identifier correspond to the value of the parsing status flag;
[0070] In step S1, the data length identifier is used to identify the actual serial communication protocol including the data length. In this embodiment, the electric servo receives the actual serial communication protocol of the electric servo sent by the main function of the servo control software in the form of function parameters.
[0071] Step S2: Initialize the value of the parsing state flag to the value of the parsing state flag corresponding to the frame header 1;
[0072] Step S3: Receive the data to be parsed frame by frame; if the element parameter corresponding to the value of the current parsing status flag is a data length identifier, use the data to be parsed as the data length of the cache array and store it in the first byte of the cache array, update the value of the parsing status flag to the value of the parsing status flag corresponding to the data cache identifier, and receive the next frame of data to be parsed.
[0073] Preferably, the specific execution process of step S3 is described as follows:
[0074] Receive the data to be parsed frame by frame; each time a frame of data to be parsed is received, execute:
[0075] Get the value of the current parsing status flag;
[0076] If the element parameter corresponding to the value is frame header 1, frame header 2, master station address or slave station address, and the data to be parsed is the same as the element parameter, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the next element parameter of the element parameter in the data structure, and the next frame of data to be parsed is received;
[0077] If the element parameter corresponding to the value is a data length identifier, the data to be parsed is used as the data length of the cache array and stored in the first byte of the cache array, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data cache identifier, and the next frame of data to be parsed is received;
[0078] If the value corresponds to the data cache identifier, the data to be parsed is sequentially stored in the cache array, and the next frame of data to be parsed is received until the cache array is full; verification is performed based on the full cache array. In step S3, the following operations are specifically performed:
[0079] Step S31: If the element parameter corresponding to the value is frame header 1, execute:
[0080] Determine whether the data to be parsed is equal to frame header 1,
[0081] If it is not equal to frame header 1, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed;
[0082] If it is equal to frame header 1, determine whether the actual serial communication protocol includes frame header 2.
[0083] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 2, and receive the next frame of data to be parsed;
[0084] If not included, determine whether the actual serial communication protocol includes the master station address.
[0085] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed;
[0086] If not, determine whether the actual serial communication protocol includes the slave address.
[0087] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed;
[0088] If not included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the data length identifier, and receive the next frame of data to be parsed. Step S32: If the element parameter corresponding to the value is frame header 2, execute:
[0089] Determine whether the data to be parsed is equal to frame header 2,
[0090] If it is not equal to frame header 2, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed;
[0091] If it is equal to frame header 2, it is determined that the actual serial communication protocol includes the master station address.
[0092] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed;
[0093] If not, determine whether the actual serial communication protocol includes the slave address.
[0094] If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed;
[0095] If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
[0096] Step S33: If the element parameter corresponding to the value is the master station address, execute:
[0097] Determine whether the data to be parsed is equal to the master station address.
[0098] If it is not equal to the master station address, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the frame header 1, and the next frame of data to be parsed is received;
[0099] If it is equal to the master station address, determine whether the actual serial communication protocol includes the slave station address. If it does, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave station address, and receive the next frame of data to be parsed;
[0100] If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
[0101] Step S34: assign the data to be parsed to the data length PacketRL, store PacketRL into the first byte of the cache array, update the value of the parsing status flag to the value of the parsing status flag corresponding to the data cache identifier, and receive the next frame of data to be parsed.
[0102] Step S35: If the value corresponds to the data cache identifier, execute:
[0103] The data to be parsed is stored in the cache array in sequence, and the data receiving counter CountR+1; then, it is determined whether CountR is greater than or equal to PacketRL-1.
[0104] If not, receive the next frame of data to be parsed;
[0105] If yes, check based on the full cache array;
[0106] The initial value of the data receiving counter CountR is 0.
[0107] In step S35, based on the full cache array, a check is performed:
[0108] The data of the first PacketRL-1 bytes in the cache array are accumulated and calculated to obtain the cumulative sum; the data of the PacketRL-th byte in the cache array is assigned to the checksum; then, it is determined whether the received checksum is equal to the calculated cumulative sum.
[0109] If not equal, it means that the data verification is wrong, and the data parsing is terminated; the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the frame header 1, and CountR is assigned a value of 0; then, the next frame of data to be parsed is received;
[0110] If they are equal, extract the function code and instruction data from the cache array; update the value of the parsing status flag to the value of the parsing status flag corresponding to the frame header 1, and assign CountR to 0;
[0111] Then, receive the next frame of data to be parsed.
[0112] It should be noted that, since the first byte in the cache array is the data length, the second byte in the cache array is the function code, and the data from the 3rd to PacketRL-1 bytes are the instruction data. In addition, the electric servo sends the function code and instruction data extracted from the cache array to the main function of the servo control software, so that the main function of the servo control software executes the corresponding instruction based on the function code and instruction data.
[0113] To sum up, the universal parsing method of serial communication protocol containing data length provided in this embodiment can configure and tailor the complete serial communication protocol according to actual conditions during the use of different electric servos, so as to obtain the actual serial communication protocol containing data length, and design a method that can realize the universal parsing of various forms of actual serial communication protocols containing data length. The parsing process is coordinated with the parsing status identification of different element parameters, which is clear and convenient for technical personnel in this field to implement. It effectively solves the problem of difficulty in universalization of electric servos in the prior art due to the diversification of communication protocol data formats, can improve the versatility of servos, improve production efficiency, and save production costs.
[0114] Example 2
[0115] In order to facilitate those skilled in the art to better implement the solution of the present invention, this embodiment 2 provides a specific application method of the general parsing method of the serial communication protocol containing data length, and the flow chart is as follows: Figure 3 The specific process is described as follows:
[0116] Step S1: Obtain element parameters of the actual serial communication protocol;
[0117] The values of the parsing status flags corresponding to frame header 1, frame header 2, master station address, slave station address, data length identifier, and data cache identifier are 0 to 5 respectively;
[0118] Step S2: Initialize the value of the parsing state flag to 0, and initialize the data receiving counter CountR to 0;
[0119] Step S3: receiving the data to be parsed frame by frame; the data to be parsed is obtained by processing the control instructions of the integrated control device on the missile; each time a frame of data to be parsed is received, executing:
[0120] Step S4: Determine whether the parsing status flag is equal to 0.
[0121] If it is not equal to 0, jump to step S5;
[0122] Otherwise, it indicates that the detection of frame header 1 is currently being executed. At this time, it is determined whether the data to be parsed is equal to frame header 1.
[0123] If it is not equal to frame header 1, the parsing status flag is assigned a value of 0 and the process jumps to step S3;
[0124] Otherwise, determine whether the actual serial communication protocol includes frame header 2.
[0125] If yes, assign the parsing status flag to 1 and go to step S3;
[0126] Otherwise, it indicates that there is only one frame header. Determine whether the actual serial communication protocol includes the master station address.
[0127] If yes, the parsing status flag is assigned a value of 2 and the process jumps to step S3;
[0128] Otherwise, determine whether the actual serial communication protocol includes the slave address.
[0129] If yes, the parsing status flag is assigned a value of 3 and the process jumps to step S3;
[0130] Otherwise, the parsing status flag is assigned a value of 4 and the process jumps to step S3.
[0131] Step S5: Determine whether the parsing status flag is equal to 1.
[0132] If it is not equal to 1, jump to step S6;
[0133] Otherwise, it indicates that the serial communication protocol includes 2 frame headers. At this time, the detection of frame header 2 is performed to determine whether the data to be parsed is equal to frame header 2.
[0134] If it is not equal to frame header 2, the parsing status flag is assigned a value of 0 and the process jumps to step S3;
[0135] Otherwise, it indicates that the frame header 2 check has passed, and it is determined whether the actual serial communication protocol includes the master station address.
[0136] If yes, the parsing status flag is assigned a value of 2 and the process jumps to step S3;
[0137] Otherwise, determine whether the actual serial communication protocol includes the slave address.
[0138] If yes, the parsing status flag is assigned a value of 3 and the process jumps to step S3;
[0139] Otherwise, the parsing status flag is assigned a value of 4 and the process jumps to step S3.
[0140] Step S6: Determine whether the parsing status flag is equal to 2.
[0141] If not equal to 2, jump to step S7;
[0142] Otherwise, determine whether the data to be parsed is equal to the master station address.
[0143] If not, set the parsing status flag to 0 and jump to step S3;
[0144] Otherwise, determine whether the actual serial communication protocol includes the slave address.
[0145] If yes, the parsing status flag is assigned a value of 3 and the process jumps to step S3;
[0146] Otherwise, the parsing status flag is assigned a value of 4 and the process jumps to step S3.
[0147] Step S7: Determine whether the parsing status flag is equal to 3,
[0148] If not equal to 3, jump to step S8;
[0149] Otherwise, determine whether the data to be parsed is equal to the slave address.
[0150] If not, set the parsing status flag to 0 and jump to step S3;
[0151] Otherwise, the parsing status flag is assigned a value of 4 and the process jumps to step S3.
[0152] Step S8: Determine whether the parsing status flag is equal to 4.
[0153] If not equal to 4, jump to step S9;
[0154] Otherwise, the data to be parsed is assigned to the data length PacketRL, the data length PacketRL is stored in the first byte of the cache array, the length of the cache array is the data length PacketRL, the parsing status flag is assigned to 5, and the process jumps to step S3;
[0155] The length of the cache array is equal to the data length PacketRL.
[0156] Step S9: Determine whether the parsing status flag is equal to 5,
[0157] If it is not equal to 5, an error is reported and the parsing process ends;
[0158] If it is equal to 5, execute: store the data to be parsed into the cache array in the order of reception, and the data reception counter CountR+1; then, determine whether CountR is greater than or equal to the data length PacketRL-1,
[0159] If not, it means that a packet of data has not been received, and jump to step S3;
[0160] If yes, jump to step S10;
[0161] Step S10: Accumulate the first PacketRL-1 data in the cache array to obtain a cumulative sum; assign the PacketRL data in the cache array to the checksum; then, determine whether the received checksum is equal to the calculated cumulative sum.
[0162] If not, it indicates that the data verification is wrong, and the data parsing is terminated; the parsing status flag is assigned to 0, CountR is assigned to 0, and the process jumps to step S3;
[0163] If they are equal, extract the function code and instruction data from the cache array and send them to the main function of the servo control software, so that the main function of the servo control software executes the corresponding instructions (self-test, zero adjustment or action program) based on the function code and instruction data; at the same time, assign the parsing status flag to 0, assign CountR to 0, and jump to step S3.
[0164] Example 3
[0165] The methods in Embodiment 1 and Embodiment 2 of the present invention can realize universal analysis of the serial communication protocol containing data length of the electric servo, and can be directly applied in the interaction process between the electric servo and the integrated control device on the missile.
[0166] Preferably, a response data transceiver component may be built inside the electric servo to receive and process control instructions from the integrated control device on the missile. The response data transceiver component includes a response data receiving unit, a user protocol parsing unit and a response data sending unit.
[0167] 1) A response data receiving unit, which is used to receive and analyze the control instructions sent by the integrated control device on the missile to obtain the data to be analyzed;
[0168] 2) A user protocol parsing unit, which is used to perform a generalized parsing of the data to be parsed according to the parsing method in Example 1 or Example 2 according to the user protocol parsing function (with the element parameters of the actual serial communication protocol built in) pointed to by the user protocol parsing function pointer, to obtain a function code and instruction data; and to pass the function code and instruction data to the main function of the steering gear control software, which processes the function code and instruction data and generates response data, and feeds back the response data to the user protocol parsing unit; and is also used to package the received response data and pass it to the response data sending unit;
[0169] In this embodiment, the user protocol parsing function is to parse the data to be parsed received by the response data receiving unit, and to package the response data.
[0170] The user agreement parsing function is agreed upon by the user.
[0171] 3) A response data sending unit, used to send the packaged data to be sent to the missile integrated control device.
[0172] In this embodiment, the control instructions of the missile integrated control device mainly include self-test instructions, zeroing instructions and action instructions. Correspondingly, the response data output by the response data transceiver mainly include the following: self-test results, zeroing results, action instructions and steering gear feedback (for example, steering gear angular displacement or linear displacement feedback). Specifically,
[0173] When the control instruction is a self-test instruction, the response data includes the self-test result;
[0174] When the control instruction is a zeroing instruction, the response data includes a zeroing result;
[0175] When the servo command is an action command, the response data includes the action command and the servo feedback.
[0176] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0177] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A general parsing method for serial communication protocols containing data length, characterized in that: include: Get the element parameters of the actual serial communication protocol; The mandatory items of the element parameters include frame header 1 and data length identifier, and the optional items include frame header 2, master station address and slave station address; The various element parameters in the actual serial communication protocol are arranged in the order of data structure; frame header 1, frame header 2, master station address, slave station address, data length identifier and data buffer identifier correspond to the values of the parsing status flag; The value of the initialization parsing state flag is the value of the parsing state flag corresponding to frame header 1; The data to be parsed is received frame by frame; if the element parameter corresponding to the value of the current parsing status flag is the data length identifier, the data to be parsed is used as the data length of the cache array and stored in the first byte of the cache array, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data cache identifier, and the next frame of data to be parsed is received.
2. The general parsing method of serial communication protocol containing data length according to claim 1, characterized in that: If the element parameter corresponding to the value is frame header 1, frame header 2, master station address or slave station address, and the data to be parsed is the same as the element parameter, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the next element parameter of the element parameter in the data structure, and the next frame of data to be parsed is received.
3. The general parsing method of serial communication protocol containing data length according to claim 2, characterized in that: The data to be analyzed are obtained by processing the control instructions of the integrated control device on the missile; The control instructions of the on-board integrated control device include self-check instructions, zero adjustment instructions and action instructions.
4. The general parsing method of serial communication protocol containing data length according to claim 2, characterized in that: If the element parameter corresponding to the value is frame header 1, execute: Determine whether the data to be parsed is equal to frame header 1, If it is not equal to frame header 1, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed; If it is equal to frame header 1, determine whether the actual serial communication protocol includes frame header 2. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 2, and receive the next frame of data to be parsed; If not included, determine whether the actual serial communication protocol includes the master station address. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed; If not, determine whether the actual serial communication protocol includes the slave address. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed; If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
5. The general parsing method of serial communication protocol containing data length according to claim 4, characterized in that: If the element parameter corresponding to the value is frame header 2, execute: Determine whether the data to be parsed is equal to frame header 2, If it is not equal to frame header 2, update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and receive the next frame of data to be parsed; If it is equal to frame header 2, determine whether the actual serial communication protocol includes the master station address. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the master station address, and receive the next frame of data to be parsed; If not, determine whether the actual serial communication protocol includes the slave address. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed; If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
6. The universal parsing method of serial communication protocol containing data length according to claim 5, characterized in that: If the element parameter corresponding to the value is the master address, execute: Determine whether the data to be parsed is equal to the master station address. If it is not equal to the master station address, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the frame header 1, and the next frame of data to be parsed is received; If it is equal to the master address, determine whether the actual serial communication protocol includes the slave address. If included, update the value of the parsing status flag to the value of the parsing status flag corresponding to the slave address, and receive the next frame of data to be parsed; If not included, the value of the parsing status flag is updated to the value of the parsing status flag corresponding to the data length identifier, and the next frame of data to be parsed is received.
7. The general parsing method for serial communication protocol containing data length according to any one of claims 2 to 6, characterized in that: If the value corresponds to the data cache identifier, the data to be parsed is sequentially stored in the cache array, and the next frame of data to be parsed is received until the cache array is full; and verification is performed based on the full cache array.
8. The universal parsing method of serial communication protocol containing data length according to claim 7, characterized in that: If the value corresponds to the data cache identifier, execute: The data to be parsed is stored in the cache array in sequence, and the data receiving counter CountR+1; then, it is determined whether CountR is greater than or equal to the data length PacketRL-1, If not, receive the next frame of data to be parsed; If yes, check based on the full cache array; The initial value of the data receiving counter CountR is 0.
9. The universal parsing method of serial communication protocol containing data length according to claim 8, characterized in that: To verify based on a full cache array, execute: The data of the first PacketRL-1 bytes in the cache array are accumulated and calculated to obtain the cumulative sum; the data of the PacketRL-th byte in the cache array is assigned to the checksum; then, it is determined whether the received checksum is equal to the calculated cumulative sum. If not equal, it means data verification error, and data parsing ends; the value of the parsing status flag is updated to the value of the parsing status flag corresponding to frame header 1, and CountR is assigned to 0; Then, receive the next frame of data to be parsed; If they are equal, extract the function code and instruction data from the cache array; Update the value of the parsing status flag to the value of the parsing status flag corresponding to frame header 1, and assign CountR to 0; Then, receive the next frame of data to be parsed.
10. The universal parsing method of serial communication protocol containing data length according to claim 9, characterized in that: Extracting the function code and command data from the cache array and sending them to the main function of the servo control software, so that the main function of the servo control software executes the corresponding command based on the function code and command data; The second byte of data in the cache array is the function code, and the data from the 3rd to PacketRL-1 bytes are the instruction data.
