Disclosure of Invention
The present invention provides a testing method and device supporting multiple communication protocols, so as to solve the problem that the conventional single testing system cannot perform testing communication on the conventional systems with different communication modes.
The invention provides a test method supporting multiple communication protocols, which comprises the following steps:
the upper computer receives a test instruction;
according to the protocol analysis packet, performing instruction analysis on the test instruction, converting the test instruction into a specified lower protocol instruction, and sending the specified lower protocol instruction to a specified lower computer;
and receiving a lower protocol feedback instruction sent by the lower computer, performing instruction analysis on the lower protocol feedback instruction according to the protocol analysis packet, and converting the lower protocol feedback instruction into an upper feedback instruction for processing.
Further, the test method supporting multiple communication protocols further includes, before the test instruction is input according to the upper protocol:
loading the upper protocol and a plurality of lower protocols;
loading the upper protocol analysis packet and a plurality of corresponding lower protocol analysis packets, and forming the protocol analysis packet;
analyzing the upper protocol, and designing an instruction list according to analysis content;
and setting a preset value and selecting a lower protocol.
Further, in the test method supporting multiple communication protocols, the step of converting into the upper feedback instruction for processing further includes:
and comparing the data in the upper feedback instruction with the preset value to obtain a comparison value, and converting a test result.
Further, in the test method supporting multiple communication protocols, the upper protocol is a ModBus protocol.
Further, in the test method supporting multiple communication protocols, the lower level protocol includes a ModBus protocol, a Can protocol, a BACnet protocol, and a LonWorks protocol.
The invention provides a testing device supporting multiple communication protocols, comprising:
the receiving module is used for receiving the test instruction by the upper computer;
the first analysis module is used for analyzing the test instruction according to the protocol analysis packet, converting the test instruction into a specified lower protocol instruction and sending the specified lower protocol instruction to a specified lower computer;
and the second analysis module is used for receiving the lower protocol feedback instruction sent by the lower computer, performing instruction analysis on the lower protocol feedback instruction according to the protocol analysis packet, and converting the lower protocol feedback instruction into an upper feedback instruction for processing.
Further, the above test apparatus supporting multiple communication protocols further includes:
the first loading module is used for loading the upper protocol and the plurality of lower protocols;
a second loading module, configured to load the upper protocol analysis packet and the corresponding multiple lower protocol analysis packets, and compose the protocol analysis packet;
the third analysis module is used for analyzing the upper protocol and designing an instruction list according to analysis contents;
and the selection module is used for setting a preset value and selecting the lower protocol.
Furthermore, in the testing apparatus supporting multiple communication protocols, the second parsing module further includes a processing module,
and the processing module is used for comparing the data in the upper feedback instruction with a preset value to obtain a comparison value and converting a test result.
Further, in the above test apparatus supporting multiple communication protocols, the upper protocol loaded by the processing module is a ModBus protocol.
Further, in the test apparatus supporting multiple communication protocols, the lower level protocol loaded by the processing module includes: ModBus protocol, Can protocol, BACnet protocol, and LonWorks protocol.
According to the testing method and device supporting multiple communication protocols, the upper protocol is added in front of the lower protocol, so that a single testing system can be connected with multiple testing lower computers, redundant manpower for controlling the lower computers by multiple users is saved, labor cost is reduced, operation steps are simplified, the users only need to master the upper computer, the operation method of the upper protocol can control multiple devices applying different communication protocols, and personnel training time is reduced.
Detailed Description
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 only a part of the embodiments of the present invention, and not all of the embodiments. 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.
In addition, the descriptions related to "first", "second", etc. in the present invention are for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
Referring to fig. 1, an embodiment of the present invention provides a test method for supporting multiple communication protocols, including the following steps:
s10, the upper computer receives a test instruction;
s20, analyzing the test instruction according to the protocol analysis packet, converting the test instruction into a specified lower protocol instruction, and sending the specified lower protocol instruction to a specified lower computer;
and S30, receiving the lower protocol feedback instruction sent by the lower computer, performing instruction analysis on the lower protocol feedback instruction according to the protocol analysis packet, and converting the lower protocol feedback instruction into an upper feedback instruction for processing.
In step S10, the upper computer receives a specified test command according to the command list generated by the upper protocol loaded in the test method supporting multiple communication protocols.
As the above step S20, according to the upper protocol analysis packet in the protocol analysis packet, analyzing the input test instruction, encrypting the analyzed content according to the specified lower protocol to generate a lower protocol instruction, and sending the lower protocol instruction to the specified lower computer, where the same lower protocol instruction may be sent to multiple lower computers, each lower computer may receive only one lower protocol command, where the specified lower protocol may be a single lower protocol or multiple lower protocols, and when multiple lower protocols are selected, multiple lower protocol instructions corresponding to the lower protocol instructions one to one are generated, and each lower protocol instruction corresponds to only one lower protocol; the upper protocol and the lower protocol may be the same communication protocol.
Referring to fig. 1-2, in an embodiment, when the selected lower protocol is the same as the upper protocol in use, the step S20 is stopped, and the step S21 is executed instead, where the step S21 specifically includes: in the test method supporting multiple communication protocols, the upper computer directly adopts the test command input in the step S10 as the lower protocol command, and sends the lower protocol command to a designated lower computer.
In step S30, after the test is completed, the lower protocol feedback command fed back from each lower computer is received, the lower protocol feedback command is subjected to command analysis based on a plurality of lower protocol analysis packets in the protocol analysis packets, and the analyzed content is encrypted according to a specified upper protocol, so as to generate an upper feedback command.
Referring to fig. 1-2, in an embodiment, when the selected lower protocol is the same as the upper protocol in use, the step S30 is stopped, and the step S31 is executed instead, where the step S31 specifically includes: in the test method supporting multiple communication protocols, the upper computer directly takes the lower protocol feedback instruction fed back by the lower computer as the upper feedback instruction and processes the upper feedback instruction.
Referring to fig. 3, in this embodiment, before the test instruction is input according to the upper protocol, the test method supporting multiple communication protocols further includes:
s1, loading the upper protocol and a plurality of lower protocols;
s2, loading the upper protocol analysis packet and a plurality of corresponding lower protocol analysis packets to form the protocol analysis packet;
s3, analyzing the upper protocol, and designing an instruction list according to the analysis content;
and S4, setting a preset value and selecting a lower protocol.
In the step S1, the upper protocol and the plurality of lower protocols are loaded, the loaded upper protocol and the loaded plurality of lower protocols are temporarily stored after the loading is completed, the user can select to store the upper protocol and the plurality of lower protocols for a long time after the testing process is completed, and if the user selects not to store the upper protocol and the plurality of lower protocols for a long time or does not select the upper protocol and the plurality of lower protocols for a limited time, the system defaults to delete the upper protocol and the plurality of lower protocols loaded in the step S1, the limited time is generally defined to be 10 to 50 seconds, preferably 30 seconds, wherein the types of the loaded plurality of lower protocols may include the same type of communication protocol as the upper protocol.
Referring to fig. 3-4, in an embodiment, when the plurality of lower protocols loaded in the step S1 include the same kind of communication protocol as the upper protocol, before the step S2, a step S5 is additionally performed, where the step S5 is specifically: the test method for supporting multiple communication protocols gives a prompt of a prompt window or a flashing signal indicator lamp displayed in a voice or a display screen, reminds a user that the multiple lower level protocols comprise communication protocols of the same type as the upper level protocol, marks the lower level protocols, and needs to perform corresponding feedback operations according to the prompt, for example, clicking a confirmation or cancellation button in the prompt window or pressing a confirmation or cancellation button of an operation table, if cancellation is selected or not selected within a limited time, the system deletes the communication protocols of the same type as the upper level protocol in the multiple lower level protocols, so as to prevent the situation that the system runs for a long time and the like when the user loads the communication protocols by mistake when the user loads the communication protocols, wherein the limited time is generally defined as 10-50 seconds, and the preferred limited time is 10 seconds.
In step S2, the upper protocol analysis packet corresponding to the communication protocol loaded in step S1 and the plurality of lower protocol analysis packets corresponding to the communication protocol are loaded, and compose the protocol analysis packet, temporarily store the loaded upper protocol analysis packet and a plurality of lower protocol analysis packets after the loading is completed, after the test process is completed, the user may select to store the upper protocol analysis package and the plurality of lower protocol analysis packages for a long time, and if the user selects not to store the upper protocol analysis package and the plurality of lower protocol analysis packages for a long time or does not select within a limited time, the system may delete the upper protocol analysis package and the plurality of lower protocol analysis packages loaded in the step S2 by default, the limited time is generally defined as 10 to 50 seconds, and preferably 30 seconds, the type of the loaded lower protocol analysis packets may include a communication protocol analysis packet of the same type as the upper protocol analysis packet.
Referring to fig. 3-4, in an embodiment, when the plurality of lower protocol analysis packets loaded in the step S2 include a communication protocol analysis packet of the same type as the upper protocol analysis packet, before the step S3, the step S6 is additionally performed, and the step S6 is specifically: the test method for supporting multiple communication protocols gives a prompt of a prompt window or a flashing signal indicator lamp displayed in a voice or a display screen to remind a user that the multiple lower protocol analysis packets include the communication protocol analysis packets of the same type as the upper protocol analysis packet and label the lower protocol analysis packets, the user needs to perform corresponding feedback operation according to the prompt, for example, click a confirmation or cancellation button in the prompt window or press a confirmation or cancellation button of an operation console, if the user selects to cancel or does not select within a limited time, the system deletes the communication protocol analysis packets of the same type as the upper protocol analysis packet in the multiple lower protocol analysis packets by default so as to prevent the user from mistakenly loading the communication protocol analysis packets when loading the communication protocol analysis packets, thereby causing the system to have the situations of crash and the like in the analysis process, wherein, the limited time is generally defined to be 10 to 50 seconds, and the preferred limited time is 10 seconds.
In the step S3, the upper protocol loaded in the step S1 is analyzed according to the upper protocol analysis package loaded in the step S2, and a command list is designed according to the analysis content, wherein the storage state of the command list is generally divided into temporary storage and long-term storage, and the preferred default storage state of the test method supporting multiple communication protocols is temporary storage, and the storage state of the command list is identical to the storage state of the communication protocol loaded in the step S1.
In step S4, a preset value is set according to the condition of the test target, and the corresponding lower protocol corresponding to the test lower computer is selected from the plurality of lower protocols loaded in step S1.
Referring to fig. 5, in the test method supporting multiple communication protocols according to this embodiment, the step of converting into the upper feedback command for processing further includes:
and S40, comparing the data in the upper feedback instruction with the preset value to obtain a comparison value, and converting a test result.
As the above step S40, according to the upper protocol analysis packet in the protocol analysis packet, the upper feedback instruction is analyzed to obtain the feedback data, and according to the comparison between the feedback data and the preset value, the comparison value is obtained, and the test result is converted, and the result data is output in the form of a list.
In this embodiment, in the test method supporting multiple communication protocols, the upper protocol is a ModBus protocol.
The upper protocol is generally one of communication protocols such as ModBus protocol, Can protocol, BACnet protocol, and LonWorks protocol, and preferably ModBus protocol.
In this embodiment, the test method supporting multiple communication protocols includes communication protocols such as ModBus protocol, Can protocol, BACnet protocol, and LonWorks protocol.
The ModBus protocol is an industrial field bus protocol; the Can protocol is a controller area network bus protocol; the BACnet protocol is a building automatic control network data communication protocol; the LonWorks protocol is a field bus protocol, replaces the traditional transmission of 4-20mA analog signals and common switching value signals by digital communication, and is a full-digital, bidirectional and multi-station communication system for connecting intelligent field equipment and an automatic system.
In another specific embodiment, in the testing device supporting multiple communication protocols, the upper protocol and the lower protocol may further include wireless communication protocols such as ieee802.15.4 protocol and 802.11ac protocol.
Referring to fig. 6, an embodiment of the present invention further provides a testing apparatus supporting multiple communication protocols, including:
the receiving module 100 is used for receiving a test instruction by an upper computer;
the first analysis module 200 is configured to perform instruction analysis on the test instruction according to the protocol analysis packet, convert the test instruction into a specified lower-level protocol instruction, and send the specified lower-level protocol instruction to a specified lower-level computer;
the second parsing module 300 is configured to receive the lower protocol feedback instruction sent by the lower computer, perform instruction parsing on the lower protocol feedback instruction according to the protocol parsing packet, and convert the lower protocol feedback instruction into an upper feedback instruction for processing.
The receiving module 100 is configured to receive a specified test instruction by an upper computer according to an instruction list generated by an upper protocol loaded in the test method supporting multiple communication protocols.
The first parsing module 200 is configured to parse an input test instruction according to an upper protocol parsing packet in a protocol parsing packet, encrypt parsed content according to a known and specified lower protocol, generate a lower protocol instruction, and send the lower protocol instruction to a specified lower computer, where a same lower protocol instruction may be sent to multiple lower computers, and each lower computer receives only one lower protocol command, where the specified lower protocol may be a single lower protocol or multiple lower protocols, and when multiple lower protocols are selected, multiple lower protocol instructions corresponding to the lower protocol instructions one to one are generated, and each lower protocol instruction corresponds to only one lower protocol; the upper protocol and the lower protocol may be the same communication protocol.
In an embodiment, when the selected lower protocol is the same as the upper protocol in use, the first parsing module 200 stops performing the step S20, and instead performs the step S21, where the step S21 specifically includes: the test method supporting multiple communication protocols directly adopts the test command input in the step S10 as the lower protocol command.
The second parsing module 300 is configured to receive the lower protocol feedback instruction fed back by each lower computer after the test is completed, perform instruction parsing on the lower protocol feedback instruction according to a plurality of lower protocol parsing packets in the protocol parsing packets, and encrypt parsed contents according to a specified upper protocol to generate an upper feedback instruction, where the upper protocol and the lower protocol may be the same communication protocol.
In an embodiment, when the selected lower protocol is the same as the upper protocol in use, the second parsing module 300 stops performing the step S30, and instead performs the step S31, where the step S31 specifically includes: in the test method supporting multiple communication protocols, the lower protocol feedback instruction is directly used as the upper feedback instruction.
Referring to fig. 7, in this embodiment, the test apparatus supporting multiple communication protocols further includes:
a first loading module 400, configured to load the upper protocol and the plurality of lower protocols;
a second loading module 500, configured to load the upper protocol analysis packet and the corresponding multiple lower protocol analysis packets, and compose the protocol analysis packet;
a third parsing module 600, configured to parse the upper protocol and design an instruction list according to parsing content;
the selecting module 700 is used for setting a preset value and selecting a lower protocol.
The first loading module 400 is configured to load the upper protocol and the plurality of lower protocols, temporarily store the loaded upper protocol and the loaded plurality of lower protocols after the loading is completed, and after the testing process is completed, a user may select to store the upper protocol and the plurality of lower protocols for a long time, and if the user selects not to store the upper protocol and the plurality of lower protocols for a long time or does not select the upper protocol and the plurality of lower protocols for a limited time, the first loading module 400 defaults to delete the upper protocol and the plurality of lower protocols loaded by the first loading module 400, where the limited time is generally defined as 10 to 50 seconds, and preferably defined as 30 seconds, and a type of the loaded plurality of lower protocols may include a communication protocol of the same type as the upper protocol.
In an embodiment, when the first loading module 400 loads the plurality of lower protocols including the same type of communication protocol as the upper protocol, the first loading module 400 additionally performs step S5 before performing step S2, where step S5 specifically includes: the testing method supporting multiple communication protocols sends a prompt signal through the first loading module 400, prompts a user through operations such as displaying a prompt window or flashing signal indicator lights in a voice or a display screen, reminds the user that the multiple lower protocols include the communication protocols of the same type as the upper protocol, marks the lower protocols, and the user needs to perform corresponding feedback operations according to the prompt, for example, clicking a confirmation or cancellation button in the prompt window or pressing a confirmation or cancellation button of an operating console, if the user selects to cancel or does not select within a limited time, the processing module 300 deletes the communication protocols of the same type as the upper protocol in the multiple lower protocols, so as to prevent the user from mistakenly loading the communication protocols when loading the communication protocols, which results in the situation that the system runs during sending, and the like, the limited time is generally defined to be 10 to 50 seconds, and the preferred limited time is 10 seconds.
The second loading module 500 is configured to load the upper protocol analysis packet corresponding to the communication protocol loaded in the step S1 and the plurality of corresponding lower protocol analysis packets, and compose the protocol analysis packet, temporarily store the loaded upper protocol analysis packet and a plurality of lower protocol analysis packets after the loading is completed, after the testing procedure is completed, the user can choose to store the upper protocol analysis packet and the plurality of lower protocol analysis packets for a long time, if the user chooses not to store the upper protocol analysis packets for a long time or choose not to store the upper protocol analysis packets and the plurality of lower protocol analysis packets within a limited time, the second loader module 500 deletes the upper protocol analysis packet and the plurality of lower protocol analysis packets loaded by the second loader module 500 by default, and the limited time is generally 10 to 50 seconds, preferably 30 seconds, the type of the loaded lower protocol analysis packets may include a communication protocol analysis packet of the same type as the upper protocol analysis packet.
In an embodiment, when the second loading module 500 loads the plurality of lower protocol analysis packets including the communication protocol analysis packet of the same type as the upper protocol analysis packet, the second loading module 500 additionally performs step S6, where the step S6 is specifically: the testing method supporting multiple communication protocols sends a prompt signal through the second loading module 500, prompts a user through operations such as displaying a prompt window or flashing signal indicator lights in a voice or display screen, reminds the user that the plurality of lower protocol analysis packets include the communication protocol analysis packets of the same type as the upper protocol analysis packet, marks the lower protocol analysis packets, and the user needs to perform corresponding feedback operations according to the prompt, for example, clicking a confirmation or cancellation button in the prompt window or pressing a confirmation or cancellation button of an operating console, if the user selects to cancel or does not select within a limited time, the second loading module 500 defaults to delete the communication protocol analysis packets of the same type as the upper protocol analysis packet in the plurality of lower protocol analysis packets, so as to prevent the user from mistakenly loading the communication protocol analysis packets when the communication protocol analysis packets are loaded, the system is rushed during the analysis process, wherein the limited time is generally defined as 10-50 seconds, and the preferred limited time is 10 seconds.
The third parsing module 600 is configured to parse the upper protocol loaded by the third parsing module 600 according to the upper protocol parsing packet loaded by the third parsing module 600, and design a command list according to parsing contents, where a storage state of the command list is consistent with a storage state of the communication protocol loaded by the third parsing module 600, the storage state is generally divided into temporary storage and long-term storage, and a preferred default storage state of the test method supporting multiple communication protocols is temporary storage.
The selection module 700 is configured to set a preset value according to a condition of a test target, and select the corresponding lower protocol corresponding to the test lower computer from the plurality of lower protocols loaded by the selection module 700.
In this embodiment, in the testing apparatus supporting multiple communication protocols, the second parsing module 300 further includes a processing module 800,
and the processing module 800 is configured to compare the data in the upper feedback instruction with the preset value to obtain a comparison value, and convert the comparison value into a test result.
The processing module 800 is configured to analyze the upper feedback instruction according to an upper protocol analysis packet in the protocol analysis packet to obtain feedback data, compare the feedback data with a preset value to obtain a comparison value, convert the comparison value into a test result, and output the result data in a list form.
In the embodiment, in the testing apparatus supporting multiple communication protocols, the upper protocol loaded by the processing module 800 is a ModBus protocol.
The upper protocol loaded by the processing module 800 is generally one of communication protocols such as ModBus protocol, Can protocol, BACnet protocol, LonWorks protocol, and the like, and preferably the ModBus protocol.
In this embodiment, in the test apparatus supporting multiple communication protocols, the lower level protocol loaded by the processing module 800 includes: communication protocols such as ModBus protocol, Can protocol, BACnet protocol and LonWorks protocol.
The ModBus protocol is an industrial field bus protocol; the Can protocol is a controller area network bus protocol; the BACnet protocol is a building automatic control network data communication protocol; the LonWorks protocol is a field bus protocol, replaces the traditional transmission of 4-20mA analog signals and common switching value signals by digital communication, and is a full-digital, bidirectional and multi-station communication system for connecting intelligent field equipment and an automatic system.
In another specific embodiment, the test apparatus supporting multiple communication protocols, the upper protocol and the lower protocol loaded by the processing module may further include wireless communication protocols such as an ieee802.15.4 protocol and an 802.11ac protocol.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.