CAN network virtualization method, system, device and medium

The CAN hardware is simulated through the QEMU virtual machine, and the virtual nodes are connected with Kvaser Virtual CAN Driver driver, which solves the problems of high R&D costs and long development cycle of traditional CAN bus hardware, realizes the simulation and operation of the virtual CAN network, and improves the flexibility and development efficiency of the model.

CN119835109APending Publication Date: 2025-04-15XIAN AVIATION COMPUTING TECH RES INST OF AVIATION IND CORP OF CHINA

Patent Information

Application Number
CN202411810280.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

Traditional CAN bus hardware has high R&D costs and long development cycles, which makes it impossible for drivers and application software to be developed and verified in advance.

Method used

The CAN hardware is simulated through the QEMU virtual machine, a virtual CAN network is established, and the virtual nodes are connected with the Kvaser Virtual CAN Driver driver to realize the simulation and operation of the virtual CAN hardware nodes.

Benefits of technology

It separates the logical analysis and actual operation of virtual devices, reduces coupling, improves model flexibility, solves the problems of high hardware costs and long development cycles of CAN networks, and allows for advance development and verification of drivers and application software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119835109A_ABST
    Figure CN119835109A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computer hardware virtualization, and discloses a CAN network virtualization method, system, device and medium, a virtual CAN network is established through QEMU virtual machines, each QEMU virtual machine can be used as a node, all the nodes are connected through a Kvaser Virtual CAN Driver driver to form a virtual CAN network, the virtual CAN network can be used for simulation and testing, and the virtual CAN network can be used for simulating and testing. Therefore, logic analysis of the virtual device is separated from actual operation of the device, the front end is mainly used for reading, writing and the like of a register, and when hardware operation is involved, the operation is transmitted to the rear end, so that coupling is reduced, the flexibility of a model is improved, and the reliability of the model is improved. The problem that drivers and application software cannot be developed and verified in advance due to high CAN network hardware cost and long development period is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of computer hardware virtualization and discloses a CAN network virtualization method, system, equipment and medium. Background Art

[0002] CAN bus has been widely used in various technical fields such as industrial control, commercial products, military defense, aerospace technology, etc. due to its low cost, high reliability, strong anti-interference ability and high real-time performance. However, due to the high R&D cost and long development cycle of traditional CAN bus hardware, it cannot meet the needs of rapid testing and verification of drivers and application software during the design and development process. Summary of the invention

[0003] The purpose of the present invention is to provide a CAN network virtualization method, system, device and medium, which solves the problem that the driver and application software cannot be developed and verified in advance due to the high hardware cost and long development cycle of the CAN network.

[0004] In order to achieve the above technical effects, the technical solution adopted by the present invention is:

[0005] A CAN network virtualization method, comprising:

[0006] The CAN hardware is simulated based on the QEMU virtual machine to obtain a CAN hardware node simulation model based on the CAN network;

[0007] Build a CAN hardware node network based on virtual CAN driver;

[0008] The working state of the CAN hardware node is simulated by using the QEMU virtual machine to determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states;

[0009] According to the specific operation of the actual device corresponding to the CAN hardware node, the CAN hardware node is operated using the virtual CAN driver; wherein:

[0010] When the CAN hardware node needs to send a message, the CAN hardware node network implements the message sending through the library function canWrite of the virtual CAN driver;

[0011] When the CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the library function canRead function of the virtual CAN driver.

[0012] Furthermore, the method for determining the specific operation of the actual device corresponding to the CAN hardware node includes:

[0013] The QEMU virtual machine is used to simulate the working state of the CAN hardware node and analyze the behavior logic of the CAN hardware node; according to the behavior logic of the CAN hardware node, the specific operation of the actual device corresponding to the CAN hardware node is determined; the behavior logic includes hardware device initialization and interrupt enabling.

[0014] Furthermore, when the virtual CAN driver is used to operate the CAN hardware node, the -device parameter of the QEMU virtual machine is used to start the CAN hardware node, and the -object parameter is used to start the CAN hardware node network, and the CAN hardware node is associated as a network.

[0015] In order to achieve the above technical effects, the present invention also provides a CAN network virtualization system for implementing the CAN network virtualization method, comprising:

[0016] The hardware node building module is used to simulate the CAN hardware based on the QEMU virtual machine and obtain a CAN hardware node simulation model based on the CAN network;

[0017] CAN network building module, used to build a CAN hardware node network based on virtual CAN driver;

[0018] An analysis module is used to simulate the working state of the CAN hardware node using the QEMU virtual machine to determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states;

[0019] The simulation module is used to operate the CAN hardware node using a virtual CAN driver according to the specific operation of the actual device corresponding to the CAN hardware node; wherein:

[0020] When the CAN hardware node needs to send a message, the CAN hardware node network implements the message sending through the library function canWrite of the virtual CAN driver;

[0021] When the CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the library function canRead function of the virtual CAN driver.

[0022] Furthermore, the analysis module uses the QEMU virtual machine to simulate the working state of the CAN hardware node and analyzes the behavior logic of the CAN hardware node; according to the behavior logic of the CAN hardware node, the specific operation of the actual device corresponding to the CAN hardware node is determined; the behavior logic includes hardware device initialization and interrupt enabling.

[0023] Furthermore, in the simulation module, when the virtual CAN driver is used to operate the CAN hardware node, the -device parameter of the QEMU virtual machine is used to start the CAN hardware node, and the -object parameter is used to start the CAN hardware node network, and the CAN hardware nodes are associated as a network.

[0024] To achieve the above technical effects, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the CAN network virtualization method when executing the computer program.

[0025] In order to achieve the above technical effects, the present invention also provides a computer-readable storage medium, which stores a computer program for executing the CAN network virtualization method.

[0026] Compared with the prior art, the present invention has the following beneficial effects: the present invention establishes a virtual CAN network through a QEMU virtual machine, each QEMU virtual machine can be used as a node, and each node is connected through the Kvaser Virtual CAN Driver to form a virtual CAN network, which can be used for simulation and testing, thereby realizing the separation of the logic analysis of the virtual device and the actual operation of the device, wherein the front end mainly realizes the reading and writing of registers, etc., and when it involves the operation of the hardware, the operation is passed to the back end, thereby reducing coupling, improving the flexibility of the model, and solving the problem that the driver and application software cannot be developed and verified in advance due to the high cost of CAN network hardware and the long development cycle. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 It is a flow chart of the CAN network virtualization method in the embodiment;

[0028] Figure 2 It is a structural block diagram of the CAN network virtualization system in the embodiment;

[0029] Among them, 1. Hardware node construction module; 2. CAN network construction module; 3. Analysis module; 4. Simulation module. DETAILED DESCRIPTION

[0030] The present invention is further described in detail below in conjunction with the embodiments and drawings. However, it should not be understood that the scope of the above subject matter of the present invention is limited to the following embodiments, and all technologies realized based on the content of the present invention belong to the scope of the present invention.

[0031] Example

[0032] See also Figure 1-Figure 2 , a CAN network virtualization method, comprising:

[0033] The CAN hardware is simulated based on the QEMU virtual machine to obtain a CAN hardware node simulation model based on the CAN network;

[0034] Build a CAN hardware node network based on Kvaser Virtual CAN Driver (virtual CAN driver);

[0035] The working state of the CAN hardware node is simulated by using the QEMU virtual machine to determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states;

[0036] According to the specific operation of the actual device corresponding to the CAN hardware node, the CAN hardware node is operated using Kvaser Virtual CANDriver; wherein:

[0037] When a CAN hardware node needs to send a message, the CAN hardware node network uses the canWrite function of the Kvaser Virtual CANDriver library to send the message.

[0038] When a CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the canRead function of the Kvaser Virtual CANDriver library.

[0039] In this embodiment, the working state of the CAN hardware node is simulated by using the QEMU virtual machine, the specific operation of the actual device corresponding to the CAN hardware node is determined, and the CAN hardware node is operated by using the Kvaser Virtual CAN Driver; when the CAN hardware node needs to send a message, the CAN hardware node network realizes the sending of the message through the library function canWrite function of the Kvaser Virtual CAN Driver; when the CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the library function canRead function of the Kvaser Virtual CAN Driver. The present invention establishes a virtual CAN network through the QEMU virtual machine, each QEMU virtual machine can be used as a node, and each node is connected by the KvaserVirtual CAN Driver to form a virtual CAN network, which can be used for simulation and testing, thereby realizing the separation of the logical analysis of the virtual device and the actual operation of the device, wherein the front end mainly realizes the reading and writing of the register, etc., and when it comes to the operation of the hardware, the operation is passed to the back end, thereby reducing coupling, improving the flexibility of the model, and solving the problem that the driver and application software cannot be developed and verified in advance due to the high cost of CAN network hardware and the long development cycle.

[0040] In this embodiment, the method for determining the specific operation of the actual device corresponding to the CAN hardware node includes:

[0041] The QEMU virtual machine is used to simulate the working state of the CAN hardware node and analyze the behavior logic of the CAN hardware node; according to the behavior logic of the CAN hardware node, the specific operation of the actual device corresponding to the CAN hardware node is determined; the behavior logic includes hardware device initialization and interrupt enabling.

[0042] In this embodiment, when the Kvaser Virtual CAN Driver is used to operate the CAN hardware node, the -device parameter of the QEMU virtual machine is used to start the CAN hardware node, the -object parameter is used to start the CAN hardware node network, and the CAN hardware node is associated as a network.

[0043] Based on the same inventive concept, this embodiment also provides a CAN network virtualization system, including:

[0044] The hardware node construction module 1 is used to simulate the CAN hardware based on the QEMU virtual machine to obtain a CAN hardware node simulation model based on the CAN network;

[0045] CAN network construction module 2, used to build a CAN hardware node network based on Kvaser Virtual CAN Driver (virtual CAN driver);

[0046] Analysis module 3, used to simulate the working state of the CAN hardware node using the QEMU virtual machine, and determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states;

[0047] The simulation module 4 is used to operate the CAN hardware node using the Kvaser Virtual CAN Driver according to the specific operation of the actual device corresponding to the CAN hardware node; wherein:

[0048] When a CAN hardware node needs to send a message, the CAN hardware node network uses the canWrite function of the Kvaser Virtual CANDriver library to send the message.

[0049] When a CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the canRead function of the Kvaser Virtual CANDriver library.

[0050] Based on the same inventive concept, this embodiment also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the CAN network virtualization method when executing the computer program.

[0051] Specifically, the computer device may be a computer terminal, a server or a similar computing device.

[0052] Based on the same inventive concept, this embodiment also provides a computer-readable storage medium, which stores a computer program for executing the CAN network virtualization method.

[0053] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0054] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A CAN network virtualization method, characterized in that: include: The CAN hardware is simulated based on the QEMU virtual machine to obtain a CAN hardware node simulation model based on the CAN network; Build a CAN hardware node network based on virtual CAN driver; The working state of the CAN hardware node is simulated by using the QEMU virtual machine to determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states; According to the specific operation of the actual device corresponding to the CAN hardware node, the CAN hardware node is operated using the virtual CAN driver; wherein: When the CAN hardware node needs to send a message, the CAN hardware node network implements the message sending through the library function canWrite of the virtual CAN driver; When the CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the library function canRead function of the virtual CAN driver.

2. The CAN network virtualization method according to claim 1, characterized in that: Methods for determining the specific operation of the actual device corresponding to the CAN hardware node include: The QEMU virtual machine is used to simulate the working state of the CAN hardware node and analyze the behavior logic of the CAN hardware node; according to the behavior logic of the CAN hardware node, the specific operation of the actual device corresponding to the CAN hardware node is determined; the behavior logic includes hardware device initialization and interrupt enabling.

3. The CAN network virtualization method according to claim 1, characterized in that: When using the virtual CAN driver to operate the CAN hardware node, use the -device parameter of the QEMU virtual machine to start the CAN hardware node, and the -object parameter to start the CAN hardware node network, and associate the CAN hardware node into a network.

4. A CAN network virtualization system, used to implement the CAN network virtualization method according to any one of claims 1 to 3, characterized in that: include: The hardware node building module is used to simulate the CAN hardware based on the QEMU virtual machine and obtain a CAN hardware node simulation model based on the CAN network; CAN network building module, used to build a CAN hardware node network based on virtual CAN driver; An analysis module is used to simulate the working state of the CAN hardware node using the QEMU virtual machine to determine the specific operation of the actual device corresponding to the CAN hardware node; the working state includes data reception and data transmission; the specific operation includes setting baud rate parameters, setting receiving filters, enabling interrupts, receiving and sending CAN messages, resetting devices, and saving register states; The simulation module is used to operate the CAN hardware node using a virtual CAN driver according to the specific operation of the actual device corresponding to the CAN hardware node; wherein: When the CAN hardware node needs to send a message, the CAN hardware node network implements the message sending through the library function canWrite of the virtual CAN driver; When the CAN hardware node needs to receive a message, the CAN hardware node network receives the message through the library function canRead function of the virtual CAN driver.

5. The CAN network virtualization system according to claim 4, characterized in that: The analysis module uses the QEMU virtual machine to simulate the working state of the CAN hardware node and analyzes the behavior logic of the CAN hardware node; according to the behavior logic of the CAN hardware node, the specific operation of the actual device corresponding to the CAN hardware node is determined; the behavior logic includes hardware device initialization and interrupt enabling.

6. The CAN network virtualization system according to claim 4, characterized in that: In the simulation module, when the virtual CAN driver is used to operate the CAN hardware node, the -device parameter of the QEMU virtual machine is used to start the CAN hardware node, and the -object parameter is used to start the CAN hardware node network, and the CAN hardware nodes are associated as a network.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the CAN network virtualization method described in any one of claims 1 to 3 is implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the CAN network virtualization method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Embedded software simulation target machine construction method based on general computing platform

    CN116401018A

  • CAN bus parameter simulation analysis method and device based on CANoe tool

    CN118473950A

Cited By

  • Hardware-in-loop test-oriented MCP2515CAN controller virtual simulation and integration method and system

    CN121050413A

  • Mcp2515 can controller virtual simulation and integration method and system for hardware-in-the-loop test

    CN121050413B