Communication protocol testing method, device, electronic device and storage medium

Through automated test scripts, the battery management system sends Modbus protocol signals, records and converts the signal values, and compares the signal values ​​according to the mapping relationship, solving the cumbersome and time-consuming problems of the existing Modbus protocol testing methods, and achieving efficient automated testing.

CN118972295BActive Publication Date: 2025-02-25SHENZHEN PENGCHENG WUXIAN NEW ENERGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411444078.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-02-25
Estimated Expiration
2044-10-16

Smart Images

  • Figure CN118972295B_ABST
    Figure CN118972295B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a test method, device, electronic device and storage medium for a communication protocol, which belongs to the field of communication technology. The method includes: simulating a battery management system to send a battery management signal generated based on a first communication protocol by running a test script; recording the first signal value of the battery management signal at different times, and recording the second signal value at different times in each different address converted by the second communication protocol; comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain the test result. The above technical scheme improves the efficiency of the test by simulating the battery management signal that follows the first communication protocol under actual working conditions, automatically recording the values ​​of these signals at different time points, and comparing the signal value of the first communication protocol with the address value of the second communication protocol through the mapping relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and more specifically, to a communication protocol testing method, device, electronic device and storage medium. Background Art

[0002] Modbus protocol is a communication protocol widely used in industrial automation and control systems. In energy storage BMS (Battery Management System), Modbus protocol is used to monitor and control various parameters of the battery, such as voltage, temperature and current. In order to improve the accuracy of data transmission, tests are usually performed before applying the Modbus protocol.

[0003] In related technologies, Modbus protocol testing usually relies on manually written test cases. Testers need to manually set the CAN (Controller Area Network) signal value and observe whether the forwarding and calculation of the corresponding address in Ethernet are correct through the host computer. This process is cumbersome and time-consuming, especially when there are many Modbus addresses to be verified, which increases the time cost of testing. Summary of the invention

[0004] The present application provides a communication protocol testing method, device, electronic device and storage medium to improve the testing efficiency of the communication protocol.

[0005] In a first aspect, an embodiment of the present application provides a method for testing a communication protocol, comprising:

[0006] Sending a battery management signal generated by a simulated battery management system based on a first communication protocol by running a test script;

[0007] Recording the first signal value of the battery management signal at different times, and recording the second signal value of each different address converted by the battery management signal through the second communication protocol at different times;

[0008] The first signal value and the second signal value are compared according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

[0009] In the above technical solution, by simulating the battery management signal that follows the first communication protocol under actual working conditions, the values ​​of these signals at different time points are automatically recorded, and how these signals are converted and transmitted through the second communication protocol is monitored, so as to capture the second signal value of the corresponding address at different times, and then compare the signal value of the first communication protocol with the address value of the second communication protocol through the mapping relationship, which can automatically verify the compatibility and data consistency between different communication protocols and improve the efficiency of the test.

[0010] In some embodiments, recording the first signal value of the battery management signal at different times, and recording the second signal value of each different address converted by the second communication protocol at different times, includes:

[0011] Recording the first signal value of the battery management signal at different times at preset intervals through a first log file in a first preset format; the first log file includes a timestamp corresponding to each first signal value;

[0012] The second log file in a second preset format records the conversion of the battery management signal into second signal values ​​at different times in different addresses through a second communication protocol at preset time intervals; the second log file includes timestamps corresponding to the second signal values ​​in different addresses.

[0013] In the above technical solution, by introducing the log file recording mechanism, detailed tracking and data capture of the communication protocol test process are achieved. This parallel recording method not only improves time synchronization, but also provides a clear timing context for the signal value through the standardized format and timestamp of the log file, which is convenient for subsequent data processing and analysis.

[0014] In some embodiments, the method further comprises:

[0015] When the format of the timestamp corresponding to the first signal value is different from the format of the timestamp corresponding to the second signal value, the format of the timestamp corresponding to the first signal value and the format of the timestamp corresponding to the second signal value are adjusted to the same format.

[0016] In the above technical solution, when the timestamp formats of the first signal value and the second signal value are inconsistent, the formats are adjusted to improve the consistency of the timestamps, so as to facilitate subsequent signal value comparison and improve subsequent test efficiency.

[0017] In some embodiments, the comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes:

[0018] Matching addresses corresponding to each battery management signal according to the mapping relationship;

[0019] The first signal values ​​of each battery management signal at different times are compared with the second signal values ​​of the addresses corresponding to each battery management signal at different times to obtain a test result.

[0020] In the above technical solution, through the mapping relationship, the battery management signal under the first communication protocol can be accurately matched with the address of the second communication protocol, so as to obtain the corresponding relationship of the signals under different communication protocol environments. During the signal value comparison process, the corresponding relationship can be used for comparison, which can verify the reliability of the signal during the transmission process and enhance the accuracy of the test results.

[0021] In some embodiments, comparing the first signal value of each battery management signal at different times with the second signal value of the address corresponding to each battery management signal at different times includes:

[0022] For the first signal values ​​at different times, a second signal value whose recording time is later than the first signal value and whose recording time is closest to the first signal value is compared with the first signal value.

[0023] In the above technical solution, by selecting the second signal value that is recorded at the closest time point later than the first signal value for comparison, the two signal values ​​are made as close as possible in time, taking into account the time delay or synchronization problems that may be encountered in the signal transmission process, so that the test results more truly reflect the performance of the signal in the actual communication protocol conversion, thereby improving the accuracy of the test.

[0024] In some embodiments, the comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes:

[0025] When the precision and the offset of the second communication protocol do not satisfy the first preset condition, calculating a third signal value corresponding to the second signal value according to the precision and the offset;

[0026] The first signal value and the third signal value are compared to obtain a test result.

[0027] In the above technical solution, when the accuracy and offset of the second communication protocol do not meet the preset conditions, the third signal value corresponding to the second signal value is calculated to adapt to the accuracy of signal conversion between different communication protocols, so that the compared signal values ​​are directly consistent, so that different signals can be compared under the condition of consistency, thereby further improving the accuracy of the test.

[0028] In some embodiments, the comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes:

[0029] When the mapping relationship satisfies a second preset condition, converting the second signal value into a binary value;

[0030] The first signal value and the binary value are compared according to the mapping relationship to obtain a test result.

[0031] In the above technical solution, by converting the second signal value into a binary value when the mapping relationship meets a specific condition, even slight differences at the bit level can be accurately identified during the comparison process, thereby improving the accuracy of the test.

[0032] In some embodiments, the test script is generated according to the following method:

[0033] Parsing the signals generated in the battery management system based on the first communication protocol to obtain properties of each signal;

[0034] Based on the attributes of each signal, a signal sending statement is written for each signal using a preset grammar;

[0035] Write the signal sending statement into the test script.

[0036] In the above technical solution, by parsing the signal generated based on the first communication protocol in the battery management system, the properties of the signal can be automatically obtained. These properties can be used as reference information, and the preset grammar rules can be used to automatically write signal sending statements for each signal. These signal sending statements can be integrated into the test script to form a set of automated test scripts, which reduces the time for manual writing of test scripts and improves test efficiency.

[0037] In some embodiments, the writing strategy of the signal sending statement includes: sending a specific value of each signal or enumerating and sending values ​​within a value range of each signal.

[0038] In the above technical solution, by sending specific values ​​of each signal, known key data points can be tested, which helps to verify the response and processing capabilities to specific inputs; enumerating the values ​​within the value range of each signal can perform comprehensive stress testing and functional testing, thereby revealing potential problems or defects.

[0039] In a second aspect, an embodiment of the present application provides a communication protocol testing device, including:

[0040] A sending module, used to simulate the battery management system to send a battery management signal generated based on the first communication protocol by running a test script;

[0041] A recording module, used to record the first signal value of the battery management signal at different times, and to record the second signal value at different times in each different address converted by the battery management signal through the second communication protocol;

[0042] The comparison module is used to compare the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

[0043] In the above technical solution, by simulating the battery management signal that follows the first communication protocol under actual working conditions, the values ​​of these signals at different time points are automatically recorded, and how these signals are converted and transmitted through the second communication protocol is monitored, so as to capture the second signal value of the corresponding address at different times, and then compare the signal value of the first communication protocol with the address value of the second communication protocol through the mapping relationship, which can automatically verify the compatibility and data consistency between different communication protocols and improve the efficiency of the test.

[0044] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for testing the communication protocol as described in the first aspect above is implemented.

[0045] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the communication protocol testing method as described in the first aspect above.

[0046] In a fifth aspect, the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the testing method of the communication protocol as described in the first aspect above.

[0047] In a sixth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the testing method of the communication protocol as described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 It is a flowchart of a method for testing a communication protocol provided in an embodiment of the present application;

[0050] Figure 2 It is a scenario diagram of a method for testing a communication protocol provided in an embodiment of the present application;

[0051] Figure 3 It is a structural schematic diagram of a test device for a communication protocol provided in an embodiment of the present application;

[0052] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0054] Unless otherwise defined, all technical and scientific terms used in this application have the same meanings as those commonly understood by technicians in the technical field of this application; the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification of this application or the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order or a primary and secondary relationship.

[0055] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0056] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", and "attached" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0057] The term "and / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.

[0058] The term "multiple" as used in the present application refers to more than two (including two). Similarly, the term "multiple groups" refers to more than two groups (including two groups), and the term "multiple sheets" refers to more than two sheets (including two sheets).

[0059] Modbus protocol is a serial communication protocol that supports multiple communication media and electrical interfaces, such as RS-232, RS-485, Ethernet, etc., and can be transmitted on multiple physical media. Modbus gateway is a network hub communication protocol conversion device. The Modbus master station communicates with the Modbus gateway through the network, and the Modbus gateway communicates with the Modbus slave station through the serial port. Before applying the Modbus protocol, tests are usually performed to verify whether the implementation of the Modbus protocol meets the standards and improve the accuracy of data transmission.

[0060] In recent years, new energy vehicles have developed by leaps and bounds. In the field of electric vehicles, power batteries, as the power source of electric vehicles, play an irreplaceable and important role. The battery consists of a box and multiple battery cells contained in the box. Among them, batteries, as core components of new energy vehicles, have high requirements in terms of safety and cycle life. BMS plays an important role in monitoring and managing battery status. BMS can send a variety of signals, which are mainly used to monitor battery voltage, current, temperature and other parameters, and control the battery charging and discharging process to ensure battery safety and performance. Therefore, whether the signals sent by BMS can be received correctly is crucial to ensuring battery safety and performance.

[0061] The inventors found that in the protocol test of related BMS signal transmission, Modbus protocol test usually relies on manually written test cases. The tester needs to manually set the CAN signal value and observe whether the forwarding and calculation of the corresponding address in Ethernet are correct through the host computer. This process is cumbersome and time-consuming, especially when there are many Modbus addresses to be verified, which increases the time cost of the test.

[0062] In order to solve at least one of the above problems, the inventors have designed a communication protocol testing method after in-depth research, including: running a test script to simulate a battery management system sending a battery management signal generated based on a first communication protocol; recording the first signal value of the battery management signal at different times, and recording the second signal value at different times in each different address converted by a second communication protocol; comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

[0063] This communication protocol testing method simulates battery management signals that follow the first communication protocol under actual working conditions, automatically records the values ​​of these signals at different time points, and monitors how these signals are converted and transmitted through the second communication protocol, thereby capturing the second signal value of the corresponding address at different times, and then comparing the signal value of the first communication protocol with the address value of the second communication protocol through a mapping relationship. This can automatically verify the compatibility and data consistency between different communication protocols, thereby improving the efficiency of the test.

[0064] The test method of the communication protocol disclosed in the embodiment of the present application can be used in, but not limited to, the fields of industrial automation, smart grid, vehicles, smart homes, aerospace, etc. The test method, device, electronic device, and storage medium having the communication protocol disclosed in the present application can be used to test the communication protocol used, which is conducive to improving the test efficiency.

[0065] Taking the communication protocol testing method of an embodiment of the present application as an example, the first communication protocol may be the CAN protocol, and the second communication protocol may be the Modbus protocol. For example, the BMS may periodically send battery voltage, current, temperature and other parameters through the CAN protocol, and this information may be received by the vehicle infotainment system or the vehicle's central control system through the Modbus protocol to monitor the battery status and provide feedback to the driver.

[0066] The following, in conjunction with the accompanying drawings, describes in detail the communication protocol testing method, device, electronic device and storage medium provided in the embodiments of the present application through specific embodiments and their application scenarios.

[0067] The communication protocol testing method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.

[0068] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or a tablet computer having a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer having a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).

[0069] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.

[0070] The test method for the communication protocol provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the test method for the communication protocol. The electronic device has the function of a gateway device. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The test method for the communication protocol provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.

[0071] like Figure 1 As shown, the communication protocol testing method includes: step 110, step 120 and step 130.

[0072] Step 110: Simulate the battery management system by running the test script to send a battery management signal generated based on the first communication protocol.

[0073] In the embodiment of the present application, the test script is an automated test tool that includes a series of predefined test operations and verification points for automatically executing test cases. The test script can simulate the BMS sending battery management signals such as battery voltage, current, and temperature generated based on the first communication protocol, and can also simulate the vehicle control unit sending battery management signals such as capacity management and driving mode control generated based on the first communication protocol.

[0074] It should be noted that the battery management signal is a signal sent in the BMS. For example, the battery management signal may include voltage, temperature, current, battery state of charge, battery health status and other signals related to the battery status; the battery management signal may also include power-off protection, alarm protection, overvoltage protection and other signals related to control commands. The battery management signal may include multiple different types of signals, each of which may have different values. Different signals may be sent at different times through the test script. When sending temperature signals, temperature signals with different values ​​may be sent at different times.

[0075] The first communication protocol may be a CAN protocol, a LIN (Local Interconnect Network), a FlexRay protocol, etc., which is not limited in the embodiments of the present application.

[0076] Step 120 , recording the first signal value of the battery management signal at different times, and recording the second signal value of each different address converted by the battery management signal through the second communication protocol at different times.

[0077] In an embodiment of the present application, the first signal value of the battery management signal generated based on the first communication protocol at different times can be recorded. For example, if the first signal value of the temperature signal sent is "20°C", the first signal value "20°C" is recorded, and the corresponding time is recorded.

[0078] In the embodiment of the present application, the second communication protocol may be a Modbus protocol, a Profibus protocol, a Profinet protocol, etc., which is not limited in the embodiment of the present application. These protocols may use addresses to distinguish different data types and data points. For example, Modbus addresses are generally divided into four types: coils, discrete inputs, input registers, and holding registers. For example, the coil address ranges from 00000 to 09999, and the input register address ranges from 40000 to 49999.

[0079] In the embodiment of the present application, since the data formats and data structures adopted by different communication protocols are different, the battery management signal generated based on the first communication protocol needs to be converted into a format that can be understood by the second communication protocol and stored in the address of the second communication protocol. For example, the BMS sends battery voltage information through the CAN protocol, and this battery voltage information is captured and received by a gateway or control system. The system may need to convert the battery voltage information into a format that can be understood by the Modbus protocol and store it in a specific Modbus address, such as in a register with an address of 40011, where 40011 represents the 11th position of the register.

[0080] In the embodiment of the present application, the data in each address of the second communication protocol can be recorded as the second signal value, and the second signal value at different times in each address of the second communication protocol can be recorded. For example, if there is data in the register with address 40011, the second signal value in the register with address 40011 and the writing time of the second signal value are recorded.

[0081] Step 130 : Compare the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

[0082] The mapping relationship is to convert the signal of the first communication protocol into a format that can be understood and processed by the second communication protocol, because different communication protocols may use different data formats or addressing schemes. For example, in the Modbus protocol, data is usually stored in different types of registers, such as discrete inputs, coil status, input registers, and holding registers, all of which have specific address ranges. For example, for a temperature signal generated based on the CAN protocol, after the temperature signal is converted through the Modbus protocol, it can be stored in a Modbus register with an address of 40001. For a battery voltage signal generated based on the CAN protocol, after the battery voltage signal is converted through the Modbus protocol, it can be stored in a Modbus register with an address of 40002. In this way, the mapping relationship can be that the temperature signal corresponds to address 40001, and the battery voltage signal corresponds to address 40002.

[0083] In the embodiment of the present application, the mapping relationship may be predefined, for example, a predefined mapping relationship between a signal of the first communication protocol and an address of the second communication protocol is stored in a protocol document or a database. The mapping relationship may be obtained through the protocol document or the database.

[0084] After the mapping relationship is obtained, the first signal value of the battery management signal having the mapping relationship and the second signal value in the address of the second communication protocol may be compared to obtain a test result.

[0085] For example, in the record of the battery management signal, the first signal value of the temperature signal at different times and the first signal value of the battery voltage signal at different times are included. In the address record of the second communication protocol, the second signal value at different times in the Modbus register with address 40001 and the second signal value at different times in the Modbus register with address 40002 are included. According to the mapping relationship, it can be determined that the temperature signal corresponds to address 40001 and the battery voltage signal corresponds to address 40002. Then, the first signal value of the temperature signal at different times can be compared with the second signal value at different times in the Modbus register with address 40001, and the first signal value of the battery voltage signal at different times can be compared with the second signal value at different times in the Modbus register with address 40002. If the comparison result is that the first signal value is the same as the second signal value, it means that the second signal value obtained after the conversion through the second protocol meets the expectations, and the data consistency is still maintained during the conversion process, then the test passes, and a test report of the test passing can be generated. For example, for the temperature signal, the corresponding first signal value is "25° C.", and in the Modbus register at the second bit 40002, the second signal value is also "25° C.", indicating that the test is passed.

[0086] In the above technical solution, by simulating signals that follow the first communication protocol under actual working conditions, automatically recording the values ​​of these signals at different time points, and monitoring how these signals are converted and transmitted through the second communication protocol, the second signal value of the corresponding address at different times is captured, and then the signal value of the first communication protocol is compared with the address value of the second communication protocol through a mapping relationship. This can automatically verify the compatibility and data consistency between different communication protocols, thereby improving the efficiency of the test.

[0087] In some embodiments, recording a first signal value of a battery management signal at different times, and recording a second signal value at different times in each different address after converting the battery management signal through a second communication protocol, includes:

[0088] Recording the first signal value of the battery management signal at different times at preset intervals through a first log file in a first preset format; the first log file includes a timestamp corresponding to each first signal value;

[0089] The second log file in the second preset format records the conversion of the battery management signal into the second signal value at different times in each different address through the second communication protocol at preset time intervals; the second log file includes the timestamps corresponding to the second signal values ​​in different addresses.

[0090] In this embodiment, the first preset format and the second preset format may be the same format or different formats. In some embodiments, in order to facilitate the comparison of the signal values ​​in the first log file and the second log file, the first preset format and the second preset format are formats that can be opened by the same software, for example, the first preset format and the second preset format can both be opened by Excel, and the first preset format and the second preset format may be in xlsx format or in csv format. Of course, the first preset format and the second preset format may also be in other formats, which are not limited in the embodiments of the present application.

[0091] For example, during the test, you can use CANoe software to simulate the sending of battery management signals, and use CANoe to record a first log file in xlsx format, which includes the signal values ​​of the battery management signals at different times and the corresponding timestamps; you can use the Modbus Poll tool to record a second log file in csv format, which includes the signal values ​​of each Modbus address of the ETH (Ethernet Module, Ethernet communication module) at different times, and the timestamps corresponding to the signal values.

[0092] In the above technical solution, by introducing the log file recording mechanism, detailed tracking and data capture of the communication protocol test process are achieved. This parallel recording method not only improves time synchronization, but also provides a clear timing context for the signal value through the standardized format and timestamp of the log file, which is convenient for subsequent data processing and analysis.

[0093] In some embodiments, the method further comprises:

[0094] When the format of the timestamp corresponding to the first signal value is different from the format of the timestamp corresponding to the second signal value, the format of the timestamp corresponding to the first signal value and the format of the timestamp corresponding to the second signal value are adjusted to the same format.

[0095] In this embodiment, since the formats of the first log file and the second log file may be different, the formats of the timestamps in the first log file and the second log file may also be different. In order to facilitate the subsequent comparison of the first signal value in the first log file and the second signal value in the second log file, the formats of the timestamps in the first log file and the second log file may be unified into the same format in advance. For example, the format of the timestamp is unified into "year / month / day hour:minute:second", such as: 2024 / 9 / 4 15:07:59.

[0096] In the above technical solution, when the timestamp formats of the first signal value and the second signal value are inconsistent, the formats are adjusted to improve the consistency of the timestamps, so as to facilitate subsequent signal value comparison and improve subsequent test efficiency.

[0097] In some embodiments, the first signal value and the second signal value are compared according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result, including:

[0098] Match the addresses corresponding to each battery management signal according to the mapping relationship;

[0099] The first signal values ​​of each battery management signal at different times are compared with the second signal values ​​of the addresses corresponding to each battery management signal at different times to obtain a test result.

[0100] In this embodiment, the mapping relationship defines the corresponding relationship between the battery management signal and the address of the second communication protocol. For example, the mapping relationship may include: CAN temperature signal->Modbus address 40001. When a message indicating that the temperature signal is sent via the CAN protocol, the gateway device converts the content of the message into the format of the Modbus protocol and stores it in address 40001. In this way, it can be determined which first signal values ​​are compared with which second signal values.

[0101] For example, when the battery management signal is a temperature signal, the temperature value (first signal value) corresponding to the temperature signal at different times can be compared with the temperature value (second signal value) at different times under address 40001; when the battery management signal is a battery voltage signal, the voltage value (first signal value) corresponding to the battery voltage signal at different times can be compared with the voltage value (second signal value) at different times under address 40002. If the two values ​​are equal, it can be considered that the conversion of the signal between the first communication protocol and the second communication protocol is correct. If they are not equal, the difference can be recorded for subsequent fault diagnosis and performance optimization.

[0102] In the above technical solution, through the mapping relationship, the battery management signal under the first communication protocol can be accurately matched with the address of the second communication protocol, so as to obtain the corresponding relationship of the signals under different communication protocol environments. During the signal value comparison process, the corresponding relationship can be used for comparison, which can verify the reliability of the signal during the transmission process and enhance the accuracy of the test results.

[0103] In some embodiments, comparing the first signal value of each battery management signal at different times with the second signal value of the address corresponding to each battery management signal at different times includes:

[0104] For the first signal values ​​at different times, a second signal value whose recording time is later than the first signal value and whose recording time is closest to the first signal value is compared with the first signal value.

[0105] In this embodiment, for a certain battery management signal, different first signal values ​​may correspond to different times. Similarly, different addresses include second signal values ​​at different times. If a comparison is to be performed, it is also necessary to determine which time's first signal value is to be compared with which time's second signal value.

[0106] Specifically, the signal values ​​to be compared can be determined by looking up the timestamps of the first signal value and the second signal value. Due to the time delay that may be encountered during the transmission of the signal, the first signal value and the second signal value with the same timestamp are usually not compared. Instead, the second signal value with a timestamp later than the first signal value and closest to the first signal value is selected for comparison. For example, for the first signal value of the battery management signal with a timestamp of 2024 / 9 / 4 15:07:59, the second signal value with a timestamp of 2024 / 9 / 4 15:08:00 at the corresponding address can be selected for comparison.

[0107] In the above technical solution, by selecting the second signal value that is recorded at the closest time point later than the first signal value for comparison, the two signal values ​​are made as close as possible in time, taking into account the time delay or synchronization problems that may be encountered in the signal transmission process, so that the test results more truly reflect the performance of the signal in the actual communication protocol conversion, thereby improving the accuracy of the test.

[0108] In some embodiments, the first signal value and the second signal value are compared according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result, including:

[0109] When the precision and offset of the second communication protocol do not satisfy the first preset condition, calculating a third signal value corresponding to the second signal value according to the precision and offset;

[0110] The first signal value and the third signal value are compared to obtain a test result.

[0111] In communication protocol testing, precision and offset are used to convert signal values ​​from one format to another. Precision refers to the proportional relationship between the signal value and the actual physical quantity. Precision can be expressed as a proportional factor, which defines the amount by which the actual physical quantity changes when the signal value changes by one unit. For example, if the precision is 0.1, then for every one unit change in the signal value, the actual physical quantity will change by 0.1 units.

[0112] Offset refers to a constant that needs to be added or subtracted when converting a signal value to an actual physical value. Offset is often used to process physical quantities that cannot be directly expressed as non-negative numbers, such as temperature or pressure. By adding an offset, these physical quantities can be converted into positive integer values ​​that can be transmitted.

[0113] For example, the precision of the second communication protocol is 0.1, the offset is 0, the value of the battery voltage signal (battery management signal) sent through the first communication protocol is 3.7V, the battery management signal is parsed through the second communication protocol to obtain the second signal value, and the second signal value is stored in the corresponding Modbus address, then the second signal value is 37. Among them, the relationship between the physical value (second signal value) and the original value (first signal value) in the Modbus address is: physical value = original value × precision + offset.

[0114] According to the definition of precision and offset, when the precision is 1 and the offset is 0, the original value of the battery management signal is the same as the physical value. Therefore, in this case, the first signal value can be directly compared with the second signal value. When the precision of 1 and the offset of 0 are not met, the second signal value needs to be restored to a third signal value through precision and offset, and then the third signal value is compared with the first signal value. If the third signal value is equal to the first signal value, then it can be considered that the conversion of the signal between the first communication protocol and the second communication protocol is correct. If they are not equal, the difference can be recorded for subsequent fault diagnosis and performance optimization. Among them, the first preset condition can be that the precision of the second communication protocol is 1 and the offset is 0.

[0115] In the above technical solution, when the accuracy and offset of the second communication protocol do not meet the preset conditions, the third signal value corresponding to the second signal value is calculated to adapt to the accuracy of signal conversion between different communication protocols, so that the compared signal values ​​are directly consistent, so that different signals can be compared under the condition of consistency, thereby further improving the accuracy of the test.

[0116] In some embodiments, the first signal value and the second signal value are compared according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result, including:

[0117] When the mapping relationship satisfies the second preset condition, converting the second signal value into a binary value;

[0118] The first signal value and the binary value are compared according to the mapping relationship to obtain a test result.

[0119] In this embodiment, the mapping relationship may include direct mapping or mapping to a specific bit. Direct mapping means that a signal value directly corresponds to a value under an address of another protocol. For example, a temperature sensor sends a temperature signal through the CAN protocol, and the temperature value is 23.5°C. In the case of direct mapping, if the Modbus address 40011 is mapped to the temperature signal, then the temperature value 23.5°C will be directly stored in the Modbus address 40011.

[0120] Mapping to a specific bit means that a certain feature of the transmitted signal (such as the switch status) is mapped to a specific bit of another protocol address. For example, the BMS sends a battery management signal containing multiple states through the CAN protocol. This battery management signal contains three status bits: fire system status (bit 0), safety door status (bit 1), and alarm system status (bit 2). If these states need to be mapped to specific bits of the Modbus protocol, such as mapping to bits 0, 1, and 2 of address 40021, then bits 0, 1, and 2 of the battery management signal can be mapped to the corresponding bits of the Modbus address respectively. The first signal value of the battery management signal: 0b110 (binary representation, where bits 0 and 2 are 1, indicating that the fire system and alarm system are activated, respectively). The second signal value of the Modbus address: 6 (decimal representation).

[0121] Therefore, when the mapping relationship is mapped to a specific bit position, since the first signal value of the battery management signal is represented in binary, in order to facilitate the comparison between the first signal value and the second signal value, the second signal value can be converted into binary representation and then compared with the first signal value.

[0122] In the above technical solution, by converting the second signal value into a binary value when the mapping relationship meets a specific condition, even slight differences at the bit level can be accurately identified during the comparison process, thereby improving the accuracy of the test.

[0123] In some embodiments, the test script is generated according to:

[0124] Parsing signals generated in the battery management system based on the first communication protocol to obtain properties of each signal;

[0125] Based on the properties of each signal, use the preset syntax to write a signal sending statement for each signal;

[0126] Write the signal sending statements into the test script.

[0127] In this embodiment, various signals generated by the battery management system through the first communication protocol can be obtained from the database. For example, in the field of electric vehicles, various signals generated by the BMS through the CAN protocol can be obtained from the database, and these signals are parsed to obtain the properties of these signals. Among them, the properties may include the signal ID, data type, data length, range, initial value, maximum value, minimum value, invalid value, etc.

[0128] According to the properties of each signal obtained by parsing, a preset syntax, such as the CAPL (Communication Access Programming Language) syntax used in the CANoe test environment, can be used to write a signal sending statement to simulate the sending of battery management signals. Then the written signal sending statement is written into the test script, which can be executed to automatically send the battery management signal. For example, in the test script, a series of CAPL commands can be included, which are composed of signal sending statements for sending different signals. Of course, in order to adapt to various test processes, the sending time interval of different signals can also be adjusted.

[0129] In the above technical solution, by parsing the signal generated by the first communication protocol, the properties of the signal can be automatically obtained. By using these properties as reference information and utilizing preset grammar rules, signal sending statements can be automatically written for each signal, and these signal sending statements can be integrated into the test script to form a set of automated test scripts, which reduces the time for manual writing of test scripts and improves test efficiency.

[0130] In some embodiments, the writing strategy of the signal sending statement includes: sending a specific value of each signal or enumerating and sending values ​​within a value range of each signal.

[0131] In this embodiment, the writing strategy of the signal sending statement is the key to enable the test process to cover various possible situations. The writing strategy can include sending a specific value or traversing the possible values ​​of the signal. The specific value can include a normal value, a maximum value, a minimum value, an invalid value, an abnormal value, etc. Enumerating the values ​​within the range of each signal value indicates the possible values ​​of the sent signal. For example, the output range of a temperature sensor is -40°C to 85°C, and the test script can send values ​​within this range.

[0132] In the above technical solution, by sending specific values ​​of each signal, known key data points can be tested, which helps to verify the response and processing capabilities to specific inputs; enumerating the values ​​within the value range of each signal can perform comprehensive stress testing and functional testing, thereby revealing potential problems or defects.

[0133] The following is a scenario example to further illustrate the communication protocol testing method provided by this application. Figure 2 As shown, in this scenario example, an application scenario of an electric vehicle is used for illustration, the first communication protocol is the CAN communication protocol, and the second communication protocol is the Modbus communication protocol.

[0134] In this scenario example, the properties of each CAN signal can be obtained by parsing the CAN communication protocol in the database, and then a test script based on CAPL can be generated. If the signal value of the CAN signal is clearly defined, such as temperature, pressure, etc., an enumeration sending strategy can be adopted, otherwise the normal value, maximum value, minimum value, invalid value, etc. can be sent.

[0135] In this scenario example, the test script can be executed in the CANoe software to simulate the test process, send the battery management signal, and record the first signal value of each battery management signal on the CAN bus at different times every 1 second through the first log file in xlsx format. The second log file in csv format is recorded every 1 second through the Modbus Poll tool. The second log file includes the second signal value of each EHT Modbus address at different times.

[0136] The formats of the timestamps in the first log file and the second log file are modified to the same format. Then, the signal values ​​in the first log file and the second log file are compared according to the mapping relationship between each battery management signal and the Modbus address. Specifically, the first signal value of a timestamp in the first log file can be compared with the second signal value of the next timestamp in the second log file. If the two values ​​are equal, it can be considered that the conversion of the signal between the CAN communication protocol and the Modbus communication protocol is correct. If they are not equal, the difference can be recorded to facilitate subsequent fault diagnosis and performance optimization. Determine the test results and generate a test report based on the comparison results.

[0137] The communication protocol testing method provided in the embodiment of the present application can be executed by a communication protocol testing device. In the embodiment of the present application, the communication protocol testing method performed by the communication protocol testing device is taken as an example to illustrate the communication protocol testing device provided in the embodiment of the present application.

[0138] The embodiment of the present application also provides a testing device for a communication protocol.

[0139] like Figure 3 As shown, the test device of the communication protocol includes:

[0140] A sending module 310, configured to simulate the battery management system sending a battery management signal generated based on the first communication protocol by running a test script;

[0141] The recording module 320 is used to record the first signal value of the battery management signal at different times, and to record the second signal value at different times in each different address converted by the battery management signal through the second communication protocol;

[0142] The comparison module 330 is used to compare the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

[0143] In the above technical solution, by simulating the battery management signal that follows the first communication protocol under actual working conditions, the values ​​of these signals at different time points are automatically recorded, and how these signals are converted and transmitted through the second communication protocol is monitored, so as to capture the second signal value of the corresponding address at different times, and then compare the signal value of the first communication protocol with the address value of the second communication protocol through the mapping relationship, which can automatically verify the compatibility and data consistency between different communication protocols and improve the efficiency of the test.

[0144] In some embodiments, the recording module 320 is further configured to:

[0145] Recording the first signal value of the battery management signal at different times at preset intervals through a first log file in a first preset format; the first log file includes a timestamp corresponding to each first signal value;

[0146] The second log file in the second preset format records the conversion of the battery management signal into the second signal value at different times in each different address through the second communication protocol at preset time intervals; the second log file includes the timestamps corresponding to the second signal values ​​in different addresses.

[0147] In some embodiments, the recording module 320 is further configured to:

[0148] When the format of the timestamp corresponding to the first signal value is different from the format of the timestamp corresponding to the second signal value, the format of the timestamp corresponding to the first signal value and the format of the timestamp corresponding to the second signal value are adjusted to the same format.

[0149] In some embodiments, the comparison module 330 is further configured to:

[0150] Match the addresses corresponding to each battery management signal according to the mapping relationship;

[0151] The first signal values ​​of each battery management signal at different times are compared with the second signal values ​​of the addresses corresponding to each battery management signal at different times to obtain a test result.

[0152] In some embodiments, the comparison module 330 is further configured to:

[0153] For the first signal values ​​at different times, a second signal value whose recording time is later than the first signal value and whose recording time is closest to the first signal value is compared with the first signal value.

[0154] In some embodiments, the comparison module 330 is further configured to:

[0155] When the precision and offset of the second communication protocol do not satisfy the first preset condition, calculating a third signal value corresponding to the second signal value according to the precision and offset;

[0156] The first signal value and the third signal value are compared to obtain a test result.

[0157] In some embodiments, the comparison module 330 is further configured to:

[0158] When the mapping relationship satisfies the second preset condition, converting the second signal value into a binary value;

[0159] The first signal value and the binary value are compared according to the mapping relationship to obtain a test result.

[0160] The communication protocol test device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0161] The communication protocol testing device in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0162] In some embodiments, Figure 4 As shown, an embodiment of the present application also provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. When the program is executed by the processor 401, each process of the test method embodiment of the above-mentioned communication protocol is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0163] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0164] An embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the test method embodiment of the above-mentioned communication protocol are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0165] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0166] An embodiment of the present application also provides a computer program product, including a computer program, which implements the testing method of the above-mentioned communication protocol when executed by a processor.

[0167] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0168] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned communication protocol-based test method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0169] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0170] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0171] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0172] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application, all of which are within the protection of the present application.

[0173] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0174] Although the embodiments of the present application have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application.

Claims

1. A communication protocol testing method, characterized in that: include: Running a test script simulates that the battery management system sends a battery management signal generated based on the first communication protocol; Recording the first signal value of the battery management signal at different times, and recording the second signal value of each different address converted by the battery management signal through a second communication protocol at different times; including: recording the first signal value of the battery management signal at different times at preset intervals through a first log file in a first preset format; The first log file includes a timestamp corresponding to each first signal value; a second log file in a second preset format records, at a preset time interval, the conversion of the battery management signal into a second signal value at different times at different addresses through a second communication protocol; the second log file includes a timestamp corresponding to the second signal value at different addresses; The first signal value and the second signal value are compared according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

2. The method according to claim 1, characterized in that The method further comprises: When the format of the timestamp corresponding to the first signal value is different from the format of the timestamp corresponding to the second signal value, the format of the timestamp corresponding to the first signal value and the format of the timestamp corresponding to the second signal value are adjusted to the same format.

3. The method according to claim 1, characterized in that The comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes: Matching addresses corresponding to each battery management signal according to the mapping relationship; The first signal values ​​of each battery management signal at different times are compared with the second signal values ​​of the addresses corresponding to each battery management signal at different times to obtain a test result.

4. The method according to claim 3, characterized in that The comparing the first signal value of each battery management signal at different times with the second signal value of the address corresponding to each battery management signal at different times includes: For the first signal values ​​at different times, a second signal value whose recording time is later than the first signal value and whose recording time is closest to the first signal value is compared with the first signal value.

5. The method according to claim 1, characterized in that The comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes: When the precision and the offset of the second communication protocol do not satisfy the first preset condition, calculating a third signal value corresponding to the second signal value according to the precision and the offset; The first signal value and the third signal value are compared to obtain a test result.

6. The method according to claim 1, characterized in that The comparing the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result includes: When the mapping relationship satisfies a second preset condition, converting the second signal value into a binary value; The first signal value and the binary value are compared according to the mapping relationship to obtain a test result.

7. The method according to claim 1, characterized in that The test script is generated in the following way: Parsing the signals generated in the battery management system based on the first communication protocol to obtain properties of each signal; Based on the attributes of each signal, a signal sending statement is written for each signal using a preset grammar; Write the signal sending statement into the test script.

8. The method according to claim 7, characterized in that The writing strategy of the signal sending statement includes: sending a specific value of each signal or enumerating and sending values ​​within a value range of each signal.

9. A communication protocol testing device, characterized in that: include: A sending module, used to simulate the battery management system to send a battery management signal generated based on the first communication protocol by running a test script; A recording module, used to record the first signal value of the battery management signal at different times, and record the second signal value at different times in each different address after the battery management signal is converted through a second communication protocol; the recording module is also used to: record the first signal value of the battery management signal at different times at preset intervals through a first log file of a first preset format; the first log file includes a timestamp corresponding to each first signal value; record the second signal value at different times in each different address after the battery management signal is converted through a second communication protocol through a second log file of a second preset format at preset intervals; the second log file includes a timestamp corresponding to the second signal value at different addresses; The comparison module is used to compare the first signal value and the second signal value according to the mapping relationship between the battery management signal and the address of the second communication protocol to obtain a test result.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Protocol conversion method, device and equipment for Internet-of-Things data

    CN112104664A

  • Vehicle control unit real-time consistency test method and system and storage medium

    CN117407294A