CAN communication method and system, electronic equipment and computer readable storage medium

By building a CAN frame black and white list management mechanism, the interactive compatibility problem between different CAN networks is solved, and efficient communication and security improvement of CAN networks is achieved.

CN120499097APending Publication Date: 2025-08-15BEIJING HIGHLANDER DIGITAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510623557.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Interaction needs between different CAN networks are urgent, but due to the compatibility of underlying electrical characteristics, existing CAN to CAN box products have direct frame transmission, resulting in excessive bus load and affecting system stability and performance.

Method used

Build a protocol architecture, manage CAN frame black and white lists, provide frame filtering functions, support upper computer operation black and white lists, reduce bus load, and improve communication efficiency and security.

Benefits of technology

By accurately controlling CAN frame transmission, the bus load is reduced, communication efficiency and security are improved, and the efficient interaction needs of multi-CAN networks are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120499097A_ABST
    Figure CN120499097A_ABST
Patent Text Reader

Abstract

The invention discloses a CAN communication method and system, electronic equipment and a computer readable storage medium, the CAN communication method is applied to a CAN communication system, the CAN communication system comprises a plurality of independent CAN interfaces, each CAN interface is provided with a corresponding area controller, each area controller is in communication connection with a main control controller, and the main control controller is connected with the CAN interface. A preset filtering rule is stored in the main control controller; the method comprises the following steps: for an area controller of any CAN interface, responding to a received target data frame, and sending the target frame to a main control controller; and the main control controller responds to the received target frame, analyzes the target frame to obtain a composite code of the target frame, determines whether the target frame is allowed to pass or not according to a preset filtering rule and the composite code, responds to the target frame is allowed to pass, and forwards the target frame to the target CAN interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of industrial communication networks, and specifically relates to a CAN communication method, a CAN communication system, an electronic device, and a computer-readable storage medium. Background Art

[0002] In many fields such as automotive electronics and industrial automation, CAN networks have been widely used due to their advantages such as real-time performance, reliability and flexibility. With the expansion of application scenarios, the demand for CAN networks continues to rise, and the need for interaction between different CAN networks is becoming increasingly urgent.

[0003] However, different CAN networks face compatibility issues in their underlying electrical characteristics, limiting the flexible expansion of network nodes. Networking must strictly adhere to specific rules, making it difficult to achieve fast and efficient information communication between different CAN networks. Furthermore, existing CAN-to-CAN converters on the market suffer from significant flaws. They often transparently transmit CAN frames and lack user-defined functionality within the host computer. This design can easily lead to CAN bus overload, impacting the stability and performance of the entire system. Summary of the Invention

[0004] This application aims to solve at least one of the technical problems existing in the prior art. To this end, this application proposes a CAN communication method, system, electronic device, and computer-readable storage medium. By building a protocol architecture, managing CAN frame blacklists and whitelists, providing frame filtering functions, and supporting host computer operation of blacklists and whitelists, this reduces bus load and improves communication efficiency and security.

[0005] In a first aspect, an embodiment of the present application provides a CAN communication method, which is applied to a CAN communication system. The CAN communication system includes multiple independent CAN interfaces, each CAN interface is configured with a corresponding regional controller, each regional controller is communicatively connected to a master controller, and the master controller stores preset filtering rules;

[0006] The method comprises:

[0007] For any one of the CAN interface zone controllers, in response to receiving a target data frame, sending the target frame to the master controller;

[0008] In response to receiving the target frame, the main controller parses the target frame to obtain the composite code of the target frame, determines whether the target frame is allowed to pass according to the preset filtering rules and the composite code, and forwards the target frame to the target CAN interface in response to the target frame being allowed to pass.

[0009] In some embodiments, after obtaining the composite encoding of the target frame, the method further includes:

[0010] The composite code is parsed to obtain a target frame ID of the target frame.

[0011] In some embodiments, the preset filtering rules include allowing only frame IDs in a whitelist to pass;

[0012] Determine whether the target frame is allowed to pass based on preset filtering rules and composite encoding, including:

[0013] Determine whether the target frame ID is in the whitelist;

[0014] In response to the target frame ID being in the white list, it is confirmed that the target frame is allowed to pass.

[0015] In some embodiments, the preset filtering rules include allowing only frame IDs that are not in the blacklist to pass;

[0016] Determine whether the target frame is allowed to pass based on preset filtering rules and composite encoding, including:

[0017] Determine whether the target frame ID is not in the blacklist;

[0018] In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

[0019] In some embodiments, the preset filtering rules include allowing only frame IDs that are in a whitelist and not in a blacklist to pass;

[0020] Determine whether the target frame is allowed to pass based on preset filtering rules and composite encoding, including:

[0021] Determine whether the target frame ID is in the whitelist;

[0022] In response to the target frame ID being in the white list, determining whether the target frame ID is not in the black list;

[0023] In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

[0024] In some embodiments, determining whether the target frame is allowed to pass according to the preset filtering rules and the composite code further includes:

[0025] Determine whether the target frame ID is not in the blacklist;

[0026] In response to the target frame ID not being in the blacklist, determining whether the target frame ID is in the whitelist;

[0027] In response to the target frame ID being in the white list, it is confirmed that the target frame is allowed to pass.

[0028] In some embodiments, the master controller is communicatively connected to a host computer;

[0029] The method further comprises:

[0030] The user can add, delete, modify and / or check the blacklist and / or whitelist in the preset filtering rules stored in the main controller through the host computer.

[0031] In a second aspect, an embodiment of the present application provides a CAN communication system, comprising a plurality of independent CAN interfaces, each CAN interface being configured with a corresponding regional controller, each regional controller being communicatively connected to a master controller, and the master controller storing preset filtering rules;

[0032] Each regional controller is configured to send a target frame to the master controller in response to receiving the target data frame;

[0033] The main controller is configured to parse the target frame in response to receiving the target frame, obtain the composite code of the target frame, determine whether the target frame is allowed to pass according to the preset filtering rules and the composite code, and forward the target frame to the target CAN interface in response to the target frame being allowed to pass.

[0034] In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the CAN communication method described in the first aspect are implemented.

[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the CAN communication method described in the first aspect are implemented.

[0036] The technical solution provided in this application offers a frame filtering function. By setting up frame filtering and building a complete protocol architecture, it enables management of CAN frame whitelists and blacklists. Users can use a host computer to conveniently add, delete, modify, and query these lists and blacklists, enabling precise control of CAN frame transmission. This solution effectively reduces bus load, improves communication efficiency and security, and enables devices to have router-like routing capabilities, meeting the needs of efficient interaction across multiple CAN networks.

[0037] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0039] Figure 1 A schematic diagram of the CAN interface structure provided in an embodiment of the present application.

[0040] Figure 2 A flow chart of a CAN communication method provided in an embodiment of the present application.

[0041] Figure 3 A schematic diagram of the CAN communication system structure provided in an embodiment of the present application.

[0042] Figure 4 This is a schematic structural diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The following describes embodiments of the present application in more detail with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are for illustrative purposes only and are not intended to limit the scope of protection of the present application.

[0044] It should be understood that the various steps described in the method embodiments of the present application can be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.

[0045] As described in the technical background section, the CAN bus has become a core fieldbus technology for inter-device communication in high-reliability fields such as industrial automation and automotive electronics, thanks to its real-time performance, anti-interference capabilities, and standardization. However, as the integration of complex systems increases, different functional modules (such as power control, sensor networks, and human-machine interaction units) often use independently designed CAN sub-networks. These differences in underlying hardware (such as electrical characteristics and transmission rates) and heterogeneous upper-layer software protocols (such as mixed standard / extended frame networking and custom protocol compatibility) lead to multiple technical bottlenecks in cross-network data exchange.

[0046] Several CAN-to-CAN boxes are currently available on the market. These products primarily implement basic CAN signal conversion, converting signals from one CAN network into signals recognizable by another, thereby enabling physical connections between different CAN networks. However, most of these products employ simple frame transparent transmission, directly forwarding received CAN frames to the other network. These lack effective filtering and management mechanisms for CAN frames.

[0047] Therefore, this application proposes a CAN communication method, system, electronic device, and computer-readable storage medium. By building a protocol architecture, managing CAN frame blacklists and whitelists, providing frame filtering functions, and supporting host computer operation of blacklists and whitelists, the method reduces bus load and improves communication efficiency and security.

[0048] The technical solution of the present application is further described in detail below through specific examples.

[0049] refer to Figure 1 , is a schematic diagram of the CAN communication system structure provided in an embodiment of the present application.

[0050] The CAN communication system provided by the present invention includes multiple independent CAN interfaces, each CAN interface is configured with a corresponding regional controller, each regional controller is communicatively connected with a main controller, and the main controller stores preset filtering rules.

[0051] Specifically, the CAN communication system provided by the present invention includes at least three independent CAN interfaces (CAN0, CAN1, and CAN2). CAN0, CAN1, and CAN2 are physically independent communication channels that support parallel transmission of different protocols or rates. For example, when a device on the CAN0 network needs to communicate with a device on the CAN1 network, data can be forwarded between the different CAN interfaces via the device itself.

[0052] Furthermore, each CAN interface can be expanded to CAN0_1 / CAN0_2 / CAN0_3, enabling multi-device access through time-division multiplexing or physical isolation. For example, in a complex industrial control system, devices with different functional modules can be connected to these three sub-interfaces to achieve centralized data transmission and processing. Each CAN interface is equipped with an independent MCU (such as the STM32F series) and CAN transceiver (such as the TJA1050) to achieve logical isolation and fault isolation.

[0053] It should be noted that the CAN communication system provided by the present invention can also implement CAN signal isolation using a digital isolator (such as the ADuM1201) or an optocoupler (such as the HCPL-063L), with a DC-DC isolated power supply (such as the B0505S-1W) powering the isolated side. The voltage range can reach 9-36VDC (compatible with 12V / 24V industrial power systems) and support ±10% transient overvoltage (e.g., a 24V system can withstand 26.4V / 100ms). Polarity reversal protection (e.g., current is clamped to <100mA if accidentally connected to -24V) can be achieved using a Schottky diode (such as the SS54) and a PMOS switch. Using a wide-input LDO (such as the TPS7A8101, with a 4-36V input range) or a DC-DC converter (such as the LM2596S) achieves an output ripple of <50mVpp (meeting the power supply requirements of the CAN transceiver).

[0054] refer to Figure 2 , which is a flow chart of a CAN communication method provided in an embodiment of the present application.

[0055] Step S201 : For any zone controller of a CAN interface, in response to receiving a target data frame, the zone controller sends the target frame to the master controller.

[0056] Specifically, the regional controller of the CAN interface detects the target data frame on the bus through the CAN transceiver, and sends the frame to the master controller through the internal high-speed bus (such as AHB) with metadata (such as reception timestamp and interface identifier).

[0057] In step S202, the main controller parses the target frame in response to receiving the target frame, obtains the composite code of the target frame, determines whether the target frame is allowed to pass according to the preset filtering rules and the composite code, and forwards the target frame to the target CAN interface in response to the target frame being allowed to pass.

[0058] Specifically, the master controller stores the received target frame into a memory buffer via DMA, reducing CPU interrupt overhead. The composite encoding of the target frame can adopt a fixed 32-bit format, taking into account the compatibility of standard frames and extended frames, while distinguishing data frames from remote frames through a frame type flag.

[0059] Refer to Table 1, which shows the composite coding structure provided by an embodiment of the present invention.

[0060]

[0061] Table 1

[0062] Among them, taking vehicle control as an example, the data frame (0) contains a data field (0-64 bytes) for transmitting sensor data, control instructions, etc. For example, the car ECU sends the engine speed (data frame, ID = 0x123, data field = [0x00, 0x78]). The remote frame (1) has no data field and only requests other nodes to send a data frame with a specified ID. For example, the gateway requests the ECU to send a fault code (remote frame, ID = 0x7DF, data field is empty). The standard frame (0) CAN ID occupies 11 bits (bit10-0), and the maximum ID = 0x7FF. For example, the car lighting control (standard frame, ID = 0x300). The extended frame (1) CAN ID occupies 29 bits (bit28-0), and the maximum ID = 0x1FFFFFFF. For example, the autonomous driving sensor data (extended frame, ID = 0x12345678). The reserved field (bit29) is used for priority tagging, which can be extended to 2 levels of priority (such as 0 = normal, 1 = emergency).

[0063] Coding example:

[0064] Standard data frame (ID = 0x123):

[0065] Frame type: 0 (data frame);

[0066] Frame format: 0 (standard frame);

[0067] Reserved: 00;

[0068] CAN ID: 0x123 (binary: 0000000100100011);

[0069] The composite code of the target frame is: 0b0000000100100011_0000000000000000000000000 (hexadecimal: 0x01230000).

[0070] Extended remote frame (ID = 0x12345678):

[0071] Frame type: 1 (remote frame);

[0072] Frame format: 1 (extended frame);

[0073] Reserved: 00;

[0074] CAN ID: 0x12345678 (binary: 00010010001101000101011001111000)

[0075] The composite code of the target frame is: 0b1100010010001101000101011001111000 (hexadecimal: 0xC4D159E8).

[0076] As an optional embodiment, after obtaining the composite code of the target frame, the method further includes: parsing the composite code to obtain a target frame ID of the target frame.

[0077] Specifically, in CAN network communications, the master controller needs to parse the target frame ID from the composite code of the target frame to determine the source or destination address of the frame. For example, the master controller receives the composite code (extended frame, ID = 0x12345678) sent by the engine control unit (ECU), parses it, and obtains the target frame ID = 0x12345678, which is then routed to the instrument panel to display the speed.

[0078] As can be seen from the background art, the lack of data filtering may allow illegal frames (such as incorrect IDs or redundant data) to directly penetrate, causing network storms or device malfunctions. Therefore, in the embodiments of the present invention, communications between CAN0 and CAN1, CAN0 to CAN2, CAN1 to CAN0, CAN1 to CAN2, CAN2 to CAN0, and CAN2 to CAN1 can be managed by enabling whitelists and blacklists.

[0079] Specifically, if the target frame ID is on the whitelist, the frame data is allowed to pass; if it is on the blacklist, the frame is not allowed to pass. Furthermore, the whitelist and blacklist can be enabled separately or simultaneously with a set priority order. This flexible filtering mechanism allows precise control of different types of data frames based on user needs. For example, in automotive electronic systems, the IDs of critical control command frames can be added to the whitelist to ensure their priority transmission; while the IDs of less important status information frames can be added to the blacklist to prevent them from occupying excessive network bandwidth.

[0080] Specifically, the frame filtering function can be implemented by preset filtering rules, and the master controller stores the preset filtering rules.

[0081] As an optional embodiment, the preset filtering rule includes allowing only frame IDs in the whitelist to pass.

[0082] Determining whether the target frame is allowed to pass according to preset filtering rules and composite coding includes: determining whether the target frame ID is in a white list; and confirming that the target frame is allowed to pass in response to the target frame ID being in the white list.

[0083] Specifically, the preset filtering rule includes "white list only", that is, only the items in the white list are allowed, and all others are prohibited.

[0084] As an optional embodiment, the preset filtering rule includes allowing only frame IDs that are not in the blacklist to pass.

[0085] Determining whether the target frame is allowed to pass according to preset filtering rules and composite coding includes: determining whether the target frame ID is not in the blacklist; and confirming that the target frame is allowed to pass in response to the target frame ID not being in the blacklist.

[0086] Specifically, the preset filtering rules also include "blacklist only", that is, only the items in the blacklist are prohibited, and all others are allowed.

[0087] In specific implementations, when only the whitelist is in effect, all unmatched frames are discarded by default (strict security mode), which is suitable for high-reliability scenarios such as military and medical. When only the blacklist is in effect, all unmatched frames are passed by default (open compatibility mode), which is suitable for rapid prototyping or temporary debugging scenarios.

[0088] As an optional embodiment, the preset filtering rule includes allowing only frame IDs in the white list and not in the black list to pass.

[0089] Determining whether the target frame is allowed to pass according to preset filtering rules and composite coding includes: determining whether the target frame ID is in the whitelist; in response to the target frame ID being in the whitelist, determining whether the target frame ID is not in the blacklist; in response to the target frame ID not being in the blacklist, confirming that the target frame is allowed to pass.

[0090] Specifically, the preset filtering rules also include "white list first, black list later", that is, first allow the items in the white list, then prohibit the items in the black list (the white list has a higher priority).

[0091] As an optional embodiment, determining whether the target frame is allowed to pass according to preset filtering rules and composite coding also includes: determining whether the target frame ID is not in the blacklist; in response to the target frame ID not being in the blacklist, determining whether the target frame ID is in the whitelist; in response to the target frame ID being in the whitelist, confirming that the target frame is allowed to pass.

[0092] Specifically, the preset filtering rules also include "blacklist first, whitelist later", that is, first prohibit the items in the blacklist, and then allow the items in the whitelist (the blacklist has a higher priority).

[0093] It should be noted that if the same ID exists in both the whitelist and the blacklist, the system can issue a log alarm and force the system to enter safe mode (discard the frame).

[0094] For example, the entire preset filtering rule can be expressed as:

[0095]

[0096]

[0097] Furthermore, the preset filtering rules are described as follows:

[0098] WHITELIST_ONLY: Directly check whether the target frame ID is in the whitelist. If yes, allow it; otherwise, deny it.

[0099] BLACKLIST_ONLY: Allow all non-blacklisted frame IDs.

[0100] WHITELIST_THEN_BLACKLIST: Priority: whitelist > blacklist. If the ID is in the whitelist, it is allowed directly; otherwise, it is checked to see if it is in the blacklist.

[0101] BLACKLIST_THEN_WHITELIST: Priority: blacklist > whitelist. If the ID is on the blacklist, reject it directly; otherwise, check whether it is on the whitelist.

[0102] As an optional embodiment, the rules for filling in the frame ID in the whitelist and blacklist are as follows:

[0103] All frames use a 4-byte ID and 32-bit data. Bit B31 indicates the frame type: 1 for a remote frame, 0 for a data frame; bit B30 indicates the frame format: 1 for an extended frame, 0 for a standard frame; bit B29 is reserved; bits B28-B0 indicate the ID. Extended frames use all bits; standard frames use bits B10-B0, with all other bits set to 0. This unified frame ID formatting rule facilitates user management and configuration while ensuring the uniqueness and identifiability of data frames.

[0104] Unlike the simple frame transparent transmission method used in the prior art, this invention effectively filters and manages CAN frames by establishing a whitelist and blacklist mechanism. Users can flexibly set which frames are allowed to pass and which are not, based on actual needs. This avoids the transmission of invalid data, reduces the CAN bus load, and improves network communication efficiency.

[0105] As an optional embodiment, the main controller is communicatively connected to the host computer; the method further includes: the user adds, deletes, modifies and / or checks the blacklist and / or whitelist in the preset filtering rules stored in the main controller through the host computer.

[0106] Specifically, the host computer receives specific protocols via the serial port and performs operations such as adding, deleting, modifying, and checking each channel's enabled macro variables, as well as whitelists and blacklists. Users can program a corresponding user interface on the host computer and communicate with the device via the serial port to conveniently and quickly manage whitelists and blacklists. For example, users can add a new frame ID to the whitelist or delete a frame ID from the blacklist through the host computer interface, thereby achieving dynamic control over CAN frame transmission.

[0107] Thus, the present invention allows users to add, delete, modify, and query whitelists and blacklists through the host computer. Users can adjust filtering rules at any time according to actual conditions to meet the personalized needs of different application scenarios. In contrast, in the existing technology, users cannot customize frame transmission settings, which is less flexible.

[0108] It should be noted that the specific filling rules of the target frame ID in the whitelist and blacklist of this application can ensure the uniqueness and identifiability of the data frame.

[0109] As an optional embodiment, CAN frame filtering can be implemented by designing a dedicated hardware logic circuit within the CAN communication system. This hardware logic circuit can perform real-time judgment and processing of received and transmitted CAN frames based on preset filtering rules, without relying on software programs or host computer operations. Specifically, a dedicated frame filtering chip (FPGA or ASIC) can be added to the CAN communication system. This chip integrates complex logic circuitry to implement whitelist and blacklist matching and filtering functions. When a CAN frame enters the device, it is first processed by the frame filtering chip, which determines whether the frame is allowed to pass based on the preset filtering rules. If allowed, the frame is forwarded to the target CAN network; if not, the frame is discarded.

[0110] As an optional embodiment, software algorithms can also be used to achieve dynamic filtering of CAN frames. The main control controller inside the CAN communication system runs a specific software program to dynamically generate and update whitelists and blacklists based on the real-time network status and user needs, thereby achieving flexible filtering of CAN frames. Specifically, an embedded operating system and a special frame filtering software module can be run in the CAN communication system. The software module monitors and analyzes network traffic and adjusts the contents of the whitelist and blacklist in real time in combination with the user's preset rules. When a CAN frame is received, the software module will judge and process the frame according to the current filtering rules. At the same time, the user can communicate with the device through the host computer and send new filtering rules or adjustment requests to the device. The software module will update the filtering rules in a timely manner based on these requests.

[0111] The present application proposes a CAN communication method, which is applied to a CAN communication system. The CAN communication system includes multiple independent CAN interfaces, each of which is configured with a corresponding regional controller. Each regional controller is in communication with a master controller, and the master controller stores preset filtering rules. The method includes: for any CAN interface, the regional controller sends the target frame to the master controller in response to receiving a target data frame; the master controller parses the target frame in response to receiving the target frame, obtains a composite code of the target frame, determines whether the target frame is allowed to pass based on the preset filtering rules and the composite code, and forwards the target frame to the target CAN interface in response to the target frame being allowed to pass. The present application builds a protocol architecture, manages CAN frame blacklists and whitelists, provides frame filtering functions, and supports host computer operation of blacklists and whitelists, thereby reducing bus load and improving communication efficiency and security.

[0112] It should be noted that the method of the embodiment of the present invention can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied in a distributed scenario, where multiple devices cooperate to perform the method. In such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiment of the present invention, and the multiple devices will interact with each other to complete the above method.

[0113] It should be noted that the above description is limited to some embodiments of the present invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in an order different from that described in the above embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0114] Corresponding to the above embodiment, the present invention also proposes a CAN communication system.

[0115] like Figure 3 As shown, the CAN communication system 300 of the embodiment of the present invention includes: multiple independent CAN interfaces 301, each CAN interface is configured with a corresponding regional controller 302, each regional controller 302 is communicatively connected to a master controller 303, and the master controller 303 stores preset filtering rules;

[0116] Each regional controller 302 is configured to send a target frame to the master controller 303 in response to receiving the target data frame;

[0117] The main controller 303 is configured to parse the target frame in response to receiving the target frame, obtain the composite code of the target frame, determine whether the target frame is allowed to pass according to the preset filtering rules and the composite code, and forward the target frame to the target CAN interface in response to the target frame being allowed to pass.

[0118] Optionally, the main controller 303 is further configured to:

[0119] Parse the composite code to obtain the target frame ID of the target frame.

[0120] Optionally, the preset filtering rule includes allowing only frame IDs in the whitelist to pass; the master controller 303 is further configured to:

[0121] Determine whether the target frame ID is in the whitelist;

[0122] In response to the target frame ID being in the white list, it is confirmed that the target frame is allowed to pass.

[0123] Optionally, the preset filtering rule includes allowing only frame IDs that are not in the blacklist to pass; the master controller 303 is further configured to:

[0124] Determine whether the target frame ID is not in the blacklist;

[0125] In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

[0126] Optionally, the preset filtering rule includes allowing only frame IDs in the whitelist and not in the blacklist to pass; the master controller 303 is further configured to:

[0127] Determine whether the target frame ID is in the whitelist;

[0128] In response to the target frame ID being in the white list, determining whether the target frame ID is not in the black list;

[0129] In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

[0130] Optionally, the main controller 303 is further configured to:

[0131] Determine whether the target frame ID is not in the blacklist;

[0132] In response to the target frame ID not being in the blacklist, determining whether the target frame ID is in the whitelist;

[0133] In response to the target frame ID being in the white list, it is confirmed that the target frame is allowed to pass.

[0134] Optionally, the master controller 303 is in communication with a host computer; the master controller 303 is further configured to:

[0135] The user can add, delete, modify and / or check the blacklist and / or whitelist in the preset filtering rules stored in the main controller 303 through the host computer.

[0136] The present application proposes a CAN communication system, comprising a plurality of independent CAN interfaces, each of which is configured with a corresponding regional controller, each of which is in communication with a master controller, and the master controller stores preset filtering rules. The method comprises: for any CAN interface, the regional controller, in response to receiving a target data frame, sends the target frame to the master controller; in response to receiving the target frame, the master controller parses the target frame to obtain a composite code of the target frame, determines whether the target frame is allowed to pass based on the preset filtering rules and the composite code, and forwards the target frame to the target CAN interface in response to the target frame being allowed to pass. The present application constructs a protocol architecture, manages CAN frame blacklists and whitelists, provides frame filtering functions, and supports host computer operation of blacklists and whitelists, thereby reducing bus load and improving communication efficiency and security.

[0137] For the convenience of description, the above system is described as being divided into various modules according to their functions. Of course, when implementing the present invention, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0138] The system of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0139] Corresponding to the above embodiment, the present invention further provides an electronic device.

[0140] refer to Figure 4 , is a block diagram of an electronic device according to some embodiments of the present invention, illustrating a more specific hardware structure of an electronic device provided by this embodiment. The device may include: a processor 410, a memory 420, an input / output interface 430, a communication interface 440, and a bus 450. The processor 410, the memory 420, the input / output interface 430, and the communication interface 440 are connected to each other within the device via the bus 450.

[0141] The processor 410 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0142] The memory 420 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 420 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 420 and is called and executed by the processor 410.

[0143] The input / output interface 430 is used to connect an input / output module to implement information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.

[0144] The communication interface 440 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).

[0145] The bus 450 comprises a pathway for transmitting information between the various components of the device, such as the processor 410 , the memory 420 , the input / output interface 430 , and the communication interface 440 .

[0146] It should be noted that although the above device only shows the processor 410, the memory 420, the input / output interface 430, the communication interface 440, and the bus 450, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.

[0147] The electronic device of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0148] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present invention further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the method of any of the above embodiments.

[0149] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NANDFLASH), solid-state drives (SSDs)), etc.

[0150] The computer instructions stored in the storage medium of the above embodiment are used to enable a computer to execute the method of any embodiment in the above exemplary method section, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0151] Furthermore, although the operations of the present method are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in that particular order, or that all of the operations shown must be performed to achieve the desired results. Rather, the steps depicted in the flowcharts may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into a single step, and / or a single step may be broken down into multiple steps.

[0152] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0153] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present invention should have the usual meanings understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the embodiments of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0154] Although the spirit and principles of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the specific embodiments disclosed, and the division into various aspects does not mean that the features of these aspects cannot be combined to benefit. Such division is merely for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.

Claims

1. A CAN communication method, characterized in that: Applied to a CAN communication system, the CAN communication system includes multiple independent CAN interfaces, each of the CAN interfaces is configured with a corresponding regional controller, each of the regional controllers is communicatively connected to a main controller, and the main controller stores preset filtering rules; The method comprises: For any one of the CAN interface zone controllers, in response to receiving a target data frame, sending the target frame to the master controller; In response to receiving the target frame, the master controller parses the target frame to obtain the composite code of the target frame, determines whether the target frame is allowed to pass according to the preset filtering rules and the composite code, and forwards the target frame to the target CAN interface in response to the target frame being allowed to pass.

2. The CAN communication method according to claim 1, wherein: After obtaining the composite encoding of the target frame, the method further includes: The composite code is parsed to obtain a target frame ID of the target frame.

3. The CAN communication method according to claim 2, wherein: The preset filtering rules include allowing only frame IDs in the whitelist to pass; The determining whether the target frame is allowed to pass according to the preset filtering rule and the composite encoding includes: Determining whether the target frame ID is in the whitelist; In response to the target frame ID being in the whitelist, it is confirmed that the target frame is allowed to pass.

4. The CAN communication method according to claim 2, wherein: The preset filtering rules include allowing only frame IDs that are not in the blacklist to pass; The determining whether the target frame is allowed to pass according to the preset filtering rule and the composite encoding includes: Determine whether the target frame ID is not in the blacklist; In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

5. The CAN communication method according to claim 2, wherein: The preset filtering rules include allowing only frame IDs in the whitelist and not in the blacklist to pass; The determining whether the target frame is allowed to pass according to the preset filtering rule and the composite encoding includes: Determine whether the target frame ID is in the whitelist; In response to the target frame ID being in the whitelist, determining whether the target frame ID is not in the blacklist; In response to the target frame ID not being in the blacklist, it is confirmed that the target frame is allowed to pass.

6. The CAN communication method according to claim 5, characterized in that: The determining whether the target frame is allowed to pass according to the preset filtering rules and the composite coding further includes: Determine whether the target frame ID is not in the blacklist; In response to the target frame ID not being in the blacklist, determining whether the target frame ID is in the whitelist; In response to the target frame ID being in the whitelist, it is confirmed that the target frame is allowed to pass.

7. The CAN communication method according to claim 6, characterized in that: The main controller is communicatively connected with the host computer; The method further comprises: The user adds, deletes, modifies and / or checks the blacklist and / or whitelist in the preset filtering rules stored in the main controller through the host computer.

8. A CAN communication system, characterized in that: It includes multiple independent CAN interfaces, each of which is configured with a corresponding regional controller, each of which is in communication with a main controller, and the main controller stores preset filtering rules; Each of the regional controllers is configured to send the target frame to the master controller in response to receiving the target data frame; The master controller is configured to, in response to receiving the target frame, parse the target frame to obtain a composite code of the target frame, determine whether the target frame is allowed to pass according to preset filtering rules and the composite code, and forward the target frame to the target CAN interface in response to the target frame being allowed to pass.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the CAN communication method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the CAN communication method according to any one of claims 1 to 7 are implemented.