Controller area network communication interface test method, device, equipment and vehicle
By generating a virtual controller area network in a virtual environment and utilizing simulators and automated test scripts, the problems of high testing costs and significant security risks in CAN communication interfaces are solved, achieving an efficient and flexible testing solution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA FAW CO LTD
- Filing Date
- 2024-10-28
- Publication Date
- 2026-05-19
AI Technical Summary
Existing testing methods for CAN communication interfaces rely on real hardware environments, resulting in high testing costs, poor flexibility, significant security risks, and difficulty in covering all testing scenarios.
By generating a virtual controller area network in a virtual environment and using simulators and automated test scripts to simulate real communication environments and behaviors, the CAN communication interface can be tested.
It reduces testing equipment and manpower costs, improves testing flexibility and portability, comprehensively covers testing scenarios, avoids hardware damage and security risks, and improves testing efficiency and accuracy.
Smart Images

Figure CN119449650B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automotive electronics technology, and in particular to a method, apparatus, equipment, and vehicle for testing controller area network communication interfaces. Background Technology
[0002] Controller Area Network (CAN) is a messaging protocol designed to provide reliable communication for multiple Electronic Control Units (ECUs). This type of network is primarily used within vehicle networks. By simplifying the connection of electronic devices within a vehicle, the CAN protocol is widely used in various vehicle systems, such as engine control units, transmission control units, and body control modules.
[0003] The testing methods for CAN communication interfaces in related technologies usually require a real hardware environment, which makes the testing cost of CAN communication interfaces high. Summary of the Invention
[0004] The main objective of this application is to provide a method, apparatus, device, and vehicle for testing controller area network (CAN) communication interfaces, aiming to reduce the testing cost of CAN communication interfaces.
[0005] To achieve the above objectives, one aspect of this application proposes a method for testing a controller area network (CAN) communication interface, comprising the following steps:
[0006] Receive controller area network creation data;
[0007] The data created through the controller area network generates a virtual controller area network in the virtual environment;
[0008] Automated test scripts are executed based on the virtual controller area network and simulator to test the communication interface of the controller area network.
[0009] The automated test script is used to control the communication process between the simulator and the controller area network, and the simulator is used to simulate the communication environment and communication behavior of the real controller area network.
[0010] In some embodiments, generating a virtual controller area network (CNR) in a virtual environment using the CNR creation data includes:
[0011] The controller area network (CAN) generates virtual nodes, virtual connections, and communication parameters by creating data within the CAN.
[0012] In some embodiments, the execution of automated test scripts based on the virtual controller area network and simulator to test the controller area network communication interface includes:
[0013] Generate the automated test script based on the automated test cases;
[0014] The automated test script is loaded into the test environment of the controller area network, the test environment including the virtual controller area network and the simulator;
[0015] The automated test script controls the test to perform tests on the controller area network communication interface based on the virtual controller area network and the simulator.
[0016] In some embodiments, controlling the automated test script to test the controller area network communication interface based on the virtual controller area network and the simulator includes:
[0017] The automated test script controls the simulator to generate and receive signal frames from the virtual controller area network (Controller Area Network) based on the virtual nodes, virtual connections, and communication parameters of the virtual Controller Area Network, thereby simulating the communication process of different nodes in the Controller Area Network.
[0018] In some embodiments, executing automated test scripts based on the virtual controller area network and simulator includes:
[0019] The virtual environment is used to monitor the communication process of different nodes in the controller area network and record the communication data.
[0020] A test report is generated using the communication data.
[0021] In some embodiments, generating the automated test script based on the automated test cases includes:
[0022] The interface data and transmission data of the controller area network are extracted through the automated test cases.
[0023] A data table is generated based on the interface data and the transmission data;
[0024] The data table is parsed to obtain multiple test items;
[0025] Generate multiple corresponding test scripts based on the multiple test items;
[0026] Multiple test scripts are merged to obtain the automated test script.
[0027] In some embodiments, the controller area network communication interface testing method further includes:
[0028] Integrate the automated test scripts into the continuous integration and continuous deployment process;
[0029] The automated test scripts are continuously validated and rapidly iterated through continuous integration and continuous deployment.
[0030] To achieve the above objectives, another aspect of this application provides a controller area network (CNR) communication interface testing device, which includes:
[0031] The receiving module is used to receive controller area network creation data;
[0032] A generation module is used to generate a virtual controller area network in a virtual environment by creating data through the controller area network;
[0033] An execution module is used to execute automated test scripts based on the virtual controller area network and simulator to test the communication interface of the controller area network.
[0034] The automated test script is used to control the communication process between the simulator and the controller area network, and the simulator is used to simulate the communication environment and communication behavior of the real controller area network.
[0035] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the controller area network communication interface testing method of the above embodiments.
[0036] To achieve the above objectives, another aspect of this application provides a vehicle in which the controller area network (CNR) communication interface is tested using the CNR communication interface testing method, the CNR communication interface testing device, or the electronic device described in the above embodiments.
[0037] The embodiments of this application include at least the following beneficial effects:
[0038] This application provides a method, apparatus, device, and vehicle for testing controller area network (CAN) communication interfaces. In this embodiment, firstly, CAN creation data is received; then, a virtual CAN is generated in a virtual environment using the CAN creation data; finally, an automated test script is executed based on the virtual CAN and a simulator to test the CAN communication interface. The automated test script controls the communication process between the simulator and the CAN, and the simulator simulates the communication environment and behavior of a real CAN. In this embodiment, because the CAN is generated in a virtual environment, and the automated test script is executed based on the virtual CAN and the simulator to test the CAN communication interface, it is not necessary to rely on a real hardware environment. This solves the problem of increased costs associated with purchasing, deploying, and maintaining a real hardware environment, thereby reducing equipment costs. Furthermore, testing the CAN communication interface based on the automated test script reduces testing manpower costs. Therefore, this embodiment can reduce the testing cost of the CAN communication interface.
[0039] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0040] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0041] Figure 1 This is a flowchart of a controller area network communication interface testing method provided in some embodiments of this application;
[0042] Figure 2 This is another flowchart of a controller area network communication interface testing method provided in some embodiments of this application;
[0043] Figure 3 This is a schematic block diagram of a controller area network communication interface testing device provided in some embodiments of this application;
[0044] Figure 4 These are schematic diagrams of the hardware structure of electronic devices provided in some embodiments of this application. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the reference to "embodiment" herein means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. The implementation methods described in the following exemplary embodiments do not represent all implementation methods consistent with the embodiments of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0046] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0047] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0049] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0050] To facilitate understanding of the inventive concept of this application, before providing a detailed description of the embodiments of this application, the English abbreviations (terms) / related concepts involved in the embodiments of this application will be explained first. The English abbreviations (terms) / related concepts involved in the embodiments of this application are subject to the following interpretation.
[0051] CAN: CAN stands for Controller Area Network, a message-based protocol designed to provide reliable communication for multiple Electronic Control Units (ECUs). This network is primarily used within vehicle networks. The CAN protocol simplifies the connection of electronic devices within a vehicle, replacing the previously complex and expensive multi-point wiring harness system. Based on message passing, the CAN protocol allows each node on the network to send and receive messages. It is designed to maintain stable and reliable communication in harsh automotive environments. In a CAN network, any node can become a master node without central control. The CAN protocol features error detection and correction capabilities to ensure data integrity.
[0052] A2L File: The A2L file is a commonly used file format in automotive electronic control unit (ECU) calibration. It is a text-based description file used to describe in detail the ECU's communication parameters, calibration variables, addresses of observed variables, and formulas for calculating physical values.
[0053] CI / CD: CI / CD stands for Continuous Integration / Continuous Deployment. It is an important part of modern software development and helps improve development efficiency, software quality, and delivery speed.
[0054] Controller Area Network (CAN) is a messaging protocol designed to provide reliable communication for multiple Electronic Control Units (ECUs). This type of network is primarily used within vehicle networks. By simplifying the connection of electronic devices within a vehicle, the CAN protocol is widely used in various vehicle systems, such as engine control units, transmission control units, and body control modules.
[0055] Research revealed that, on the one hand, testing methods for CAN communication interfaces in related technologies typically rely on real hardware environments. For example, a realistic CAN communication environment needs to be established based on actual network equipment; specialized testing equipment, such as the VN1640 CAN analyzer, is required to directly connect to the CAN network and capture and analyze data in real time. Testing CAN communication interfaces in a real hardware environment not only limits testing flexibility and portability but also increases testing costs. Furthermore, testing on actual vehicles or equipment may involve complex configuration and safety issues. Failures due to configuration or testing problems could lead to equipment damage or safety risks, further increasing costs.
[0056] On the other hand, even if software testing tools are available, they often need to be used in conjunction with hardware testing tools. Therefore, instead of reducing testing costs, software testing tools can usually only cover software-level testing and cannot fully simulate hardware behavior, leading to situations that do not meet expectations in the actual use environment, thus affecting the accuracy and reliability of test results.
[0057] On the other hand, testing in a real-world environment may not cover all possible scenarios and conditions, and test results may be affected by environmental factors and are not easily repeatable, which makes it difficult to locate and solve problems.
[0058] In view of this, this application proposes a method, apparatus, device, and vehicle for testing Controller Area Network (CAN) communication interfaces. This scheme involves receiving CAN creation data; then, generating a virtual CAN in a virtual environment using the CAN creation data; finally, executing an automated test script based on the virtual CAN and a simulator to test the CAN communication interface. The automated test script controls the communication process between the simulator and the CAN, and the simulator simulates the communication environment and behavior of a real CAN. In this embodiment, because the CAN is generated in a virtual environment, and the automated test script is executed based on the virtual CAN and the simulator to test the CAN communication interface, it eliminates the need for a real hardware environment, thus solving the problem of increased costs associated with purchasing, deploying, and maintaining real hardware, thereby reducing equipment costs. Testing the CAN communication interface based on the automated test script reduces testing manpower costs, improves testing flexibility and portability, comprehensively covers test scenarios and conditions, improves testing efficiency, and avoids equipment damage and security risks caused by configuration issues.
[0059] The method provided in this application embodiment can be applied to the electronic device provided in this application embodiment, wherein the electronic device can be a terminal or a server.
[0060] The terminal can be a tablet computer, a laptop computer, a desktop computer, etc., but is not limited to these.
[0061] A server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks, and big data and artificial intelligence platforms.
[0062] The implementation steps of a controller area network communication interface testing method provided in this application will be described in detail below with reference to the accompanying drawings.
[0063] Please refer to Figure 1 , Figure 1 The flowchart illustrates a controller area network (CNR) communication interface testing method provided for some embodiments of this application. It should be noted that the steps shown in the flowchart can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in a different order than that shown here.
[0064] The method of the embodiments of this application includes the following steps:
[0065] Step 101: Receive controller area network creation data;
[0066] Step 102: Generate a virtual controller area network in the virtual environment by creating data through the controller area network;
[0067] Step 103: Execute automated test scripts based on the virtual controller area network and simulator to test the controller area network communication interface;
[0068] The automated test scripts are used to control the communication process between the simulator and the controller area network, while the simulator is used to simulate the communication environment and behavior of the real controller area network.
[0069] Steps 101 to 103 as illustrated in this application embodiment utilize a virtual controller area network (CAN) generated in a virtual environment. Automated test scripts are executed based on this virtual CAN and the simulator to test the CAN communication interface. This eliminates the need for a real hardware environment, thus mitigating the increased costs associated with purchasing, deploying, and maintaining real hardware, thereby reducing equipment costs. Furthermore, using automated test scripts to test the CAN communication interface reduces manpower costs, improves testing flexibility and portability, comprehensively covers test scenarios and conditions, enhances testing efficiency, and avoids equipment damage and security risks arising from configuration issues.
[0070] The specific implementation methods for each of the above steps are described below.
[0071] In step 101, controller area network creation data is received.
[0072] CAN network creation data typically includes the necessary data for creating a CAN network. This data may include information that determines the physical and logical topology of the CAN network, and node definition data. The node definition data defines the individual nodes in the network, including their functions, the types of messages they send and receive, and their roles within the network.
[0073] The data created by the CAN network also includes parameters of the transmitted signals, such as: signal name, signal ID, signal length (number of bits), signal type (e.g., integer, floating point), transmission period, transmitting node, receiving node, and verification method (e.g., CRC).
[0074] The CAN network creation data also includes network configuration data, which includes baud rate (bit rate), MAC address of network nodes or similar identifiers, and connection relationships between nodes, etc. This application does not limit this.
[0075] The embodiments provided in this application provide a data foundation for the subsequent generation of a CAN network by receiving CAN network creation data.
[0076] In step 102, data is created via the CAN network to generate a virtual controller area network in the virtual environment.
[0077] A virtual environment is a software solution for developing and testing CAN networks. It typically features a visual interface to facilitate testers in inputting network data, monitoring, and managing the testing process. Furthermore, the virtual environment can generate a virtual controller area network based on received CAN network data.
[0078] It should be understood that the virtual environment can also receive input CAN network creation data through the user interface it provides, via controls in the user interface.
[0079] The virtual environment that can be used to create a virtual CAN network can be Vector Tools, which includes a comprehensive test, simulation, and development environment for testing and simulating CAN, LIN, FlexRay, Ethernet, and other networks. It also includes tools for measuring, analyzing, and testing CAN networks. The virtual environment can also be SocketCAN, which is based on Linux kernel modules and allows users to create virtual CAN network interfaces and monitor data on the CAN bus. The virtual environment can also be LabVIEW, which includes the NI-CAN toolkit for creating and testing CAN networks; this application does not limit the choice of virtual environment.
[0080] A virtual CAN network is a software-based solution that simulates a real CAN network, used for testing CAN bus and communication interface-related applications. In a virtual CAN network, no physical CAN hardware interface is required; all CAN nodes are simulated in software. Virtual CAN networks allow for easy addition or removal of CAN nodes and rapid modification of network parameters, improving testing flexibility and efficiency. They can also simulate large and complex CAN networks without the need to purchase physical CAN hardware, thus reducing testing costs.
[0081] Virtual CAN networks can be created based on a virtual environment. It should be understood that the methods for creating virtual CAN networks will differ depending on the virtual environment used.
[0082] For example, you can click "Create" in the user interface menu of the virtual environment, add a new CAN channel in the pop-up configuration window, then select "Virtual Channel" as the interface type, configure the channel parameters such as baud rate and network name, and click "OK" to save the settings. This will establish a virtual CAN network.
[0083] In some implementations, virtual nodes, virtual connections, and communication parameters for the controller area network can be generated using data from the acquired CAN network.
[0084] The CAN network creation data obtained in step 101 includes data for determining the physical and logical topology of the CAN network, node definition data of the CAN network, parameters of transmitted signals, and network configuration data. Based on this data, virtual nodes, virtual connections, and communication parameters of the CAN network can be generated through a virtual environment.
[0085] Virtual nodes typically refer to software-simulated nodes that can mimic the behavior of actual hardware nodes in a CAN network. These virtual nodes can perform network communication, protocol testing, software development, and debugging without using actual hardware.
[0086] A virtual connection refers to simulating the physical connections in a CAN network within a network simulation or testing environment. This connection is not implemented through actual CAN bus hardware, but rather through software that simulates the communication between CAN nodes. In the development of automotive electronics or industrial automation systems, virtual connections can be used to test the CAN protocol stack, applications, and communication protocols without the need for physical hardware.
[0087] Communication parameters are key parameters that define the communication characteristics of a CAN network. These parameters ensure correct communication between nodes on the network.
[0088] The embodiments provided in this application generate a virtual controller area network in a virtual environment by creating data through a CAN network. This enables easy addition or removal of CAN nodes and quick modification of network parameters to improve testing flexibility and efficiency. The virtual CAN network can also simulate large and complex CAN networks without the need to purchase matching physical CAN hardware, thereby reducing testing costs.
[0089] In step 103, automated test scripts can be executed based on a virtual CAN network and simulator to test the CAN communication interface.
[0090] A simulator is a software or hardware simulator capable of simulating the behavior of the CAN communication interface. It can simulate a real CAN network environment, including the behavior of the CAN controller, physical layer, and data link layer. The simulator can generate and receive CAN frames, simulating the communication process between different nodes.
[0091] An automated test script is a type of code used to automate the testing of software applications. These scripts can be used for various types of testing, including unit testing, integration testing, end-to-end testing, and performance testing.
[0092] Automated test scripts are typically determined by the projects to be tested. Specifically, they can be user-designed test cases implemented using a software language. The specific software language can be determined based on the chosen testing framework. The testing framework could be JUnit, and the corresponding software language could be Java. Alternatively, the testing framework could be NUnit, and the corresponding software language could be .NET. The testing framework could also be pytest, and the corresponding software language could be Python, etc. This application does not impose any restrictions on these.
[0093] For example, automated test scripts can be written based on Vector CAN using the Communication Access Programming Language (CAPL). These scripts can control the behavior of simulators and virtual environments, such as sending CAN messages and simulating faults. Automated test scripts written using CAPL can implement test cases, define test steps, and output expected results.
[0094] In some implementations, automated test scripts can be generated based on automated test cases. Then, the automated test scripts are loaded into the CAN test environment, which includes a virtual controller area network and a simulator. The automated test scripts are then used to test the controller area network communication interface based on the virtual controller area network and the simulator.
[0095] In testing the CAN communication interface, to improve testing efficiency and reliability, a series of detailed automated test cases can be designed first, based on specific testing requirements and specifications. These test cases cover various normal operating scenarios and potential abnormal situations of the CAN communication interface. Subsequently, professional scripting tools or programming languages (such as CAPL) can be used to generate corresponding automated test scripts based on these automated test cases.
[0096] These automated test scripts can then be loaded into a test environment specifically designed for CAN communication. This test environment can include the following key components: a virtual CAN network, which can simulate the behavior of a real CAN network without relying on physical hardware, allowing R&D personnel to test and verify the communication protocol in the early stages of product development; and a simulator, which can simulate the various nodes in the CAN network, enabling them to send, receive, and process CAN messages to simulate the behavior of real devices.
[0097] In the testing environment, automated test scripts will execute according to preset logic and steps to test the CAN communication interface based on a virtual CAN network and simulator.
[0098] These tests may include: basic functional tests of the interface, including message sending and receiving capabilities; network performance tests, such as message transmission latency and packet loss rate; abnormal situation handling capability tests, such as performance when the network load is too high or the node fails; compatibility tests; long-term operational stability tests to verify the reliability and durability of the system, etc., which are not limited in this application.
[0099] In some implementations, automated test scripts can be used to control the simulator to generate and receive signal frames from the virtual controller area network (Controller Area Network) based on the virtual nodes, virtual connections, and communication parameters of the virtual Controller Area Network, thereby simulating the communication process between different nodes in the Controller Area Network.
[0100] By designing automated test scripts, virtual nodes, virtual connections, and communication parameters in a virtual CAN network can be precisely controlled, thereby generating and receiving signal frames from the controller area network on the simulator.
[0101] In automated testing processes, test scripts can precisely manipulate the virtual CAN network environment based on preset test scenarios and parameters. This is achieved by loading the automated test script into a test environment designed for CAN communication and calling the simulator and application programming interface (API) of the virtual environment within the test environment. During testing, the simulator simulates a real CAN communication environment, generating and receiving CAN frames. The virtual environment monitors the testing process and records the test results.
[0102] For example, the automated test script first configures virtual nodes according to the test requirements. These nodes simulate physical devices in an actual CAN network at the software level. Next, the script establishes connections between the virtual nodes, simulating physical lines on the CAN bus. To ensure correct transmission of signal frames, the script sets communication parameters according to the test case requirements. These parameters may include data frame length, remote frame requests, error frame generation, and overload frame handling. The script controls the simulator to generate various types of CAN signal frames, such as data frames, remote frames, and error frames, to simulate the communication behavior of different nodes in the network. These frames can carry specific data for testing data processing and responses in the network. Simultaneously, the script configures the simulator to receive signal frames from other nodes in the virtual network and parse and process them. This process verifies whether nodes can correctly receive, parse, and respond to messages on the network. Through these script operations, the communication process between different nodes in a CAN network can be simulated, including functions such as inter-node synchronous communication, event triggering, error handling, and network management.
[0103] This highly automated testing method not only simulates complex network interactions but also ensures that the communication interface of the controller area network can work stably and efficiently in diverse test scenarios.
[0104] In some implementations, the communication process of different nodes in the CAN network can be monitored through a virtual environment, and communication data can be recorded to generate a test report.
[0105] Monitoring tools can be deployed in a virtual environment, and these tools can capture and analyze data flows in the network.
[0106] These monitoring tools can be used to monitor the communication activities of all nodes in a CAN network in real time and record key information during the communication process. The communication activities of nodes in a CAN network include data frames, remote frames, error frames, and overload frames. Key information during the communication process includes frame ID, data content, transmission timestamp, reception timestamp, and frame type.
[0107] The monitored communication data can be stored in log files, which can then be analyzed to check whether the communication conforms to the expected protocols and standards. Abnormal situations during the communication process can be identified, such as communication interruptions, frequent occurrences of error frames, and excessively long response times. Detailed test reports are generated based on the analysis results.
[0108] In some implementations, interface data and transmission data of the CAN network can be extracted through automated test cases. Then, a data table is generated based on the interface data and transmission data. The data table is parsed to obtain multiple test items. Multiple test scripts are generated based on the multiple test items. The multiple test scripts are merged to obtain an automated test script.
[0109] It should be understood that automated test cases typically define input data, verification processes, and output data for the test item. This data can be stored in the form of files, such as DBC files and ARXML files.
[0110] For example, interface variables and transmission data variables can be extracted by traversing DBC and ARXML files, and these extracted variables can be input into a test generation tool. The test generation tool generates a test input table based on the extracted variables. The test input table defines the test input data and expected output. By parsing the contents of this table, a corresponding test script can be generated according to the test item. The test script generation tool can merge the generated test scripts to finally generate a CAPL automated test script.
[0111] A DBC file is a file format used to describe message communication on a Controller Area Network (CAN). It defines the signals, messages, frame formats, nodes (controllers) on the CAN network, and the communication relationships between them. In the automotive industry, DBC files are commonly used to define the communication protocols for ECUs (Electronic Control Units).
[0112] ARXML files are XML description file formats used in the Automotive Open System Architecture (AUTOSAR) standard. AUTOSAR is a global automotive industry consortium that aims to create and promote an open, standardized software architecture for automotive electronic control units (ECUs) and in-vehicle networks. ARXML files are used to describe the ECU's software architecture, including configuration, parameters, interfaces, and data exchange formats.
[0113] The above method for generating test scripts can generate multiple test scripts based on test cases, and then merge these scripts to improve testing efficiency. This test script generation method can enhance testing flexibility.
[0114] Some implementations of this application can also integrate automated test scripts into continuous integration and continuous deployment processes; continuous integration and continuous deployment can be used to continuously verify and rapidly iterate automated test scripts.
[0115] Continuous Integration (CI) and Continuous Deployment (CD) are important components of modern software development, helping to improve development efficiency, software quality, and delivery speed.
[0116] CI can be used for version control, which involves using a version control system (such as Git) to manage source code and ensure all developers are on the same page. CI can also be used for automated testing, which involves writing unit tests, integration tests, and end-to-end tests and ensuring these tests run automatically, thus automating the build process. It encourages developers to frequently integrate code into the main branch to reduce merge conflicts and integration issues.
[0117] CD can be used to script the deployment process so that it can be automated, and use blue-green deployment or canary release strategies to reduce deployment risks and allow for rapid rollback.
[0118] Using CI / CD tools to automate the deployment process eliminates the need for human intervention throughout the entire build-to-deployment process, thereby accelerating software development and delivery while maintaining or improving software quality.
[0119] The following is a detailed description and explanation of the solutions in the embodiments of the present invention, using specific application examples:
[0120] In this embodiment of the application, a CAN communication interface testing method is provided, which is used to test the CAN network interface of a vehicle.
[0121] For detailed testing procedures, please refer to [link / reference]. Figure 2 , Figure 2 This is another flowchart of a controller area network communication interface testing method provided in some embodiments of this application. Figure 2 First, the simulator and virtual environment are configured, and the software system for deploying the virtual CAN network is deployed. This may include setting the creation data of the virtual CAN network through the user interface provided by the virtual environment. Then, based on this creation data, the corresponding virtual CAN network is generated in the virtual environment, and the virtual nodes and communication parameters are configured.
[0122] Based on testing requirements, use a scripting language (such as CAPL) to write automated test scripts. A script can define multiple test cases, each containing a series of test steps and expected results.
[0123] After creating the virtual CAN network, import the A2L and CAPL test scripts. The A2L file is a commonly used file format in automotive electronic control unit (ECU) calibration, used to describe in detail the ECU's communication parameters, calibration variables, addresses of observed variables, and calculation formulas for physical values. A2L files can be generated from ELF and HEX files using A2L generation tools. ELF files store program code and data for easy linking and execution. In the automotive field, ELF files typically contain the ECU's machine code instructions and the data required for program execution. HEX files are a text-based file format containing machine code, commonly used in firmware flashing and update processes.
[0124] Automated testing is performed based on imported A2L and CAPL test scripts, and test reports are generated. Specifically, the test scripts can be loaded into the test system, and test tasks can be executed automatically by calling the APIs of the simulator and virtual environment. During the test, the simulator will simulate a real CAN communication environment, generating and receiving CAN frames. The virtual environment will monitor the test process and record the test results. This step can be integrated into CI / CD and scheduled to be implemented automatically.
[0125] After the test is completed, the system will generate a test report, displaying the test results and performance data. Testers can analyze the test results based on the report to evaluate the performance and stability of the CAN communication interface.
[0126] The embodiments of this application use automated test scripts to perform tests on the CAN network communication interface, which can greatly improve test efficiency and reduce manual intervention and errors; configuring a virtual CAN network based on a virtual environment allows testers to flexibly configure the test environment and simulate the CAN communication process in different scenarios; and testing can be performed without actual hardware, reducing test costs and shortening the development cycle.
[0127] The above is a description of the implementation method of the controller area network communication interface testing method provided in this application.
[0128] The implementation of the controller area network communication interface testing device provided in this application will now be described in detail with reference to the accompanying drawings.
[0129] Regarding the controller area network (CNR) communication interface testing method provided in the above embodiments, this application also provides a CNR communication interface testing apparatus for implementing the above method, such as... Figure 3 As shown, Figure 3 This is a schematic block diagram of a controller area network (CNR) communication interface testing device according to an embodiment of this application. The CNR communication interface testing device 300 includes:
[0130] Receiver module 301 is used to receive controller area network creation data;
[0131] The generation module 302 is used to generate a virtual controller area network in a virtual environment by creating data through the controller area network;
[0132] Execution module 303 is used to execute automated test scripts based on a virtual controller area network and simulator to test the controller area network communication interface;
[0133] The automated test scripts are used to control the communication process between the simulator and the controller area network, while the simulator is used to simulate the communication environment and behavior of the real controller area network.
[0134] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0135] like Figure 4 As shown, this application embodiment also provides an electronic device, the electronic device 400 including a memory 401 and one or more processors 402. Figure 4 (Only one is shown in the image) and a computer program stored in memory 401 and executable on processor 402. Memory 401 stores software programs and units. Processor 402 executes various functional applications and data processing by running the software programs and units stored in memory 401 to obtain resources corresponding to the aforementioned preset events. Optionally, processor 401 implements the aforementioned controller area network communication interface testing method by running the aforementioned computer program stored in memory 402.
[0136] Memory 401 serves as a non-transitory computer-readable medium for storing non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory 401 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 401 may optionally include memory remotely located relative to the processor, which can be connected to the processor 402 via a network.
[0137] It is understood that the content of the above method embodiments is applicable to the embodiments of this electronic device. The specific functions implemented by the embodiments of this electronic device are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0138] This application also provides a vehicle in which the CAN communication interface is tested using the aforementioned controller area network communication interface testing method, device, or the electric drive assembly of the aforementioned electronic equipment. Specifically, the vehicle can be a private car, such as a sedan, SUV, MPV, or pickup truck. The vehicle can also be a commercial vehicle, such as a van, bus, small truck, or large trailer. The vehicle can be a gasoline-powered vehicle or a new energy vehicle. When the vehicle is a new energy vehicle, it can be a hybrid vehicle or a pure electric vehicle.
[0139] It is understood that the content of the above method embodiments is applicable to this vehicle embodiment. The specific functions implemented in this vehicle embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0140] This application also provides a computer program product, which includes a computer program that, when executed by one or more processors, can implement the steps of the controller area network communication interface testing method described above.
[0141] It is understood that the content of the above method embodiments is applicable to this computer program product. The specific functions implemented by the embodiments of this computer program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0142] The controller area network (CNB) communication interface testing method, apparatus, electronic device, vehicle, and computer program product provided in this application embodiment receive controller area network (CNB) creation data; then, a virtual controller area network (CNB) is generated in a virtual environment using the CNB creation data; finally, an automated test script is executed based on the virtual CNB and a simulator to test the CNB communication interface; wherein, the automated test script is used to control the communication process between the simulator and the CNB, and the simulator is used to simulate the communication environment and communication behavior of a real controller area network. In this embodiment, by using simulators and virtual environments, the purchase and maintenance of a large number of real hardware devices are eliminated, thereby reducing testing costs. Simulators and virtual environments allow for the rapid creation and configuration of test environments. Automated test scripts reduce manual intervention, thus shortening the testing cycle and improving testing efficiency. Testing in a virtual environment avoids potential damage and security risks that may occur on actual hardware. Simulators and virtual environments can simulate various scenarios and conditions, thereby covering more test cases and improving test coverage. Integrating automated test scripts into the CI / CD process enables continuous code verification and rapid iteration, thereby quickly discovering and fixing problems and improving software quality. Since the test environment is based on simulators and virtual environments, it can be easily copied and expanded, facilitating collaboration between teams and cross-platform testing. The embodiments provided in this application provide an efficient, safe, and reliable solution for testing CAN communication interfaces by building simulators and virtual environments combined with automated test scripts. This effectively reduces testing costs, improves testing efficiency, enhances testing security and reliability, and promotes the implementation of continuous integration and continuous deployment.
[0143] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0144] Although specific embodiments are described herein, those skilled in the art will recognize that many other modifications or alternative embodiments are also within the scope of this disclosure. For example, any of the functions and / or processing capabilities described in connection with a particular device or component can be performed by any other device or component. Furthermore, while various exemplary embodiments and architectures have been described according to embodiments of this disclosure, those skilled in the art will recognize that many other modifications to the exemplary embodiments and architectures described herein are also within the scope of this disclosure.
[0145] The foregoing description, with reference to block diagrams and flowcharts of systems, methods, systems, and / or computer program products according to exemplary embodiments, has described certain aspects of this disclosure. It should be understood that one or more blocks in the block diagrams and flowcharts, as well as combinations of blocks in the block diagrams and flowcharts, can be implemented by executing computer-executable program instructions, respectively. Similarly, according to some embodiments, some blocks in the block diagrams and flowcharts may not need to be executed in the order shown, or may not all need to be executed. Furthermore, additional components and / or operations beyond those shown in the blocks in the block diagrams and flowcharts may exist in some embodiments.
[0146] Therefore, blocks in block diagrams and flowcharts support combinations of means for performing a specified function, combinations of elements or steps for performing a specified function, and program instruction means for performing a specified function. It should also be understood that each block in a block diagram and flowchart, and combinations of blocks in block diagrams and flowcharts, can be implemented by a dedicated hardware computer system or a combination of dedicated hardware and computer instructions that performs a specific function, element, or step.
[0147] The program modules, applications, etc., described herein may include one or more software components, including, for example, software objects, methods, data structures, etc. Each such software component may include computer-executable instructions that, in response to execution, cause at least a portion of the functionality described herein (e.g., one or more operations of the exemplary methods described herein) to be performed.
[0148] Software components can be coded using any of a variety of programming languages. An exemplary programming language could be a low-level programming language, such as assembly language associated with a specific hardware architecture and / or operating system platform. Software components including assembly language instructions may need to be converted into executable machine code by an assembler before being executed by the hardware architecture and / or platform. Another exemplary programming language could be a higher-level programming language that is portable across multiple architectures. Software components including higher-level programming languages may need to be converted into an intermediate representation by an interpreter or compiler before execution. Other examples of programming languages include, but are not limited to, macro languages, shell or command languages, job control languages, scripting languages, database query or search languages, or report writing languages. In one or more exemplary embodiments, a software component containing instructions from one of the above-described programming language examples can be executed directly by the operating system or other software components without first being converted into another form.
[0149] Software components can be stored as files or other data storage structures. Software components of similar type or related function can be stored together in a specific directory, folder, or library. Software components can be static (e.g., pre-defined or fixed) or dynamic (e.g., created or modified at runtime).
[0150] The embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of this application.
Claims
1. A method for testing controller area network communication interfaces, characterized in that, Includes the following steps: Receive controller area network creation data; The data created through the controller area network generates a virtual controller area network in the virtual environment; Automated test scripts are executed based on the virtual controller area network and simulator to test the communication interface of the controller area network, including: Generating the automated test script based on the automated test cases includes: extracting interface data and transmission data of the controller area network through the automated test cases; generating a data table based on the interface data and the transmission data; parsing the data table to obtain multiple test items; generating multiple test scripts corresponding to the multiple test items; and merging the multiple test scripts to obtain the automated test script. The automated test script is loaded into the test environment of the controller area network, the test environment including the virtual controller area network and the simulator; Controlling the automated test script to test the communication interface of the controller area network based on the virtual controller area network and the simulator includes: controlling the simulator to generate and receive signal frames of the controller area network according to the virtual nodes, virtual connections and communication parameters of the virtual controller area network, so as to simulate the communication process of different nodes in the controller area network. The automated test script is used to control the communication process between the simulator and the controller area network, and the simulator is used to simulate the communication environment and communication behavior of the real controller area network.
2. The controller area network communication interface testing method according to claim 1, characterized in that, The step of generating a virtual controller area network (CNR) in a virtual environment through the CNR creation data includes: The controller area network (CAN) generates virtual nodes, virtual connections, and communication parameters by creating data within the CAN.
3. The controller area network communication interface testing method according to claim 1, characterized in that, The execution of automated test scripts based on the virtual controller area network and simulator includes: The virtual environment is used to monitor the communication process of different nodes in the controller area network and record the communication data. A test report is generated using the communication data.
4. The controller area network communication interface testing method according to any one of claims 1-3, characterized in that, The method further includes: Integrate the automated test scripts into the continuous integration and continuous deployment process; The automated test scripts are continuously validated and rapidly iterated through continuous integration and continuous deployment.
5. A controller area network communication interface testing device, characterized in that, The device includes: The receiving module is used to receive controller area network creation data; A generation module is used to generate a virtual controller area network in a virtual environment by creating data through the controller area network; An execution module is used to execute automated test scripts based on the virtual controller area network and simulator to test the communication interface of the controller area network, including: Generating the automated test script based on the automated test cases includes: extracting interface data and transmission data of the controller area network through the automated test cases; generating a data table based on the interface data and the transmission data; parsing the data table to obtain multiple test items; generating multiple test scripts corresponding to the multiple test items; and merging the multiple test scripts to obtain the automated test script. The automated test script is loaded into the test environment of the controller area network, the test environment including the virtual controller area network and the simulator; Controlling the automated test script to test the communication interface of the controller area network based on the virtual controller area network and the simulator includes: controlling the simulator to generate and receive signal frames of the controller area network according to the virtual nodes, virtual connections and communication parameters of the virtual controller area network, so as to simulate the communication process of different nodes in the controller area network. The automated test script is used to control the communication process between the simulator and the controller area network, and the simulator is used to simulate the communication environment and communication behavior of the real controller area network.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the controller area network communication interface testing method as described in any one of claims 1 to 4.
7. A vehicle, characterized in that, The controller area network (CNN) communication interface in the vehicle is tested using the CNN communication interface test method as described in any one of claims 1-4, the CNN communication interface test device as described in claim 5, or the electronic device as described in claim 6.