CN111338616A - Protocol analysis code generation method and device and electronic equipment - Google Patents

Protocol analysis code generation method and device and electronic equipment Download PDF

Info

Publication number
CN111338616A
CN111338616A CN202010213940.4A CN202010213940A CN111338616A CN 111338616 A CN111338616 A CN 111338616A CN 202010213940 A CN202010213940 A CN 202010213940A CN 111338616 A CN111338616 A CN 111338616A
Authority
CN
China
Prior art keywords
protocol
code
analysis code
protocol analysis
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010213940.4A
Other languages
Chinese (zh)
Inventor
周达文
姚树茂
张建设
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ziroom Information Technology Co Ltd
Original Assignee
Beijing Ziroom Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ziroom Information Technology Co Ltd filed Critical Beijing Ziroom Information Technology Co Ltd
Priority to CN202010213940.4A priority Critical patent/CN111338616A/en
Publication of CN111338616A publication Critical patent/CN111338616A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention relates to the technical field of communication, in particular to a method, a device and electronic equipment for generating protocol analysis codes, wherein the method comprises the steps of displaying a protocol parameter setting interface; responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by a user to generate a protocol analysis code; wherein the protocol parameters include a packet header and a command word. According to the method for generating the protocol analysis code, the protocol parameter setting interface is provided for a user, and the user can automatically generate the protocol analysis code after the user performs related setting on the protocol parameters on the protocol parameter setting interface, wherein for the user, only some protocol parameters need to be provided, specifically, the protocol analysis code generated by the protocol parameters is automatically executed by a background without artificial participation, and the efficiency of developing the protocol analysis code can be improved.

Description

Protocol analysis code generation method and device and electronic equipment
Technical Field
The invention relates to the technical field of communication, in particular to a method and a device for generating a protocol analysis code and electronic equipment.
Background
At present, the types of intelligent household equipment are continuously increased, and then the intelligent household equipment can be controlled by the terminal through an Internet of things system formed by the intelligent gateway and the intelligent household equipment. For example, the smart socket is controlled to be opened by a mobile phone, then a data packet sent by the mobile phone is forwarded to the smart socket through the smart gateway, and a protocol analysis code running in an internal driver of the smart socket analyzes the received data packet to obtain a correct control instruction.
However, for the smart home devices, the protocol analysis codes running in the internal driver thereof need to be developed by engineers according to the steps of reading the protocols corresponding to the smart home devices, understanding the protocols, building a development framework, compiling the codes, testing, trial and error, and the like. Moreover, the development quality of the protocol depends on the level, experience and other factors of an engineer, so that errors are continuously generated in development and test engineering, and a large amount of research and development and test resources are wasted. Therefore, a large amount of research and development force is often required to be put into the protocol docking for continuous debugging, time and labor are wasted in the process, the unstable situation exists, and products need to be polished repeatedly.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for generating a protocol analysis code, and an electronic device, so as to solve the problem of low development efficiency of an existing protocol analysis code.
According to a first aspect, an embodiment of the present invention provides a method for generating a protocol parsing code, including:
displaying a protocol parameter setting interface;
responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by a user to generate a protocol analysis code; wherein the protocol parameters include a packet header and a command word.
According to the method for generating the protocol analysis code, the protocol parameter setting interface is provided for the user, and the user can automatically generate the protocol analysis code after the user performs the related setting of the protocol parameters on the protocol parameter setting interface, wherein for the user, only some protocol parameters need to be provided, specifically, the generation of the protocol analysis code by the protocol parameters is automatically executed by a background without artificial participation, and the efficiency of protocol analysis code development can be improved.
With reference to the first aspect, in a first implementation manner of the first aspect, the generating a protocol parsing code in response to setting of a position and a length of a protocol parameter on the protocol parameter setting interface by a user includes:
acquiring the position and the length of the set protocol parameter;
setting corresponding protocol parameters in a position corresponding to the protocol parameters in a preset protocol analysis code template to form a target protocol analysis code frame;
combining code files corresponding to the target protocol analysis code frame to obtain the protocol analysis code; wherein the code file comprises source code and a library file.
The method for generating the protocol analysis code provided by the embodiment of the invention is based on the preset protocol analysis code template, generates the specific target protocol analysis code frame by using the set protocol parameters, and combines the corresponding code files after the target protocol analysis code frame is generated to obtain the protocol analysis code. The method is based on the preset protocol analysis code template, and can generate the target protocol analysis code frame by directly utilizing the set protocol parameters, thereby avoiding the repeated debugging of the codes caused by manual program compiling and improving the generation efficiency of the protocol analysis codes.
With reference to the first embodiment of the first aspect, in a second embodiment of the first aspect, the combining the code files corresponding to the target protocol analysis code frame to obtain the protocol analysis code includes:
extracting the source code and the library file corresponding to the target protocol analysis code frame;
and combining the source code and the library file according to the form of the target protocol analysis code frame to obtain the protocol analysis code.
With reference to the first implementation manner of the first aspect, in a third implementation manner of the first aspect, the protocol parameter further includes: address, data length, data location, and packet trailer.
With reference to any one of the first to third embodiments of the first aspect, in a fourth embodiment of the first aspect, the protocol parameter further includes a verification manner;
wherein, the position corresponding to the protocol parameter in the preset protocol analysis code template is used for setting the corresponding protocol parameter so as to form a target protocol analysis code frame, and the method comprises the following steps:
acquiring a plurality of preset groups of checking algorithms;
determining a target verification algorithm from the multiple groups of verification algorithms by using the acquired verification modes;
and setting the corresponding target verification algorithm at a position corresponding to the verification mode in the preset protocol analysis code template to form the target protocol analysis code frame.
According to the method for generating the protocol analysis code, provided by the embodiment of the invention, a plurality of groups of check algorithms are arranged in the background, and the corresponding check algorithms are directly extracted from the plurality of groups of check algorithms by using the set check mode, so that the protocol analysis code comprises the check code of the set check mode, and the check code is prevented from being written again.
With reference to the fourth implementation manner of the first aspect, in the fifth implementation manner of the first aspect, the checking manner includes CRC checking, or accumulation and checking.
With reference to the first aspect, in a sixth implementation manner of the first aspect, the protocol parameter setting interface includes input boxes corresponding to the protocol parameters one to one.
According to a second aspect, an embodiment of the present invention further provides a method for testing a protocol parsing code, including:
acquiring a protocol analysis code generated in the first aspect of the present invention or any implementation manner of the first aspect;
acquiring test data in a development environment and calling the protocol code to analyze the test data;
determining whether the test for the protocol parsing code passes based on the parsing result.
In the method for testing the protocol analysis code provided by the embodiment of the invention, after the protocol analysis code is generated by using the method for generating the protocol analysis code, the protocol analysis code needs to be tested to confirm the accuracy of the protocol analysis code; because the test data comes from the development environment and the protocol analysis code is subsequently used in the development environment, the protocol analysis code can be better tested by using the actual test data in the development environment.
With reference to the second aspect, in a first embodiment of the second aspect, the method further comprises:
and when the test on the protocol analysis code is not passed, prompting that the protocol parameter is set wrongly.
According to the test mode of the protocol analysis code provided by the embodiment of the invention, when the test of the protocol analysis code is failed, the setting error of the protocol parameter is prompted to the user so as to remind the user to reset the protocol parameter on the protocol parameter setting interface.
According to a third aspect, an embodiment of the present invention further provides a device for generating a protocol parsing code, including:
the display module is used for displaying a protocol parameter setting interface;
the response module is used for responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by the user so as to generate a protocol analysis code; wherein the protocol parameters include a packet header and a command word.
The device for generating the protocol analysis code provided by the embodiment of the invention can automatically generate the protocol analysis code after the user sets the relevant protocol parameters on the protocol parameter setting interface by providing the protocol parameter setting interface for the user, wherein for the user, only some protocol parameters need to be provided, specifically, the protocol analysis code generated by the protocol parameters is automatically executed by a background without artificial participation, and the efficiency of developing the protocol analysis code can be improved.
According to a fourth aspect, an embodiment of the present invention further provides a device for testing a protocol analysis code, including:
a first obtaining module, configured to obtain a protocol parsing code generated in the first aspect of the present invention or in any implementation manner of the first aspect;
the second acquisition module is used for acquiring test data in a development environment and calling the protocol code to analyze the test data;
and the testing module is used for determining whether the test on the protocol analysis code passes or not based on the analysis result.
According to the test device for the protocol analysis code provided by the embodiment of the invention, after the protocol analysis code is generated by using the generation method for the protocol analysis code, the protocol analysis code needs to be tested to confirm the accuracy of the protocol analysis code; because the test data comes from the development environment and the protocol analysis code is subsequently used in the development environment, the protocol analysis code can be better tested by using the actual test data in the development environment.
According to a fifth aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing therein computer instructions, and the processor executing the computer instructions to perform a method for generating a protocol analysis code according to the first aspect or any one of the embodiments of the first aspect, or to perform a method for testing a protocol analysis code according to the second aspect or any one of the embodiments of the second aspect.
According to a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions for causing a computer to execute the protocol generation method described in the first aspect or any one of the embodiments of the first aspect, or execute the protocol analysis code testing method described in the second aspect or any one of the embodiments of the second aspect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method of generating a protocol resolution code according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method of generating protocol resolution code according to an embodiment of the invention;
FIG. 3 is a flow diagram of a method of testing protocol resolution code according to an embodiment of the invention;
fig. 4 is a block diagram of a structure of a protocol analysis code generation apparatus according to an embodiment of the present invention;
FIG. 5 is a block diagram of a test apparatus for resolving a code according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the protocol analysis code described in the embodiment of the present invention may be applied to a driver of an intelligent home device to implement automatic analysis on a received data packet, so as to obtain a corresponding control instruction. The smart home devices may be smart sockets, smart switches, etc., and the specific types of the smart devices are not limited herein.
In accordance with an embodiment of the present invention, there is provided an embodiment of a method for generating protocol-resolved code, it should be noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
In this embodiment, a method for generating a protocol analysis code is provided, which can be used in an electronic device, such as a computer for generating a protocol analysis code. Fig. 1 is a flowchart of a method for generating a protocol resolution code according to an embodiment of the present invention, and as shown in fig. 1, the flowchart includes the following steps:
and S11, displaying a protocol parameter setting interface.
The electronic equipment displays a protocol parameter setting interface to a user, wherein the protocol parameter setting interface is provided with a plurality of input boxes, and each input box corresponds to one protocol parameter so as to facilitate the setting of the protocol parameters on the protocol parameter interface.
And S12, responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by the user to generate the protocol analysis code.
Wherein the protocol parameters include a packet header and a command word.
After the user inputs specific protocol parameters in the input boxes corresponding to the respective protocol parameters of the protocol parameter setting interface described in the above S11, the electronic device responds to the operation. Since the input boxes of the protocol parameter setting interface correspond to the protocol parameters one to one as described above, after the user inputs the parameters in a certain input box, the electronic device knows which protocol parameter the input parameters correspond to at the moment.
After acquiring the protocol parameters input by the user, the electronic equipment automatically generates a protocol analysis code. The protocol analysis code may be generated by presetting a protocol analysis code template in the electronic device, where the template may be a general analysis code, and after the electronic device acquires a specific protocol parameter, the electronic device may generate the protocol analysis code by setting the protocol parameter at a corresponding position in the protocol analysis code template. Details regarding this step will be described below.
Optionally, the protocol parameter further includes: address, data length, data location, and packet trailer.
According to the method for generating the protocol analysis code, the protocol parameter setting interface is provided for the user, and the user can automatically generate the protocol analysis code after the user performs the relevant setting of the protocol parameters on the protocol parameter setting interface, wherein for the user, only some protocol parameters need to be provided, specifically, the generation of the protocol analysis code by the protocol parameters is automatically executed by a background, and no artificial participation is involved, so that the efficiency of developing the protocol analysis code can be improved.
In this embodiment, a method for generating a protocol analysis code is provided, which can be used in an electronic device, such as a computer for generating a protocol analysis code. Fig. 2 is a flowchart of a method for generating a protocol resolution code according to an embodiment of the present invention, and as shown in fig. 2, the flowchart includes the following steps:
and S21, displaying a protocol parameter setting interface.
Please refer to S11 in fig. 1, which is not described herein again.
And S22, responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by the user to generate the protocol analysis code.
Specifically, the step S22 includes the following steps:
s221, acquiring the position and the length of the set protocol parameter.
As described above, the input boxes provided by the protocol parameter setting interface correspond to the protocol parameters one to one, and after the user inputs the specific protocol parameters, the electronic device can acquire the specific protocol parameters and can determine the position and length of each protocol parameter.
S222, setting corresponding protocol parameters in the positions corresponding to the protocol parameters in the preset protocol analysis code template to form a target protocol analysis code frame.
The electronic equipment is preset with a preset protocol analysis code template, and the electronic equipment sets corresponding protocol parameters at the positions of the preset protocol analysis code template corresponding to the protocol parameters, so that a target protocol analysis code frame corresponding to the set protocol parameters is obtained, and the customization of the target protocol analysis code frame is realized.
After the target protocol analysis code frame is formed, the electronic equipment can utilize the callback function to realize the output of the target protocol analysis code frame and generate a corresponding header file.
And S223, combining the code files corresponding to the target protocol analysis code frame to obtain a protocol analysis code.
Wherein the code file comprises source code and a library file.
After the electronic equipment obtains the target protocol analysis code frame, extracting the source code and the library file corresponding to the target protocol analysis code frame, and combining the source code and the library file according to the form of the target protocol analysis code frame to obtain the protocol analysis code.
After the electronic device generates the protocol resolution code, the protocol resolution code may be output for subsequent testing.
In the method for generating a protocol analysis code provided by this embodiment, based on a preset protocol analysis code template, a specific target protocol analysis code frame is generated by using a set protocol parameter, and after the target protocol analysis code frame is generated, the corresponding code files are combined to obtain the protocol analysis code. The method is based on the preset protocol analysis code template, and can generate the target protocol analysis code frame by directly utilizing the set protocol parameters, thereby avoiding the repeated debugging of the codes caused by manual program compiling and improving the generation efficiency of the protocol analysis codes.
As some optional embodiments of this embodiment, the protocol parameter further includes a check mode, where the check mode may be CRC check, or may be accumulation and check, and the like, and may be specifically set according to an actual situation. Specifically, the step S222 further includes:
(1) and acquiring multiple preset groups of verification algorithms.
A plurality of groups of verification algorithms are stored in the electronic equipment, and the verification algorithms correspond to the verification modes one to one.
(2) And determining a target verification algorithm from the multiple groups of verification algorithms by using the acquired verification modes.
After the electronic equipment acquires the verification mode input by the user on the protocol parameter setting interface, the electronic equipment selects from the multiple groups of verification algorithms by using the acquired verification mode so as to determine a target verification algorithm corresponding to the input verification mode.
(3) And setting a corresponding target verification algorithm at a position corresponding to the verification mode in the preset protocol analysis code template to form a target protocol analysis code frame.
After the target verification algorithm is determined, the electronic device sets the target verification algorithm (for example, in a function call mode) at a position corresponding to a verification mode in a preset protocol analysis code template, so as to form a target protocol analysis code frame.
By arranging multiple groups of check algorithms in the background and directly extracting corresponding check algorithms from the multiple groups of check algorithms by using the set check mode, the protocol analysis codes can comprise the check codes of the set check mode, and the check codes are prevented from being written again.
In accordance with an embodiment of the present invention, there is provided an embodiment of a method for testing protocol-resolved code, it being noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than that presented herein.
The embodiment also provides a test method of the protocol analysis code, which can be used for electronic equipment, such as a computer in an actual development environment. Fig. 3 is a flowchart of a test method for protocol resolution code according to an embodiment of the present invention, and as shown in fig. 3, the flowchart includes the following steps:
s31, the protocol resolution code generated in the above embodiment is acquired.
The protocol parameters used for generating the protocol analysis code are related to a specific development environment, and please refer to the related description of the embodiment shown in fig. 1 or fig. 2 for a specific method for generating the protocol analysis code, which is not described herein again.
And S32, acquiring the test data in the development environment and calling the protocol code to analyze the test data.
After acquiring the test data in the development environment, the electronic device calls the protocol analysis code acquired in S31 to analyze the test data.
And S33, determining whether the test for the protocol analysis code passes or not based on the analysis result.
When the electronic equipment calls the protocol analysis code to analyze the test data, if the result can be analyzed, the electronic equipment indicates that the test on the protocol analysis code passes, and if the result cannot be analyzed, the electronic equipment indicates that the test does not pass. The analysis result indicates that the result is output in the analysis, and if no result is output, the analysis fails, namely the test on the protocol analysis code fails.
In the method for testing the protocol analysis code provided by this embodiment, after the protocol analysis code is generated by using the method for generating the protocol analysis code, the protocol analysis code needs to be tested to confirm the accuracy of the protocol analysis code; because the test data comes from the development environment and the protocol analysis code is subsequently used in the development environment, the protocol analysis code can be better tested by using the actual test data in the development environment.
In some optional implementations of this embodiment, when the test on the protocol parsing code fails, the protocol parameter setting error is prompted.
When the test of the protocol analysis code is failed, the method prompts the user of the setting error of the protocol parameters so as to remind the user to set the protocol parameters again on a protocol parameter setting interface.
In this embodiment, a device for generating a protocol analysis code is further provided, where the device is used to implement the foregoing embodiment and preferred embodiments, and details are not repeated for what has been described. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The present embodiment provides a device for generating a protocol analysis code, as shown in fig. 4, including:
a display module 41, configured to display a protocol parameter setting interface;
a response module 42, configured to respond to setting of a position and a length of a protocol parameter on the protocol parameter setting interface by a user to generate a protocol parsing code; wherein the protocol parameters include a packet header and a command word.
The device for generating protocol analysis codes provided by this embodiment provides a protocol parameter setting interface for a user, and after the user performs related setting of protocol parameters on the protocol parameter setting interface, the protocol analysis codes can be automatically generated, wherein for the user, only some protocol parameters need to be provided, specifically, the generation of the protocol analysis codes by the protocol parameters is automatically executed by a background, and no artificial participation is involved, so that the efficiency of developing the protocol analysis codes can be improved.
In this embodiment, a test apparatus for protocol analysis codes is further provided, and the apparatus is used to implement the foregoing embodiments and preferred embodiments, and the description of the apparatus is omitted for brevity. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The embodiment further provides a device for testing a protocol analysis code, as shown in fig. 5, including:
a first obtaining module 51, configured to obtain a protocol parsing code generated in the first aspect of the present invention or in any implementation manner of the first aspect;
a second obtaining module 52, configured to obtain test data in a development environment and call the protocol code to analyze the test data;
and the testing module 53 is used for determining whether the test for the protocol analysis code passes or not based on the analysis result.
In the test apparatus for protocol analysis codes provided in this embodiment, after the protocol analysis codes are generated by using the above generation method for protocol analysis codes, the protocol analysis codes need to be tested to confirm the accuracy of the protocol analysis codes; because the test data comes from the development environment and the protocol analysis code is subsequently used in the development environment, the protocol analysis code can be better tested by using the actual test data in the development environment.
The protocol analysis code generation device or the test device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and a memory that execute one or more software or fixed programs, and/or other devices that can provide the above functions.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
An embodiment of the present invention further provides an electronic device, which has the apparatus for generating a protocol analysis code shown in fig. 4 or the apparatus for testing a protocol analysis code shown in fig. 5.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an alternative embodiment of the present invention, and as shown in fig. 6, the electronic device may include: at least one processor 61, such as a CPU (Central Processing Unit), at least one communication interface 63, memory 64, at least one communication bus 62. Wherein a communication bus 62 is used to enable the connection communication between these components. The communication interface 63 may include a Display (Display) and a Keyboard (Keyboard), and the optional communication interface 63 may also include a standard wired interface and a standard wireless interface. The Memory 64 may be a high-speed RAM Memory (volatile Random Access Memory) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 64 may optionally be at least one memory device located remotely from the processor 61. Wherein the processor 61 may be in connection with the apparatus described in fig. 4 or 5, the memory 64 stores an application program, and the processor 61 calls the program code stored in the memory 64 for performing any of the above-mentioned method steps.
The communication bus 62 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 62 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
The memory 64 may include a volatile memory (RAM), such as a random-access memory (RAM); the memory may also include a non-volatile memory (english: non-volatile memory), such as a flash memory (english: flash memory), a hard disk (english: hard disk drive, abbreviation: HDD), or a solid-state drive (english: SSD); the memory 64 may also comprise a combination of the above types of memory.
The processor 61 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of CPU and NP.
The processor 61 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The aforementioned PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Optionally, the memory 64 is also used to store program instructions. The processor 61 may call program instructions to implement a method for generating a protocol resolution code as shown in the embodiments of fig. 1 and 2 of the present application, or a method for testing a protocol resolution code as shown in the embodiment of fig. 3.
The embodiment of the invention also provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the generation method or the test method of the protocol analysis code in any method embodiment. The storage medium may be a magnetic Disk, an optical Disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a flash Memory (FlashMemory), a Hard Disk (Hard Disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (10)

1. A method for generating a protocol analysis code, comprising:
displaying a protocol parameter setting interface;
responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by a user to generate a protocol analysis code; wherein the protocol parameters include a packet header and a command word.
2. The method of claim 1, wherein generating a protocol resolution code in response to a user setting a position and a length of a protocol parameter on the protocol parameter setting interface comprises:
acquiring the position and the length of the set protocol parameter;
setting corresponding protocol parameters in a position corresponding to the protocol parameters in a preset protocol analysis code template to form a target protocol analysis code frame;
combining code files corresponding to the target protocol analysis code frame to obtain the protocol analysis code; wherein the code file comprises source code and a library file.
3. The method of claim 2, wherein the combining the code files corresponding to the target protocol parsing code framework to obtain the protocol parsing code comprises:
extracting the source code and the library file corresponding to the target protocol analysis code frame;
and combining the source code and the library file according to the form of the target protocol analysis code frame to obtain the protocol analysis code.
4. The method of claim 2, wherein the protocol parameters further comprise: address, data length, data location, and packet trailer.
5. The method according to any one of claims 2 to 4, wherein the protocol parameters further include a verification means;
wherein, the position corresponding to the protocol parameter in the preset protocol analysis code template is used for setting the corresponding protocol parameter so as to form a target protocol analysis code frame, and the method comprises the following steps:
acquiring a plurality of preset groups of checking algorithms;
determining a target verification algorithm from the multiple groups of verification algorithms by using the obtained verification mode;
and setting the corresponding target verification algorithm at a position corresponding to the verification mode in the preset protocol analysis code template to form the target protocol analysis code frame.
6. The method of claim 5, wherein the check means comprises a CRC check, or a sum check.
7. The method of claim 1, wherein the protocol parameter setting interface comprises input boxes corresponding to the protocol parameters one to one.
8. An apparatus for generating a protocol analysis code, comprising:
the display module is used for displaying a protocol parameter setting interface;
the response module is used for responding to the setting of the position and the length of the protocol parameter on the protocol parameter setting interface by the user so as to generate a protocol analysis code; wherein the protocol parameters include a packet header and a command word.
9. An electronic device, comprising:
a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the method of generating a protocol code according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer instructions for causing a computer to execute the method for generating a protocol code according to any one of claims 1 to 7.
CN202010213940.4A 2020-03-24 2020-03-24 Protocol analysis code generation method and device and electronic equipment Pending CN111338616A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010213940.4A CN111338616A (en) 2020-03-24 2020-03-24 Protocol analysis code generation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010213940.4A CN111338616A (en) 2020-03-24 2020-03-24 Protocol analysis code generation method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN111338616A true CN111338616A (en) 2020-06-26

Family

ID=71182514

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010213940.4A Pending CN111338616A (en) 2020-03-24 2020-03-24 Protocol analysis code generation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN111338616A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112714044A (en) * 2020-12-28 2021-04-27 北京恒光信息技术股份有限公司 Network data analysis method and device based on formal language protocol
CN113377363A (en) * 2021-07-14 2021-09-10 深圳市集贤科技有限公司 Cloud implementation method for automatically generating source codes for various electric control end private protocols
CN113377362A (en) * 2021-07-14 2021-09-10 深圳市集贤科技有限公司 Automatic source code generation and adaptation method for private protocol analysis of electric control end
CN114115833A (en) * 2022-01-25 2022-03-01 北京安帝科技有限公司 Automatic generation method and device of protocol audit code

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070025259A1 (en) * 2005-08-01 2007-02-01 Barry Reinhold Communication protocol testing system
CN104331292A (en) * 2014-11-03 2015-02-04 重庆邮电大学 Method for generating configuration for middleware protocol conversion of Internet of vehicles
CN106603482A (en) * 2016-05-26 2017-04-26 欣旺达电子股份有限公司 Method and device for automatically generating CAN communication protocol code
CN106850531A (en) * 2016-11-21 2017-06-13 中国航天科工集团第四研究院第四总体设计部 A kind of protocol code generation method based on template
CN109344230A (en) * 2018-10-31 2019-02-15 任志颖 Code library file generation, code search, connection, optimization and transplantation method
CN109887263A (en) * 2019-02-14 2019-06-14 广州视源电子科技股份有限公司 Data transmission method, device, equipment and storage medium
CN110249307A (en) * 2018-12-29 2019-09-17 阿里巴巴集团控股有限公司 System and method for executing primary contract on block chain

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070025259A1 (en) * 2005-08-01 2007-02-01 Barry Reinhold Communication protocol testing system
CN104331292A (en) * 2014-11-03 2015-02-04 重庆邮电大学 Method for generating configuration for middleware protocol conversion of Internet of vehicles
CN106603482A (en) * 2016-05-26 2017-04-26 欣旺达电子股份有限公司 Method and device for automatically generating CAN communication protocol code
CN106850531A (en) * 2016-11-21 2017-06-13 中国航天科工集团第四研究院第四总体设计部 A kind of protocol code generation method based on template
CN109344230A (en) * 2018-10-31 2019-02-15 任志颖 Code library file generation, code search, connection, optimization and transplantation method
CN110249307A (en) * 2018-12-29 2019-09-17 阿里巴巴集团控股有限公司 System and method for executing primary contract on block chain
CN109887263A (en) * 2019-02-14 2019-06-14 广州视源电子科技股份有限公司 Data transmission method, device, equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112714044A (en) * 2020-12-28 2021-04-27 北京恒光信息技术股份有限公司 Network data analysis method and device based on formal language protocol
CN112714044B (en) * 2020-12-28 2022-06-07 北京恒光信息技术股份有限公司 Network data analysis method, device and storage medium based on formal language protocol
CN113377363A (en) * 2021-07-14 2021-09-10 深圳市集贤科技有限公司 Cloud implementation method for automatically generating source codes for various electric control end private protocols
CN113377362A (en) * 2021-07-14 2021-09-10 深圳市集贤科技有限公司 Automatic source code generation and adaptation method for private protocol analysis of electric control end
CN113377362B (en) * 2021-07-14 2022-05-17 深圳市集贤科技有限公司 Automatic source code generation and adaptation method for private protocol analysis of electric control end
CN114115833A (en) * 2022-01-25 2022-03-01 北京安帝科技有限公司 Automatic generation method and device of protocol audit code

Similar Documents

Publication Publication Date Title
CN111338616A (en) Protocol analysis code generation method and device and electronic equipment
CN111782330B (en) Page data acquisition method, device and equipment based on Web application
CN112996020B (en) Bluetooth-based automatic test method and device and Bluetooth test terminal
CN110209520B (en) Method and device for improving SSD (solid State disk) testing efficiency, computer equipment and storage medium
CN109739700B (en) Interface testing method and device
CN105302722A (en) CTS automatic test method and apparatus
CN112115055A (en) Multi-machine automatic testing method and device and computer equipment
CN112286825A (en) Screen testing method and device for intelligent cabin and electronic equipment
CN114780326A (en) Cross-platform calibration test method, device and equipment
CN109656791B (en) gPC performance test method and device based on Jmeter
CN111277476A (en) Gateway controller function verification method, gateway controller function verification device, computer equipment and storage medium
CN112858876A (en) Self-adaptive chip automatic testing method
CN110908489A (en) Test method and test equipment for battery management system
CN112583617A (en) Fault determination method, server, control terminal and storage medium
CN112486497A (en) Compiling configuration file generation method and device, electronic equipment and storage medium
CN114442930A (en) Method and device for controlling group disk array, electronic equipment and readable storage medium
CN111949510B (en) Test processing method, device, electronic equipment and readable storage medium
CN112486838A (en) Interface testing method and device, computer equipment and storage medium
CN115766541B (en) Device testing method, device, computer equipment and storage medium
CN114448848B (en) Switch testing method and device, electronic equipment and storage medium
CN116610557B (en) Action binding information debugging method and device, storage medium and electronic equipment
CN110231812B (en) Industrial Internet of things linkage and execution method and device, intelligent equipment and system
CN109800167B (en) Test method, test client and test system
CN115685959A (en) Diagnostic write configuration test method, device, equipment and storage medium
CN113656289A (en) Test method, test device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200626