CAN bus communication matrix automatic test method and test system thereof

By analyzing DBC files and connecting to the ECU using XCP protocol, automated testing of the CAN bus communication matrix is ​​realized, solving the problems of low testing efficiency and high cost in the existing technology, and achieving efficient and comprehensive testing coverage.

CN119854159APending Publication Date: 2025-04-18浙江创驱智能科技有限公司
View PDF 8 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing CAN bus communication matrix testing methods have problems such as complex system, low testing efficiency and expensive testing, and cannot achieve efficient and comprehensive automated testing.

Method used

By loading the DBC file, parse and obtain the ECU node list, CAN message data and DCB message data, select the ECU node under test, load the calibration description file, connect to the ECU using the XCP protocol, set the test status, receive and send CAN message data, test the message cycle and data domain length, and generate simulated messages for testing.

Benefits of technology

The full coverage test of CAN signals is realized, which reduces the cost of test equipment, avoids complex hardware dependence, improves testing efficiency, can cope with frequent matrix changes, and greatly reduces test time and labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119854159A_ABST
    Figure CN119854159A_ABST
Patent Text Reader

Abstract

The invention discloses a CAN (Controller Area Network) bus communication matrix automatic test method, which comprises the following steps of: loading a DBC (Direct Business Control) file, and carrying out analysis processing on the DBC file; selecting a node of the tested ECU, and loading a calibration description file of the tested ECU; finding a corresponding variable name in the corresponding calibration description file, and extracting variable information; connecting the tested ECU through an XCP protocol, and setting the tested ECU to be in a calibration mode; setting a test state through an XCP protocol; receiving CAN bus message data sent by the tested ECU; the maximum value, the minimum value and the intermediate value of the sending signal are tested in sequence in the testing process; and testing the maximum value, the minimum value and the intermediate value of the received signal in sequence in the testing process. The invention also discloses a test system for realizing the CAN bus communication matrix automatic test method. According to the invention, the cost of test equipment is reduced, and the test time and labor cost are greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automobile control equipment, and in particular to an automatic testing method and a testing system for a CAN bus communication matrix. Background Art

[0002] In the development of automotive ECU controller software, the CAN bus communication matrix often needs to be changed, and the ECU's communication messages and signal volume are usually large. Especially when customizing for new customers, the development and testing workload of the CAN communication matrix is ​​often very large.

[0003] Currently, there are several commonly used CAN bus communication matrix test methods:

[0004] Existing Solution 1: Currently, the test of CAN bus communication matrix mainly adopts manual test. The ECU receiving test can send the CAN message received by ECU through software such as Bus Master and PCAN Explorer, and then use the simulator or XCPMaster client, such as Etas Inca, to manually compare whether the sent and received signals are consistent. The ECU sending test needs to add temporary test code, and then receive it through software such as Bus Master and PCAN Explorer for manual comparison.

[0005] The main drawbacks of this solution are: the CAN bus communication matrix changes frequently, manual testing requires a lot of manpower and material resources, manual comparison is prone to omissions, and the officially released software cannot be tested by temporary test codes.

[0006] Existing Solution 2: Chinese invention application CN106850372A discloses a controller CAN signal testing method and system, which generates a cmm script file from a CAN protocol DBC file through a Perl script; imports the cmm script file into a simulation test tool, and sends simulated CAN data according to the cmm script file; receives the simulated CAN data of the controller to be tested through a network analysis test tool, and uses the CAN protocol dbc file to determine whether the received simulated CAN data is consistent with the sent simulated CAN data.

[0007] The main drawbacks of this solution are that the test method requires multiple manual operations to generate cmm files and load cmm scripts into Trace32. The equipment is expensive and has a low degree of automation. In addition, it can only test the CAN sending signal of the controller, but not the receiving signal.

[0008] Existing Solution 3: Chinese invention application CN111064628A discloses a CAN bus automatic test system, including a motor controller, a hardware-in-the-loop test system, a calibration system and CAN test software. The hardware-in-the-loop test system communicates with the motor controller under test through CAN communication, and is used to simulate the motor, battery and whole vehicle controlled by the motor controller, modify the model parameters in the hardware-in-the-loop test system, and compare the corresponding received signal values ​​in the motor controller to test the CAN signal receiving function of the motor controller; the calibration system observes and calibrates the parameters of the motor controller through CAN calibration, modifies the calibration values ​​in the motor controller, and compares the corresponding received signal values ​​in the hardware-in-the-loop test system to test the CAN signal sending function of the motor controller; the CAN test software parses the files in the motor controller and the hardware-in-the-loop test system, establishes a mapping relationship between each CAN signal from the motor controller to the hardware-in-the-loop test system, generates a test case for each CAN signal, and executes the test case.

[0009] The main drawback of this solution is that the system needs to modify model parameters or calibration data in the hardware-in-the-loop system and the calibration system, and the test software needs to rely on Labcar hardware and software and INCA software.

[0010] Existing Solution 4: Chinese invention patent CN113904967B discloses an automatic testing device and method for automobile CAN communication module interface software, which loads the CAN protocol and generates corresponding test cases according to the content of the CAN protocol, parses the CAN protocol, identifies the row and column information in the CAN protocol, obtains the information of all messages, and generates two types of test cases, *.cmm files and *.can files, one type is related to CAN sending signals, and the other type is related to CAN receiving signals; the test unit selects different tools to automatically load the case file according to whether the controller sends or receives signals, compares the data value of the signal sent or received by the controller with the data value sent or received in the test case, if they are consistent, the test passes, otherwise the test fails, and reports the test results.

[0011] The main drawback of this solution is that it is somewhat similar to the above solution 2. The ECU sending test generates a cmm file and loads it into Trace32 to simulate the controller sending CAN signals. The receiving test runs the Toolsend.can file through CANalyzer to send CAN signals to the controller. They both rely on expensive Trace32 and have a low degree of automation, requiring multiple manual interventions.

[0012] In summary, the existing test methods all have certain limitations and cannot achieve efficient and comprehensive CAN bus communication matrix automated testing. To this end, the applicant has found a solution to the above problem through beneficial exploration and research, and the technical solution to be introduced below is generated under this background. Summary of the invention

[0013] One of the technical problems to be solved by the present invention is to provide a CAN bus communication matrix automatic testing method in view of the deficiencies in the prior art, so as to solve the problems existing in the current CAN bus communication matrix testing method, such as complex system, low testing efficiency, high price, etc.

[0014] The second technical problem to be solved by the present invention is to provide a test system for realizing the above-mentioned CAN bus communication matrix automatic test method.

[0015] As a first aspect of the present invention, a CAN bus communication matrix automatic testing method comprises:

[0016] Loading a DBC file and parsing the DBC file to obtain an ECU node list, CAN message data, and DCB message data of a CAN bus communication matrix;

[0017] Select the node of the ECU under test and load the calibration description file of the ECU under test;

[0018] Match the sent and received signal lists by the node name of the ECU under test, and find the corresponding variable name in the corresponding calibration description file according to the DBC signal name and the ECU's send / receive variable name rules, and extract the variable information;

[0019] Connect to the ECU under test through the XCP protocol and set the ECU under test to calibration mode;

[0020] Set the test status through the XCP protocol to prohibit the upper-layer software from modifying the sent signal variables;

[0021] Receive the CAN bus message data sent by the ECU under test, and test the message period and data field length of the CAN bus message data sent by the ECU under test;

[0022] Generate a simulation message according to the DBC file, and send the generated simulation message to the ECU under test for testing. During the test, the maximum value, minimum value and intermediate value of the sent signal are tested in turn; and

[0023] The sending variables of the ECU under test are set through the XCP protocol, and the CAN message data sent by the ECU under test is received for testing. During the test, the maximum value, minimum value and intermediate value of the received signal are tested in turn.

[0024] In a preferred embodiment of the present invention, the ECU node list includes all node names of the CAN network; the CAN message data includes the IDs, sending cycles, data field lengths and corresponding sending nodes and receiving nodes of all CAN messages; the DCB message data includes the signal names, start bits, lengths, units, factors and offsets of all DCB messages.

[0025] In a preferred embodiment of the present invention, the calibration description file of the ECU under test includes the names and variable address information of the sending and receiving signals of the CAN.

[0026] In a preferred embodiment of the present invention, setting the test status through the XCP protocol includes:

[0027] The test enable variable Task_Switch_Gb is set to 1 through the SET_MTA and DOWNLOAD commands in the XCP protocol to prohibit the upper-layer software from modifying the sent signal variables.

[0028] In a preferred embodiment of the present invention, the maximum value, the minimum value and the intermediate value of the transmitted signal are tested in sequence during the test, including:

[0029] The maximum, minimum or median value of all signals received by the ECU under test is sent via CAN. The period, data domain length (DLC), checksum and other information of the sent CAN message are consistent with the description in the DBC file;

[0030] Read the variable values ​​corresponding to all CAN signals received by the ECU under test through the SHORT_UPLOAD command of the XCP protocol; and

[0031] Check whether the sent CAN signal is consistent with the corresponding XCP observation read; if consistent, it is judged as OK, otherwise the test result is marked as NG.

[0032] In a preferred embodiment of the present invention, the maximum value, the minimum value and the intermediate value of the received signal are tested in sequence during the test, including:

[0033] Set the variables corresponding to the CAN signals sent by all ECUs to the maximum, minimum or middle values ​​through the SET_MTA and DOWNLOAD commands of the XCP protocol;

[0034] Read all messages sent by the ECU under test through CAN, and parse the values ​​of all received signals through DBC; and

[0035] Check whether the received CAN signal value is equal to the send variable value set to the ECU; if they are equal, it is judged as OK, otherwise the test result is marked as NG.

[0036] As a second aspect of the present invention, a test system for implementing the above-mentioned CAN bus communication matrix automatic test method includes a host computer and an ECU under test, wherein the host computer is connected to the ECU under test via a USB CAN interface, and a computer program is stored in the host computer. When the computer program is executed by the host computer, the following steps are implemented:

[0037] Loading a DBC file and parsing the DBC file to obtain an ECU node list, CAN message data, and DCB message data of a CAN bus communication matrix;

[0038] Select the node of the ECU under test and load the calibration description file of the ECU under test;

[0039] Match the sent and received signal lists by the node name of the ECU under test, and find the corresponding variable name in the corresponding calibration description file according to the DBC signal name and the ECU's send / receive variable name rules, and extract the variable information;

[0040] Connect to the ECU under test through the XCP protocol and set the ECU under test to calibration mode;

[0041] Set the test status through the XCP protocol to prohibit the upper-layer software from modifying the sent signal variables;

[0042] Receive the CAN bus message data sent by the ECU under test, and test the message period and data field length of the CAN bus message data sent by the ECU under test;

[0043] Generate a simulation message according to the DBC file, and send the generated simulation message to the ECU under test for testing. During the test, the maximum value, minimum value and intermediate value of the sent signal are tested in turn; and

[0044] The sending variables of the ECU under test are set through the XCP protocol, and the CAN message data sent by the ECU under test is received for testing. During the test, the maximum value, minimum value and intermediate value of the received signal are tested in turn.

[0045] Due to the adoption of the above technical solution, the beneficial effects of the present invention are: the present invention can automatically generate test cases, support full coverage testing of CAN signals, rely on standard USB CAN devices, reduce the cost of test equipment, and avoid complex hardware dependence. The present invention has high test efficiency, can cope with frequent matrix changes, and greatly reduces test time and labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 It is a structural schematic diagram of an embodiment of the test system of the present invention.

[0048] Figure 2 It is a structural schematic diagram of another embodiment of the test system of the present invention.

[0049] Figure 3 It is a schematic diagram of the mapping relationship between the signal name of the DBC of the present invention and the variable name of the ECU.

[0050] Figure 4 It is a schematic diagram of the updating method of the enabling switch variable control variable of the present invention.

[0051] Figure 5 It is a schematic diagram of parsing messages, signals and signal attributes from a DBC file of the present invention.

[0052] Figure 6 It is a flow chart of the automatic testing method of the CAN bus communication matrix of the present invention.

[0053] Figure 7 It is a flow chart of the CAN receiving test of the present invention.

[0054] Figure 8 It is a flow chart of the CAN sending test of the present invention. DETAILED DESCRIPTION

[0055] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below with reference to specific diagrams.

[0056] See also Figure 1 The test system of the present invention includes a host computer 10 and an ECU 20 under test. The host computer 10 is connected to the ECU 20 under test via a USB CAN interface 11 (which may also be a hardware CAN card). Figure 2 Some ECU XCPs have independent debugging CAN ports, and two USB CANs are required to connect the vehicle CAN and the debugging CAN respectively, such as Figure 2 The host computer 10 stores a computer program, which, when executed by the host computer, implements the steps in the following CAN bus communication matrix automatic testing method.

[0057] The ECU under test can achieve the following functions:

[0058] 1) The signal variable names of the ECU's CAN communication send and receive need to have a one-to-one mapping relationship with the DBC signals. For example, the variable name defined by the ECU software is the DBC signal name with "COM_" added to it. In this way, the corresponding variable name of the ECU software can be inferred from the DBC signal name, such as Figure 3 shown.

[0059] 2) ECU implements a test enable switch variable such as Task_Switch_Gb. This variable enables the upper software to update the send variable under normal working conditions. When entering the test mode, the upper software is prohibited from updating the variable. The upper computer software sets the value of the send variable through XCP, such as Figure 4 shown.

[0060] 3) ECU sets the XCP send variable memory area to Writable, so that the host computer software can modify the values ​​of the send variable and the switch variable Task_Switch_Gb through the XCP SET_MTA and DOWNLOAD commands, and it is not necessary for this variable to be a calibrated value.

[0061] The host computer software can realize the following functions:

[0062] 1) Parse the DBC file, extract the ECU list of the DBC file and the message name, CAN ID and data length sent and received by the ECU, extract the signal list of the CAN message and the signal name, start bit, bit length, factor and other information corresponding to the signal, such as Figure 5 shown.

[0063] 2) CAN message sending and receiving and message parsing through DBC;

[0064] 3) Extract the send and receive variable addresses and data types of CAN signals by parsing the calibration description file (A2L file);

[0065] 4) Implement the XCP Master protocol, at least the CONNECT, DOWNLOAD, SET_MTA and SHORT_UPLOAD commands.

[0066] See also Figure 6 , the figure shows a CAN bus communication matrix automatic testing method, including the following steps:

[0067] Step S10, load the DBC file, and parse the DBC file to obtain the ECU node list, CAN message data and DCB message data of the CAN bus communication matrix. In an embodiment, the ECU node list includes all node names of the CAN network; the CAN message data includes the ID, transmission cycle, data domain length (DLC) of all CAN messages and the corresponding sending node and receiving node; the DCB message data includes the signal name, start bit, length, unit, factor and offset of all DCB messages. By loading DBC, the host computer obtains all ECU nodes of the CAN network for subsequent user selection.

[0068] Step S20, select the node of the ECU under test to determine the message and signal information sent and received by the ECU under test, and load the calibration description file (A2L file) of the ECU under test. The A2L file contains the name and variable address information of the CAN send and receive signals. At the same time, the host computer obtains the CAN ID and baud rate information of the XCP connection.

[0069] Step S30, match the sent and received signal list through the node name of the ECU under test, and find the corresponding variable name in the corresponding calibration description file (A2L file) according to the DBC signal name and the ECU's send / receive variable name rules, and extract variable information such as variable address and data type. By obtaining the address and data type of the variable, the host computer can read and write the variable value through XCP, and there is no need to load the HEX file corresponding to the ECU.

[0070] Step S40: connecting to the ECU under test through the XCP protocol, and setting the ECU under test to a calibration mode.

[0071] Step S50, setting the test state through the XCP protocol to prohibit the upper layer software from modifying the sent signal variables. In step S50, the test enable variable Task_Switch_Gb is set to 1 through the SET_MTA and DOWNLOAD commands in the XCP protocol to prohibit the upper layer software from modifying the sent signal variables.

[0072] Step S60, receiving the CAN bus message data sent by the ECU under test, and testing the message period and data domain length (DLC) of the CAN bus message data sent by the ECU under test, by comparing the tested message period and length with the message period and data domain length described in the DBC, if they are inconsistent, it is judged as NG.

[0073] Step S70, generating a simulation message according to the DBC file, and sending the generated simulation message to the ECU under test for testing. During the test, the maximum value, minimum value and intermediate value of the transmitted signal are tested in turn.

[0074] Step S80, setting the transmission variables of the ECU under test through the SET_MTA and DOWNLOAD commands of the XCP protocol, and receiving the CAN message data sent by the ECU under test for testing. During the test, the maximum value, minimum value and intermediate value of the received signal are tested in turn.

[0075] See also Figure 7 In step S70, the maximum value, minimum value and intermediate value of the transmitted signal are tested in turn during the test process, including the following steps:

[0076] Step S61, the maximum value, minimum value or intermediate value of all signals received by the ECU under test is sent through CAN, and the period, data domain length (DLC), checksum and other information of the sent CAN message are consistent with the description in the DBC file. Among them, the maximum value and the minimum value are directly obtained from the DBC file, and the intermediate value is calculated by adding the maximum value and the minimum value and dividing by 2.

[0077] Step S62, reading variable values ​​corresponding to all CAN signals received by the ECU under test through the SHORT_UPLOAD command of the XCP protocol.

[0078] Step S63, checking whether the sent CAN signal is consistent with the read corresponding XCP observation value; if consistent, it is judged as OK, otherwise the test result is marked as NG.

[0079] See also Figure 8 In step S80, the maximum value, minimum value and intermediate value of the received signal are tested in turn during the test process, including the following steps:

[0080] Step S71, set the variables corresponding to the CAN signals sent by all ECUs to the maximum value, minimum value or middle value through the SET_MTA and DOWNLOAD commands of the XCP protocol. The maximum value and the minimum value are directly obtained through the DBC file, and the middle value is calculated by adding the maximum value and the minimum value and dividing by 2.

[0081] Step S72, reading all messages sent by the ECU under test through CAN, and parsing the values ​​of all received signals through DBC;

[0082] Step S73, check whether the received CAN signal value is equal to the sending variable value set to the ECU; if they are equal, it is judged as OK, otherwise the test result is marked as NG.

[0083] The present invention can automatically generate test cases, support full coverage testing of CAN signals, rely on standard USBCAN devices, reduce the cost of test equipment, and avoid complex hardware dependence. The present invention has high test efficiency, can cope with frequent matrix changes, and greatly reduces test time and labor costs.

[0084] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A CAN bus communication matrix automatic testing method, characterized in that: include: Loading a DBC file and parsing the DBC file to obtain an ECU node list, CAN message data, and DCB message data of a CAN bus communication matrix; Select the node of the ECU under test and load the calibration description file of the ECU under test; Match the sent and received signal lists by the node name of the ECU under test, and find the corresponding variable name in the corresponding calibration description file according to the DBC signal name and the ECU's send / receive variable name rules, and extract the variable information; Connect to the ECU under test through the XCP protocol and set the ECU under test to calibration mode; Set the test status through the XCP protocol to prohibit the upper-layer software from modifying the sent signal variables; Receive the CAN bus message data sent by the ECU under test, and test the message period and data field length of the CAN bus message data sent by the ECU under test; Generate a simulation message according to the DBC file, and send the generated simulation message to the ECU under test for testing. During the test, the maximum value, minimum value and intermediate value of the sent signal are tested in turn; and The sending variables of the ECU under test are set through the XCP protocol, and the CAN message data sent by the ECU under test is received for testing. During the test, the maximum value, minimum value and intermediate value of the received signal are tested in turn.

2. The CAN bus communication matrix automated testing method according to claim 1, characterized in that: The ECU node list includes all node names of the CAN network; the CAN message data includes the IDs, sending cycles, data field lengths and corresponding sending nodes and receiving nodes of all CAN messages; the DCB message data includes the signal names, start bits, lengths, units, factors and offsets of all DCB messages.

3. The CAN bus communication matrix automated testing method according to claim 1, characterized in that: The calibration description file of the ECU under test includes the names and variable address information of the sending and receiving signals of the CAN.

4. The CAN bus communication matrix automated testing method according to claim 1, characterized in that: The step of setting the test status through the XCP protocol includes: The test enable variable Task_Switch_Gb is set to 1 through the SET_MTA and DOWNLOAD commands in the XCP protocol to prohibit the upper-layer software from modifying the sent signal variables.

5. The CAN bus communication matrix automated testing method according to claim 1, characterized in that: The test process sequentially tests the maximum value, minimum value and intermediate value of the transmitted signal, including: The maximum, minimum or median value of all signals received by the ECU under test is sent via CAN. The period, data domain length (DLC), checksum and other information of the sent CAN message are consistent with the description in the DBC file; Read the variable values ​​corresponding to all CAN signals received by the ECU under test through the SHORT_UPLOAD command of the XCP protocol; and Check whether the sent CAN signal is consistent with the corresponding XCP observation read; if consistent, it is judged as OK, otherwise the test result is marked as NG.

6. The CAN bus communication matrix automated testing method according to claim 1, characterized in that: The test process sequentially tests the maximum value, minimum value and intermediate value of the received signal, including: Set the variables corresponding to the CAN signals sent by all ECUs to the maximum, minimum or middle values ​​through the SET_MTA and DOWNLOAD commands of the XCP protocol; Read all messages sent by the ECU under test through CAN, and parse the values ​​of all received signals through DBC; and Check whether the received CAN signal value is equal to the send variable value set to the ECU; if they are equal, it is judged as OK, otherwise the test result is marked as NG.

7. A test system, comprising a host computer and an ECU under test, wherein the host computer is connected to the ECU under test via a USB CAN interface, wherein a computer program is stored in the host computer, and when the computer program is executed by the host computer, the steps in the CAN bus communication matrix automatic test method as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Controller CAN signal test method and system

    CN106850372A

  • Automatic test system for CAN bus

    CN111064628A

  • An automatic testing device and method for automotive CAN communication module interface software

    CN113904967B

  • Bus message checking method, device and system for hardware in-loop testing

    CN109634258A

  • CAN communication function test method and test system

    CN115348200A