A gateway CAN message routing optimization method and system
By sinking the routing channel into MCAL, directly performing data processing and routing, the problem of long routing time and inconsistency in the existing technology is solved, and fast and reliable gateway CAN message routing is achieved.
Patent Information
- Application Number
- CN202211352138.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-10-31
AI Technical Summary
In the prior art, the gateway has long routing paths and is prone to data inconsistency. Especially under the Autosar software architecture, the signals are routed through the BSW layer, the RTE layer, and to the application layer module SWIN, and then routed by SWIN, RTE, and BSW, resulting in a long routing time and data inconsistency.
Sink the routing channel into MCAL for data processing and routing. It does not pass RTE and application layer runnable, but uses API interface functions PduR_ComReceive() and PduR_ComTransmit() and data link layer for data reading and writing. It adopts FIFO first-in-first-out processing method to optimize the API function interface.
The routing time of packets is minimized, data inconsistency is avoided, and the time requirements for IMMO authentication are met. The routing time is reduced from 8ms to within 0.5ms.
Smart Images

Figure CN115811492B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of vehicle-mounted gateways, and in particular relates to a gateway CAN message routing optimization method and system. Background Art
[0002] The widespread use of automotive electronics has led to an increasing number of controllers in vehicles and a surge in interactive information. Network structures have evolved from single segments to complex ones. Furthermore, the use of multiple buses has led to the emergence of in-vehicle gateways. As the bridge between the entire vehicle network, the gateway is the core of the entire network. The gateway performs vertical signal forwarding in two ways: signal routing and message routing.
[0003] In the prior art, for gateways using the Autosar software architecture, the routing path is as follows: the signal passes through the BSW layer, the RTE layer, and the application layer module SWIN, and then is routed out through SWIN, RTE, and BSW. This results in a long routing time and is prone to data inconsistency (for example, the value of the currently transmitted message may be the value of the previous cycle). Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a gateway CAN message routing optimization method and system, aiming to solve the problems raised in the background technology.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] A gateway CAN message routing optimization method, the method specifically comprising the following steps:
[0007] Sink the routing channel and perform data processing and routing in MCAL;
[0008] When the CAN controller receives a data message, it processes it accordingly and passes the PDU ID and data pointer to the data link layer;
[0009] The data message is written into the data buffer, and data is read and written with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0010] As a further limitation of the technical solution of the embodiment of the present invention, when the CAN controller receives the data message, performing corresponding processing and transmitting the PDU ID and data pointer to the data link layer specifically includes the following steps:
[0011] Analyze the original software of the gateway to determine whether the CAN controller has received the data message;
[0012] When the CAN controller receives a data message, it writes the data message into the RX data register;
[0013] Pass the PDU ID and data pointer to the data link layer.
[0014] As a further limitation of the technical solution of the embodiment of the present invention, the data message is written into the data buffer, and the data reading and writing with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit() specifically includes the following steps:
[0015] The data message is written into the data buffer;
[0016] Optimize the routing path and obtain the API function interface;
[0017] The PDUR network layer reads and writes data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0018] As a further limitation of the technical solution of the embodiment of the present invention, the step of performing routing path optimization to obtain an API function interface specifically includes the following steps:
[0019] Optimize API function interface;
[0020] The IMMO data is directly processed in the PDUR interaction layer.
[0021] As a further limitation of the technical solution of the embodiment of the present invention, the data processing adopts a FIFO first-in-first-out processing method.
[0022] As a further limitation of the technical solution of the embodiment of the present invention, in the process of sinking the routing channel and performing data processing and routing in MCAL, data routing is not performed through RTE and application layer runnable.
[0023] As a further limitation of the technical solution of the embodiment of the present invention, the MCAL is a microcontroller abstraction layer, which is located at the lowest layer in the BSW layer.
[0024] As a further limitation of the technical solution of the embodiment of the present invention, the PDU is a protocol data unit, which is a data unit transmitted between peer levels in a hierarchical network structure; and the PDU ID is an identity identifier of the protocol data unit.
[0025] A gateway CAN message routing optimization system, the system includes a channel sinking unit, a message processing unit and a data reading and writing unit, wherein:
[0026] The channel sinking unit is used to sink the routing channel and perform data processing and routing in MCAL;
[0027] The message processing unit is used to process the data message received by the CAN controller and pass the PDU ID and data pointer to the data link layer;
[0028] The data read and write unit is used to write data messages into the data buffer and read and write data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0029] As a further limitation of the technical solution of the embodiment of the present invention, the message processing unit specifically includes:
[0030] The receiving judgment module is used to analyze the original software of the gateway and determine whether the CAN controller has received the data message;
[0031] The message writing module is used to write the data message into the RX data register when the CAN controller receives the data message;
[0032] The link transmission module is used to pass the PDU ID and data pointer to the data link layer.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] This embodiment of the present invention performs data processing and routing in the MCAL by sinking the routing channel. When the CAN controller receives a data message, it processes it accordingly and passes the PDU ID and data pointer to the data link layer. The data message is then written to the data buffer for data reading and writing. This eliminates the need for data routing through the RTE and application layer runnables by sinking the routing channel directly to the MCAL for data processing and routing. This minimizes message routing time and effectively avoids long routing times and data inconsistencies. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention.
[0036] Figure 1 A flow chart of a method provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0038] It is understandable that in the prior art, for gateways using the Autosar software architecture, the routing path is: the signal passes through the BSW layer, the RTE layer, to the application layer module SWIN, and then is routed out through SWIN, RTE, and BSW, resulting in a long routing time and prone to data inconsistency (for example, the value of the currently transmitted message may be the value of the previous cycle).
[0039] To address these issues, an embodiment of the present invention shifts routing channels downward, performing data processing and routing in the MCAL. When a CAN controller receives a data message, it processes it accordingly, passing the PDU ID and data pointer to the data link layer. The data message is then written to the data buffer for data reading and writing. By shifting routing channels downward directly to the MCAL for data processing and routing, data routing is minimized, effectively avoiding long routing times and data inconsistencies.
[0040] Figure 1 A flow chart of a method provided by an embodiment of the present invention is shown.
[0041] Specifically, a gateway CAN message routing optimization method includes the following steps:
[0042] Step S101: sink the routing channel and perform data processing and routing in MCAL;
[0043] Step S102: When the CAN controller receives the data message, it performs corresponding processing and passes the PDU ID and data pointer to the data link layer;
[0044] Step S103: The data message is written into the data buffer, and data is read and written with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0045] Specifically, when the CAN controller receives a data message, it performs corresponding processing and transmits the PDU ID and data pointer to the data link layer, which specifically includes the following steps:
[0046] Analyze the original software of the gateway to determine whether the CAN controller has received the data message;
[0047] When the CAN controller receives a data message, it writes the data message into the RX data register;
[0048] Pass the PDU ID and data pointer to the data link layer.
[0049] Specifically, the data message is written into the data buffer, and the data link layer is read and written through the API interface functions PduR_ComReceive() and PduR_ComTransmit(), which specifically include the following steps:
[0050] The data message is written into the data buffer;
[0051] Optimize the routing path and obtain the API function interface;
[0052] The PDUR network layer reads and writes data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0053] Specifically, the routing path optimization to obtain the API function interface specifically includes the following steps:
[0054] Optimize API function interface;
[0055] The IMMO data is directly processed in the PDUR interaction layer.
[0056] In an embodiment of the present invention, data routing is not performed through the RTE and application layer runnable, the routing channel is directly sunk, and data processing and routing are performed in the MCAL. By analyzing the original software of the gateway, when the CAN controller receives a message, it writes to the RX data register and passes the PDU ID and data pointer to the data link layer. At the same time, the data is written to the RX Buffer data buffer zone, and the PDUR network layer reads and writes data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0057] Furthermore, in an embodiment of the present invention, the software can be optimized as follows: 1. Routing path optimization: optimize the API function interface and process the IMMO data directly in the PDUR interaction layer; 2. Data lag optimization: data processing adopts the FIFO first-in-first-out processing method to ensure the consistency of data transmission.
[0058] As you can understand, CAN controller stands for CAN Local Area Network Controller. It is a serial data communication bus developed to facilitate data exchange between the numerous measurement and control components in modern automobiles. CAN offers data transmission rates up to 1Mbit / s, facilitating real-time control. Furthermore, its hardware error detection features enhance CAN's immunity to electromagnetic interference. Originally designed for automotive monitoring and control systems, CAN controllers are now widely adopted in industries such as aerospace, electric power, petrochemicals, metallurgy, textiles, papermaking, and warehousing. CAN technology is also widely used in automated control equipment such as trains, ships, robots, building automation systems, medical devices, CNC machine tools, and process automation instruments.
[0059] It's understood that a Protocol Data Unit (PDU) refers to the unit of data transferred between peer layers. A PDU at the physical layer is a bit, a PDU at the data link layer is a frame, a PDU at the network layer is a packet, a PDU at the transport layer is a segment, and PDUs at higher layers are messages.
[0060] In an embodiment of the present invention, compared with the prior art, in a CAN bus, when a source node forwards a CAN signal from a source network segment to a target network segment through a gateway, the gateway's source network segment CAN transceiver takes time from receiving the CAN signal to forwarding it to the target network segment. This time delay may affect the user's experience and satisfaction with vehicle functions (for example, anti-theft authentication between the BCM and the transmitter control unit). The original software, in accordance with the AUTOSAR general design method, transmits IMMO data via the BSW and RTE to the application module SWIN for processing, and then transmits it from SWIN and writes it to the BSW by RTE. The routing path is long and cannot meet the time requirements for IMMO authentication. After optimization, the routing time is reduced from 8ms to less than 0.5ms. The entire authentication process in the embodiment of the present invention, calculated based on only one successful data authentication, takes a total of 40ms. If the 100ms delay time for waiting for the first frame of PEPS is included, the total cycle is 140ms, which is less than the required 150ms.
[0061] Furthermore, in another preferred embodiment provided by the present invention, a gateway CAN message routing optimization system includes a channel sinking unit, a message processing unit and a data reading and writing unit, wherein:
[0062] The channel sinking unit is used to sink the routing channel and perform data processing and routing in MCAL;
[0063] The message processing unit is used to process the data message received by the CAN controller and pass the PDU ID and data pointer to the data link layer;
[0064] The data read and write unit is used to write data messages into the data buffer and read and write data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0065] In an embodiment of the present invention, the channel sinking unit does not perform data routing through the RTE and application layer runnable, but directly sinks the routing channel, performs data processing and routing in the MCAL, and by analyzing the original software of the gateway, when the CAN controller receives a data message, the message processing unit writes the data message into the RX data register, and passes the PDU ID and the data pointer of the data message to the data link layer. At the same time, the data reading and writing unit writes the data message into the RX Buffer data buffer, and the PDUR network layer reads and writes the data message with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit().
[0066] Specifically, in a preferred embodiment of the present invention, the message processing unit specifically includes:
[0067] The receiving judgment module is used to analyze the original software of the gateway and determine whether the CAN controller has received the data message;
[0068] The message writing module is used to write the data message into the RX data register when the CAN controller receives the data message;
[0069] The link transmission module is used to pass the PDU ID and data pointer to the data link layer.
[0070] In summary, the present invention implements this approach by sinking the routing channel and performing data processing and routing in the MCAL. When the CAN controller receives a data message, it processes it accordingly, passing the PDU ID and data pointer to the data link layer. The data message is written to the data buffer, and data is read and written to the data link layer via the API functions PduR_ComReceive() and PduR_ComTransmit(). By bypassing the RTE and application layer runnables for data routing and sinking the routing channel directly, data processing and routing are performed in the MCAL. This minimizes message routing time and effectively avoids long routing times and data inconsistencies.
[0071] It should be understood that, although the various steps in the flow chart of each embodiment of the present invention are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless otherwise specified herein, the execution of these steps is not strictly limited in order, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0072] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0073] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0074] The above-described embodiments merely illustrate several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.
[0075] The above description is only a preferred embodiment of the present invention and is 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 scope of protection of the present invention.
Claims
1. A gateway CAN message routing optimization method, characterized in that: The method specifically comprises the following steps: Sink the routing channel and perform data processing and routing in MCAL; When the CAN controller receives a data message, it processes it accordingly and passes the PDU ID and data pointer to the data link layer; The data message is written into the data buffer, and the data is read and written with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit(); When the CAN controller receives a data message, it performs corresponding processing and transmits the PDU ID and data pointer to the data link layer, specifically comprising the following steps: Analyze the original software of the gateway to determine whether the CAN controller has received the data message; When the CAN controller receives a data message, it writes the data message into the RX data register; Pass the PDU ID and data pointer to the data link layer; The data message is written into the data buffer, and the data link layer is read and written through the API interface functions PduR_ComReceive() and PduR_ComTransmit(), which specifically include the following steps: The data message is written into the data buffer; Optimize the routing path and obtain the API function interface; The PDUR network layer reads and writes data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit(); The routing channel is sunk, and during the data processing and routing in MCAL, data routing is not performed through RTE and application layer runnable.
2. The gateway CAN message routing optimization method according to claim 1, characterized in that: According to the routing path optimization, obtaining the API function interface specifically includes the following steps: Optimize API function interface; The IMMO data is directly processed in the PDUR interaction layer.
3. The gateway CAN message routing optimization method according to claim 2, characterized in that: The data processing adopts a FIFO first-in first-out processing method.
4. The gateway CAN message routing optimization method according to claim 1, characterized in that: The MCAL is a microcontroller abstraction layer, located at the lowest layer in the BSW layer.
5. The gateway CAN message routing optimization method according to claim 1, characterized in that: The PDU is a protocol data unit, which is a data unit transmitted between peer levels in a hierarchical network structure; the PDUID is an identifier of the protocol data unit.
6. A gateway CAN message routing optimization system, characterized in that: For executing the gateway CAN message routing optimization method according to claim 1, the system includes a channel sinking unit, a message processing unit and a data reading and writing unit, wherein: The channel sinking unit is used to sink the routing channel and perform data processing and routing in MCAL; The message processing unit is used to process the data message received by the CAN controller and pass the PDU ID and data pointer to the data link layer; The data reading and writing unit is used to write data messages into the data buffer, and read and write data with the data link layer through the API interface functions PduR_ComReceive() and PduR_ComTransmit(); The message processing unit specifically includes: The receiving judgment module is used to analyze the original software of the gateway and determine whether the CAN controller has received the data message; The message writing module is used to write the data message into the RX data register when the CAN controller receives the data message; The link transmission module is used to pass the PDU ID and data pointer to the data link layer.