Vehicle-mounted gateway and vehicle-mounted gateway control method for CAN message forwarding

By setting independent mask registers in the on-board gateway and allocating and mode setting according to the priority of CAN message ID, the problems of low efficiency and large delay in the on-board network are solved, and the effects of efficient forwarding and low delay are achieved, while ensuring timely processing of system tasks.

CN119966762APending Publication Date: 2025-05-09XIAMEN AUTOSTAR ELECTRONICS CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510068318.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

In on-vehicle networks, the forwarding efficiency of CAN messages is low, resulting in increased delays, and the problems of receiving frame drops and untimely processing of system tasks may occur.

Method used

By setting independent mask registers in the message cache of each CAN network segment of the vehicle gateway, filtering and allocation according to the ID priority of the CAN message, and setting different reception and transmission modes to achieve efficient processing of messages of different priority.

Benefits of technology

It improves the efficiency of forwarding CAN packets, reduces forwarding delays, and ensures timely processing of other tasks in the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119966762A_ABST
    Figure CN119966762A_ABST
Patent Text Reader

Abstract

The invention relates to a vehicle-mounted gateway and a vehicle-mounted gateway control method for CAN (Controller Area Network) message forwarding. The method comprises the following steps: setting an independent mask register in a message cache; counting the total number of CAN messages needing to be received and sent by each path of CAN network segment, judging whether the total number of the message caches is greater than or equal to the total number of the messages, and if so, configuring the filtering ID of the independent mask register corresponding to the message caches to be in a one-to-one mode; otherwise, configuring the filtering ID of the independent mask register corresponding to the partial message cache into a one-to-one mode and corresponding to the message with higher ID priority; and configuring the filtering ID of the independent mask register corresponding to the remaining message cache into a one-to-many mode, wherein the filtering ID corresponds to the message with lower priority. According to the invention, the forwarding efficiency of the CAN message is improved, and the forwarding delay time of the CAN message is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to an on-board gateway and an on-board gateway control method for CAN message forwarding. Background Art

[0002] With the development of automobile intelligence, electrification and networking, the number of on-board electronic control devices continues to increase, and the demand for CAN network communication between electronic control devices in different network segments is increasing. Therefore, the on-board network communication based on CAN communication is becoming more and more complicated. As a relay device for communication between many electronic control devices, the on-board gateway ensures that CAN messages can be correctly received and forwarded. When the CAN communication load is high, the need to improve the forwarding efficiency of CAN message signals and effectively reduce the message forwarding delay becomes more and more prominent.

[0003] The existing scheme generally adopts a message buffer to receive CAN messages of all IDs, interrupts the reception of CAN message data frames through multiple message buffers, and queues the CAN message data frames for transmission through multiple sending message buffers. With this design method, when the bus load rate is high, for some data frames with higher ID priority and shorter transmission cycle, the old data frames stored in the message buffer may not be processed in time and be overwritten by the newly received CAN message data frames, resulting in frame loss. The forwarding delay of CAN message data frames will also be relatively large. It is also possible that other tasks of the system may not be processed in time due to frequent interruptions. Summary of the invention

[0004] In order to solve the above problems, the present invention proposes an in-vehicle gateway and an in-vehicle gateway control method for forwarding CAN messages.

[0005] The specific plan is as follows:

[0006] A vehicle-mounted gateway control method for CAN message forwarding, comprising:

[0007] An independent mask register for filtering the ID of the CAN message is set in all message caches corresponding to each CAN network segment supported by the vehicle gateway;

[0008] Count the total number of CAN messages that need to be received and sent by each CAN network segment, and determine whether the total number of message buffers corresponding to the CAN network segment is greater than or equal to the total number of CAN messages that need to be received and sent by the CAN network segment. If so, assign a corresponding message buffer one-to-one to each received and sent CAN message, and configure the filter ID of the independent mask register corresponding to the assigned message buffer to a one-to-one mode, and set the message receiving or sending mode corresponding to the message buffer to a query mode; otherwise, configure the filter ID of the independent mask register corresponding to some message buffers to a one-to-one mode, and correspond to messages with higher ID priority, and set the message receiving or sending mode corresponding to the message buffer to a query mode; configure the filter ID of the independent mask register corresponding to the remaining message buffers to a one-to-many mode, and correspond to messages with lower priority, and set the message receiving or sending mode corresponding to the message buffer to an interrupt mode.

[0009] Furthermore, a corresponding sending cache queue is constructed for each corresponding independent mask register configured as a message cache in a one-to-many mode; for CAN messages received on each CAN network segment, if there is a need to forward them to other network segments, when the independent mask register in the corresponding message cache is in a one-to-one mode, the current transmission is in an idle state and is sent immediately, otherwise the CAN messages to be forwarded are stored in the sending cache queue; when the independent mask register in the corresponding message cache is in a one-to-many mode, first determine whether the message cache has any sending tasks being executed and whether there are any unsent CAN messages in the sending cache queue; if there are no sending tasks being executed in the message cache and there are no unsent CAN messages in the sending cache queue, the CAN messages to be forwarded are sent immediately; otherwise, wait until the sending task is idle before sending.

[0010] Furthermore, all electronic control devices supporting CAN communication are divided according to functional domains, and electronic control devices in the same functional domain are integrated into the same road network segment.

[0011] A vehicle-mounted gateway comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned method in an embodiment of the present invention when executing the computer program.

[0012] The present invention adopts the above technical scheme, and according to the CAN message ID priority characteristics, the independent mask register corresponding to the message cache is set differently, thereby realizing different processing methods for CAN messages of different priorities. At the same time, for each message cache that needs to be received or sent, it is separately set to interrupt or query mode according to the filter ID priority order. When the bus load is high, it can ensure that all messages can be correctly received and forwarded, thereby improving the forwarding efficiency of CAN messages and reducing the CAN message forwarding delay time, while also taking into account that other tasks of the system can be processed in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 FIG. 1 is a schematic diagram showing the communication relationship of the vehicle gateway in the first embodiment of the present invention. DETAILED DESCRIPTION

[0014] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.

[0015] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.

[0016] Embodiment 1:

[0017] The vehicle-mounted gateway needs to be able to support receiving and forwarding messages from multiple CAN segments in the same time period. The gateway controller used in the vehicle-mounted gateway can support CAN communications of multiple channels. The CAN module corresponding to each channel (i.e., each CAN segment) has multiple message buffers (Message Buffer, hereinafter referred to as MB) (64 are used in this embodiment). The message data frame stored in each MB can be independently set to receive or send mode, and the reception or transmission of each data frame can be set to query or interrupt mode accordingly. Each MB also has an independent receive mask (Rx Individual Mask) control. By flexibly setting the MB independent receive mask, the data frame ID stored in each MB can be set to a one-to-one or one-to-many mode. Based on the flexible use of MB in the CAN controller, CAN messages can be efficiently forwarded even under high load conditions.

[0018] Based on this, the present embodiment provides a high-efficiency, low-latency vehicle gateway control method for CAN message forwarding, including: setting an independent mask register for filtering the ID of the CAN message in all message caches corresponding to each CAN network segment supported by the vehicle gateway. Count the total number of CAN messages that need to be received and sent by each CAN network segment, and determine whether the total number of message buffers corresponding to the CAN network segment is greater than or equal to the total number of CAN messages that need to be received and sent by the CAN network segment. If so, assign a corresponding message buffer one-to-one to each received and sent CAN message, and configure the filter ID of the independent mask register corresponding to the assigned message buffer to a one-to-one mode (one independent mask register filters one ID), and set the message receiving or sending mode corresponding to the message buffer to query mode; otherwise, configure the filter ID of the independent mask register corresponding to some message buffers to a one-to-one mode, and correspond to messages with higher ID priority, and set the message receiving or sending mode corresponding to the message buffer to query mode; configure the filter ID of the independent mask register corresponding to the remaining message buffers to a one-to-many mode (one independent mask register filters multiple IDs), and correspond to messages with lower priority, and set the message receiving or sending mode corresponding to the message buffer to interrupt mode.

[0019] In the above method, CAN messages are classified with different IDs according to the forwarding requirements of CAN messages, and the total number of CAN messages that the vehicle gateway needs to receive and send on each CAN network segment is counted. If the number of MBs corresponding to a certain CAN network segment can meet the one-to-one matching of the CAN message IDs that need to be received and sent in the current network segment (i.e., one MB only sends CAN messages with one ID), the IDs corresponding to the receiving and sending MBs are preferentially filtered by setting the receiving independent mask register (i.e., the set independent mask register only filters the unique ID); otherwise, the data frames with high ID priority (according to the CAN message ID priority characteristics, generally the smaller the ID value, the higher the ID priority) are filtered by setting the receiving independent mask register and assigned independent MBs, and the corresponding receiving or sending mode is generally set to query receiving or sending mode; for data frames with low ID priority, the independent mask register filtering ID is configured as a one-to-many shared MB (i.e., one MB sends CAN messages with multiple IDs), so that data frames with different IDs can enter the same MB (i.e., the set independent mask register filters multiple IDs), and the corresponding data frame receiving or sending mode is generally set to interrupt receiving or sending mode.

[0020] Based on the above design principles, for the CAN bus receiving data frames, data frames with high ID priority enter the independent MB first, and the data frames in the MB are read by query reception; data frames with low ID priority enter the shared MB, and the MB data frames are read by interrupt reception to ensure the timeliness of receiving data frames.

[0021] In this embodiment, a corresponding sending buffer queue is constructed for each corresponding independent mask register configured as a message buffer in a one-to-many mode, and a special memory is opened up for storing the sending buffer queue. For the CAN data frame received on each network segment, if there is a need to forward it to other network segments, the ID of the CAN message data frame to be forwarded is matched with the corresponding MB by querying. If it is set to an independent (i.e., one-to-one) sending MB, the forwarding data frame will be sent immediately if the current sending is in an idle state, otherwise the forwarded data frame will be stored in the sending buffer queue; if it is set to a shared (i.e., one-to-many) sending MB, first determine whether the current MB has a sending message task in execution and whether there are still data frames in the sending buffer queue that have not been sent. If the current MB has no sending task in execution and there are no data frames that need to be sent in the sending buffer queue, the data frame that needs to be forwarded will be sent immediately, otherwise it is necessary to wait for the corresponding MB to send the task when it is idle. By flexibly setting the independent receiving mask corresponding to each MB and the corresponding receiving and sending mode, it is ensured that all network segment data frames on the CAN bus are correctly received and no frames are missed, thereby improving the forwarding efficiency of data frames and reducing data frame delay.

[0022] The communication method corresponding to the vehicle gateway is as follows Figure 1 As shown in FIG. 1 , the gateway controller serves as the hub for all CAN network segment communications in the vehicle, completing the reception, filtering and forwarding of all CAN network segment messages. Figure 1 As shown in the CAN1~CAN6 network segments, there are many on-board CAN bus devices, and it is impossible to support all CAN devices to be installed in the same network segment. Therefore, in this embodiment, all electronic control devices that support CAN communication are divided according to functional domains, and electronic control devices in the same functional domain are integrated into the same network segment to ensure the timeliness of mutual communication between electronic control devices and the safety of work. Figure 1 The device shown can independently or partially complete a certain function on board through electronic control or assist in completing it according to functional requirements. The MB is a fixedly allocated memory inside the MCU for the gateway controller to receive or send messages. The receiving independent mask is a register used in pair with the MB to filter the CAN message ID. By setting the associated bit of the receiving independent mask register (0: means don't care about this bit, 0 or 1 will be received; 1: means care about this bit, must be the same as the field of the programming ID buffer segment), the programming ID stored in the receiving message cache can be matched with the ID received by the CAN bus.

[0023] According to the CAN message ID priority characteristics and based on the gateway controller's requirements for receiving and forwarding CAN messages, the embodiment of the present invention flexibly designs the gateway CAN controller MB and the receiving independent mask to preferentially assign one-to-one MBs for data frame storage and query processing for CAN messages with high ID priority. For individual ID data frames with special timeliness requirements, they can also be set to an interrupt processing mode; data frames with low ID priority are uniformly assigned to a shared MB for storage and interrupt processing. Through the above design method, some ID data frames that do not need to be received and processed are first filtered from the hardware to reduce the system processing time. The above design method can improve the forwarding efficiency of CAN messages and reduce the delay time of CAN message forwarding when the bus load is high, while ensuring that all messages can be correctly received and forwarded, while also taking into account that other tasks of the system can be processed in a timely manner.

[0024] Embodiment 2:

[0025] The present invention further provides a vehicle-mounted gateway, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above method embodiment of the first embodiment of the present invention when executing the computer program. Figure 1 The gateway controller in the system is usually an MCU.

[0026] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.

Claims

1. A vehicle gateway control method for CAN message forwarding, characterized in that: include: An independent mask register for filtering the ID of the CAN message is set in all message caches corresponding to each CAN network segment supported by the vehicle gateway; Count the total number of CAN messages that need to be received and sent by each CAN network segment, and determine whether the total number of message buffers corresponding to the CAN network segment is greater than or equal to the total number of CAN messages that need to be received and sent by the CAN network segment. If so, assign a corresponding message buffer one-to-one to each received and sent CAN message, and configure the filter ID of the independent mask register corresponding to the assigned message buffer to a one-to-one mode, and set the message receiving or sending mode corresponding to the message buffer to a query mode; otherwise, configure the filter ID of the independent mask register corresponding to some message buffers to a one-to-one mode, and correspond to messages with higher ID priority, and set the message receiving or sending mode corresponding to the message buffer to a query mode; configure the filter ID of the independent mask register corresponding to the remaining message buffers to a one-to-many mode, and correspond to messages with lower priority, and set the message receiving or sending mode corresponding to the message buffer to an interrupt mode.

2. The vehicle-mounted gateway control method for CAN message forwarding according to claim 1, characterized in that: A corresponding sending buffer queue is constructed for each corresponding independent mask register configured as a message buffer in one-to-many mode; for CAN messages received on each CAN network segment, if there is a need to forward them to other network segments, when the independent mask register in the corresponding message buffer is in one-to-one mode, the current transmission is in idle state and then sent immediately, otherwise the CAN messages to be forwarded are stored in the sending buffer queue; when the independent mask register in the corresponding message buffer is in one-to-many mode, first determine whether the message cache has any sending tasks being executed and whether there are any unsent CAN messages in the sending buffer queue. If there are no sending tasks being executed in the message cache and there are no unsent CAN messages in the sending buffer queue, the CAN messages to be forwarded are sent immediately; otherwise, wait until the sending task is idle before sending.

3. The vehicle-mounted gateway control method for CAN message forwarding according to claim 1, characterized in that: All electronic control devices that support CAN communication are divided into functional domains, and electronic control devices in the same functional domain are integrated into the same road network segment.

4. A vehicle-mounted gateway, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 3 when executing the computer program.

Citation Information

Cited By

  • CAN mailbox filtering rule configuration method and device, equipment and storage medium

    CN120528887A