Hardware testing method and device, electronic equipment and storage medium
By processing the controller LAN database files, a node model is automatically generated for simulating communication with the electronic controller unit to be tested, solving the accuracy and efficiency of manually building the model, and achieving efficient and accurate hardware-in-loop testing.
Patent Information
- Application Number
- CN202411499193.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-28
AI Technical Summary
Manually building hardware-in-loop (HIL) test models has signal accuracy and calculation accuracy problems, and is long and costly, especially when building complex or large number of repetitive models.
By processing the database files of the controller LAN, a node model is automatically generated for simulating communication with the electronic controller unit to be tested, and hardware-in-loop testing is realized without manually building the model.
It improves the accuracy and construction efficiency of the model, is suitable for testing scenarios of various electronic controller units, and reduces labor costs and construction cycles.
Smart Images

Figure CN119537113A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of hardware-in-the-loop testing, and in particular to a hardware testing method, device, electronic equipment and storage medium. Background Art
[0002] Hardware-in-the-Loop (HIL) is a development and testing technology for complex equipment controllers. It connects to a real controller and uses or partially uses a real-time simulation model to simulate the controlled object and the system operating environment to achieve simulation testing of the entire system.
[0003] When performing HIL testing, HIL equipment is used to replace the real controlled object, receive all control instructions, and simulate all status information to return to the real controller, so that the controller thinks it is controlling the real object, thus forming a test closed loop. HIL equipment includes a simulation model of the controlled object, that is, a simulation model of the controlled object needs to be established before HIL testing. At present, model development generally adopts manual development. However, manual model development faces many problems. On the one hand, manual model building affects the accuracy of the signal and the accuracy of the calculation inside the model; on the other hand, the manual model building cycle is long. In the process of building complex models and a large number of repeated models, manual model building is prone to many uncertain factors; in addition, some researchers have proposed a method of multi-person collaboration, where different people build and verify each subsystem model separately. This method can ensure the accuracy of the model to a certain extent, but there are problems such as long construction cycle and high labor cost. Summary of the invention
[0004] In order to solve the above technical problems, the present invention discloses a hardware testing method, device, electronic device and storage medium. By processing the database file of the controller local area network, a model for simulating the node communicating with the electronic controller unit to be tested is automatically generated to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build the model, which improves the accuracy of the model and the efficiency of model building.
[0005] In order to achieve the above object, the present invention provides a hardware testing method, comprising:
[0006] Acquire a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested;
[0007] Receiving a first message sent by the electronic controller unit under test through the target model, processing the first message, generating a feedback message corresponding to the first message, and sending the feedback message to the electronic controller unit under test;
[0008] Acquire a second message generated after the electronic controller unit under test processes the feedback message;
[0009] The second message is analyzed, and a test result of the electronic controller unit to be tested is determined based on the analysis result.
[0010] In an optional embodiment, before obtaining the target model corresponding to the electronic controller unit to be tested, the method further includes:
[0011] Acquire a target database file; the target database file includes node information of a preset electronic controller unit on the controller area network bus, and target message configuration information related to communication with the electronic controller unit to be tested, the target message configuration information includes first configuration information for configuring the electronic controller unit to be tested to send a message and second configuration information for configuring the electronic controller unit to be tested to receive a message;
[0012] Determine the target electronic controller unit from preset electronic controller units;
[0013] Establishing a target subsystem corresponding to the target electronic controller unit based on the target database file; the target subsystem is used to realize communication between the electronic controller unit to be tested and the target electronic controller unit;
[0014] The target model is generated based on the target subsystem.
[0015] In an optional embodiment, obtaining the target database file includes:
[0016] In response to a selection operation on a target path storing the target database file, acquiring file information under the target path; the file information includes an extension of each file;
[0017] The files under the target path are traversed, and the files with the extensions of the preset extensions are determined as the target database files.
[0018] In an optional embodiment, determining the target electronic controller unit from preset electronic controller units includes:
[0019] Loading the target database file to obtain node information of the preset electronic controller unit;
[0020] generating an electronic controller unit node list based on the node information;
[0021] In response to a selection operation of at least one node information in the electronic controller unit node list, the target electronic controller unit is determined from the electronic controller unit node list.
[0022] In an optional embodiment, after determining the target electronic controller unit from the preset electronic controller units, the method further includes:
[0023] acquiring an initial node name of the target electronic controller unit based on the node information of the target electronic controller unit;
[0024] The initial node name is subjected to data type conversion processing to obtain a target node name of the target electronic controller unit; the target node name is a node name that matches the target subsystem.
[0025] In an optional embodiment, the establishing a target subsystem corresponding to the target electronic controller unit based on the target database file includes:
[0026] Loading the target database file, obtaining the first configuration information and the second configuration information;
[0027] Reading a target node name of the target electronic controller unit;
[0028] The target subsystem is established based on the target node name, the first configuration information, and the second configuration information.
[0029] In an optional embodiment, the target subsystem includes a first subsystem and a second subsystem, and establishing the target subsystem based on the target node name, the first configuration information, and the second configuration information includes:
[0030] The first subsystem is established based on the target node name of the target electronic controller unit and the first configuration information; the first subsystem is used to receive a first message sent by the electronic controller unit to be tested, and process the first message to generate a feedback message corresponding to the first message;
[0031] The second subsystem is established based on the target node name of the target electronic controller unit and the second configuration information; the second subsystem is used to send the feedback message to the electronic controller unit to be tested.
[0032] The present invention also provides a hardware testing device, comprising:
[0033] A model acquisition module is used to acquire a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, and the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested;
[0034] A test module, configured to receive a first message sent by the electronic controller unit to be tested through the target model, process the first message, generate a feedback message corresponding to the first message, and send the feedback message to the electronic controller unit to be tested;
[0035] A message acquisition module, used for acquiring a second message generated after the electronic controller unit under test processes the feedback message;
[0036] The test result determination module is used to analyze the second message and determine the test result of the electronic controller unit to be tested based on the analysis result.
[0037] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the hardware testing method as described above.
[0038] The present invention also provides a computer-readable storage medium, in which at least one instruction or at least one program is stored. The at least one instruction or the at least one program is loaded and executed by a processor to implement the hardware testing method as described above.
[0039] Implementing the embodiments of the present invention has the following beneficial effects:
[0040] The hardware testing method disclosed in the present invention obtains a controller area network database file containing communication configuration information related to the electronic controller unit to be tested. By processing the database file of the controller area network, a model for simulating a node that communicates with the electronic controller unit to be tested can be automatically generated to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build a model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the hardware testing method, device, electronic device and storage medium described in the present invention, the drawings required for the embodiments 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.
[0042] Figure 1 A flowchart of a hardware testing method provided by an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a flow chart of a model generation method provided by an embodiment of the present invention;
[0044] Figure 3 A schematic diagram of the structure of a hardware testing device provided by an embodiment of the present invention;
[0045] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0047] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0048] Please refer to Figure 1, which shows a flowchart of a hardware testing method provided by an embodiment of the present invention. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many, and does not represent the only execution order. When the actual system or server product is executed, it can be executed in the order of the method shown in the embodiment or the accompanying drawings. Specifically, Figure 1 As shown, the method includes:
[0049] S101, obtaining a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested;
[0050] In the embodiments of this specification, the Electronic Control Unit (ECU) is an integrated circuit in the car, which is responsible for controlling various electronic systems of the car. The ECU receives signals from various sensors and then controls the actuators according to these signals, thereby achieving precise control of various systems of the car. Hardware-in-the-Loop (HIL) is a development and testing technology for complex device controllers. By connecting to a real controller, using or partially using a real-time simulation model to simulate the controlled object and the system operating environment, the simulation test of the entire system is achieved.
[0051] In the embodiments of this specification, the electronic controller unit to be tested is a real controller. When the electronic controller unit to be tested is subjected to hardware-in-the-loop testing, a target model corresponding to the electronic controller unit to be tested needs to be established. The target model is used to simulate a target electronic controller unit that communicates with the electronic controller unit to be tested on a controller area network bus;
[0052] In an embodiment of the present specification, a target model corresponding to the electronic controller unit to be tested is automatically generated based on a target database file, and the target database file contains communication configuration information related to the electronic controller unit to be tested. The communication configuration information may include node information of the target electronic controller unit on the controller local area network bus that communicates with the electronic controller unit to be tested, first configuration information related to sending messages by the electronic controller unit to be tested, and second configuration information related to receiving messages by the electronic controller unit to be tested.
[0053] In the embodiments of this specification, Figure 2A flow chart of a model generation method provided by an embodiment of the present invention, before obtaining the target model corresponding to the electronic controller unit to be tested, the method further includes:
[0054] S201, obtaining a target database file; the target database file includes node information of a preset electronic controller unit on the controller area network bus, and target message configuration information related to communication with the electronic controller unit to be tested, the target message configuration information includes first configuration information for configuring the electronic controller unit to be tested to send a message and second configuration information for configuring the electronic controller unit to be tested to receive a message;
[0055] In the embodiments of this specification, the target database file refers to a DBC (Database for CAN) file, which usually has a ".dbc" extension. The DBC file contains a series of entries, each of which defines a specific message on the CAN bus. These messages can contain one or more signals. Signals are data fields that make up the message. They can be numbers, status bits, or other types of data. The main function of the DBC file is to provide a standardized method to describe and parse CAN messages. The DBC file contains the definition of network nodes, message frames, signals, annotations, features, and a numerical table. In HIL testing, the DBC file is used to define how to extract specific physical quantities from the original CAN bus signal data, and how to convert these physical quantities into signals that the ECU can understand and process. The DBC file contains information such as the signal name, length, start bit, byte order, data type, initial value, precision, offset, minimum value, and maximum value;
[0056] In the embodiments of this specification, the preset electronic controller unit on the controller area network bus refers to all ECUs participating in the communication on the CAN bus, and the node information of the preset electronic controller unit includes the node name, node alias, node communication address, message transmission attribute, signal attribute, signal group, comment, environment variable, attribute definition, value table and other information of each ECU;
[0057] In the embodiments of this specification, the first configuration information refers to information related to the message sent by the electronic controller unit under test, and the second configuration information refers to information related to the message received by the electronic controller unit under test. The first configuration information / second configuration information includes the message name, message ID, message length, signal definition, transmission period, frame type, signal group, frame period, value table, comments, environment variables, attribute definition and other information of each message.
[0058] S203, determining the target electronic controller unit from preset electronic controller units;
[0059] In the embodiments of the present specification, the preset electronic controller unit includes one or more target electronic controller units that communicate with the electronic controller unit to be tested via a CAN bus, and the target electronic controller unit is the object to be simulated.
[0060] S205, establishing a target subsystem corresponding to the target electronic controller unit based on the target database file; the target subsystem is used to realize communication between the electronic controller unit to be tested and the target electronic controller unit;
[0061] In the embodiment of this specification, the target subsystem is used to implement the interaction between the electronic controller unit to be tested and the target model.
[0062] S207: Generate the target model based on the target subsystem.
[0063] In the embodiments of the present specification, the target subsystem includes at least one subsystem, and the at least one subsystem constitutes a target model corresponding to the electronic controller unit to be tested.
[0064] The embodiments of this specification obtain a controller area network database file containing communication configuration information related to the electronic controller unit to be tested. By processing the database file of the controller area network, a model for simulating a node that communicates with the electronic controller unit to be tested can be automatically generated to implement hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build a model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units.
[0065] In the embodiment of this specification, the step of obtaining the target database file includes:
[0066] In response to a selection operation on a target path storing the target database file, acquiring file information under the target path; the file information includes an extension of each file;
[0067] The files under the target path are traversed, and the files with the extensions of the preset extensions are determined as the target database files.
[0068] In the embodiment of this specification, the target database file refers to a DBC file, so the default extension is ".dbc". After the developer / tester selects the target path, he obtains information about all files and folders under the target path, and finds the file with the extension ".dbc" by traversing, which is the target database file.
[0069] The embodiment of this specification determines the controller local area network database file based on the extension name. The controller local area network database file contains communication configuration information related to the electronic controller unit to be tested. By further processing the database file of the controller local area network, a model for simulating the node communicating with the electronic controller unit to be tested can be automatically generated to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build the model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units.
[0070] In the embodiment of this specification, the step of determining the target electronic controller unit from the preset electronic controller units includes:
[0071] Loading the target database file to obtain node information of the preset electronic controller unit;
[0072] generating an electronic controller unit node list based on the node information;
[0073] In response to a selection operation of at least one node information in the electronic controller unit node list, the target electronic controller unit is determined from the electronic controller unit node list.
[0074] In the embodiment of the present specification, by loading a target database file with an extension of ".dbc", node information of a preset electronic controller unit participating in communication on the CAN bus contained in the target database file can be obtained;
[0075] In the embodiment of the present specification, the electronic controller unit node list is generated based on the node names of each preset electronic controller unit;
[0076] In the embodiment of the present specification, after the developer / tester selects a node name corresponding to at least one node communicating with the electronic controller unit to be tested from the electronic controller unit node list, the node corresponding to the node name is determined as the target electronic controller unit, i.e., the object to be simulated;
[0077] In the embodiments of the present specification, the target electronic controller unit may include one or more electronic controller units.
[0078] The embodiment of this specification first obtains a controller area network database file containing communication configuration information related to the electronic controller unit to be tested, generates a list of nodes to be selected based on the node information contained in the controller area network database file, determines the selected nodes as objects to be simulated, and further processes the database file of the controller area network to automatically generate a model for simulating the selected nodes, so as to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build the model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units.
[0079] In the embodiment of this specification, after determining the target electronic controller unit from the preset electronic controller units, the method further includes:
[0080] acquiring an initial node name of the target electronic controller unit based on the node information of the target electronic controller unit;
[0081] The initial node name is subjected to data type conversion processing to obtain a target node name of the target electronic controller unit; the target node name is a node name that matches the target subsystem.
[0082] In the embodiment of this specification, in the subsequent process of generating the target model corresponding to the electronic controller unit to be tested, it is necessary to generate the corresponding target subsystem according to the node name of the target electronic controller unit, so it is necessary to perform format conversion processing on the node name of the target electronic controller unit to match it with the target subsystem;
[0083] In the embodiment of the present specification, after determining the target electronic controller unit, the initial node name of the target electronic controller unit is obtained, and then the format of the initial node name is converted into a string data type, and the node name after format conversion is determined as the target node name of the target electronic controller unit.
[0084] After the embodiment of this specification determines the target electronic controller unit that communicates with the electronic controller unit to be tested, the node name of the target electronic controller unit is formatted and processed to ensure that the node name of the target electronic controller unit matches the target subsystem in the target model, and then the controller local area network database file containing communication configuration information related to the electronic controller unit to be tested is further processed to automatically generate a model for simulating the target electronic controller unit, thereby realizing automated model building and improving the accuracy and efficiency of the model.
[0085] In the embodiment of this specification, the target subsystem corresponding to the target electronic controller unit is established based on the target database file, including:
[0086] Loading the target database file, obtaining the first configuration information and the second configuration information;
[0087] Reading a target node name of the target electronic controller unit;
[0088] The target subsystem is established based on the target node name, the first configuration information, and the second configuration information.
[0089] In the embodiment of the present specification, by loading the target database file with the extension ".dbc", the first configuration information related to the message sent by the electronic controller unit under test and the second configuration information related to the message received by the electronic controller unit under test can be obtained;
[0090] In an embodiment of the present specification, a target subsystem can be generated based on the target node name, first configuration information and second configuration information of the target electronic controller unit. The target subsystem is used to realize communication between the electronic controller unit to be tested and the target model. The target subsystem includes at least one subsystem, and each subsystem is used to realize one or more links in the communication process.
[0091] The embodiment of this specification obtains a controller area network database file containing communication configuration information related to the electronic controller unit to be tested. Based on the network node information contained in the controller area network database file and the message configuration information related to the communication with the electronic controller unit to be tested, a model for simulating the node communicating with the electronic controller unit to be tested can be automatically generated to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build the model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units.
[0092] In the embodiment of the present specification, the target subsystem includes a first subsystem and a second subsystem, and establishing the target subsystem based on the target node name, the first configuration information, and the second configuration information includes:
[0093] The first subsystem is established based on the target node name of the target electronic controller unit and the first configuration information; the first subsystem is used to receive a first message sent by the electronic controller unit to be tested, and process the first message to generate a feedback message corresponding to the first message;
[0094] The second subsystem is established based on the target node name of the target electronic controller unit and the second configuration information; the second subsystem is used to send the feedback message to the electronic controller unit to be tested.
[0095] In the embodiment of the present specification, based on the target node name of the target electronic controller unit and the first configuration information, the correspondence between the electronic controller unit to be tested, the first message sent by the electronic controller unit to be tested, and the simulated target electronic controller unit that receives the first message can be determined, so that a first subsystem can be generated, which is used to control the target model to receive the first message sent by the electronic controller unit to be tested, and process the first message to generate a feedback message corresponding to the first message;
[0096] In an embodiment of the present specification, based on the target node name of the target electronic controller unit and the second configuration information, the correspondence between the simulated target electronic controller unit, the feedback message sent by the simulated target electronic controller unit, and the electronic controller unit under test that receives the feedback message can be determined, so that a second subsystem can be generated for controlling the target model to send the feedback message corresponding to the first message to the electronic controller unit under test.
[0097] The embodiment of this specification obtains a controller area network database file containing communication configuration information related to the electronic controller unit to be tested. Based on the network node information contained in the controller area network database file and the message configuration information related to the communication with the electronic controller unit to be tested, a model for simulating the node communicating with the electronic controller unit to be tested can be automatically generated to realize hardware-in-the-loop testing of the electronic controller unit to be tested. There is no need to manually build the model, which improves the accuracy of the model and the efficiency of model building, and is suitable for testing scenarios of various electronic controller units.
[0098] In the embodiments of this specification, the target model corresponding to the electronic controller unit to be tested can be generated based on the MATLAB / Simulink environment. Specifically, the code for generating the target model corresponding to the electronic controller unit to be tested is exemplified as follows. This script is used to create and configure the model based on the CAN database (.dbc file).
[0099] clear% Clear all variables in the MATLAB workspace
[0100] clc % Clear the command window
[0101] path = uigetdir; %Get the target path
[0102] dbcdir=dir(path); %Get the file information under the target path
[0103] Model_Name = 'IO'; %Define the target model name
[0104] open_system(new_system(Model_Name)) %Create and open a new Simulink model
[0105] index_xcan = 0;
[0106] for i=1:length(dbcdir)%Traverse each file in the target path
[0107] if~isempty(strfind(dbcdir(i).name,'.dbc')) % Check if the file name contains ".dbc"
[0108] dbc=canDatabase([path,'\',dbcdir(i).name]); % Load the target database file
[0109] xcan_Name=strrep(dbcdir(i).name,'.dbc',");
[0110] [indx] = listdlg('PromptString','Select an ECU Node','listString',dbc.Nodes); %Display the electronic controller unit node list, and determine the selected node as the target electronic controller unit to be simulated ECUNode = string(dbc.Nodes(indx)); %Convert the node name of the target electronic controller unit to a string data type
[0111] index_xcan=index_xcan+1;
[0112] path xcan=add empty subsystem(Model_Name,xcan_Name); %Add a new empty subsystem to the target model
[0113] set_param(path_xcan,'position',[300,-50+130*index_xcan,600,30+130*index_xcan]); %Set the position of the subsystem
[0114] ECUtoMDL(path_xcan,dbc,xcan_Name,ECUNode)
[0115] MDLtoECU(path_xcan,dbe,ECUNode)
[0116] end
[0117] end
[0118] Among them, Model_Name = 'IO' means that the name of the target model is IO. Through the for loop and if judgment, each file in the target path is traversed to find the target database file with the extension ".dbc". xcan_Name = strrep (dbcdir (i).name, '.dbc', ") means that the name of the target subsystem is consistent with the target database file. [indx] = listdlg ('PromptString', 'Select an ECU Node','listString',dbc.Nodes) indicates that a list of electronic controller unit nodes is generated based on the node information of all ECUs on the CAN bus, and the selected node is determined as the target electronic controller unit to be simulated. path_xcan=add_empty_subsystem(Model_Name,xcan_Name) indicates that a target subsystem is added to the target model. The set_param function is used to set the position of the target subsystem in the target model. ECUtoMDL indicates a first subsystem, which is used to receive a first message sent by the electronic controller unit to be tested, and to process the first message to generate a feedback message corresponding to the first message. MDLtoECU indicates a second subsystem, which is used to send a feedback message corresponding to the first message to the electronic controller unit to be tested, thereby realizing hardware-in-the-loop testing of the electronic controller unit to be tested.
[0119] S103, receiving a first message sent by the electronic controller unit to be tested through the target model, processing the first message, generating a feedback message corresponding to the first message, and sending the feedback message to the electronic controller unit to be tested;
[0120] In an embodiment of the present specification, the target model includes a first subsystem and a second subsystem. The first subsystem is used to control the target model to receive a first message sent by the electronic controller unit to be tested, and to process the first message to generate a feedback message corresponding to the first message. The second subsystem is used to control the target model to send the feedback message corresponding to the first message to the electronic controller unit to be tested.
[0121] S105, obtaining a second message generated after the electronic controller unit under test processes the feedback message;
[0122] In the embodiment of the present specification, after receiving the feedback message sent by the target model, the real electronic controller unit to be tested further analyzes and processes the feedback message, and generates a second message based on the feedback message;
[0123] In the embodiment of the present specification, the first message and the second message sent by the electronic controller unit to be tested may be messages related to control instructions.
[0124] S107, analyzing the second message, and determining a test result of the electronic controller unit to be tested based on the analysis result.
[0125] In the embodiment of this specification, by analyzing the second message generated by the electronic controller unit under test based on the feedback message, it can be determined whether the electronic controller unit under test can make a reasonable decision, thereby determining whether the performance of the electronic controller unit under test meets the requirements.
[0126] It can be seen from the above-mentioned embodiments of the hardware testing method provided by the present invention that the embodiment of the present invention obtains a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate the target electronic controller unit that communicates with the electronic controller unit to be tested on the controller local area network bus, and the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested; the first message sent by the electronic controller unit to be tested is received through the target model, the first message is processed, a feedback message corresponding to the first message is generated, and the feedback message is sent to the electronic controller unit to be tested; the second message generated after the electronic controller unit to be tested processes the feedback message is obtained; the second message is analyzed, and the test result of the electronic controller unit to be tested is determined based on the analysis result. The technical solution provided in the embodiment of this specification automatically generates a model for simulating a node that communicates with the electronic controller unit to be tested by processing the database file of the controller local area network, so as to realize hardware-in-the-loop testing of the electronic controller unit to be tested, without the need to manually build a model, thereby improving the accuracy of the model and the efficiency of model building.
[0127] The embodiment of the present invention also provides a hardware testing device, such as Figure 3 As shown, it is a structural schematic diagram of a hardware testing device provided by an embodiment of the present invention; specifically, the device includes:
[0128] The model acquisition module 310 is used to acquire a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, and the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested;
[0129] The test module 320 is used to receive a first message sent by the electronic controller unit under test through the target model, process the first message, generate a feedback message corresponding to the first message, and send the feedback message to the electronic controller unit under test;
[0130] A message acquisition module 330, configured to acquire a second message generated after the electronic controller unit under test processes the feedback message;
[0131] The test result determination module 340 is used to analyze the second message and determine the test result of the electronic controller unit to be tested based on the analysis result.
[0132] In the embodiment of this specification, the device also includes:
[0133] A database file acquisition module, used to acquire a target database file; the target database file includes node information of a preset electronic controller unit on the controller local area network bus, and target message configuration information related to the communication of the electronic controller unit to be tested, the target message configuration information includes first configuration information for configuring the electronic controller unit to be tested to send a message and second configuration information for configuring the electronic controller unit to be tested to receive a message;
[0134] A target electronic controller unit determination module, used to determine the target electronic controller unit from preset electronic controller units;
[0135] A target subsystem generation module, used to establish a target subsystem corresponding to the target electronic controller unit based on the target database file; the target subsystem is used to realize communication between the electronic controller unit to be tested and the target electronic controller unit;
[0136] A target model generating module is used to generate the target model based on the target subsystem.
[0137] In the embodiment of this specification, the database file acquisition module includes:
[0138] A file information acquisition unit, configured to acquire file information under a target path in response to a selection operation on a target path storing the target database file; the file information includes an extension of each file;
[0139] The target database file determination unit is used to traverse the files under the target path and determine the file with the preset extension as the target database file.
[0140] In the embodiment of this specification, the target electronic controller unit determination module includes:
[0141] A node information acquisition unit, used to load the target database file and acquire the node information of the preset electronic controller unit;
[0142] A node list generating unit, used for generating an electronic controller unit node list based on the node information;
[0143] The target electronic controller unit determining unit is used to determine the target electronic controller unit from the electronic controller unit node list in response to a selection operation on at least one node information in the electronic controller unit node list.
[0144] an initial node name acquiring unit, configured to acquire an initial node name of the target electronic controller unit based on the node information of the target electronic controller unit;
[0145] The target node name determination unit is used to perform data type conversion processing on the initial node name to obtain the target node name of the target electronic controller unit; the target node name is a node name that matches the target subsystem.
[0146] In the embodiment of this specification, the target subsystem generation module includes:
[0147] A configuration information acquisition unit, used to load the target database file and acquire the first configuration information and the second configuration information;
[0148] A target node name reading unit, used for reading the target node name of the target electronic controller unit;
[0149] The target subsystem generating unit is used to establish the target subsystem based on the target node name, the first configuration information and the second configuration information.
[0150] In the embodiment of this specification, the target subsystem includes a first subsystem and a second subsystem, and the target subsystem generation unit includes:
[0151] The first subsystem generates a subunit, which is used to establish the first subsystem based on the target node name of the target electronic controller unit and the first configuration information; the first subsystem is used to receive a first message sent by the electronic controller unit to be tested, and process the first message to generate a feedback message corresponding to the first message;
[0152] The second subsystem generates a subunit, which is used to establish the second subsystem based on the target node name of the target electronic controller unit and the second configuration information; the second subsystem is used to send the feedback message to the electronic controller unit under test.
[0153] An embodiment of the present invention also provides an electronic device, which includes a processor and a memory; the memory stores one or more instructions, and the one or more instructions are suitable for the processor to load and execute to implement the hardware testing method as described in the above method embodiment.
[0154] The memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device or other volatile solid-state storage device. Accordingly, the memory can also include a memory controller to provide the processor with access to the memory.
[0155] Figure 4 The schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, the internal structure of the electronic device may include but is not limited to: a processor 401, a memory 402 and a communication interface 403, wherein the processor 401, the memory 402 and the communication interface 403 in the electronic device may be connected by a bus or other means, and the embodiment shown in this specification Figure 4 The example of connecting through bus is taken in the following.
[0156] Among them, the processor 401 (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device. The communication interface 403 is used for communication between the memory 402 and the processor 401. The memory 402 (Memory) is used to store programs and data. It can be understood that the memory here can be a high-speed RAM storage device or a non-volatile storage device (non volatile memory), such as at least one disk storage device; optionally, it can also be at least one storage device located away from the aforementioned processor. The memory provides a storage space, which stores the operating system of the electronic device, which may include but is not limited to: Windows system (an operating system), Linux system (an operating system), etc., and the present invention does not limit this; and, a computer program (including program code) suitable for being loaded and executed by the processor is also stored in the storage space. In the embodiment of this specification, the processor 401 loads and executes the computer program stored in the memory 402 to implement the hardware testing method provided in the above method embodiment.
[0157] An embodiment of the present invention also provides a computer-readable storage medium, which can be set in an electronic device to store at least one instruction, at least one program, code set or instruction set related to a hardware testing method in an implementation method embodiment. The at least one instruction, the at least one program, the code set or instruction set can be loaded and executed by a processor of the electronic device to implement the hardware testing method provided by the above-mentioned method embodiment.
[0158] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0159] It should be noted that the sequence of the embodiments of the present invention described above is for description only and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of this specification, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0160] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0161] Those skilled in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
[0162] The above disclosure is only a preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A hardware testing method, characterized in that: include: Acquire a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested; Receiving a first message sent by the electronic controller unit to be tested through the target model, processing the first message, generating a feedback message corresponding to the first message, and sending the feedback message to the electronic controller unit to be tested; Acquire a second message generated after the electronic controller unit under test processes the feedback message; The second message is analyzed, and a test result of the electronic controller unit to be tested is determined based on the analysis result.
2. The hardware testing method according to claim 1, characterized in that: Before obtaining the target model corresponding to the electronic controller unit to be tested, the method further includes: Acquire a target database file; the target database file includes node information of a preset electronic controller unit on the controller area network bus, and target message configuration information related to communication with the electronic controller unit to be tested, the target message configuration information includes first configuration information for configuring the electronic controller unit to be tested to send a message and second configuration information for configuring the electronic controller unit to be tested to receive a message; Determine the target electronic controller unit from preset electronic controller units; Establishing a target subsystem corresponding to the target electronic controller unit based on the target database file; the target subsystem is used to realize communication between the electronic controller unit to be tested and the target electronic controller unit; The target model is generated based on the target subsystem.
3. The hardware testing method according to claim 2, characterized in that: The step of obtaining the target database file comprises: In response to a selection operation on a target path storing the target database file, acquiring file information under the target path; the file information includes an extension of each file; The files under the target path are traversed, and the files with the extensions of the preset extensions are determined as the target database files.
4. The hardware testing method according to claim 2, characterized in that: The step of determining the target electronic controller unit from the preset electronic controller units comprises: Loading the target database file to obtain node information of the preset electronic controller unit; generating an electronic controller unit node list based on the node information; In response to a selection operation of at least one node information in the electronic controller unit node list, the target electronic controller unit is determined from the electronic controller unit node list.
5. The hardware testing method according to claim 2, characterized in that: After determining the target electronic controller unit from the preset electronic controller units, the method further includes: acquiring an initial node name of the target electronic controller unit based on the node information of the target electronic controller unit; The initial node name is subjected to data type conversion processing to obtain a target node name of the target electronic controller unit; the target node name is a node name that matches the target subsystem.
6. The hardware testing method according to claim 5, characterized in that: The step of establishing a target subsystem corresponding to the target electronic controller unit based on the target database file comprises: Loading the target database file, obtaining the first configuration information and the second configuration information; Reading a target node name of the target electronic controller unit; The target subsystem is established based on the target node name, the first configuration information, and the second configuration information.
7. The hardware testing method according to claim 6, characterized in that: The target subsystem includes a first subsystem and a second subsystem, and establishing the target subsystem based on the target node name, the first configuration information, and the second configuration information includes: The first subsystem is established based on the target node name of the target electronic controller unit and the first configuration information; the first subsystem is used to receive a first message sent by the electronic controller unit to be tested, and process the first message to generate a feedback message corresponding to the first message; The second subsystem is established based on the target node name of the target electronic controller unit and the second configuration information; the second subsystem is used to send the feedback message to the electronic controller unit to be tested.
8. A hardware testing device, characterized in that: include: A model acquisition module is used to acquire a target model corresponding to the electronic controller unit to be tested; the target model is used to simulate a target electronic controller unit on a controller area network bus that communicates with the electronic controller unit to be tested, and the target model is generated based on a target database file, and the target database file includes communication configuration information related to the electronic controller unit to be tested; A test module, configured to receive a first message sent by the electronic controller unit to be tested through the target model, process the first message, generate a feedback message corresponding to the first message, and send the feedback message to the electronic controller unit to be tested; A message acquisition module, used for acquiring a second message generated after the electronic controller unit under test processes the feedback message; The test result determination module is used to analyze the second message and determine the test result of the electronic controller unit to be tested based on the analysis result.
9. An electronic device, characterized in that: The device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the hardware testing method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the hardware testing method according to any one of claims 1 to 7.