CN112948194B - Communication protocol testing method and device - Google Patents

Communication protocol testing method and device Download PDF

Info

Publication number
CN112948194B
CN112948194B CN202110276154.3A CN202110276154A CN112948194B CN 112948194 B CN112948194 B CN 112948194B CN 202110276154 A CN202110276154 A CN 202110276154A CN 112948194 B CN112948194 B CN 112948194B
Authority
CN
China
Prior art keywords
command
response command
communication protocol
parameters
field
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.)
Active
Application number
CN202110276154.3A
Other languages
Chinese (zh)
Other versions
CN112948194A (en
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.)
China United Network Communications Group Co Ltd
China Information Technology Designing and Consulting Institute Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
China Information Technology Designing and Consulting Institute 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 China United Network Communications Group Co Ltd, China Information Technology Designing and Consulting Institute Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202110276154.3A priority Critical patent/CN112948194B/en
Publication of CN112948194A publication Critical patent/CN112948194A/en
Application granted granted Critical
Publication of CN112948194B publication Critical patent/CN112948194B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • G06F11/221Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test buses, lines or interfaces, e.g. stuck-at or open line faults
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The application provides a method and a device for testing a communication protocol, relates to the technical field of communication, and aims at least to solve the problems that communication protocol test software with specific protocol requirements is compiled for different devices in the prior art, and development workload is large. The test method of the communication protocol is applied to a first electronic device in a communication system, the communication system comprises the first electronic device and a second electronic device, and the test method of the communication protocol comprises the following steps: acquiring a configuration file; the configuration file comprises a down command and a first response command corresponding to the target communication protocol; sending an issuing command; receiving a second response command from the second electronic device; and under the condition that the second response command is consistent with the first response command, determining that a target communication protocol is adopted between the first electronic device and the second electronic device.

Description

Communication protocol testing method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for testing a communication protocol.
Background
Currently, a large number of devices have serial interfaces, for example, devices such as an air conditioner, a power distribution cabinet, an uninterruptible power supply (uninterruptible power supply, UPS) and the like all have serial interfaces, and serial communication protocols of different devices often have large differences, for example, the verification manners of the serial communication protocols are different. Thus, when testing the communication protocol of the equipment, the communication protocol test program required by the specific protocol needs to be developed for different equipment, and the development workload is large.
Disclosure of Invention
The application provides a method and a device for testing a communication protocol, which at least solve the problems of the prior art that communication protocol test software with specific protocol requirements is compiled aiming at different devices, and the development workload is large. The technical scheme of the application is as follows:
according to a first aspect of the present application, there is provided a method for testing a communication protocol, applied to a first electronic device in a communication system, the communication system including the first electronic device and a second electronic device, the method for testing the communication protocol comprising: the first electronic device acquires the configuration file and sends a down command. And then, the first electronic device receives a second response command from the second electronic device, and determines that a target communication protocol is adopted between the first electronic device and the second electronic device under the condition that the second response command is consistent with the first response command. The configuration file comprises a down command and a first response command corresponding to the target communication protocol.
In the above scheme, the first electronic device determines the issuing command according to the configuration file, compares the received second response command with the first response command in the configuration file, and determines the communication protocol between the first electronic device and the second electronic device. In this way, the configuration file is independent of the test program of the device, and when the communication protocol between two devices (such as the first electronic device and the second electronic device) is tested, only the configuration file required by the device is required to be configured, and the communication protocol between the two devices can be determined by utilizing the universal test program. The communication protocol testing program which is required by specific protocol needs to be developed for different equipment when the communication protocol of the equipment is tested is avoided, the universality of the test communication protocol scheme is improved, and the development workload is reduced.
Optionally, the first response command and the second response command each include a check field, and before "determining that the second response command is consistent with the first response command", the method for testing a communication protocol further includes: the first electronic device determines a check value of the first response command according to the second response command and a preset formula.
In the above scheme, the first electronic device determines the check value in the first response command according to the preset formula and the second response command. In this way, whether the target communication protocol is adopted between the first electronic device and the second electronic device or not can be detected according to whether the check value in the second response command is consistent with the check value in the first response command or not, and whether errors occur in the check value in the second response command in the transmission process can also be detected.
Optionally, the first reply command and the second reply command each include at least one parameter, and the method for determining that the second reply command is consistent with the first reply command includes: the first electronic device performs a comparison operation on the parameters in the second reply command and the parameters in the first reply command, and determines that the second reply command is consistent with the first reply command if it is determined that the parameters in the second reply command are the same as the parameters in the first reply command.
The comparison operation comprises the following steps: the first electronic device determines the reception parameters and the configuration parameters and determines the first field and the second field. Then, the first electronic device determines that the reception parameter and the configuration parameter are the same in the case that the content of the second field is determined to be the same as the content of the first field. The configuration parameters are any parameters in the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command. The first field belongs to a configuration parameter, the second field belongs to a receiving parameter, and the length of the first field is the same as that of the second field.
In the scheme, the first electronic equipment extracts and compares the fields in the receiving parameters (belonging to the second response command) and the configuration parameters (belonging to the first response command), and the fields are irrelevant to the factors such as Chinese character description, byte total length and the like of the parameters, so that the universality of the test communication protocol scheme is further improved.
According to a second aspect of the present application, there is provided a test apparatus for a communication protocol, applied to a first electronic device in a communication system, the communication system including the first electronic device and a second electronic device. The testing device comprises an acquisition module, a sending module and a determining module. The acquisition module is used for acquiring the configuration file; the configuration file comprises a down command and a first response command corresponding to the target communication protocol; the sending module is used for sending the issuing command acquired by the acquisition module; the acquisition module is also used for receiving a second response command from the second electronic equipment; and the determining module is used for determining that a target communication protocol is adopted between the first electronic equipment and the second electronic equipment under the condition that the second response command acquired by the acquiring module is consistent with the first response command.
Optionally, the first response command and the second response command each include a check field; the determining module is further configured to determine a check value of the first response command according to the second response command and a preset formula.
Optionally, the first reply command and the second reply command each include at least one parameter; the determining module is specifically configured to: performing a comparison operation on the parameters in the second response command and the parameters in the first response command; in the case that the parameters in the second answer command are determined to be the same as the parameters in the first answer command, the second answer command is determined to be consistent with the first answer command.
The comparison operation comprises the following steps: determining a receiving parameter and a configuration parameter; the configuration parameters are any parameters in the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command; determining a first field and a second field, wherein the first field belongs to a configuration parameter, the second field belongs to a receiving parameter, and the length of the first field is the same as that of the second field; in the case where it is determined that the content of the second field is the same as the content of the first field, it is determined that the reception parameter and the configuration parameter are the same.
According to a third aspect of the present application, there is provided a test apparatus of a communication protocol, for use with a first electronic device in a communication system, the test apparatus comprising: a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to execute instructions to implement the method of testing of any of the alternative communication protocols as in the first aspect.
According to a fourth aspect of the present application there is provided a computer readable storage medium having instructions stored thereon which, when executed by a processor of a test apparatus of a communication protocol, enable the test apparatus of a communication protocol to perform the method of testing a communication protocol as selectable in any of the first aspects above.
According to a fifth aspect of the present application there is provided a computer program product comprising computer instructions which, when executed by a processor of a test apparatus of a communication protocol, cause the test apparatus of a communication protocol to perform the test method of any of the alternative communication protocols as in the first aspect.
It should be appreciated that any of the above-mentioned testing apparatuses, computer-readable storage media or computer program products for communication protocols are used to perform the above-mentioned methods, and thus, the advantages achieved by the methods are referred to as the advantages of the above methods and the corresponding solutions in the following detailed embodiments, and will not be described herein.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application and do not constitute a undue limitation on the application.
Fig. 1 is a schematic diagram of a communication system according to an exemplary embodiment;
FIG. 2 is a schematic diagram of a hardware architecture of a computing device, shown according to an example embodiment;
FIG. 3 is one of the flow charts of a method of testing a communication protocol shown in accordance with an exemplary embodiment;
FIG. 4 is a flowchart illustrating a determination that an answer command is consistent in accordance with an example embodiment;
FIG. 5 is a second flow chart of a method of testing a communication protocol, shown in accordance with an exemplary embodiment;
fig. 6 is a schematic diagram showing a structure of a test apparatus of a communication protocol according to an exemplary embodiment.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the embodiments of the present application, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, the words "first", "second", etc. are used to distinguish the same item or similar items having substantially the same function and effect. It will be appreciated by those of skill in the art that the words "first," "second," and the like do not limit the amount and order of execution, and that the words "first," "second," and the like do not necessarily differ. The technical features described in the first and second descriptions are not sequential or in order of magnitude.
In embodiments of the application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g." in an embodiment should not be taken as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion that may be readily understood.
In the description of the present application, unless otherwise indicated, "/" means that the objects associated in tandem are in a "or" relationship, e.g., A/B may represent A or B; the "and/or" in the present application is merely an association relationship describing the association object, and indicates that three relationships may exist, for example, a and/or B may indicate: there are three cases, a alone, a and B together, and B alone, wherein a, B may be singular or plural. Also, in the description of the present application, unless otherwise indicated, "a plurality" means two or more than two. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b, or c may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or plural.
In the embodiment of the present application, at least one may also be described as one or more, and a plurality may be two, three, four or more, and the present application is not limited thereto.
Serial ports (such as RS232, RS485, RS422 and the like) communication can be widely applied to various devices due to the advantages of low price, mature technology and the like. For example, air conditioning, power distribution cabinets, UPS and other devices all have serial interfaces. However, due to the wide variety of devices, and the serial communication protocols of different devices often have large differences, for example, the verification manners of the serial communication protocols are often different. In addition, even if the modbus protocol implemented based on serial ports is also used, the fields of the monitoring content, control commands, etc. are generally determined by the protocol developer. Thus, when testing the communication protocol of the equipment, the communication protocol test program required by the specific protocol needs to be developed for different equipment, and the development workload is large.
In view of the above problems, the present application provides a method for testing a communication protocol, which obtains a first response command in a configuration file, receives a second response command from a second electronic device, and determines that a target communication protocol is adopted between the first electronic device and the second electronic device when determining that the second response command is consistent with the first response command, so that the universality of a test communication protocol scheme can be improved, and the development workload can be reduced.
The environment in which embodiments of the present application are implemented will be described.
The serial communication is generally master-slave communication, the upper computer sends a down command, and the lower computer replies a response command. Therefore, fig. 1 is a schematic structural diagram of a communication system according to an embodiment of the present application, and the method for testing a communication protocol according to the embodiment of the present application may be applied to the communication system. As shown in fig. 1, the communication system comprises a first electronic device 11 and a second electronic device 12. The first electronic device 11 communicates with the second electronic device 12 through a wired communication method or a wireless communication method.
In the communication system, the first electronic device 11 and the second electronic device 12 may both be used as an upper computer to send a down command, or may be used as a lower computer to reply to a response command, which is not limited in the present application. In the present application, the first electronic device 11 is used as an upper computer to send a down command, and the second electronic device 12 is used as a lower computer to reply to a response command.
The first electronic device 11 is mainly configured to obtain a configuration file and send a command to issue; a second reply command is received from the second electronic device 12 and, in the event that the second reply command is determined to be consistent with the first reply command, a targeted communication protocol is determined to be employed with the second electronic device 12. The second electronic device 12 is mainly configured to receive the issuing command from the first electronic device 11, generate a second response command, and send the second response command to the first electronic device 11.
In some embodiments, the first electronic device 11 and the second electronic device 12 may be mobile phones, tablet computers, notebook computers, desktop computers, portable computers, and the like, which are not limited in this application.
The basic hardware structure of the first electronic device 11 and the second electronic device 12 is similar, and includes elements included in the computing apparatus shown in fig. 2. The hardware configuration of the first electronic device 11 and the second electronic device 12 will be described below using the computing apparatus shown in fig. 2 as an example.
FIG. 2 is a schematic diagram of a computing device, according to an example embodiment. The computing device is applied to the communication system, and the computing device may be: smart phones, tablet computers, notebook computers or desktop computers, etc. The computing device may include a processor 202, the processor 202 being configured to execute application code to implement the method of testing a communication protocol of the present application.
The processor 202 may be a central processing unit (central processing unit, CPU), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
As shown in fig. 2, the computing device may also include a memory 203. The memory 203 is used for storing application program codes for executing the scheme of the present application, and the execution is controlled by the processor 202.
The memory 203 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc read-only memory (compact disc read-only memory) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory 203 may be stand alone and be coupled to the processor 202 via a bus 204. Memory 203 may also be integrated with processor 202.
As shown in fig. 2, the computing device may also include a communication interface 201, wherein the communication interface 201, processor 202, memory 203 may be coupled to each other, for example, via bus 204. The communication interface 201 is used to interact with other devices, for example to support information interaction of a computing apparatus with other devices.
It should be noted that the apparatus structure shown in fig. 2 does not constitute a limitation of the computing device, and the computing device may include more or less components than those shown in fig. 2, or may combine some components, or may be arranged in different components.
The following describes a method for testing a communication protocol according to an embodiment of the present application with reference to the accompanying drawings.
Fig. 3 is a flow chart diagram illustrating a method of testing a communication protocol, according to an exemplary embodiment. As shown in fig. 3, the method for testing the communication protocol may include the following steps.
Step 31: the testing device of the communication protocol obtains the configuration file.
The configuration file comprises a down command and a first response command corresponding to the target communication protocol.
The command (including issuing command and response command) fields of the configuration file in the present application include, but are not limited to, frame header, communication protocol version number, device address, device type, command control word, command information, check field, frame end.
Specifically, the frame header is used to indicate a flag bit for starting transmission of the communication protocol.
The communication protocol version number is used to represent the version number that the communication protocol follows, where the communication protocol typically has multiple versions.
The device address is an address mark of a lower computer (second electronic device in the application), wherein the lower computer cannot communicate if the address is not matched.
The device type is used to represent the device code of the lower computer. For example, air conditioning, diesel engines, batteries, etc. have different equipment codes.
The command control word (corresponding to the response feedback of the lower computer) is used to indicate the code of the command issued by the upper computer (the first electronic device in the present application). For example, the code of the command such as analog quantity, remote control, setting parameter, etc. is acquired. Similarly, the response feedback of the lower computer is used for representing the coding of the content type of the response feedback of the upper computer by the lower computer. For example, command frames are normal, command frame address errors, command frame control command errors, etc.
The command information (corresponding to the response information of the lower computer) includes an information body of the upper computer issuing the command. Similarly, the response information includes an information body of the lower computer response command.
One or more check fields are provided, and the correctness of the transmission data is checked according to a preset check mode.
The end of frame is the communication protocol transmission end character.
The correctness of the transmission data is checked according to a preset check mode because the check field is required. Therefore, in order to facilitate calculation of the check value corresponding to the check field in the command, the configuration file in the present application adopts a file format capable of writing a function. For example, the excel file is used to generate the configuration file, so that a corresponding check function can be written for the check field in the excel file, and one or more check values can be generated in the check field. For other information in the command field, the configuration file may be entered by the relevant personnel line by line according to the communication protocol content.
Optionally, the configuration file may further include one or more of a test command sequence number, a test command name, a number system flag bit, a data type, a data proportion, a transfer data type, a data value, and an end of frame.
Specifically, the test command serial number is used to represent the serial number of the test command on the test interface of the test software.
The test command name is the Chinese description of the displayed test command in the test interface of the test software. For example, analog quantity is obtained, the remote control oil engine is started, the remote control switch power supply is started, and the like.
The number system flag bit is used for indicating the number system of the data in the configuration file. E.g., 10, 16, etc. For example, when the command of 'setting the starting temperature of the air conditioner' is issued, setting parameters are manually filled, 30 degrees of 10 system are filled, which is more convenient and visual than 16 system, and when the flag bit is 10 system, the test software can convert 30 of 10 system into 30 of 16 system (namely 1 EH) and issue.
Data types include floating point types (including double-precision floating point numbers and single-precision floating point numbers), signed integer types, unsigned integer types, character types, and the like. In the command information of the command field, the value may be directly filled in, and then converted to 16 by test software, or to a us information exchange standard code (American standard code for information interchange, ASII) code. In the response information of the command field, the test software converts the 16-ary (or ASII code) value of the relevant 1 or more bytes into a readable 10-ary according to the data type hint.
The data ratio is used to represent the number of transmit integers.
The transmission data type is used to represent a number system when transmitting data in a command field, for example, converting the data in the command field into 16-ary, or ASII code transmission.
The data value is used to represent a numerical value of command information and response information of the display command field according to the above-described number constraint condition.
The end of frame is a data transfer end identifier.
For other information except the command field in the configuration file, the configuration file can be input by related personnel line by line according to the content of the communication protocol.
And then, the testing device of the communication protocol reads the configuration file to obtain a issuing command and a first response command corresponding to the target communication protocol.
Step 32: the test device of the communication protocol sends a down command.
Specifically, the testing device of the communication protocol sends a down command to the second electronic device.
Step 33: the test means of the communication protocol receives a second answer command from the second electronic device.
Wherein, the first response command and the second response command both comprise check fields.
In one possible implementation, the test device of the communication protocol determines the check value of the first response command according to the second response command and a preset formula.
Specifically, after receiving the second response command, the testing device of the communication protocol calls a check function corresponding to a check field of the issuing command in the configuration file, and calculates a check value of the first response command according to parameters and the check function in the second response command.
In the above scheme, the testing device of the communication protocol determines the check value in the first response command according to the preset formula and the second response command. In this way, whether the target communication protocol is adopted between the testing device of the communication protocol and the second electronic equipment or not can be detected according to whether the check value in the second response command is consistent with the check value in the first response command or not, and whether an error occurs in the check value in the second response command in the transmission process can also be detected.
Step 34: and the testing device of the communication protocol determines that the target communication protocol is adopted between the first electronic equipment and the second electronic equipment under the condition that the second response command is consistent with the first response command.
Wherein the first reply command and the second reply command each include at least one parameter.
Specifically, as shown in fig. 4, the method for determining that the second response command is consistent with the first response command by the test device of the communication protocol includes the following steps.
S1, the testing device of the communication protocol executes comparison operation on the parameters in the second response command and the parameters in the first response command.
Specifically, the comparison operation includes: the test device of the communication protocol determines the receiving parameters and the configuration parameters, and determines the first field and the second field, and in the case that the content of the second field is determined to be the same as the content of the first field, the test device of the communication protocol determines that the receiving parameters and the configuration parameters are the same.
The configuration parameters are any one parameter of the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command. The first field belongs to a configuration parameter, the second field belongs to a receiving parameter, and the length of the first field is the same as that of the second field.
For example, when the configuration parameter is obtained by taking 2 bytes from the frame header to obtain the first field, the receiving parameter is also obtained by taking 2 bytes from the frame header to obtain the second field, and then, in the case that the content of the second field is the same as the content of the first field, the testing device of the communication protocol determines that the receiving parameter and the configuration parameter are the same.
Wherein the lengths of the first field and the second field are related to the data type in the configuration file. For example, the data type in the configuration file is of a character type, the length of the first field and the second field takes 1 byte, or the data type in the configuration file is of an unsigned integer type, the length of the first field and the second field takes 2 bytes, or the data type in the configuration file is of a floating point type, the length of the first field and the second field takes 4 bytes.
S2, under the condition that the parameters in the second response command and the parameters in the first response command are the same, the testing device of the communication protocol determines that the second response command is consistent with the first response command.
In the scheme, the testing device of the communication protocol extracts and compares the fields in the receiving parameters (belonging to the second response command) and the configuration parameters (belonging to the first response command), is irrelevant to the factors such as Chinese character description, byte total length and the like of the parameters, and further improves the universality of the scheme of the test communication protocol.
In this way, the test device of the communication protocol determines that the second response command is consistent with the first response command when the parameters in the second response command are determined to be the same as the parameters in the first response command, and determines that the target communication protocol is adopted between the first electronic device and the second electronic device when the second response command is determined to be consistent with the first response command.
In the application, the testing device of the communication protocol determines the issuing command according to the configuration file, compares the received second response command with the first response command in the configuration file, and determines the communication protocol between the testing device of the communication protocol and the second electronic equipment. In this way, the configuration file is independent of the test program of the device, and when the communication protocol between two devices (such as the test device of the communication protocol and the second electronic device) is tested, only the configuration file required by the device is required to be configured, and the communication protocol between the two devices can be determined by utilizing the universal test program. The communication protocol testing program which is required by specific protocol needs to be developed for different equipment when the communication protocol of the equipment is tested is avoided, the universality of the test communication protocol scheme is improved, and the development workload is reduced.
Fig. 5 is a flow chart diagram illustrating a method of testing a communication protocol, according to an exemplary embodiment. When the method is applied to a communication system as shown in fig. 1, the method may include the following steps as shown in fig. 5.
Step 51: the first electronic device obtains a configuration file.
The configuration file comprises a down command and a first response command corresponding to the target communication protocol.
Step 52: the first electronic device sends a down command.
Step 53: the second electronic device replies to the second reply command.
Step 54: and the first electronic device determines to adopt a target communication protocol with the second electronic device under the condition that the second response command is consistent with the first response command.
In the embodiments, the steps 51 to 54 are similar to the steps 31 to 34 in another embodiment, and the detailed description of the steps 31 to 34 is referred to herein and will not be repeated.
In the above scheme, the first electronic device determines the issuing command according to the configuration file, compares the received second response command with the first response command in the configuration file, and determines the communication protocol between the first electronic device and the second electronic device. In this way, the configuration file is independent of the test program of the device, and when the communication protocol between two devices (such as the first electronic device and the second electronic device) is tested, only the configuration file required by the device is required to be configured, and the communication protocol between the two devices can be determined by utilizing the universal test program. The communication protocol testing program which is required by specific protocol needs to be developed for different equipment when the communication protocol of the equipment is tested is avoided, the universality of the test communication protocol scheme is improved, and the development workload is reduced.
The embodiment of the application can divide the functional modules of the test device of the communication protocol according to the method embodiment, for example, each functional module can be divided corresponding to each function, and two or more functions can be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
The method provided by the embodiment of the application is described in detail above with reference to fig. 3-5. The following describes in detail a testing apparatus for a communication protocol according to an embodiment of the present application with reference to fig. 6. It should be understood that the descriptions of the apparatus embodiments and the descriptions of the method embodiments correspond to each other, and thus, descriptions of details not described may be referred to the above method embodiments, which are not repeated herein for brevity.
Fig. 6 is a schematic diagram showing a structure of a test apparatus of a communication protocol according to an exemplary embodiment. Referring to fig. 6, the test device of the communication protocol is applied to a first electronic device in a communication system, where the communication system includes the first electronic device and a second electronic device, and the test device includes an acquisition module 61, a transmission module 62, and a determination module 63.
An obtaining module 61, configured to obtain a configuration file; the configuration file comprises a down command and a first response command corresponding to the target communication protocol. For example, referring to fig. 3, the obtaining module 61 is configured to perform step 31. A sending module 62, configured to send the issuing command acquired by the acquiring module 61. For example, referring to FIG. 3, a sending module 62 is shown for performing step 32. The obtaining module 61 is further configured to receive a second response command from the second electronic device. For example, referring to fig. 3, the obtaining module 61 is further configured to perform step 33. A determining module 63, configured to determine that the target communication protocol is adopted between the first electronic device and the second electronic device when the second answer command obtained by the obtaining module 61 is consistent with the first answer command. For example, referring to FIG. 3, the determination module 63 is further configured to perform step 34.
Optionally, the first response command and the second response command each include a check field; the determining module 63 is further configured to determine a check value of the first response command according to the second response command and a preset formula.
Optionally, the first reply command and the second reply command each include at least one parameter; the determining module 63 is specifically configured to: performing a comparison operation on the parameters in the second response command and the parameters in the first response command; in the case that the parameters in the second answer command are determined to be the same as the parameters in the first answer command, the second answer command is determined to be consistent with the first answer command. For example, referring to fig. 4, the determining module 63 is specifically configured to perform steps S1-S2. The comparison operation comprises the following steps: determining a receiving parameter and a configuration parameter; the configuration parameters are any parameters in the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command; determining a first field and a second field, wherein the first field belongs to a configuration parameter, the second field belongs to a receiving parameter, and the length of the first field is the same as that of the second field; in the case where it is determined that the content of the second field is the same as the content of the first field, it is determined that the reception parameter and the configuration parameter are the same.
Of course, the testing device for the communication protocol provided by the embodiment of the application includes, but is not limited to, the above module.
In actual implementation, the acquisition module 61, the transmission module 62, and the determination module 63 may be implemented by the processor 202 shown in fig. 2 calling the program code in the memory 203. The specific implementation process may refer to the description of the test method part of any one of the communication protocols shown in fig. 3 to 5, and will not be repeated here.
Another embodiment of the present application also provides a computer readable storage medium having instructions stored therein that, when executed on a test device of a communication protocol, perform a test method of a communication protocol according to any of the embodiments shown in fig. 3-5.
In another embodiment of the present application, there is also provided a computer program product comprising computer-executable instructions stored in a computer-readable storage medium. The processor of the test device of the communication protocol may read the computer-executable instructions from the computer-readable storage medium, the processor executing the computer-executable instructions causing the test device of the communication protocol to perform the test method of the communication protocol of any of the embodiments shown in fig. 3-5.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (6)

1. A method for testing a communication protocol, applied to a first electronic device in a communication system, wherein the communication system includes the first electronic device and a second electronic device, the method comprising:
acquiring a configuration file; the configuration file comprises a down command and a first response command corresponding to the target communication protocol; the configuration file also comprises one or more of a test command sequence number, a test command name, a number system flag bit, a data type, a data proportion, a transmission data type, a data value and a frame tail;
sending the issuing command;
receiving a second answer command from the second electronic device; after receiving the second response command, calling a check function corresponding to a check field of the issuing command in the configuration file, and calculating a check value of the first response command according to parameters and the check function in the second response command;
and under the condition that the second response command is consistent with the first response command, determining that the target communication protocol is adopted between the first electronic device and the second electronic device.
2. The method of claim 1, wherein the first reply command and the second reply command each include at least one parameter, and wherein determining that the second reply command is consistent with the first reply command comprises:
executing comparison operation on the parameters in the second response command and the parameters in the first response command;
determining that the second response command is consistent with the first response command under the condition that the parameters in the second response command are the same as the parameters in the first response command;
the comparison operation comprises the following steps:
determining a receiving parameter and a configuration parameter; the configuration parameters are any parameters in the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command;
determining a first field and a second field, wherein the first field belongs to the configuration parameter, the second field belongs to the receiving parameter, and the length of the first field is the same as that of the second field;
in the case that the content of the second field is determined to be the same as the content of the first field, the reception parameter and the configuration parameter are determined to be the same.
3. The device for testing the communication protocol is applied to first electronic equipment in a communication system and is characterized in that the communication system comprises the first electronic equipment and second electronic equipment, and the device for testing comprises an acquisition module, a sending module and a determining module;
the acquisition module is used for acquiring the configuration file; the configuration file comprises a down command and a first response command corresponding to the target communication protocol; the configuration file also comprises one or more of a test command sequence number, a test command name, a number system flag bit, a data type, a data proportion, a transmission data type, a data value and a frame tail;
the sending module is used for sending the issuing command acquired by the acquisition module;
the acquisition module is further used for receiving a second response command from the second electronic equipment;
the determining module is used for calling a check function corresponding to a check field of the issuing command in the configuration file after receiving the second response command, and calculating a check value of the first response command according to parameters and the check function in the second response command;
the determining module is configured to determine that the target communication protocol is adopted between the first electronic device and the second electronic device when it is determined that the second response command acquired by the acquiring module is consistent with the first response command.
4. A test device for a communication protocol according to claim 3 wherein the first reply command and the second reply command each comprise at least one parameter;
the determining module is specifically configured to:
executing comparison operation on the parameters in the second response command and the parameters in the first response command;
determining that the second response command is consistent with the first response command under the condition that the parameters in the second response command are the same as the parameters in the first response command;
the comparison operation comprises the following steps:
determining a receiving parameter and a configuration parameter; the configuration parameters are any parameters in the first response command, and the receiving parameters are parameters corresponding to the configuration parameters in the second response command;
determining a first field and a second field, wherein the first field belongs to the configuration parameter, the second field belongs to the receiving parameter, and the length of the first field is the same as that of the second field;
in the case that the content of the second field is determined to be the same as the content of the first field, the reception parameter and the configuration parameter are determined to be the same.
5. A test device of a communication protocol, applied to a first electronic device in a communication system, characterized in that the test device of the communication protocol comprises:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the method of testing a communication protocol according to claim 1 or 2.
6. A computer readable storage medium having instructions stored thereon, which, when executed by a processor of a test device of a communication protocol, cause the test device of a communication protocol to perform the test method of a communication protocol according to claim 1 or 2.
CN202110276154.3A 2021-03-15 2021-03-15 Communication protocol testing method and device Active CN112948194B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110276154.3A CN112948194B (en) 2021-03-15 2021-03-15 Communication protocol testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110276154.3A CN112948194B (en) 2021-03-15 2021-03-15 Communication protocol testing method and device

Publications (2)

Publication Number Publication Date
CN112948194A CN112948194A (en) 2021-06-11
CN112948194B true CN112948194B (en) 2023-08-15

Family

ID=76229900

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110276154.3A Active CN112948194B (en) 2021-03-15 2021-03-15 Communication protocol testing method and device

Country Status (1)

Country Link
CN (1) CN112948194B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113836015A (en) * 2021-09-23 2021-12-24 中国农业银行股份有限公司 Data processing method and device
CN116669064B (en) * 2022-12-08 2024-04-05 荣耀终端有限公司 Wireless protocol testing method and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104469501A (en) * 2014-10-27 2015-03-25 福建新大陆通信科技股份有限公司 Set top box automatic set-up method based on serial communication protocol
CN104536887A (en) * 2014-12-18 2015-04-22 珠海格力电器股份有限公司 Communication data detection method and device
CN106330593A (en) * 2015-07-01 2017-01-11 中兴通讯股份有限公司 Protocol detection method and device
CN109445968A (en) * 2018-11-09 2019-03-08 金瓜子科技发展(北京)有限公司 Service request processing method, device, equipment and the storage medium of different agreement
CN111459794A (en) * 2020-02-25 2020-07-28 西安广和通无线软件有限公司 Communication network testing method, device, computer equipment and storage medium
CN111614612A (en) * 2020-04-03 2020-09-01 视联动力信息技术股份有限公司 Communication protocol implementation method, device, network management server and storage medium
CN112491645A (en) * 2020-11-11 2021-03-12 深圳数联天下智能科技有限公司 Automatic test method and automatic test equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104469501A (en) * 2014-10-27 2015-03-25 福建新大陆通信科技股份有限公司 Set top box automatic set-up method based on serial communication protocol
CN104536887A (en) * 2014-12-18 2015-04-22 珠海格力电器股份有限公司 Communication data detection method and device
CN106330593A (en) * 2015-07-01 2017-01-11 中兴通讯股份有限公司 Protocol detection method and device
CN109445968A (en) * 2018-11-09 2019-03-08 金瓜子科技发展(北京)有限公司 Service request processing method, device, equipment and the storage medium of different agreement
CN111459794A (en) * 2020-02-25 2020-07-28 西安广和通无线软件有限公司 Communication network testing method, device, computer equipment and storage medium
CN111614612A (en) * 2020-04-03 2020-09-01 视联动力信息技术股份有限公司 Communication protocol implementation method, device, network management server and storage medium
CN112491645A (en) * 2020-11-11 2021-03-12 深圳数联天下智能科技有限公司 Automatic test method and automatic test equipment

Also Published As

Publication number Publication date
CN112948194A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
CN112948194B (en) Communication protocol testing method and device
US7631097B2 (en) Method and apparatus for optimizing the responsiveness and throughput of a system performing packetized data transfers using a transfer count mark
CN107463348B (en) Method and system for realizing Web end custom format printing based on B/S architecture
CN110474896A (en) Data communications method and relevant device based on Modbus consensus standard
CN108965052A (en) A kind of data reading system for the electronic control unit software debugging after entrucking
CN112507449B (en) Vehicle performance simulation data construction method based on XML
CN105320553A (en) Method and system for updating network card firmware on basis of domestic processor platform
CN113364732B (en) Vehicle-mounted terminal communication protocol analysis method and device
CN111367764A (en) PCIE monitoring method, system, equipment and computer storage medium
CN112506454A (en) Mobile terminal and data display method and device thereof
CN110209605A (en) The register reading/writing method and calculating equipment of PCIE Cardbus NIC Cardbus
CN104205071A (en) Information processing system, information processing method, communications terminal, server, control method therefor, and control program
CN109697166B (en) Test data preparation method and related device
CN112306472A (en) Program interface parameter transmission method, system and related equipment
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN113900718B (en) Decoupling method, system and device for BMC and BIOS asset information
CN108667805A (en) The analytic method and its device and computer readable storage medium of data
CN113608889A (en) Message data processing method, device, equipment and storage medium
CN108255732B (en) Method for tracking running state of single chip microcomputer system
CN111752737A (en) Log storage method, electronic device and storage medium
CN115102634B (en) Method and device for testing Bluetooth function of electric energy meter, equipment and storage medium
CN215298072U (en) Universal hardware platform
CN220605938U (en) Moving ring monitoring device with serial port forwarding function
CN114691412A (en) Data verification method and related equipment thereof
CN117155779A (en) Binding method, storage medium, monitoring terminal and Internet of things system

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
GR01 Patent grant
GR01 Patent grant