CN113189970B - Hardware-in-loop automatic test method and system of CAN bus controller and storage medium - Google Patents

Hardware-in-loop automatic test method and system of CAN bus controller and storage medium Download PDF

Info

Publication number
CN113189970B
CN113189970B CN202110507919.XA CN202110507919A CN113189970B CN 113189970 B CN113189970 B CN 113189970B CN 202110507919 A CN202110507919 A CN 202110507919A CN 113189970 B CN113189970 B CN 113189970B
Authority
CN
China
Prior art keywords
fault code
fault
sub
controller
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110507919.XA
Other languages
Chinese (zh)
Other versions
CN113189970A (en
Inventor
孙卫军
张萌
宋文浩
杨光
刘道坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dongfeng Cummins Engine Co Ltd
Original Assignee
Dongfeng Cummins Engine Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dongfeng Cummins Engine Co Ltd filed Critical Dongfeng Cummins Engine Co Ltd
Priority to CN202110507919.XA priority Critical patent/CN113189970B/en
Publication of CN113189970A publication Critical patent/CN113189970A/en
Application granted granted Critical
Publication of CN113189970B publication Critical patent/CN113189970B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B23/00Testing or monitoring of control systems or parts thereof
    • G05B23/02Electric testing or monitoring
    • G05B23/0205Electric testing or monitoring by means of a monitoring system capable of detecting and responding to faults
    • G05B23/0208Electric testing or monitoring by means of a monitoring system capable of detecting and responding to faults characterized by the configuration of the monitoring system
    • G05B23/0213Modular or universal configuration of the monitoring system, e.g. monitoring system having modules that may be combined to build monitoring program; monitoring system that can be applied to legacy systems; adaptable monitoring system; using different communication protocols
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/24Pc safety
    • G05B2219/24065Real time diagnostics
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)

Abstract

The invention relates to the technical field of electronic test, in particular to a hardware-in-loop automatic test method and system of a CAN bus controller and a storage medium. The automatic test module simulates and triggers the fault of a sub-controller in the test environment simulation module according to the content of a fault code database file, the sub-controller simulates and sends a fault code message of a custom protocol to the HCM, the HCM converts the message into the fault code message of the J1939-73 protocol and sends the fault code message to the CAN bus, the fault code analysis module analyzes the fault code message sent by the HCM into information combination of { SPN, FMI and FC }, the automatic test module compares the analysis result of the fault code analysis module with the fault code database, judges whether the fault code message of the HCM is correct or not, and generates a test report. The invention can greatly improve the testing efficiency, reduce the testing cost, reduce the dependence on testing resources and has universality.

Description

Hardware-in-loop automatic test method and system of CAN bus controller and storage medium
Technical Field
The invention relates to the technical field of electronic test, in particular to a hardware-in-loop automatic test method and system of a CAN bus controller and a storage medium.
Background
The electric special vehicle is provided with a plurality of CAN bus controllers, including a main controller HCM and a plurality of sub-controllers. The HCM is responsible for coordinating and controlling the various sub-controllers. The sub-controller controls the operation of the motor system on one hand, and sends the fault information of the sub-controller and the motor system controlled by the sub-controller to the HCM in a message form of a custom protocol on the other hand. The HCM summarizes the fault information of each sub-controller, converts the fault information into a fault code message which accords with the J1939-73 protocol and broadcasts the fault code message to the CAN bus.
In order to ensure that the HCM can correctly implement the fault diagnosis function, it needs to be tested. The traditional test method is that firstly, faults are manufactured manually, then a universal CAN tool is used for reading fault code messages sent by the HCM, and whether the read fault code messages conform to the J1939-73 protocol or not is checked manually. There are two methods of artificially creating faults. First, failures are artificially made on test benches or real vehicles, but some failures can cause damage to the test equipment. Second, the manual simulation test device sends out fault information through the CAN tool, but this method is inefficient.
In order to efficiently and safely test the fault diagnosis function of the HCM, it is necessary to provide an automatic test system capable of efficiently and safely testing the fault diagnosis function of the HCM.
Disclosure of Invention
The invention aims to provide a hardware-in-loop automatic test method, a system and a storage medium of a CAN bus controller aiming at the defects of the prior art, which CAN efficiently and safely automatically test the function of processing the fault code message of the custom protocol of the sub-controller by the HCM of the CAN bus controller, improve the test efficiency, reduce the test cost and shorten the HCM software development cycle. .
The invention relates to a hardware-in-loop automatic test method of a CAN bus controller, which comprises the following steps
S100: the sub-controller imports a fault code database, a fault code message ID and an initial position of a fault code data word of the sub-controller from an external configuration file, and a fault code analysis module Tester and an automatic test module imports the fault code database from the external configuration file;
s200: the automatic test module assigns values to n system variables of the jth sub-controller ECU _ j in the test environment simulation module according to the content of the fault code database;
s300: the sub-controller ECU _ j assigns values to each bit of a fault code data word of a fault code message of the sub-controller ECU _ j according to the numerical values of the n system variables, and then sends the fault code message to the CAN bus controller HCM;
s400: the CAN bus controller HCM converts each fault contained in the fault code message of the sub-controller ECU _ j into a fault code message conforming to a specified protocol and broadcasts the fault code message to a CAN network;
s500: the fault code analysis module Tester analyzes a fault code message sent by the CAN bus controller HCM into a system variable combination { testSPN, testFMI, testFC };
s600: the automatic test module compares the system variable combination { testSPN, testFMI, testFC } with the content of the fault code database, and judges whether the CAN bus controller HCM correctly converts and sends a fault code message of the sub-controller ECU _ j;
s700: repeating the step S200-S600 until all the sub-controllers are completely executed;
s800: the automatic test module generates a test report according to the judgment result of the fault code messages of all the sub-controllers;
wherein, each time the steps S200-S600 are executed, the initial value of 1,j is added to the value of j is 1.
Preferably, the failure code database includes an array dtc _ dictionary, the array dtc _ dictionary includes n element groups, each element group is composed of identification codes SPN, FMI, and FC, and the element group is { SPN, FMI, FC }.
Preferably, the S200 comprises
The automatic test module assigns a value to the ith system variable Fault of the sub-controller ECU _ j according to the value of the identification code FC in the ith element group of the array dtc _ dictionary;
when the value of the identification code FC in the ith element group of the array dtc _ dictionary is 0, assigning the ith system variable Fault of the sub-controller ECU _ j to be 0;
when the value of the identification code FC in the ith element group of the array dtc _ dictionary is 1, assigning the ith system variable Fault of the sub-controller ECU _ j to be 1.
Preferably, the S300 includes
And the sub-controller ECU _ j assigns the value of the ith system variable Fault to the kth bit of the Fault code data word of the Fault code message.
Preferably, the S500 includes
The fault code analysis module Tester analyzes the fault code message sent by the CAN bus controller HCM into a plurality of { SPN, FMI, FC } combinations;
the fault code analysis module Tester assigns a plurality of { SPN, FMI, FC } combinations to a plurality of system variable combinations { testSPN, testFMI, testFC };
the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 1 in the fault code data word of the fault code message of ECU _ j is assigned to the { SPN, FMI, FC } combination corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message of the array dtc _ dictionary, and the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message is assigned to {0,0,0}.
Preferably, the S600 includes
The automatic test module compares an element group { SPN, FMI, FC } with an identification code FC of 0 in n element groups of the array dtc _ dictionary with a system variable combination { testSPN, testFMI, testFC } with a numerical value of 0,0,0;
if the two are identical, the controller HCM judges that the fault code message of the current sub-controller is correctly converted and sent.
Preferably, the external configuration file comprises a fault code message address file and a fault code database file;
the fault code database is obtained from the fault code database file, and the fault code message ID and the initial position of the fault code data word of the sub-controller are obtained from the fault code message address file.
Preferably, the fault code database in the external configuration file is generated according to a fault code comparison table and a fault code message mapping table, the fault code comparison table is used for recording the comparison relation between each bit of a fault code data word and corresponding fault identification codes SPN, FMI and FC, the fault code message mapping table is used for recording the mapping relation between a CAN bus controller HCM fault code message HCM _ DTC and a sub-controller fault code message ECU _ j _ DTC, wherein the ECU _ j _ DTC is the fault code message of the jth sub-controller.
The invention relates to a hardware-in-loop automatic test system of a CAN bus controller, which comprises
The CAN bus controller HCM is used for converting each fault contained in the fault code message of the sub-controller ECU _ j into a fault code message conforming to a specified protocol and broadcasting the fault code message to the CAN network;
the test environment simulation module is used for simulating the functions of each sub-controller ECU _ j;
the sub-controller ECU _ j is used for importing a Fault code database, a Fault code message ID and an initial position of a Fault code data word of the sub-controller from an external configuration file, assigning a value to each bit of the Fault code data word of the Fault code message of the sub-controller ECU _ j according to the numerical values of n system variables Fault, and sending the Fault code message to the CAN bus controller HCM;
the automatic test module is used for importing a Fault code database from an external configuration file, assigning n system variables Fault of the jth sub-controller ECU _ j in the test environment simulation module according to the content of the Fault code database, comparing the system variable combination { testSPN, testFMI and testFC } with the content of the Fault code database, judging whether the CAN bus controller HCM correctly converts and sends Fault code messages of the sub-controllers ECU _ j, and generating a test report according to the judgment result of the Fault code messages of all the sub-controllers;
and the fault code analysis module Tester is used for importing a fault code database from an external configuration file and analyzing a fault code message sent by the CAN bus controller HCM into a system variable combination { testSPN, testFMI, testFC }.
The invention also provides a computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, is adapted to carry out the above-mentioned method steps.
The invention has the beneficial effects that: the invention uses the test environment simulation module to replace the real vehicle test environment, thereby reducing the dependence on real vehicle test resources and reducing the test cost. The automatic test module of the invention replaces manual test, thus improving the test efficiency. The method and the system can be applied to different application projects without changing a computer program, a database DBC and a system variable set and only by pre-configuring two plain text files containing the fault code database, the fault code message ID and the initial position of the fault code data word of the sub-controller, and the universality of the method and the system is improved.
Drawings
FIG. 1 is a schematic flow chart of a hardware-in-loop automatic testing method of a CAN bus controller according to the present invention;
FIG. 2 is a schematic diagram of a hardware-in-the-loop automatic test system of a CAN bus controller according to the present invention;
FIG. 3 is an expanded view of a test environment simulation module according to the present invention;
fig. 4 is a diagram of a CAN network topology structure according to the present invention.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
The invention relates to a hardware-in-loop automatic test method of a CAN bus controller, wherein an automatic test module respectively triggers each sub-controller to send fault code messages of a custom protocol to an HCM (host computer), each sub-controller ECU (electronic control Unit) sends the fault code messages of the custom protocol to the CAN bus controller HCM through a CANoe adapter, and the CAN bus controller HCM converts the fault code messages sent by each sub-controller into fault code messages of a J1939-73 protocol and broadcasts the fault code messages to a CAN network through a CANoe adapter. And the fault code analysis module Tester analyzes each fault code contained in the fault code message sent by the HCM into different combinations of { SPN, FMI and FC }, each combination represents a unique fault code, and then assigns the combinations of { SPN, FMI and FC } to system variable combinations of { testSPN, testFMI and testFC }. And the automatic test module compares the system variable combination { testSPN, testFMI, testFC } with the corresponding { SPN, FMI, FC } combination of the database to judge whether the test is passed or not. And after the test is finished, the automatic test module generates a test report.
For different application projects, the number of the fault modes and the fault codes of the sub-controllers is different, and the IDs of the fault code messages are also different. The simulation program of the sub-controller can obtain the fault codes of different application projects and the IDs of the fault code messages by calling the fault code database file and the fault code message address file, so that the universality of the invention is improved.
As shown in fig. 1, a hardware-in-loop automatic testing method of a CAN bus controller has the following procedures:
s100: the sub-controller imports a fault code database, a fault code message ID and the initial position of a fault code data word of the sub-controller from an external configuration file, and the fault code analysis module Tester and the automatic test module imports the fault code database from the external configuration file.
The external configuration files are two pure text files, one is a fault code message address file specific info. And the fault code database is obtained from the fault code database file, and the ID of the fault code message and the initial position of the fault code data word of the sub-controller are obtained from the fault code message address file. Txt is used for configuring the ID of the custom protocol fault code message of the sub-controller and the starting position of a fault code data word (word) in a custom protocol fault code message data field (data field).
And the fault code database in the external configuration file is generated according to the fault code comparison table and the fault code message mapping table. The fault code mapping table is used for recording the mapping relation between each bit of a fault code data word and corresponding fault identification codes SPN, FMI and FC, and the fault code message mapping table is used for recording the mapping relation between a CAN bus controller HCM fault code message HCM _ DTC and a sub-controller fault code message ECU _ j _ DTC, wherein the ECU _ j _ DTC is the fault code message of the jth sub-controller.
S200: the automatic test module assigns values to n system variables Fault of the jth sub-controller ECU _ j in the test environment simulation module according to the content of the Fault code database;
the failure code database comprises an array dtc _ dictionary, wherein the array dtc _ dictionary comprises n element groups, each element group consists of identification codes SPN, FMI and FC, and the element groups are { SPN, FMI and FC }.
The automatic test module assigns a value to the ith system variable Fault of the sub-controller ECU _ j according to the value of the identification code FC in the ith element group of the array dtc _ dictionary;
when the value of the identification code FC in the ith element group of the array dtc _ dictionary is 0, assigning the ith system variable Fault of the sub-controller ECU _ j to be 0;
when the value of the identification code FC in the ith element group of the array dtc _ dictionary is 1, the ith system variable Fault of the sub-controller ECU _ j is assigned to 1.
S300: the sub-controller ECU _ j assigns values to each bit of a fault code data word of a fault code message of the sub-controller ECU _ j according to the numerical values of the n system variables, and then sends the fault code message to the CAN bus controller HCM;
and the sub-controller ECU _ j assigns the value of the ith system variable Fault to the kth bit of the Fault code data word of the Fault code message.
S400: the CAN bus controller HCM converts each fault contained in the fault code message of the sub-controller ECU _ j into a fault code message conforming to a specified protocol and broadcasts the fault code message to a CAN network;
s500: the fault code analysis module Tester analyzes a fault code message sent by the CAN bus controller HCM into a system variable combination { testSPN, testFMI, testFC };
the fault code analysis module Tester analyzes a fault code message sent by the CAN bus controller HCM into a plurality of { SPN, FMI, FC } combinations;
the fault code analysis module Tester assigns a plurality of { SPN, FMI, FC } combinations to a plurality of system variable combinations { testSPN, testFMI, testFC };
the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 1 in the fault code data word of the fault code message of ECU _ j is assigned to the { SPN, FMI, FC } combination corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message of the array dtc _ dictionary, and the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message is assigned to {0,0,0}.
S600: the automatic test module compares the system variable combination { testSPN, testFMI, testFC } with the content of the fault code database, and judges whether the CAN bus controller HCM correctly converts and sends a fault code message of the sub-controller ECU _ j;
the automatic test module compares an element group { SPN, FMI, FC } with an identification code FC not being 0 in n element groups of the array dtc _ dictionary with a system variable combination { testSPN, testFMI, testFC } with a numerical value not being {0,0,0 };
if the two are identical, the controller HCM judges that the fault code message of the current sub-controller is correctly converted and sent.
S700: repeating the step S200-S600 until all the sub-controllers are completely executed;
s800: the automatic test module generates a test report according to the judgment result of the fault code messages of all the sub-controllers;
wherein, each time the steps S200-S600 are executed, the initial value of 1,j is added to the value of j to be 1.
Example one
The starting position of the fault code data word is explained by taking the sub-controller ECU _1 as an example. As shown in table 1 (fault code comparison table), the fault code data word means that the data field of the custom protocol fault code message of the sub-controller has 8 bytes, but only 2 adjacent bytes are allocated to the fault code, the 2 adjacent bytes constitute the fault code data word, and the remaining 6 bytes can be used for other purposes or reserved. The start position of the codeword of the fault code in table 1 is determined by the communication protocol of the sub-controller.
The starting position of the fault code data word of the custom protocol fault code message ECU _1 _DTCof the sub-controller ECU _1 is 1, which indicates that the 1 st fault code of the ECU _1 corresponds to the 0 th bit (bit 0) of the byte1 (byte 1) of the data field of the message ECU _1_DTC, the 2 nd fault code corresponds to the 1 st bit of the byte1, and so on until the 16 th fault code corresponds to the last bit (bit 7) of the byte2 (byte 2) of the custom protocol fault code message data field. The sequence number of the initial byte of the message data field is 0, and the sequence number of the initial bit of the byte is 0.
The fault code database file is used for configuring fault code information of the main controller HCM and the sub-controllers, lines 1, 2 and 3 of the file respectively correspond to the SPN, FMI and FC of a first fault code of the ECU _1, lines 4, 5 and 6 respectively correspond to the SPN, FMI and FC of a second fault code of the ECU _1, and the like. Where SPN and FMI are fault location and fault pattern for each fault code specified by the J1939-73 protocol and FC is fault code for each fault specified by the HCM software developer. The following two tables are used to illustrate how the trouble code database file is configured.
In table 1, the custom protocol fault code message name of the ECU _1 is ECU _1_dtc, the data field length of which is 8 bytes, but only two bytes, byte1 and byte2, are defined as fault code data words, and the rest bytes are used for other purposes. Each bit of the fault code data word represents a fault code, and each fault is assigned a unique combination of { SPN, FMI, FC } information. When the value of a certain bit is 1, indicating that the fault code corresponding to the bit is activated; when the value of the bit is 0, it indicates that the fault code corresponding to the bit is not activated. If the number of fault codes is less than 16, the SPN, FMI, FC corresponding to the unassigned bits is set to 0.
TABLE 1 comparison table of each bit of fault code data word and corresponding fault SPN, FMI, FC
Figure BDA0003059159910000101
In table 2 (fault code message mapping table), the custom protocol fault code message name of the HCM is HCM _ DTC, and the custom protocol fault code message names of the sub-controllers are respectively ECU _1_dtc to ECU _4_dtc. The fault code data word of the message ECU _1 \ DTC includes byte1 and byte2, which are mapped to byte 0 and byte1 of the HCM _ DTC, respectively. The mapping method of the custom protocol fault code messages of the ECU _2 to the ECU _4 and the HCM _ DTC is the same as that of the ECU _ 1. With the mapping of Table 2, each bit of the HCM _ DTC also corresponds to a unique set of { SPN, FMI, FC } combinations.
Table 2 main controller fault code message and sub-controller fault code message mapping table
HCM_DTC byte 7 byte 6 byte 5 byte 4 byte 3 byte 2 byte 1 byte 0
ECU_1_DTC byte 2 byte 1
ECU_2_DTC byte 1 byte 0
ECU_3_DTC byte 3 byte 2
ECU_4_DTC byte 1 byte 0
And writing the SPN, FMI and FC corresponding to each bit of the HCM _ DTC into a fault code database file according to the byte arrangement sequence of the HCM _ DTC message data field, wherein one row of the fault code database file is a number, and a fault code database is formed.
If the number of fault codes of one sub-controller is more than 16, or the number of the sub-controllers is more than 4, one or more controller address files and fault code database files can be reconfigured.
Therefore, for different application projects, only two external configuration files need to be configured, and the automatic test system can be directly used.
The CAN network topology structure comprises a CAN line, a CAN bus master controller HCM hung on the CAN line, CAN bus sub-controllers ECU _ 1-ECU _4, a fault code analysis Module Tester and an automatic Test Module Test _ Module.
The automatic test module comprises a main test program and a test case of the HCM for processing results of the fault code messages of the custom protocol of each sub-controller. The main test program is used for organizing and triggering each test case.
A test case is described by taking a fault code message of the ECU _1 as an example.
The automatic test module leads the content of the fault code database file DTCDACT.txt into an array dtc _ dictionary [ row1] [ col ], wherein row1 is equal to 64, and the fact that 64 fault codes can be tested in total is shown. col is equal to 3, and each fault code comprises three identification codes of SPN, FMI and FC. The three identification codes of SPN, FMI and FC form an element group of the array dtc _ dictionary, and the automatic test module determines whether each of the 16 system variables of Fault 0-Fault 15 is 0 according to whether the value of the 2 nd element (namely FC) of the 0 th to 15 th element groups of the array dtc _ dictionary is 0. For example, FC for the 0 th element group is not 0, then FAULT0 is set to 1; if FC of the 0 th element group is 0, then FAult0 is set to 0. The system variables assigned by the automatic test module can be directly used in the test environment simulation module.
The test environment simulation module assigns each bit of the Fault code data word of the Fault code message ECU _1_DTC of the ECU _1 according to the states of the system variables Fault 0-Fault 15, for example, the value of Fault0 is assigned to the bit 1.0 of the ECU _1_DTC, and so on until the value of Fault15 is assigned to the bit 2.7 of the ECU _1_DTC, and then the message ECU _1_DTC is sent to the CAN bus.
After receiving the message ECU _1 \/DTC, the HCM converts the fault code with the value of 1 in the byte1 and the byte2 of the ECU _1 \/u DTC into a message with a J1939-73 protocol according to the tables 1 and 2 and sends the message to the CAN bus according to the communication protocol of the HCM and the ECU _ 1.
The fault code analysis module Tester receives a fault code message of ECU _1 which is transmitted by the HCM and converted into a J1939-73 protocol, analyzes the fault code message into { SPN, FMI, FC } combinations, assigns the combinations to a system variable combination { testSPN, testFMI, testFC }, each system variable combination corresponds to a bit with the value of 1 in a fault code data word of the ECU _1_DTC message, and assigns the bits with the value of 0 in the fault code data word to { testSPN, testFMI, testFC }, which are all assigned to {0,0,0}. The system variable combinations may be used directly in an automatic test module.
The fault code analysis module Tester analyzes each fault code of the fault code message which is from the HCM and accords with the J1939-73 protocol into a combination of { SPN, FMI and FC } according to the J1939-73 protocol, and assigns the combination to a system variable combination of { testSPN, testFMI and testFC }.
The description will be made taking the ECU _1 as an example. The fault code analysis module Tester leads the content of the fault code database file DTCIDxt into an array dtc _ dictionary [ row1] [ col ], wherein row1 is equal to 64, and represents that 64 fault codes can be tested in total. col is equal to 3, indicating that each fault code contains three identification codes SPN, FMI, FC, which constitute an element group of array dtc _ dictionary.
The Tester analyzes the fault code message which is from the HCM and accords with the J1939-73 protocol into a plurality of { SPN, FMI } combinations, searches the FC corresponding to each { SPN, FMI } combination from the array dtc _ dictionary [ row1] [ col ], and establishes the { SPN, FMI, FC } combinations.
Assigning contents of the first set of { SPN, FMI, FC } combinations to a first set of system variable combinations { testSPN [0], testFMI [0], testFC [0] };
and so on until the content of the twelfth set of SPN, FMI, FC combinations is assigned to the value
{testSPN[11],testFMI[11],testFC[11]},
{ testSPN [12], testFMI [12], testFC [12] } to
{ testSPN [15], testFMI [15], testFC [15] } are all assigned {0,0,0}.
The HCM coding fault code message and the Tester parsing fault code message both execute the J1939-73 protocol, and the principle and rule thereof are necessary knowledge of professionals in the field and will not be explained herein.
The automatic test module compares the combination { SPN, FMI, FC } of the element group 0 of the array dtc _ dictionary, wherein FC is not 0, with the combination { testSPN, testFMI, testFC } of the system variable with the value not {0,0,0} in the element group 15, and compares the rest of the two parts, if the two parts are identical, the test is passed, otherwise, the test is failed. Specifically, the method comprises the following steps:
{ dtc _ dictionary [0] [0], dtc _ dictionary [0] [1], dtc _ dictionary [0] [2] }and
{ testSPN [0], testFMI [0], testFC [0] } comparison;
{ dtc _ dictionary [1] [0], dtc _ dictionary [1] [1], dtc _ dictionary [1] [2] }and
{ testSPN [1], testFMI [1], testFC [1] } comparison;
and so on until
{ dtc _ dictionary [11] [0], dtc _ dictionary [11] [1], dtc _ dictionary [11] [2] } and
{ testSPN [11], testFMI [11], testFC [11] };
{ dtc _ dictionary [12] [0], dtc _ dictionary [12] [1], dtc _ dictionary [12] [2] } to
{dtc_dictionary[15][0],dtc_dictionary[15][1],dtc_dictionary[15][2]}
And then respectively matched with { testSPN [12], testFMI [12], testFC [12] }
To { testSPN [15], testFMI [15], testFC [15] }.
The fault code test of the ECUs _2 to ECU _4 performs the same operation as the fault code test of the ECU _ 1. Different, each bit of the Fault code data word of the Fault code message of the ECU _2 corresponds to the 16 th to 31 th element groups of the array dtc _ dictionary and the system variables Fault15 to Fault31. Each bit of the Fault code message Fault code data word of the ECU _3 corresponds to the 32 th to 47 th element groups of the array dtc _ dictionary and the system variables Fault32 to Fault347 respectively. Each bit of the Fault code data word of the Fault code message of the ECU _4 corresponds to the 48 th to 63 th element groups of the array dtc _ dictionary and the system variables Fault48 to Fault63. And after the fault code messages of all 4 ECUs are tested, the automatic test module automatically generates a test report.
Fig. 2 shows a schematic structural diagram of a hardware-in-the-loop automatic test system of a CAN bus controller provided in a preferred embodiment of the present application (fig. 2 shows a first embodiment of the present application), and for convenience of description, only the parts related to this embodiment are shown, and the detailed description is as follows:
the system comprises a computer PC, a CANoe adapter and a CAN bus controller HCM. The computer PC comprises an external configuration file, a testing environment simulation module developed based on CANoe and used for testing the fault diagnosis function of the CAN bus controller HCM, a fault code analysis module, an automatic testing module and a CAN network topology structure. The CAN network topology structure comprises a CAN line, a CAN bus master controller HCM hung on the CAN line, a sub-controller ECU, a fault code analysis Module Tester and an automatic Test Module Test _ Module. The test environment simulation module comprises a simulation program, a human-computer interaction panel, a system variable set and a database DBC, wherein the human-computer interaction panel is related to the simulation program. The CANoe adapter is connected with the computer PC through a USB line, and the CANoe adapter is connected with the CAN bus controller HCM through a CAN line.
As shown in FIG. 3, the test environment simulation module comprises a simulation program and a human-computer interaction panel, a system variable set and a database DBC which are associated with the simulation program.
The man-machine interaction panel is used for debugging the simulation program and displaying the test process in the automatic test in real time. It includes 64 check boxes and a text output box control. The 64 check controls are respectively associated with system variables Fault0, fault1, fault2, … … and Fault63. And the text output box is used for displaying all fault code combinations { testSPN, testFMI and testFC } analyzed by the Tester.
The database DBC describes the CAN network structure of the test environment and the attributes of all CAN bus controllers, including the ECU source address, the name and ID of the message, the length of the message, the source address and destination address of the message, the sending frequency of the message, the name of the signal contained in the message, the position of the signal in the message, etc.
The system variable set is the set of system variables, including Fault 0-Fault 63, { testSPN [0], testFMI [0], testFC [0] } -to { testSPN [15], testFMI [15], testFC [15] }. System variables are global variables to a project (project) of CANoe and can be used in all programs and human-machine interaction panels of the project.
The test environment simulation program simulates the functions of the ECU of each sub-controller in the CAN network topology, and is described by taking the ECU _1 as an example.
The test environment simulation module leads the content of the fault code database file DTCDACT.txt into an array dtc _ dictionary [ row1] [ col ], wherein row1 is equal to 64, and the test environment simulation module indicates that 64 fault codes can be tested in total. col is equal to 3, indicating that each fault code contains three identification codes SPN, FMI, FC, which constitute an element group of the array dtc _ dictionary.
The automatic test module assigns values to system variables Fault 0-Fault 15, the test environment simulation module assigns the values of Fault 0-Fault 15 to each bit of byte1 and byte2 of a Fault code message ECU _1 \\/DTC data field of the ECU _1 respectively, and then sends the message ECU _1 \/DTC to the HCM according to the frequency set by the database DBC.
As shown in fig. 4, the CAN network topology includes a CAN line, a CAN bus controller hung on the CAN line, a fault code analysis Module Tester, and an automatic Test Module Test _ Module, where the bus controller includes a tested CAN bus master controller HCM, and sub-controllers ECU _1, ECU _2, ECU _3, and ECU _4, where the sub-controllers and the CAN bus form a simulation Test environment of the HCM fault diagnosis function of the tested object, and they are used to send respective custom protocol fault code messages to the HCM. The fault code analysis module Tester analyzes a fault code message which is from the HCM and accords with the J1939-73 protocol into a combination of { SPN, FMI and FC }, assigns the combination to a system variable combination of { testSPN, testFMI and testFC }, wherein the system variable combination of { testSPN, testFMI and testFC } is a data source for judging whether a test result passes or not by the automatic test module. The automatic test module assigns the Fault code messages of the ECU _1, the ECU _2, the ECU _3 and the ECU _4 in sequence through system variables Fault0 to Fault63, compares a system variable combination { testSPN, testFMI, testFC } from the Fault code analysis module Tester with Fault code information from a Fault code database file DTCTDxt to judge whether the test passes or not, and automatically generates a test report.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not constitute any limitation to the implementation process of the embodiments of the present application.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (5)

1. A hardware-in-loop automatic test method of a CAN bus controller is characterized in that: comprises that
S100: the sub-controller imports a fault code database, a fault code message ID and an initial position of a fault code data word of the sub-controller from an external configuration file, and a fault code analysis module Tester and an automatic test module imports the fault code database from the external configuration file;
s200: the automatic test module assigns values to n system variables of the jth sub-controller ECU _ j in the test environment simulation module according to the content of the fault code database;
s300: the sub-controller ECU _ j assigns values to each bit of a fault code data word of a fault code message of the sub-controller ECU _ j according to the numerical values of the n system variables, and then sends the fault code message to the CAN bus controller HCM;
s400: the CAN bus controller HCM converts each fault contained in the fault code message of the sub-controller ECU _ j into a fault code message conforming to a specified protocol and broadcasts the fault code message to a CAN network;
s500: the fault code analysis module Tester analyzes a fault code message sent by the CAN bus controller HCM into a system variable combination { testSPN, testFMI, testFC };
s600: the automatic test module compares the system variable combination { testSPN, testFMI, testFC } with the content of the fault code database, and judges whether the CAN bus controller HCM correctly converts and sends a fault code message of the sub-controller ECU _ j;
s700: repeating the step S200-S600 until all the sub-controllers are completely executed;
s800: the automatic test module generates a test report according to the judgment result of the fault code messages of all the sub-controllers;
wherein, every time the steps S200-S600 are executed, the initial value of 1,j is added to the value of j to be 1;
the method also comprises the steps that two plain text files containing the fault code database, the fault code message ID and the starting position of the fault code data word of the sub-controller are configured in advance and are applied to different application projects;
the fault code database comprises an array dtc _ dictionary, wherein the array dtc _ dictionary comprises n element groups, each element group consists of identification codes SPN, FMI and FC, and the element groups are { SPN, FMI and FC };
said S200 comprises
The automatic test module assigns a value to the ith system variable Fault of the sub-controller ECU _ j according to the value of the identification code FC in the ith element group of the array dtc _ dictionary;
when the value of the identification code FC in the ith element group of the array dtc _ dictionary is 0, assigning the ith system variable Fault of the sub-controller ECU _ j to be 0;
when the numerical value of the identification code FC in the ith element group of the array dtc _ dictionary is 1, assigning the ith system variable Fault of the sub-controller ECU _ j to be 1;
the S600 comprises
The automatic test module compares an element group { SPN, FMI, FC } with an identification code FC not being 0 in n element groups of the array dtc _ dictionary with a system variable combination { testSPN, testFMI, testFC } with a numerical value not being {0,0,0 };
if the two sub-controllers are completely the same, judging that the CAN bus controller HCM correctly converts and sends a fault code message of the current sub-controller;
the external configuration file comprises a fault code message address file and a fault code database file;
the fault code database is obtained from the fault code database file, and the fault code message ID and the initial position of the fault code data word of the sub-controller are obtained from the fault code message address file;
the fault code database in the external configuration file is generated according to a fault code comparison table and a fault code message mapping table, the fault code comparison table is used for recording the comparison relation between each bit of a fault code data word and corresponding fault identification codes SPN, FMI and FC, the fault code message mapping table is used for recording the mapping relation between a CAN bus controller HCM fault code message HCM _ DTC and a sub-controller fault code message ECU _ j _ DTC, and the ECU _ j _ DTC is the fault code message of the jth sub-controller.
2. The CAN bus controller hardware-in-loop automatic test method of claim 1, wherein: said S300 includes
And the sub-controller ECU _ j assigns the value of the ith system variable Fault to the kth bit of the Fault code data word of the Fault code message.
3. The CAN bus controller hardware-in-loop automatic test method of claim 1, wherein: the S500 comprises
The fault code analysis module Tester analyzes the fault code message sent by the CAN bus controller HCM into a plurality of { SPN, FMI, FC } combinations;
the fault code analysis module Tester assigns a plurality of { SPN, FMI, FC } combinations to a plurality of system variable combinations { testSPN, testFMI, testFC };
the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 1 in the fault code data word of the fault code message of ECU _ j is assigned to the { SPN, FMI, FC } combination corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message of the array dtc _ dictionary, and the system variable combination { testSPN, testFMI, testFC } corresponding to the bit with the numerical value of 0 in the fault code data word of the fault code message is assigned to {0,0,0}.
4. A hardware-in-the-loop automatic test system for a CAN bus controller for implementing the method of any one of claims 1 to 3, characterized by: comprises that
The CAN bus controller HCM is used for converting each fault contained in the fault code message of the sub-controller ECU _ j into a fault code message conforming to a specified protocol and broadcasting the fault code message to a CAN network;
the test environment simulation module is used for simulating the functions of each sub-controller ECU _ j;
the sub-controller ECU _ j is used for importing a Fault code database, a Fault code message ID and an initial position of a Fault code data word of the sub-controller from an external configuration file, assigning a value to each bit of the Fault code data word of the Fault code message of the sub-controller ECU _ j according to the numerical values of n system variables Fault, and then sending the Fault code message to the CAN bus controller HCM;
the automatic test module is used for importing a Fault code database from an external configuration file, assigning n system variables Fault of the jth sub-controller ECU _ j in the test environment simulation module according to the content of the Fault code database, comparing the system variable combination { testSPN, testFMI and testFC } with the content of the Fault code database, judging whether the CAN bus controller HCM correctly converts and sends Fault code messages of the sub-controllers ECU _ j, and generating a test report according to the judgment results of the Fault code messages of all the sub-controllers;
and the fault code analysis module Tester is used for importing a fault code database from an external configuration file and analyzing a fault code message sent by the CAN bus controller HCM into a system variable combination { testSPN, testFMI, testFC }.
5. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 3.
CN202110507919.XA 2021-05-10 2021-05-10 Hardware-in-loop automatic test method and system of CAN bus controller and storage medium Active CN113189970B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110507919.XA CN113189970B (en) 2021-05-10 2021-05-10 Hardware-in-loop automatic test method and system of CAN bus controller and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110507919.XA CN113189970B (en) 2021-05-10 2021-05-10 Hardware-in-loop automatic test method and system of CAN bus controller and storage medium

Publications (2)

Publication Number Publication Date
CN113189970A CN113189970A (en) 2021-07-30
CN113189970B true CN113189970B (en) 2023-04-07

Family

ID=76980954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110507919.XA Active CN113189970B (en) 2021-05-10 2021-05-10 Hardware-in-loop automatic test method and system of CAN bus controller and storage medium

Country Status (1)

Country Link
CN (1) CN113189970B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113655779A (en) * 2021-08-16 2021-11-16 上汽通用五菱汽车股份有限公司 Test method for discharging related network fault codes
CN113867318B (en) * 2021-09-30 2023-07-18 东风汽车集团股份有限公司 Automatic integration method for hardware-in-loop test engineering of CAN communication controller
CN114185329A (en) * 2021-12-07 2022-03-15 深圳市星卡软件技术开发有限公司 Automobile system fault processing method, device, equipment and medium
CN114844816B (en) * 2022-03-30 2023-05-23 东风汽车集团股份有限公司 Automobile communication disconnection simulation method
CN114815786B (en) * 2022-06-24 2022-11-01 江西五十铃汽车有限公司 Test method and system for simulating alarm function triggering and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102673495A (en) * 2011-03-16 2012-09-19 北汽福田汽车股份有限公司 CAN (Controller Area Network) bus system and fault diagnosis method thereof
JP2012194724A (en) * 2011-03-16 2012-10-11 Toyota Central R&D Labs Inc Failure diagnosis method and failure diagnosis system
CN106886214A (en) * 2017-03-28 2017-06-23 天津大学 CAN controller chip functions test system and method for testing
CN109634258A (en) * 2018-11-30 2019-04-16 北京新能源汽车股份有限公司 It is a kind of for the bus message method of calibration of hardware-in―the-loop test, apparatus and system
CN112230561A (en) * 2020-08-19 2021-01-15 东风康明斯发动机有限公司 Simulation test method and system for CAN bus controller software

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018069853A1 (en) * 2016-10-12 2018-04-19 Harman International Industries, Incorporated Systems and methods for in-vehicle predictive failure detection
CN108919788A (en) * 2018-09-10 2018-11-30 汽-大众汽车有限公司 A kind of remote monitoring system and method for the automobile bench test based on vehicle-mounted CAN bus
US11233713B2 (en) * 2019-07-19 2022-01-25 Deere & Company Controller area network and connectivity health troubleshooting system
CN112596999A (en) * 2020-12-08 2021-04-02 航天科技控股集团股份有限公司 Diagnostic fault testing method for automobile instrument

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102673495A (en) * 2011-03-16 2012-09-19 北汽福田汽车股份有限公司 CAN (Controller Area Network) bus system and fault diagnosis method thereof
JP2012194724A (en) * 2011-03-16 2012-10-11 Toyota Central R&D Labs Inc Failure diagnosis method and failure diagnosis system
CN106886214A (en) * 2017-03-28 2017-06-23 天津大学 CAN controller chip functions test system and method for testing
CN109634258A (en) * 2018-11-30 2019-04-16 北京新能源汽车股份有限公司 It is a kind of for the bus message method of calibration of hardware-in―the-loop test, apparatus and system
CN112230561A (en) * 2020-08-19 2021-01-15 东风康明斯发动机有限公司 Simulation test method and system for CAN bus controller software

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张帆等.基于SAE J1939 协议的故障诊断系统开发.《湖北汽车工业学院学报》.2020,第34卷(第34期),全文. *

Also Published As

Publication number Publication date
CN113189970A (en) 2021-07-30

Similar Documents

Publication Publication Date Title
CN113189970B (en) Hardware-in-loop automatic test method and system of CAN bus controller and storage medium
CN107145140B (en) Automatic test system and test method for CAN interface of vehicle-mounted electronic control unit
CN109740222B (en) Testing device and system for automobile networking scene
CN110888414B (en) Test method for upgrading vehicle controller
US20080313126A1 (en) Method for a distributed control system
CN113867318B (en) Automatic integration method for hardware-in-loop test engineering of CAN communication controller
CN111045416B (en) Method and device for analyzing CAN (controller area network) signal of whole vehicle by using diagnosis message
CN107370637B (en) Vehicle-mounted ECU communication function automatic test system and method
CN108132876B (en) Embedded software object code unit testing method based on injection mode
CN114326659A (en) Fault diagnosis system and method for automobile electronic control unit
CN116107893A (en) Heterogeneous platform embedded software test verification system and method
WO2024109535A1 (en) Communication interaction method and apparatus, device, and storage medium
CN115080104A (en) Method and system for automatically configuring COM (component object model) code in Autosar
CN113515307A (en) Calibratable can information processing system and method based on hybrid electric vehicle
CN113360388B (en) Method for integrally managing test process of unmanned aerial vehicle ground station software
CN102063083B (en) Multi-ECU (Electronic Control Unit) time-shared downloading method
CN113985849A (en) Method for writing DTC (digital control channel) read ECU (electronic control unit) version of automatic clear-reading whole vehicle based on CANoe software
CN104678292A (en) Test method and device for CPLD (Complex Programmable Logic Device)
CN110209142B (en) PLC module connection and detection method, device and detection equipment
CN114448851B (en) Automatic data testing method and system
CN111008113A (en) SAS-Expander test method and tool
CN111752823A (en) Method, device and equipment for testing vehicle-mounted power supply application software
CN116991706B (en) Vehicle automatic test method, device, equipment and storage medium
CN117032175A (en) Automatic test method and system for vehicle-mounted controller
CN115567340B (en) CAN bus test engineering generation method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant