Control method for interconnection and intercommunication of CAN (Controller Area Network) and Ethernet
By optimizing the routing table configuration and conversion rules, efficient and reliable data exchange between CAN and Ethernet was achieved, solving the problems of large differences in protocol stacks, complex data format conversion, and insufficient real-time performance, thus improving the system's adaptability and reliability.
Patent Information
- Application Number
- CN202511220620.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2026-01-06
AI Technical Summary
Existing technologies for interconnecting CAN and Ethernet suffer from problems such as significant differences in protocol stacks, complex data format conversion, cumbersome configuration management, insufficient real-time performance, and inadequate error handling.
By optimizing routing table configuration and conversion rules, efficient and reliable data exchange between CAN network and Ethernet is achieved. Dynamic routing table, signal/service conversion mechanism, multi-level buffering and zero-copy forwarding mechanism are adopted, combined with error handling and diagnosis mechanism.
It simplifies the integration of heterogeneous networks, improves system adaptability and real-time performance, and enhances reliability and maintainability.
Smart Images

Figure CN121284126A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive electronics technology, and more specifically to a control method for interconnecting CAN and Ethernet. Background Technology
[0002] Currently, the industry mainly achieves CAN and Ethernet interconnection by developing dedicated protocol conversion software in the gateway ECU.
[0003] Existing technologies often have the following problems:
[0004] 1) The protocol stacks of different communication networks differ greatly, and data format conversion is complex;
[0005] 2) Due to the fundamental difference between CAN's signal-based communication method and Ethernet's service-based communication method, interoperability is difficult to achieve;
[0006] 3) Existing solutions lack unified configuration management, resulting in cumbersome system configuration and difficult maintenance;
[0007] 4) Existing methods suffer from insufficient real-time performance when handling high-load communication;
[0008] 5) Most solutions lack effective error handling and diagnosis capabilities. Summary of the Invention
[0009] To address the technical problems existing in the background art, the present invention provides a control method for interconnection between CAN and Ethernet, which achieves efficient and reliable data exchange between CAN network and Ethernet by optimizing routing table configuration and conversion rules.
[0010] The technical solution adopted by this invention to solve its technical problem is: a control method for interconnecting CAN and Ethernet, comprising the following steps:
[0011] CAN to Ethernet forwarding process:
[0012] 1) The CAN controller receives the CAN frame and triggers an interrupt;
[0013] 2) The CAN driver parses the CAN frame and calls the CanIf_RxIndication function;
[0014] 3) CanIf passes the received PDU to the PDU Router;
[0015] 4) The PDU Router searches for a matching target PDU based on the routing table;
[0016] 5) If the target PDU corresponds to an Ethernet network, then apply the corresponding signal-to-service conversion rules;
[0017] 6) Pass the converted data to the SoAd module;
[0018] 7) The SoAd module sends data to the Ethernet via the TcpIp module;
[0019] Ethernet to CAN forwarding process:
[0020] 1) The Ethernet controller receives the data packet and triggers an interrupt;
[0021] 2) The Ethernet driver parses the data packets and passes them to EthIf;
[0022] 3) EthIf passes the data to the TcpIp module;
[0023] 4) The TCP / IP module parses the protocol and transmits the data to the SoAd module;
[0024] 5) The SoAd module passes the PDU to the PDU Router;
[0025] 6) The PDU Router searches for a matching target PDU based on the routing table;
[0026] 7) If the target PDU corresponds to a CAN network, then apply the corresponding service-to-signal conversion rules;
[0027] 8) Pass the converted data to the CanIf module for sending.
[0028] Preferably, the routing table is configured as follows:
[0029] 1) Configure a dynamic routing table in the PDU Router of the gateway ECU;
[0030] 2) Configure routing path groups according to communication requirements so that the routing table can be dynamically enabled or disabled at runtime;
[0031] 3) Configure a buffering policy for each routing table entry, including the buffer type and buffer depth.
[0032] Preferably, the dynamic routing table includes source PDU identifier, destination PDU identifier, routing type, data delivery method, and conversion rule identifier.
[0033] Preferably, the configuration of the conversion rules is as follows:
[0034] 1) Establish a signal / service mapping table to define the mapping relationship between CAN signals and Ethernet services;
[0035] 2) Configure data type conversion rules, including endianness conversion, bit sequence transformation, and numerical scaling;
[0036] 3) Configure triggering mechanisms, including periodic triggering, event triggering, and request triggering;
[0037] 4) Configure conversion acceleration strategies, including hash table acceleration, pre-computed tables, and parallel conversion.
[0038] Preferably, the control method includes a real-time guarantee mechanism:
[0039] 1) A multi-level buffering strategy is adopted to allocate different buffers for PDUs of different priorities;
[0040] 2) Implement a zero-copy forwarding mechanism to improve efficiency by passing pointers instead of copying data;
[0041] 3) Introduce a PDU preprocessing mechanism to pre-parse PDU header information during idle periods;
[0042] 4) Implement dynamic routing path selection, automatically selecting the best transmission path based on network load;
[0043] 5) Supports priority delivery, ensuring that high-priority CAN messages retain their high priority when forwarded to Ethernet.
[0044] Preferably, the control method further includes an error handling and diagnosis mechanism:
[0045] 1) Implement buffer overflow detection and handling;
[0046] 2) Provide error reporting and retry mechanisms for PDU forwarding failures;
[0047] 3) Record routing statistics, including throughput, latency, and packet loss rate;
[0048] 4) Implement a routing table self-checking mechanism to ensure configuration consistency;
[0049] 5) Provides a gateway monitoring interface to support external tools for diagnosis and debugging.
[0050] The present invention has the following beneficial effects:
[0051] 1) Through optimized routing table design, it provides flexible CAN and Ethernet communication configuration methods, simplifying the complexity of heterogeneous network integration;
[0052] 2) Based on the design of dynamic routing path groups, it supports dynamic adjustment of network communication strategies according to vehicle status at runtime, thereby improving system adaptability;
[0053] 3) An innovative signal / service conversion mechanism effectively solves the conversion problem between two different communication paradigms: CAN based on signals and Ethernet based on services.
[0054] 4) The multi-level buffering and zero-copy forwarding mechanism significantly improves the real-time performance of the system, meeting the demanding real-time communication requirements of vehicles;
[0055] 5) The improved error handling and diagnosis mechanism enhances the system's reliability and maintainability. Attached Figure Description
[0056] Figure 1 This is a system architecture diagram of the present invention.
[0057] Figure 2 This is a diagram of the routing table structure of the PDU Router of the present invention.
[0058] Figure 3 This is a flowchart of the signal / service conversion process of the present invention.
[0059] Figure 4 This is a flowchart of the CAN-to-Ethernet communication process of the present invention.
[0060] Figure 5 This is a flowchart of the Ethernet-to-CAN communication process of the present invention.
[0061] Figure 6 This is a schematic diagram of the multi-level buffering strategy of the present invention.
[0062] Figure 7 This is a flowchart of the error handling process of the present invention. Detailed Implementation
[0063] The technical solutions of the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0064] A control method for interconnecting CAN and Ethernet includes routing table configuration, conversion rule configuration, CAN to Ethernet forwarding process, Ethernet to CAN forwarding process, real-time guarantee mechanism, and error handling and diagnosis mechanism.
[0065] The routing table configuration includes: configuring a dynamic routing table, which includes source PDU identifier, destination PDU identifier, route type, data delivery method, and translation rule identifier; configuring route path groups so that the routing table can be dynamically enabled or disabled at runtime; and configuring a buffering policy for each routing table entry, including buffer type and buffer depth.
[0066] The conversion rule configuration includes: establishing a signal / service mapping table to define the mapping relationship between CAN signals and Ethernet services; configuring data type conversion rules, including endianness conversion, bit sequence transformation, and numerical scaling; configuring triggering mechanisms, including periodic triggering, event triggering, and request triggering; and configuring conversion acceleration strategies, including hash table acceleration, pre-computation table, and parallel conversion.
[0067] The CAN-to-Ethernet forwarding process includes: the CAN controller receiving a CAN frame and triggering an interrupt; the CAN driver parsing the CAN frame and calling the CanIf_RxIndication function; CanIf passing the received PDU to the PDU Router; the PDU Router searching for a matching target PDU according to the routing table; if the target PDU corresponds to an Ethernet network, applying the appropriate signal-to-service conversion rules; passing the converted data to the SoAd module; and the SoAd module sending the data to the Ethernet via the TCP / IP module.
[0068] The real-time performance guarantee mechanism includes: adopting a multi-level buffering strategy to allocate different buffers for PDUs of different priorities; implementing a zero-copy forwarding mechanism to improve efficiency by passing pointers instead of copying data; introducing a PDU preprocessing mechanism to pre-parse PDU header information when idle; implementing dynamic routing path selection to automatically select the best transmission path based on network load; and supporting priority passing to ensure that high-priority CAN messages maintain a high priority when forwarded to Ethernet.
[0069] Error handling and diagnosis mechanisms include: implementing buffer overflow detection and handling; providing error reporting and retry mechanisms for PDU forwarding failures; recording routing statistics, including throughput, latency, and packet loss rate; implementing a routing table self-checking mechanism to ensure configuration consistency; and providing a gateway monitoring interface to support external tools for diagnosis and debugging.
[0070] Example 1: Routing Table Configuration
[0071] The core of this invention's method is the routing table configuration of the PDU Router. For example... Figure 2 As shown, the routing table consists of multiple route path entries, and each route path entry contains the following elements:
[0072] 1) Source PDU Identifier (SrcPduId): Uniquely identifies the source PDU;
[0073] 2) Target PDU Identifier (DestPduId): Uniquely identifies the target PDU;
[0074] 3) Routing Type: Specifying it as PDUR_GATEWAY indicates that this path is used for gateway forwarding;
[0075] 4) Data Provisioning Method: PDUR_DIRECT indicates direct data provision, and PDUR_TRIGGERTRANSMIT indicates triggered data provision.
[0076] 5) Conversion Rule Identifier (ConversionRuleId): Refers to the corresponding signal / service conversion rule.
[0077] In practical applications, routing tables are either pre-compiled and linked into the application at link time, or loaded at startup via non-volatile memory. The innovation of this invention lies in the introduction of the concept of routing path groups, which allows certain routing paths to be dynamically enabled or disabled at runtime to adapt to different vehicle states and communication requirements.
[0078] The following is an example of routing table configuration code:
[0079]
[0080]
[0081] Example 2: Signal / Service Conversion Mechanism
[0082] like Figure 3 As shown, this invention proposes an innovative signal / service conversion mechanism to resolve the paradigm difference between CAN's signal-based communication and Ethernet's service-based communication. It mainly includes the following conversion types:
[0083] 1) Signal-to-service conversion: Mapping CAN signals to fields or events of Ethernet services;
[0084] 2) Service to signal conversion: Convert Ethernet service calls or notifications into CAN signals.
[0085] The conversion mechanism of this invention includes the following key elements:
[0086] 1) Data type mapping: Define the mapping relationship between CAN signal types and Ethernet service data types;
[0087] 2) Range conversion: Defines the scaling and offset relationship between signal values and service parameter values;
[0088] 3) Triggering mechanism: Define the triggering relationship between service events and signal changes;
[0089] 4) Semantic mapping: Ensure semantic consistency between CAN signals and Ethernet services.
[0090] The following is an example code for configuring conversion rules:
[0091]
[0092] Example 3: CAN to Ethernet Communication Process
[0093] like Figure 4 As shown, the CAN-to-Ethernet communication process includes the following steps:
[0094] Step 1: The CAN controller receives the CAN frame and triggers an interrupt;
[0095] Step 2: The CAN driver parses the CAN frame and calls the CanIf_RxIndication() function;
[0096] Step 3: CanIf passes the PDU to the PDU Router and calls PduR_CanIfRxIndication();
[0097] Step 4: The PDU Router checks the routing table to find the target PDU that matches the received PDU;
[0098] Step 5: If a match is found and the target is an Ethernet network, the PDU Router checks if signaling / service conversion is required;
[0099] Step 6: If conversion is required, apply the corresponding conversion rules to convert the CAN signal to the Ethernet service format;
[0100] Step 7: The PDU Router calls SoAd_Transmit() to send the converted PDU to the socket adapter;
[0101] Step 8: SoAd calls TcpIp_TcpTransmit() to pass the data to the TCP / IP protocol stack;
[0102] Step 9: The TcpIp module calls EthIf_Transmit() to pass the data packet to the Ethernet interface;
[0103] Step 10: EthIf calls Eth_Transmit() to send the data packet to the Ethernet physical layer.
[0104] The innovation of this invention lies in the introduction of an optimized signal / service conversion mechanism in steps 5-6, which significantly improves conversion efficiency through a pre-configured conversion table and an acceleration algorithm.
[0105] Example 4: Multi-level buffering strategy
[0106] like Figure 6 As shown, this invention introduces a multi-level buffering strategy to balance real-time performance and resource utilization in different communication scenarios. The main buffering strategies include the following:
[0107] 1) Last-is-best buffer: Suitable for PDUs with high timeliness requirements, such as status information, only retaining the most recently received PDU;
[0108] 2) FIFO buffer: Suitable for PDUs that require sequential processing of event information, etc., processing is performed according to the order of reception;
[0109] 3) Priority buffer: Different buffers are allocated according to the priority of the PDU, and high-priority PDUs are processed first;
[0110] 4) Pre-allocated buffer: A fixed-size buffer is pre-allocated when the system starts up to avoid the uncertainty caused by dynamic memory allocation.
[0111] The buffer strategy configuration of this invention supports dynamic adjustment based on communication type and importance, and provides a buffer overflow handling mechanism to ensure that critical information is not lost.
[0112] Example 5: Error Handling and Diagnosis Mechanism
[0113] like Figure 7 As shown, this invention provides a comprehensive error handling and diagnosis mechanism, including:
[0114] 1) Error detection: Detects abnormal situations including buffer overflow, conversion errors, and routing failures;
[0115] 2) Error Reporting: Report error information to the diagnostic module and the application layer;
[0116] 3) Error recovery: Provides recovery mechanisms such as automatic retry and alternative routing paths;
[0117] 4) Error logging: Records error history and supports offline analysis;
[0118] 5) Performance monitoring: Collect and report performance metrics such as throughput and latency.
[0119] The error handling mechanism of this invention conforms to the AUTOSAR fault management specifications and can be seamlessly integrated with on-board diagnostic systems.
[0120] Example 6: Dynamic Routing Configuration
[0121] This invention supports dynamically adjusting routing configurations at runtime via BswM (Basic Software Manager), enabling or disabling specific route path groups based on different vehicle states (such as normal driving, standby, diagnostic mode, etc.). An example of the implementation code is as follows:
[0122]
[0123] Through this dynamic configuration mechanism, the present invention can optimize network resource allocation in different scenarios and improve system responsiveness and reliability.
[0124] This invention is not limited to the above-described embodiments. Anyone should know that any structural changes made under the guidance of this invention, and any technical solutions that are the same as or similar to this invention, fall within the protection scope of this invention.
[0125] The technologies, shapes, and structures not described in detail in this invention are all known technologies.
Claims
1. A control method for CAN and Ethernet interconnection and interworking, characterized in that, The method comprises the following steps: CAN to Ethernet forwarding process: 1) CAN controller receives CAN frame and triggers interrupt; 2) CAN driver parses CAN frame and calls CanIf_RxIndication function; 3) CanIf passes received PDU to PDU Router; 4) PDU Router looks up matching target PDU according to routing table; 5) If target PDU corresponds to Ethernet network, apply corresponding signal to service conversion rule; 6) Pass converted data to SoAd module; 7) SoAd module sends data to Ethernet through TcpIp module; Ethernet to CAN forwarding process: 1) Ethernet controller receives data packet and triggers interrupt; 2) Ethernet driver parses data packet and passes to EthIf; 3) EthIf passes data to TcpIp module; 4) TcpIp module parses protocol and passes data to SoAd module; 5) SoAd module passes PDU to PDU Router; 6) PDU Router looks up matching target PDU according to routing table; 7) If target PDU corresponds to CAN network, apply corresponding service to signal conversion rule; 8) Pass converted data to CanIf module for sending.
2. The CAN and Ethernet interconnection and intercommunication control method according to claim 1, characterized in that, Configuration of the routing table: 1) Configure dynamic routing table in PDU Router of gateway ECU; 2) According to communication requirements, configure routing path group so that routing table is dynamically enabled or disabled at runtime; 3) Configure buffer strategy for each routing table entry, including buffer type and buffer depth.
3. The CAN and Ethernet interconnection and intercommunication control method according to claim 2, characterized in that, The dynamic routing table includes source PDU identifier, target PDU identifier, routing type, data provision method, and conversion rule identifier.
4. The CAN and Ethernet interconnection and intercommunication control method according to claim 1, characterized in that, Configuration of the conversion rule: 1) Establish signal / service mapping table to define mapping relationship between CAN signal and Ethernet service; 2) Configure data type conversion rule, including size end conversion, bit sequence transformation, and numerical scaling; 3) Configure trigger mechanism, including periodic trigger, event trigger, and request trigger; 4) Configure conversion acceleration strategy, including hash table acceleration, pre-computation table, and parallel conversion.
5. The CAN and Ethernet interconnection and intercommunication control method according to claim 1, characterized in that, The control method includes real-time guarantee mechanism: 1) Adopt multi-level buffer strategy to allocate different buffer areas for PDUs of different priorities; 2) Implement zero-copy forwarding mechanism to improve efficiency through pointer passing instead of data copying; 3) Introduce PDU preprocessing mechanism to pre-analyze PDU header information when idle; 4) Implement dynamic routing path selection to automatically select optimal transmission path according to network load; 5) Support priority delivery to ensure that high-priority CAN messages still maintain high priority when forwarded to Ethernet.
6. The CAN and Ethernet interconnection and intercommunication control method according to claim 1, characterized in that, The control method also includes error handling and diagnosis mechanism: 1) Implement buffer overflow detection and handling; 2) Provide error report and retry mechanism for PDU forwarding failure; 3) Record routing statistical information, including throughput, delay, and packet loss rate; 4) Implement routing table self-checking mechanism to ensure configuration consistency; 5) Provide gateway monitoring interface to support external tools for diagnosis and debugging.