Method for processing frame length in binary data frame protocol

CN117714547BActive Publication Date: 2026-09-22THE 54TH RESEARCH INSTITUTE OF CHINA ELECTRONICS TECHNOLOGY GROUP CORPORATION
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311428740.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2026-09-22
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

这种方法较机械,易出错,当协议较多时工作量大

Benefits of technology

[0015](i)本发明提出的方法可以自动计算帧长度的值,无需软件编码人员人工计算长度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117714547B_ABST
    Figure CN117714547B_ABST
Patent Text Reader

Abstract

The present application relates to protocol codec field, specifically to a kind of processing method of frame length in binary data frame protocol.Binary data frame protocol is composed of multiple fields in order, frame length field is the special field of binary data frame protocol, content is the byte length or bit length of a certain section of data in a frame of data.Due to the flexibility and uncertainty of binary data frame protocol, the processing process and encoding logic of frame length field are relatively complex and prone to error.In order to solve this problem, the present application first defaults the frame length content to 0 when encoding frame length, while recording the size of frame length, frame length attribute and the encoding start position of frame length;Second, normally encode other fields, and mark the start position and end position of frame length;Third, delay calculating frame length after protocol encoding is completed, and re-encode frame length at the start position of frame length.The method automatically calculates, reduces the error rate of code, and improves the work efficiency of software personnel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of protocol encoding and decoding, addressing the processing and encoding problems of frame length in binary data frame protocols. A binary data frame protocol consists of multiple fields arranged sequentially. Each field has different data types, lengths, ranges, and scaling factors, and can be omitted in special scenarios. The frame length field is an inherent attribute of the binary data frame protocol, generally of fixed length, and its content is the byte or bit length of a segment of data within a frame. Background Technology

[0002] Due to the flexibility and uncertainty of binary data frame protocols, the processing and encoding logic of the frame length field are complex and prone to errors. The conventional approach is to manually calculate the frame length after the protocol frame is determined and fill in a fixed value. When the protocol changes, the frame length needs to be recalculated manually, and the fixed value needs to be manually modified. This method is mechanical, error-prone, and labor-intensive when there are many protocols. This invention adopts a flexible frame length processing flow and an automated frame length encoding method. Summary of the Invention

[0003] The purpose of this invention is to provide a method for processing frame length in binary data frame protocols, solving the problems of frame length processing and encoding in binary data frame protocols. It automatically calculates and encodes frame length content, with a clear process and simple logic, greatly reducing labor costs and the probability of errors during later protocol and program modifications.

[0004] The technical solution adopted in this invention is as follows:

[0005] A method for processing frame length in a binary data frame protocol includes the following steps:

[0006] Step 1: Set the encoded frame length to 0 and record the encoding start position 'a' of the frame length; at the same time, record the relevant parameters of the frame length, including the size of the frame length and the frame length attribute. The size of the frame length refers to the number of bytes or bits, and the frame length attribute refers to the length in bytes or bits.

[0007] Step 2: When encoding the protocol, encode all fields except length, and mark the start position b and end position c of the frame length;

[0008] Step 3: Let d = cb. Convert d according to the frame length attribute to obtain the frame length, and re-encode the frame length at position a in the encoded binary data stream to complete the encoding of the frame length.

[0009] In step 3, the frame length is obtained by converting d according to the frame length attribute, specifically as follows:

[0010] 3.1: If the unit of d is bytes and the length attribute is bytes, then the frame length = d;

[0011] 3.2: If the unit of d is bits and the length attribute is bytes, then the frame length = d / 8;

[0012] 3.3: If the unit of d is bits and the length attribute is bits, then the frame length = d;

[0013] 3.4: If the unit of d is bytes and the length attribute is bits, then the frame length = d * 8.

[0014] The present invention has the following advantages:

[0015] (i) The method proposed in this invention can automatically calculate the frame length value without the need for software coders to manually calculate the length.

[0016] (ii) The method proposed in this invention can reduce the error rate of code and improve the work efficiency of software personnel. Attached Figure Description

[0017] Figure 1 This is an example diagram illustrating the frame length calculation process of this invention.

[0018] Figure 2 This is a flowchart of the frame length calculation of the present invention. Detailed Implementation

[0019] The present invention will be further described below with reference to specific embodiments and accompanying drawings:

[0020] Figure 1 This is an example of the frame length calculation process. Figure 1 The frame length is in bytes.

[0021] Step 1: The value of the encoding length field is 0, and the length field is recorded as 2 bytes, with the length attribute being bits, and the starting position of the length field is 3;

[0022] Step 2: Record the start position as 5 and the end position as 1045;

[0023] Step 3: Calculate the value of the length field. In the diagram, the length is 1045 - 5 = 1040. Since the length attribute is in bits, 1040 * 8 = 8320 = 0x2080 is encoded in the length field.

[0024] Figure 2 The specific method for handling frame length is as follows:

[0025] Step 1: Set the encoded frame length to 0 and record the encoding start position 'a' of the frame length; at the same time, record the relevant parameters of the frame length, including the size of the frame length and the frame length attribute. The size of the frame length refers to the number of bytes or bits, and the frame length attribute refers to the length in bytes or bits.

[0026] Step 2: When encoding the protocol, encode all fields except length, and mark the start position b and end position c of the frame length;

[0027] Step 3: After the protocol encoding is completed, delay the calculation of the frame length again, and re-encode the frame length at the starting position 'a' of the recorded frame length. Let d = cb. Convert d according to the frame length attribute to obtain the frame length, and re-encode the frame length at position 'a' in the encoded binary data stream to complete the frame length encoding.

[0028] Specifically, the frame length is obtained by converting d according to the frame length attribute.

[0029] 3.1: If the unit of d is bytes and the length attribute is bytes, then the frame length = d;

[0030] 3.2: If the unit of d is bits and the length attribute is bytes, then the frame length = d / 8;

[0031] 3.3: If the unit of d is bits and the length attribute is bits, then the frame length = d;

[0032] 3.4: If the unit of d is bytes and the length attribute is bits, then the frame length = d * 8.

Claims

1. A method for processing frame length in a binary data frame protocol, characterized in that, It includes the following steps: Step 1: Set the encoded frame length to 0 and record the encoding start position 'a' of the frame length; at the same time, record the relevant parameters of the frame length, including the size of the frame length and the frame length attribute. The size of the frame length refers to the number of bytes or bits, and the frame length attribute refers to the length in bytes or bits. Step 2: When encoding the protocol, encode all fields except the length field, and mark the start position b and end position c of the encoding of the other fields; Step 3: Let d = cb. Convert d according to the frame length attribute to obtain the frame length, and re-encode the frame length at position a in the encoded binary data stream to complete the encoding of the frame length.

2. The method for processing frame length in a binary data frame protocol according to claim 1, characterized in that, In step 3, the frame length is obtained by converting d according to the frame length attribute, specifically as follows: 3.1: If the unit of d is bytes and the length attribute is bytes, then the frame length = d; 3.2: If the unit of d is bits and the length attribute is bytes, then the frame length = d / 8; 3.3: If the unit of d is bits and the length attribute is bits, then the frame length = d; 3.4: If the unit of d is bytes and the length attribute is bits, the frame length = d * 8.

Citation Information

Patent Citations

  • Encoding end processing method, decoding end processing method and method for preventing pseudo start code

    CN109743581A

  • Binary data processing method, system and equipment based on JSON (JavaScript Object Notation)

    CN116016296A