Modbus-based test method and device, terminal and medium

By obtaining target testing requirements and customized parameters, combined with interface operation combination, a comprehensive test of the Modbus protocol controller is achieved, solving the shortcomings of existing tools for emerging operating systems and complex testing requirements, and improving testing efficiency and accuracy.

CN119854172APending Publication Date: 2025-04-18深圳开鸿数字产业发展有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411831561.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

When the existing Modbus test tools test the test requirements of emerging operating systems such as OpenHarmony, they cannot conduct comprehensive testing, and the existing tools only support the single mode of host/slave testing of the TCP protocol, which cannot meet complex and diverse testing needs.

Method used

Provide a Modbus-based test method, which can achieve comprehensive testing of the target controller by obtaining target testing requirements, obtaining target custom parameters, obtaining interface operation combination methods based on these parameters, and performing target test cases.

Benefits of technology

It realizes comprehensive testing of emerging operating systems such as OHOS, supports a variety of communication protocols and complex testing scenarios, reduces testing costs and difficulty, improves testing efficiency, and can discover performance bottlenecks and problems, and optimizes controller performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119854172A_ABST
    Figure CN119854172A_ABST
Patent Text Reader

Abstract

The invention discloses a Modbus-based test method, a Modbus-based test device, a Modbus-based test terminal and a Modbus-based test medium. The method comprises the steps of obtaining a target test demand, and obtaining a target customization parameter based on the target test demand; obtaining an interface operation combination mode based on the target customization parameter; and executing the target test case based on the interface operation combination mode to test the target controller. The problem that in the prior art, when a Modbus testing tool meets the testing requirement for newly-developing operating systems such as OHOS, comprehensive testing cannot be carried out can be solved. Through an interface operation combination mode, comprehensive testing of the target controller is realized, through automatic testing, the workload of manual testing is reduced, and the testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a test method, device, terminal and medium based on Modbus. Background Art

[0002] In today's industrial environment, communication between devices is crucial, ensuring the efficient operation of the production line and the accurate transmission of data. Modbus is a widely used communication protocol, mainly used to achieve data exchange between devices. This protocol occupies a pivotal position in many industrial control systems due to its simplicity and reliability. Usually, each industrial device is designed with a single communication protocol to adapt to specific application scenarios and communication requirements, and Modbus is one of the best.

[0003] Under the Windows operating system, a number of mature test tools have emerged in the market to meet the test needs of the Modbus protocol. These tools, such as Modbus Poll and Modbus Slave, can efficiently perform routine test tasks of Modbus functions. They are not only easy to operate, but also comprehensive in functions, covering multiple communication methods such as Modbus RTU and TCP, providing great convenience for users. With these tools, technicians can easily simulate master or slave devices to perform detailed tests and verifications on Modbus communications, thereby ensuring the stability and reliability of the communication system.

[0004] However, with the continuous development of operating systems and hardware devices, new demands have also emerged. As an emerging open source operating system, OpenHarmony (OHOS for short) is gradually penetrating into the field of industrial control. However, most of the existing Modbus test tools only support Windows systems and have not yet provided reliable support for OHOS. This means that when performing Modbus communication tests in the OHOS environment, users may need to find other alternatives or perform complex adaptation work on existing tools, which undoubtedly increases the cost and difficulty of testing.

[0005] In addition, existing Modbus test tools have certain limitations. They often only support the master / slave single mode test of the TCP protocol, and cannot meet more complex and diverse test requirements. For example, in some application scenarios, users may need to test both Modbus RTU and TCP communication modes at the same time, or need to test multiple devices in parallel. These requirements are often difficult to be well met in current test tools.

[0006] Therefore, the existing Modbus test tools still have certain deficiencies when it comes to emerging operating systems such as OHOS and more complex and diverse test requirements. Therefore, it is necessary to develop a more comprehensive, flexible and multi-operating system compatible Modbus test tool to meet the ever-changing test requirements in the field of industrial control.

[0007] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention

[0008] The main purpose of the present invention is to provide a test method, device, terminal and medium based on Modbus, aiming to solve the problem in the prior art that Modbus test tools cannot perform comprehensive tests when testing emerging operating systems such as OHOS.

[0009] In order to achieve the above object, the first aspect of the present invention provides a test method based on Modbus, wherein the test method based on Modbus includes:

[0010] Obtain target test requirements, and obtain target customization parameters based on the target test requirements;

[0011] Acquire an interface operation combination mode based on the target customization parameters;

[0012] Execute the target test case based on the interface operation combination mode to test the target controller.

[0013] In one implementation, after obtaining the target test requirements, the method further includes:

[0014] Acquire target configuration information, wherein the target configuration information includes test environment settings, test schedule, and test priority;

[0015] The test process or the allocation of test resources is adjusted according to the test configuration information and the target test requirement.

[0016] In one implementation, the target customization parameters include communication protocol type, device address, register address, data type, and read and write operations.

[0017] In one implementation, the interface operation combination includes an interface call sequence and parameter configuration predefined according to the target test requirements to implement a test of a specific function or performance of the target controller.

[0018] In one implementation, the interface operation combination also includes simulating abnormal situations and observing the response behavior of the target controller.

[0019] In one implementation, after executing the target test case based on the interface operation combination, the method further includes:

[0020] Obtain target log information for executing the target test case;

[0021] A test result of a target function of the target controller is acquired based on the target log information, where the test result includes a response time and a data transmission rate.

[0022] In one implementation, after obtaining the test result of the target function of the target controller based on the target log information, the method further includes:

[0023] The test results are compared with the expected results and a test report is generated, which includes whether the test passed, the reason for failure, error log, test coverage, defect statistics and repair suggestions.

[0024] A second aspect of the present invention is a Modbus-based test device, comprising:

[0025] A parameter customization module is used to obtain target test requirements and obtain target customization parameters based on the target test requirements;

[0026] A combination mode acquisition module, used for acquiring an interface operation combination mode based on the target customization parameters;

[0027] The test module is used to execute the target test case based on the interface operation combination mode to test the target controller.

[0028] According to a third aspect of the present invention, a terminal is provided, wherein the terminal comprises: a memory, a processor, and a Modbus-based test program stored in the memory and executable on the processor, wherein the Modbus-based test program implements the steps of the Modbus-based test method as described above when executed by the processor.

[0029] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any of the above-mentioned Modbus-based testing methods.

[0030] Beneficial effects: Compared with the prior art, the present invention provides a test method, device, terminal and medium based on Modbus. In the test method based on Modbus provided by the present invention, when it is necessary to test the controller based on the Modbus protocol, the target test requirements are first obtained, the target customization parameters are obtained based on the target test requirements, and then the interface operation combination mode is obtained based on the target customization parameters. Finally, the target test case is executed based on the interface operation combination mode to test the target controller. The present invention provides users with a test method based on Modbus, which solves the problem that the Modbus test tool in the prior art cannot perform comprehensive testing when testing emerging operating systems such as OHOS. In the present invention, a comprehensive test of the target controller is achieved through the interface operation combination mode, and the workload of manual testing is reduced through automated testing, and the test efficiency is improved. Furthermore, through comprehensive testing, the performance bottlenecks and problems of the target controller can be found, providing strong support for optimizing the performance of the target controller. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A flow chart of an embodiment of a test method based on Modbus provided by the present invention;

[0032] Figure 2 A structural principle diagram of an embodiment of a test device based on Modbus provided by the present invention;

[0033] Figure 3 A schematic diagram of an operating environment of an embodiment of a terminal provided by the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0035] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0036] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.

[0037] A Modbus-based testing method provided by the present invention can be applied to a terminal with computing capability, and the terminal can execute the Modbus-based testing method provided by the present invention to perform linkage control of equipment.

[0038] Embodiment 1

[0039] In today's industrial environment, communication between devices is crucial, ensuring the efficient operation of the production line and the accurate transmission of data. Modbus is a widely used communication protocol, mainly used to achieve data exchange between devices. This protocol occupies a pivotal position in many industrial control systems due to its simplicity and reliability. Usually, each industrial device is designed with a single communication protocol to adapt to specific application scenarios and communication requirements, and Modbus is one of the best.

[0040] Under the Windows operating system, a number of mature test tools have emerged in the market to meet the test needs of the Modbus protocol. These tools, such as Modbus Poll and Modbus Slave, can efficiently perform routine test tasks of Modbus functions. They are not only easy to operate, but also comprehensive in functions, covering multiple communication methods such as Modbus RTU and TCP, providing great convenience for users. With these tools, technicians can easily simulate master or slave devices to perform detailed tests and verifications on Modbus communications, thereby ensuring the stability and reliability of the communication system.

[0041] However, with the continuous development of operating systems and hardware devices, new demands have also emerged. As an emerging open source operating system, OpenHarmony (OHOS for short) is gradually penetrating into the field of industrial control. However, most of the existing Modbus test tools only support Windows systems and have not yet provided reliable support for OHOS. This means that when performing Modbus communication tests in the OHOS environment, users may need to find other alternatives or perform complex adaptation work on existing tools, which undoubtedly increases the cost and difficulty of testing.

[0042] In addition, existing Modbus test tools have certain limitations. They often only support the master / slave single mode test of the TCP protocol, and cannot meet more complex and diverse test requirements. For example, in some application scenarios, users may need to test both Modbus RTU and TCP communication modes at the same time, or need to test multiple devices in parallel. These requirements are often difficult to be well met in current test tools.

[0043] In summary, although the existing Modbus test tools have achieved remarkable results under Windows system, they still have certain shortcomings when facing emerging operating systems such as OHOS and more complex and diverse test requirements. Therefore, it is necessary to develop a more comprehensive, flexible and multi-operating system compatible Modbus test method to meet the ever-changing test requirements in the field of industrial control.

[0044] Specifically, Figure 1 As shown, the Modbus-based testing method provided in this embodiment includes the following steps:

[0045] S100: Obtain target test requirements, and obtain target customization parameters based on the target test requirements.

[0046] In the process of software testing, the first step is to obtain the target test requirements. This link is crucial and lays the foundation for the entire testing work. The target test requirements cover the various functional points and performance indicators of the target controller to be tested. These requirements not only indicate the direction of the test, but also define the scope and depth of the test. In this embodiment, the target controller is the Kaihong OHOS controller.

[0047] The function point refers to the specific function that the target controller needs to implement or verify. For example, if the target controller is a temperature control device for a smart home, its function points may include temperature setting and reading, temperature sensor calibration, temperature abnormality alarm, and linkage control with other smart home devices. For these function points, testers need to design corresponding test cases to ensure that each function meets the expected design.

[0048] The performance indicators are used to measure the operating efficiency and stability of the target controller under specific conditions. Taking temperature control equipment as an example, its performance indicators may include temperature control accuracy, temperature adjustment response time, device power consumption, and stability under long-term operation. Testers need to use a series of test methods, such as stress testing and stability testing, to verify whether the target controller meets the established performance indicators.

[0049] For example, when testing a smart lighting controller, the target test requirements may include:

[0050] Functional points: Support remote control of lighting switches through mobile phone APP; support timed light switch function; support automatic adjustment of light brightness according to ambient light; support switching of multiple lighting scene modes, etc.

[0051] Performance indicators: The response time of the control command does not exceed 1 second; the equipment operates without failure when working continuously for 7x24 hours; the power consumption of the equipment does not exceed XX watts under normal working conditions; the accuracy error of light brightness adjustment does not exceed 5%, etc.

[0052] After clarifying these test requirements, testers can design and implement corresponding test cases based on these requirements to ensure that the smart lighting controller meets the design requirements in terms of function and performance.

[0053] After obtaining the target test requirements, the following steps are also included:

[0054] Acquire target configuration information, wherein the target configuration information includes test environment settings, test schedule, and test priority;

[0055] The test process or the allocation of test resources is adjusted according to the test configuration information and the target test requirement.

[0056] Specifically, after obtaining the target test requirements, the system will further obtain the target configuration information, which is a critical step because it provides a specific framework and guidance for subsequent test activities. The target configuration information covers the three core aspects of test environment settings, test schedules, and test priorities.

[0057] The test environment setting involves the specific hardware and software configurations, network conditions, operating system versions, database configurations, etc. For example, if the target application is a mobile application for OHOS users, the test environment needs to include the latest version of OHOS devices, corresponding development tools, and simulators.

[0058] The test schedule specifies the start and end time of the test activities, as well as the time points of key milestones (such as completion of the first round of testing, regression testing after repair, etc.). This helps the project team to arrange the work rhythm reasonably, ensure that the test activities can be completed on time, and reduce time conflicts with other project activities.

[0059] Furthermore, the test priority is to set priorities for different test scenarios or functions according to the importance, risk level or business impact of the test requirements. For example, the stability test of the new user registration process may be given the highest priority because it is directly related to the availability and user experience of the application.

[0060] Next, based on the acquired test configuration information and the target test requirements, a detailed evaluation is performed, and the test process or the allocation of test resources is adjusted accordingly.

[0061] Specifically, the test process is adjusted according to the priority and schedule in the configuration information. The test team may reorder the execution order of the test cases to give priority to high-priority or time-sensitive tests. At the same time, if the test environment has special requirements (such as requiring a specific version of the database), the test process will also be adjusted accordingly to ensure that all tests are performed in the correct environment.

[0062] Allocation of testing resources includes human resources (such as test engineers), hardware resources (such as test equipment), software resources (such as test tools), etc. For example, if the test environment is complex and requires a lot of resources to build, the team may allocate more human resources in advance to assist in setting up the environment; and for time-sensitive and high-priority test tasks, more test engineers may be temporarily deployed to ensure that the test progress is not affected.

[0063] To give a practical example, suppose an e-commerce platform is preparing for an important promotion. The testing team first determines the target testing requirements based on business needs, including the stability of the payment process, the accuracy of product search, and the page display of the promotion. Then, they obtain the target configuration information and learn that the test needs to be conducted in a mirror environment of the production environment, the test time window is from 9 pm to 3 am every day of the week before the event, and the payment process has the highest testing priority. Based on this information, the testing team decides to prioritize the testing of the payment process and increase the number of test engineers to ensure that high-quality testing work is completed within a limited time. At the same time, it also includes adjusting the allocation of test resources, such as renting more test equipment to simulate payment behavior in high-concurrency scenarios, and deploying specialized test tools to monitor and record performance indicators during the test process.

[0064] The target customization parameters include communication protocol type, device address, register address, data type, and read and write operations.

[0065] Specifically, during the test process, after obtaining the target test requirements and the related test configuration information, a series of target customization parameters will be set based on the target test requirements to ensure that the test can be accurately and efficiently performed on the target controller. The target customization parameters specifically cover key information such as communication protocol type, device address, register address, data type, and read and write operations.

[0066] Among them, the communication protocol type refers to the communication protocol used by the target controller during the test, such as Modbus, CAN, Ethernet / IP, etc. The choice of communication protocol determines how the test tool performs data transmission and instruction interaction with the target controller. For example, if the target controller uses the Modbus TCP protocol, the test tool needs to be configured as a Modbus TCP client or server to match the communication method of the target controller. Specifically, in the present embodiment, two communication protocols are specifically included, the Modbus TCP protocol and the Modbus RTU protocol. The interfaces related to the Modbus TCP and Modbus RTU protocols are separated from each other and presented on the same page. The common parameter part uses JS to dynamically change the parameter type selection, and the conflicting parts such as the log output part are isolated using different erasers. Thereby realizing arbitrary switching tests of the two protocols without affecting each other. There are 3 interfaces for each protocol, a total of 6 interfaces.

[0067] The device address refers to the unique address of each device in the communication network, which is used to identify and locate the device. During the test, we need to accurately set the device address of the target controller to ensure that the test tool can correctly establish a connection with it. The setting of the device address may involve network configuration, IP address, MAC address, or the unique identifier of the device in the communication protocol.

[0068] A register is a memory unit in the target controller that is used to store data or instructions. During the test process, it may be necessary to read and write specific registers to verify the function or performance of the target controller. Therefore, the register address is an important part of the target customization parameters, which specifies the register location that the test tool needs to access.

[0069] The data type defines the format and structure of the data stored in the register. Different data types correspond to different data lengths and interpretation methods. During the test process, we need to set the correct data type according to the data format requirements of the target controller to ensure the correctness and validity of the test data.

[0070] The read and write operations are the basic way to interact with the target controller during the test. Depending on the test requirements, we may need to perform a read operation to obtain the state or data of the target controller, or perform a write operation to change its state or send instructions. The setting of the read and write operations needs to take into account factors such as the communication protocol, register address, and data type of the target controller.

[0071] In summary, the setting of the target customization parameters is an important part of the test process, which ensures that the test tool can accurately and efficiently communicate and interact with the target controller, thereby verifying whether its functions and performance meet expectations. In actual testing, testers need to carefully set these parameters according to the specific requirements and test requirements of the target controller to ensure the accuracy and effectiveness of the test.

[0072] S200: Acquire an interface operation combination mode based on the target customization parameters.

[0073] The interface operation combination method includes an interface calling sequence and parameter configuration predefined according to the target test requirements to implement a test of a specific function or performance of the target controller.

[0074] The interface operation combination method also includes simulating abnormal situations and observing the response behavior of the target controller.

[0075] Specifically, after obtaining the target customization parameters, the interface operation combination method will be further acquired and defined based on the target customization parameters. This method is the core component of the test strategy, which aims to achieve comprehensive testing of the specific functions or performance of the target controller through a series of orderly and precisely configured interface calls.

[0076] First of all, the interface operation combination method strictly follows the interface call sequence and parameter configuration predefined according to the target test requirements. This means that before the test begins, a detailed test script has been designed based on the functional characteristics, performance indicators and potential problem points of the target controller. This script lists in detail the interfaces that need to be called, the timing of calling each interface (i.e., the order), and the various parameters required for the call (such as the communication protocol type, device address, register address, data type, etc. mentioned above). This design ensures the systematic and targeted nature of the test process, and can efficiently cover the key functions and performance indicators of the target controller.

[0077] For example, if in this embodiment, the target test requirement is to verify the temperature monitoring function of an industrial controller, then the interface operation combination may include the following steps: first, through a specific interface call and parameter configuration, a request to read the current temperature value is sent to the controller; then, based on the read temperature value, an instruction to set the temperature threshold is sent to the controller through another interface call; finally, by simulating the data changes of the temperature sensor (which may need to be implemented through another interface call), observe whether the controller can trigger an alarm or take other preset response measures when the temperature exceeds the threshold.

[0078] In addition, the interface operation combination method also emphasizes the importance of simulating abnormal situations and observing the response behavior of the target controller. This is because in a real working environment, the controller may encounter various unexpected situations, such as power failure, communication interruption, data anomaly, etc. By simulating these abnormal situations, the stability and reliability of the controller under extreme conditions can be evaluated, as well as whether its built-in fault handling mechanism is effective. For example, during the test, the power supply to the controller can be deliberately cut off, and then observe whether it can automatically restart and resume normal operation after the power is restored; or, an invalid data packet can be sent to the controller through an interface call to observe whether it can recognize and handle this abnormal situation without causing the system to crash or enter an unpredictable state.

[0079] It can be seen that the interface operation combination method is constructed based on the target customized parameters, aiming to achieve comprehensive testing of the target controller through a series of orderly and precisely configured interface calls. It includes both the simulation of normal operation scenarios and the evaluation of the ability to handle abnormal situations, thus ensuring the comprehensiveness and accuracy of the test results.

[0080] S300: Execute a target test case based on the interface operation combination to test a target controller.

[0081] After executing the target test case based on the interface operation combination mode, it also includes:

[0082] Obtain target log information for executing the target test case;

[0083] A test result of a target function of the target controller is acquired based on the target log information, where the test result includes a response time and a data transmission rate.

[0084] After obtaining the test result of the target function of the target controller based on the target log information, the method further includes:

[0085] The test results are compared with the expected results and a test report is generated, which includes whether the test passed, the reason for failure, error log, test coverage, defect statistics and repair suggestions.

[0086] After obtaining the interface operation combination mode, the target test case for the target controller is formally executed based on the interface operation combination mode. This series of test cases is carefully designed based on the previous demand analysis, test plan and target customization parameters, aiming to fully verify the functions, performance and exception handling capabilities of the target controller.

[0087] In the process of executing the target test cases, the test tool will interact with the target controller according to the predetermined interface call sequence and parameter configuration, and simulate various possible operation scenarios. These test cases not only cover the functional verification under normal operation, but also include the evaluation of the ability to handle abnormal situations to ensure that the target controller can work stably and reliably under various conditions.

[0088] Once the test case is executed, the target log information generated during the execution is immediately obtained. These log information records in detail every operation during the test, the response behavior of the target controller, and any possible errors or exceptions. By analyzing these log information, we can gain a deep understanding of the internal working mechanism of the target controller and accurately evaluate the test results of its target function.

[0089] The test results usually include key performance indicators such as response time and data transfer rate. Response time refers to the time interval between the test tool sending a request and the target controller returning a response, which reflects the processing speed and response capability of the target controller. Data transfer rate refers to the rate at which data is transmitted between the test tool and the target controller during the test process, which measures the communication efficiency and bandwidth utilization of the target controller.

[0090] After obtaining the test results, the next step is to compare them with the expected results. The expected results are set in advance based on the functional specifications and performance index requirements of the target controller. They represent the expected performance of the target controller under ideal conditions. By comparing the actual test results with the expected results, we can determine whether the target controller has achieved the expected performance standards and thus determine whether the test has passed.

[0091] If the test fails, you need to carefully analyze the failure reason and check the error log to get more information about the failure details. This information will help us locate the problem and develop a corresponding repair strategy.

[0092] Finally, a detailed test report is generated based on the data and results of the entire test process. This report not only includes the conclusion of whether the test passed, but also lists the reasons for failure, error logs, test coverage, defect statistics, and repair suggestions in detail. Test coverage is an important indicator to measure the degree of coverage of the target controller functions by test cases. It helps us understand the comprehensiveness and effectiveness of the test. Defect statistics record all problems and defects found during the test, as well as their severity and priority. Repair suggestions are specific solutions to these problems and defects based on in-depth analysis and understanding of the problems.

[0093] For example, if the target controller's response time is found to exceed the expected value during the test, the test report may point this out and list possible reasons for the extended response time, such as excessive processor load, network communication delay, etc. At the same time, the test report will also make corresponding repair suggestions, such as optimizing processor resource allocation, improving network communication protocols, etc., to help the development team quickly locate and solve the problem.

[0094] ·In summary, this embodiment provides a test method based on Modbus. When it is necessary to test the controller based on the Modbus protocol, first obtain the target test requirements, obtain the target custom parameters based on the target test requirements, and then obtain the interface operation combination method based on the target custom parameters. Finally, execute the target test case based on the interface operation combination method to test the target controller. This embodiment provides users with a test method based on Modbus, which solves the problem that the Modbus test tool in the prior art cannot perform comprehensive testing when testing emerging operating systems such as OHOS. In this embodiment, a comprehensive test of the target controller is achieved through the interface operation combination method. Through automated testing, the workload of manual testing is reduced and the test efficiency is improved. Furthermore, through comprehensive testing, the performance bottlenecks and problems of the target controller can be discovered, providing strong support for optimizing the performance of the target controller.

[0095] It should be understood that, although the various steps in the flowcharts given in the accompanying drawings of the present invention are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of the steps in the present invention is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps of the present invention may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0096] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by signaling related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0097] Embodiment 2

[0098] Based on the above embodiments, the present invention also provides a test device based on Modbus, and its functional module schematic diagram is as follows: Figure 2 As shown, the Modbus-based test device includes:

[0099] A parameter customization module, used to obtain target test requirements, and obtain target customization parameters based on the target test requirements, as described in the first embodiment;

[0100] A combination mode acquisition module, used to acquire an interface operation combination mode based on the target customization parameter, as described in the first embodiment;

[0101] The test module is used to execute the target test case based on the interface operation combination mode to test the target controller, as described in the first embodiment.

[0102] Embodiment 3

[0103] like Figure 3 As shown, based on the above-mentioned Modbus-based testing method, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0104] The memory 20 may be an internal storage unit of the terminal in some embodiments, such as a hard disk or memory of the terminal. The memory 20 may also be an external storage device of the terminal in other embodiments, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal, etc. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a test program 40 based on Modbus is stored on the memory 20, and the test program 40 based on Modbus can be executed by the processor 10, thereby realizing the test method based on Modbus in the present application.

[0105] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the Modbus-based test method.

[0106] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a device bus.

[0107] In one embodiment, when the processor 10 executes the Modbus-based test program 40 in the memory 20, the following steps are implemented:

[0108] Obtain target test requirements, and obtain target customization parameters based on the target test requirements;

[0109] Acquire an interface operation combination mode based on the target customization parameters;

[0110] Execute the target test case based on the interface operation combination mode to test the target controller.

[0111] Wherein, after obtaining the target test requirements, the method further includes:

[0112] Acquire target configuration information, wherein the target configuration information includes test environment settings, test schedule, and test priority;

[0113] The test process or the allocation of test resources is adjusted according to the test configuration information and the target test requirement.

[0114] The target customization parameters include communication protocol type, device address, register address, data type, and read and write operations.

[0115] The interface operation combination method includes an interface calling sequence and parameter configuration predefined according to the target test requirements to implement a test of a specific function or performance of the target controller.

[0116] The interface operation combination method further includes simulating abnormal situations and observing the response behavior of the target controller.

[0117] Wherein, after executing the target test case based on the interface operation combination mode, it also includes:

[0118] Obtain target log information for executing the target test case;

[0119] A test result of a target function of the target controller is acquired based on the target log information, where the test result includes a response time and a data transmission rate.

[0120] Wherein, after obtaining the test result of the target function of the target controller based on the target log information, the method further includes:

[0121] The test results are compared with the expected results and a test report is generated, which includes whether the test passed, the reason for failure, error log, test coverage, defect statistics and repair suggestions.

[0122] Embodiment 4

[0123] The present invention also provides a computer-readable storage medium on which one or more programs are stored. The one or more programs can be executed by one or more processors to implement the steps of the Modbus-based testing method described in the above embodiment.

[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A test method based on Modbus, characterized in that: The Modbus-based testing method includes: Obtain target test requirements, and obtain target customization parameters based on the target test requirements; Acquire an interface operation combination mode based on the target customization parameters; Execute the target test case based on the interface operation combination mode to test the target controller.

2. The Modbus-based testing method according to claim 1, characterized in that: After obtaining the target test requirements, the following steps are also included: Acquire target configuration information, wherein the target configuration information includes test environment settings, test schedule, and test priority; The test process or the allocation of test resources is adjusted according to the test configuration information and the target test requirement.

3. The Modbus-based testing method according to claim 1, characterized in that: The target customization parameters include communication protocol type, device address, register address, data type, and read and write operations.

4. The Modbus-based testing method according to claim 1, characterized in that: The interface operation combination method includes an interface calling sequence and parameter configuration predefined according to the target test requirements to implement a test of a specific function or performance of the target controller.

5. The Modbus-based testing method according to claim 1, characterized in that: The interface operation combination method also includes simulating abnormal situations and observing the response behavior of the target controller.

6. The Modbus-based testing method according to claim 1, characterized in that: After executing the target test case based on the interface operation combination mode, it also includes: Obtain target log information for executing the target test case; A test result of a target function of the target controller is acquired based on the target log information, where the test result includes a response time and a data transmission rate.

7. The Modbus-based testing method according to claim 6, characterized in that: After obtaining the test result of the target function of the target controller based on the target log information, the method further includes: The test results are compared with the expected results and a test report is generated, which includes whether the test passed, the reason for failure, error log, test coverage, defect statistics and repair suggestions.

8. A test device based on Modbus, characterized in that: The device comprises: A parameter customization module is used to obtain target test requirements and obtain target customization parameters based on the target test requirements; A combination mode acquisition module, used for acquiring an interface operation combination mode based on the target customization parameters; The test module is used to execute the target test case based on the interface operation combination mode to test the target controller.

9. An intelligent terminal, characterized in that: The intelligent terminal includes a memory, a processor, and a Modbus-based test program stored in the memory and executable on the processor. When the Modbus-based test program is executed by the processor, the steps of the Modbus-based test method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a Modbus-based test program, and when the Modbus-based test program is executed by a processor, the steps of the Modbus-based test method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Script generation method and apparatus, and computing device, system and readable storage medium

    WO2024139538A1