CAN message scheduling method and TSN-CAN gateway

By evaluating the remaining delay of CAN messages in the TSN-CAN network and scheduling, the problem of inflexible CAN message scheduling algorithm in the prior art is solved, and more efficient data transmission and better real-time performance are achieved.

CN119402393APending Publication Date: 2025-02-07CONTINENTAL AUTOMOTIVE R & D (CHONGQING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411495721.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The existing CAN message scheduling algorithm is not flexible enough when facing complex and changing network environments and cannot meet the real-time requirements of some applications.

Method used

By receiving Ethernet messages, multiple CAN messages are obtained, and the remaining delay of each CAN message is evaluated, and the CAN message is scheduled according to the remaining delay.

Benefits of technology

It improves the real-time and flexibility of CAN message scheduling, can better meet the real-time requirements of messages, and improves the efficiency of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402393A_ABST
    Figure CN119402393A_ABST
Patent Text Reader

Abstract

The invention provides a CAN (Controller Area Network) message scheduling method and a TSN-CAN gateway. The method can be used in a TSN-CAN network, and comprises the following steps: receiving an Ethernet message from a source end, the Ethernet message comprising a plurality of CAN messages packaged by the source end; decapsulating the Ethernet message to obtain the plurality of CAN (Controller Area Network) messages; evaluating the residual time delay of each CAN message to the deadline; and scheduling the plurality of CAN messages according to the residual time delay. According to the embodiment of the invention, the real-time performance and flexibility of CAN message scheduling can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to vehicle-mounted communication technology, and in particular to a CAN message scheduling method and a TSN-CAN gateway. Background Art

[0002] Traditional in-vehicle networks are based on the CAN (Controller Area Network) bus. However, with the increasing number of in-vehicle devices and the explosive growth of data volume, the CAN bus is no longer sufficient in terms of bandwidth and efficiency of data transmission. Therefore, Ethernet is gradually being used in in-vehicle networks. Ethernet has high bandwidth, low cost and excellent scalability. The use of Ethernet can greatly improve the data transmission speed and efficiency, thus easily meeting the stringent requirements of modern in-vehicle systems such as high-definition audio and video streaming and large-scale data processing.

[0003] However, on the other hand, due to economic costs and historical system architecture issues, the CAN bus will still be used for a long time in the future, so the CAN network and the TSN network will coexist for a long time. Specifically, in the current automotive network architecture, the inter-domain backbone network generally gradually adopts TSN (Time-Sensitive Networking, which is an enhancement of standard Ethernet) for data transmission, while the ECUs (Electronic Control Units) within the domain still use the CAN bus for communication for economic and compatibility considerations. Therefore, the TSN-CAN gateway, as a bridge connecting the two networks, has become an indispensable part of ensuring the normal communication of the vehicle network.

[0004] In the TSN-CAN gateway, it involves encapsulating CAN messages into Ethernet messages and decapsulating Ethernet messages into CAN messages. After decapsulating Ethernet messages into CAN messages, when scheduling CAN messages, they are generally scheduled according to the encapsulation order of CAN messages or the CAN ID (identity identification) of CAN messages.

[0005] However, the encapsulation order of CAN messages cannot reflect the urgency and importance of the messages, and cannot meet the real-time requirements of some applications. CAN ID is usually used to identify different messages or message types, and does not directly reflect the priority or real-time requirements of the messages. Even if the importance or urgency of the CAN messages has been considered when allocating CAN IDs, different CAN messages have different transmission delays (due to different transmission links). If a CAN message has a smaller CAN ID but a smaller transmission delay, and other CAN messages have a larger CAN ID but a larger transmission delay, if CAN messages are only scheduled based on CAN IDs, some messages with larger CAN IDs will time out, and the real-time requirements of some applications cannot be met.

[0006] Therefore, the existing CAN message scheduling algorithm is not flexible enough when facing a complex and changing network environment and may not be able to meet the real-time requirements of some applications. Summary of the invention

[0007] In view of this, the present invention provides a CAN message scheduling method and a TSN-CAN gateway, which can improve the real-time performance and flexibility of CAN message scheduling.

[0008] The CAN message scheduling method of the embodiment of the present invention is used in a TSN-CAN network, comprising: receiving an Ethernet message from a source end, wherein the Ethernet message includes a plurality of CAN messages encapsulated by the source end; decapsulating the Ethernet message to obtain the plurality of CAN messages; evaluating the remaining delay of each CAN message from a deadline; and scheduling the plurality of CAN messages according to the remaining delay.

[0009] In some embodiments, the step of evaluating the remaining delay of each CAN message from the deadline includes: determining the overall delay of the CAN message from encapsulation to decapsulation based on the reception time information of the CAN message carried in the Ethernet message, and evaluating the remaining delay based on the overall delay.

[0010] In some implementations, the receiving time information in the Ethernet message is the time when the source end completely receives the first frame of the CAN message in the Ethernet message.

[0011] In some implementations, the overall delay is the time difference between the time when the Ethernet message is decapsulated and the receiving time information.

[0012] In some implementations, the remaining delay is evaluated further based on a deadline of the CAN message and a transmission delay of the CAN message at a source end and a destination end.

[0013] In some implementations, the step of scheduling the plurality of CAN messages according to the residual delay includes: when distributing the plurality of CAN messages, CAN messages with smaller residual delays are distributed preferentially.

[0014] In some embodiments, the step of scheduling the multiple CAN messages according to the residual delay includes: distributing the multiple CAN messages; determining the local priority of each CAN message according to the residual delay and CAN ID of each CAN message; and scheduling the distributed CAN messages according to the local priority.

[0015] In some implementations, before the step of scheduling the plurality of CAN messages according to the remaining delay, the method further includes: prioritizing scheduling emergency messages among the CAN messages.

[0016] In some embodiments, the method further includes: at the source end, encapsulating the multiple CAN messages into the Ethernet message according to at least one of a buffer timing strategy, a buffer capacity strategy, a CAN message quantity strategy, and an emergency trigger strategy.

[0017] A TSN-CAN gateway according to an embodiment of the present invention is used to decapsulate Ethernet messages into CAN messages, including: a first cache; a second cache; a decapsulation module, used to decapsulate received Ethernet messages to obtain multiple CAN messages, and cache the multiple CAN messages in the first cache; a distributor, used to distribute the multiple CAN messages in the first cache to multiple transmission queues in the second cache; and a scheduler, used to schedule the multiple CAN messages in the second cache to a corresponding CAN controller to be sent to a CAN network through the CAN controller; wherein, in the distributor and / or the scheduler, distribution and / or scheduling are performed according to the remaining delay of the CAN message from the deadline; the remaining delay is evaluated at least based on the overall delay of the CAN message from encapsulation to decapsulation, and the overall delay is determined at least based on the reception time information of the CAN message carried in the Ethernet message on the encapsulation side.

[0018] In some embodiments, the remaining delay is determined based on the following formula: t3≤D-t1-t2-t4; wherein t3 is the remaining delay, D is the deadline of the CAN message, t1 is the sending delay of the CAN message at the source end, t4 is the sending delay of the CAN message at the destination end, and t2 is the overall delay.

[0019] In some implementations, the receiving time information is the time when the encapsulation side completely receives the first frame CAN message in the Ethernet message, and the overall delay is the time difference between the time when the Ethernet message is decapsulated and the receiving time information.

[0020] In some implementations, the scheduler is specifically configured to: determine a priority of message scheduling according to the remaining delay and a CANID of the CAN message; and schedule the CAN message according to the determined priority.

[0021] A computer device / equipment / system according to an embodiment of the present invention includes a memory, a processor, and a computer program / instruction stored in the memory, wherein the processor executes the computer program / instruction to implement the method according to the embodiment of the present invention.

[0022] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, wherein the computer program includes executable instructions. When the executable instructions are executed by a processor, the method described in the embodiment of the present invention is implemented.

[0023] A computer program product according to an embodiment of the present invention includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to the embodiment of the present invention is implemented.

[0024] Beneficial effects of the embodiments of the present invention:

[0025] In the TSN-CAN network, when scheduling CAN messages, the CAN messages are scheduled based on the remaining delay of the message from the deadline. Therefore, compared with the scheduling method based on the order of message encapsulation or CAN ID, it can better meet the real-time requirements of the message and has better scheduling flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Other details and advantages of the present invention will become apparent from the detailed description provided below. It should be understood that the following drawings are merely illustrative and thus cannot be considered as limiting the present invention, and the following will be described in detail with reference to the drawings, wherein:

[0027] Figure 1 This is a diagram of the domain control electronic and electrical architecture based on TSN;

[0028] Figure 2 This is a diagram of the central control electronic and electrical architecture based on TSN;

[0029] Figure 3 It is a flowchart of a message transmission process according to an embodiment of the present invention;

[0030] Figure 4It is a schematic diagram of the process of message decapsulation and scheduling in the TSN-CAN gateway of an embodiment of the present invention;

[0031] Figure 5 It is a flow chart of a method for scheduling CAN messages according to an embodiment of the present invention;

[0032] Figure 6 It is a flow chart of a method for encapsulating CAN messages according to an embodiment of the present invention;

[0033] Figure 7 It is a flow chart of a message distribution method according to an embodiment of the present invention;

[0034] Figure 8 It is a flowchart of a method for scheduling distributed messages according to an embodiment of the present invention;

[0035] Fig. 9 It is a schematic diagram of the structure of a computer device / equipment / system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention clearer and more understandable, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention.

[0037] In the description of the present invention, it is to be understood that the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. Moreover, the terms "first", "second", etc. are applicable to distinguishing similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein.

[0038] The present invention relates to a CAN message scheduling method. The process of the method embodiment can refer to Figure 5 This method can be used in TSN-CAN networks, for example Figure 1 and 2 In the TSN-CAN gateway in the network architecture shown.

[0039] Figure 1This is a diagram of the domain control electronic and electrical architecture based on TSN. In a vehicle, the vehicle can be divided into five domains based on function, namely the power domain, body domain, chassis domain, cockpit domain (or intelligent information domain) and autonomous driving (ADAS) domain. Each domain is equipped with a dedicated domain controller (Domain Control Unit, DCU) for control. In the figure, only the body domain and ADAS domain are used as examples for explanation. The situations of other domains are similar and will not be repeated here.

[0040] like Figure 1 As shown in the figure, each domain communicates through Ethernet and TSN switches, and each domain communicates through the CAN bus. The conversion is performed within and between domains through the TSN-CAN gateway. The functions of the TSN-CAN gateway include: encapsulating CAN messages received from the CAN bus into Ethernet messages so that they can be transmitted on the Ethernet between domains; and decapsulating Ethernet messages received from Ethernet into CAN messages so that they can be transmitted on the CAN bus within the domain. This network architecture uses an Ethernet-based backbone network between domains. In Ethernet, the TSN switch uses queue priority management and an efficient scheduling algorithm, which can effectively alleviate congestion in the inter-domain network and reduce transmission delays.

[0041] Figure 2 This is a schematic diagram of the central control electronic and electrical architecture based on TSN. In the central control architecture, with HPC (High Performance Computer, or central controller) as the center, the electronic components in the vehicle are divided into four areas based on location: left, right, front, and rear, and corresponding zone controllers (Zone Control Unit, ZCU) are set. Figure 2 In FIG. 1 , only the zone controllers located on the left and right sides are shown as an example. Figure 2 In the architecture, HPC acts as a powerful data processing and decision-making center, gathering various information and data of the vehicle to achieve global optimization and coordinated control, thereby reducing system complexity and improving overall efficiency and response speed. Figure 1 way, such as Figure 2 As shown in the figure, the ZCU and HPC use a TSN-based backbone network for communication, and the CAN bus is used for communication within the area. The TSN-CAN gateway is used as a bridge to connect the regional network and the backbone network.

[0042] The CAN message scheduling method of this embodiment is used to Figure 1 and 2 In each TSN-CAN gateway in. It should be noted that, Figure 1 and 2This is only an example of the application scenario of this embodiment and should not be construed as limiting. In a broad sense, the method involved in this embodiment can be applied to all scenarios that require conversion between TSN and CAN networks.

[0043] Specifically, this embodiment can be applied to the process of scheduling CAN messages after decapsulating Ethernet messages into CAN messages. Figure 3 and 4 To explain.

[0044] Figure 3 It is a schematic diagram of the message transmission process in this embodiment, which involves transmitting the message from the ECU at the source end to the ECU at the destination end. Figure 4 FIG. 1 is a schematic diagram of the decapsulation and scheduling of messages in this embodiment. Figure 3 As shown in the figure, at the source end (or called: sending end / source side), the CAN messages m1~m5 generated by each ECU are transmitted to the TSN-CAN gateway 1 through the CAN bus in the domain. The TSN-CAN gateway 1 packages one or more CAN messages into application layer data in the order of reception based on the predetermined encapsulation strategy. These data are then processed by the network protocol stack, such as adding IP headers and Ethernet headers, and finally generate standardized Ethernet messages. The TSN-CAN gateway 1 sends the generated Ethernet message to the TSN-CAN gateway 2 through the TSN switch.

[0045] like Figure 3 and 4 As shown, when the TSN-CAN gateway 2 successfully receives the Ethernet message from the TSN switch, the Ethernet message is decapsulated by the decapsulation module 20, and the Ethernet header and IP header are removed to obtain CAN messages m1~m5. CAN messages m1~m5 are temporarily stored in the first buffer (Buffer) 21, waiting for the distributor 22 to schedule. The distributor 22 schedules the CAN messages m1~m5 to distribute the CAN messages to the corresponding transmission queues and store them in the second buffer 23. Finally, the scheduler 24 schedules the CAN messages from the second buffer 23 to the CAN controllers 25 and 26 to be sent to the CAN bus through the CAN controllers 25 and 26, and then sent to the destination ECU. It should be noted that the number of messages, the number of transmission queues, the number of CAN controllers, etc. in the figure are examples and not limitations of the present invention.

[0046] In the TSN-CAN gateway 1, at least one encapsulation strategy can be used to trigger the encapsulation of CAN messages. For example, the encapsulation strategies that can be used include: at least one of a buffer timing strategy, a buffer capacity strategy, a CAN message quantity strategy, and an emergency trigger strategy. Among them, the buffer timing strategy refers to setting a fixed time period, during which all received CAN messages are temporarily stored in the cache. When the timing period is reached, the TSN-CAN gateway triggers the CAN message encapsulation operation, regardless of the number of messages in the buffer. The buffer capacity strategy refers to presetting a capacity threshold, monitoring the capacity occupancy of the buffer, when the buffer capacity occupancy does not reach the threshold, the received CAN message is temporarily stored in the buffer, and when the buffer capacity occupancy reaches the threshold, the CAN message encapsulation operation is triggered. The CAN message quantity strategy refers to presetting a message quantity threshold, when the message quantity does not reach the threshold, the received CAN message is cached, and when the message quantity occupancy reaches the threshold, the CAN message encapsulation operation is triggered. The emergency trigger strategy refers to predefining some CAN IDs as emergency message identifiers. Every time a CAN message is received, it is determined whether the message is an emergency message. If so, the CAN message encapsulation operation is triggered immediately. If not, it is triggered based on other encapsulation strategies.

[0047] For example, Figure 6 As shown, it is a flow chart of an embodiment of using multiple encapsulation strategies to encapsulate CAN messages into Ethernet messages, which includes: step S60: receiving CAN messages. Step S61: judging whether the CAN message received in step S60 is an emergency message, that is, an emergency triggering strategy. Among them, some CAN IDs can be set as emergency identifiers in advance. When the CAN ID of the received CAN message can match one of these preset CAN IDs, the received CAN message is an emergency message. When the judgment result of step S61 is yes, step S68 is executed, otherwise step S62 is executed: caching the CAN message received in step S60. Step S63: judging whether the number of cached CAN messages reaches a preset number threshold, that is, a CAN message number strategy. If the judgment result is yes, step S68 is executed, otherwise step S64 is executed: judging whether the occupancy of the cache area reaches a preset capacity threshold, that is, a cache area capacity strategy. If the judgment result is yes, step S68 is executed, otherwise step S65 is executed: judging whether the cache timer has timed out, that is, a cache area timing strategy. The timeout value of the cache timer can be preset. When the judgment result is no, execute step S62, otherwise execute step S66: determine whether the load in the cache is empty, that is, whether there is a cached CAN message. When it is determined that the cache is empty, execute step S67: restart the cache timer. When it is determined that the cache is not empty, execute step S68: trigger a packaging operation.

[0048] In the TSN-CAN gateway 2, the scheduling of the CAN messages obtained by decapsulation is involved (including the distribution of the distributor 22 and / or the scheduling of the scheduler 24), wherein the efficiency of the scheduling is directly related to the real-time problem of the message. In some embodiments, scheduling is performed based on the encapsulation order or CAN ID of the message, but such a scheduling method may not meet the real-time requirements of certain applications, and does not support dynamic scheduling, and has poor flexibility and robustness. In an embodiment of the present invention, another scheduling method for CAN messages is proposed, which is based on the remaining delay of the message from the deadline, which can meet the real-time requirements of various applications and has better scheduling efficiency. Furthermore, an embodiment of the present invention also provides a method for evaluating the remaining delay. In evaluating the remaining delay, the overall delay of the message from encapsulation to decapsulation is evaluated in an overall manner, and then the remaining delay is evaluated based on the overall delay. This method can be flexibly used for various different encapsulation strategies and does not require complex modeling analysis. The following is combined with Figure 5 And related drawings for further explanation.

[0049] like Figure 5 FIG. 1 is a flow chart of an embodiment of a method for scheduling CAN messages of the present invention. The method can be used for Figure 3 and 4 In the TSN-CAN gateway 2 in the embodiment, it is specifically used to decapsulate Ethernet messages and schedule the obtained CAN messages. The method comprises the following steps:

[0050] Step S50: receiving an Ethernet message from a source end (such as the TSN-CAN gateway 1).

[0051] The Ethernet message received in step S50 encapsulates multiple CAN messages. It should be noted that there is a situation where only one CAN message is encapsulated in the Ethernet message. For only one CAN message encapsulated, the CAN message can be directly scheduled. This embodiment mainly focuses on the scheduling order of these CAN messages when multiple CAN messages are encapsulated.

[0052] Step S52: Decapsulate the Ethernet message to obtain multiple CAN messages. This step can be performed by Figure 4 The decapsulation module 20 in is executed.

[0053] Step S54: Evaluate the remaining delay of the CAN message from the deadline.

[0054] The deadline of the CAN message can be considered as the sending period of the CAN message, or a certain proportion (e.g., 80% or 90%) of the sending period of the CAN message can be used as the deadline. The sending period of the CAN message is predefined, so the deadline of the CAN message is a known quantity.

[0055] Generally, when the receiving end fails to receive the CAN message before the deadline, the corresponding fault handling logic will be triggered, which does not meet the real-time requirements of the upper-layer application. Therefore, it is necessary to ensure that the CAN message is successfully received by the receiving end before the deadline as much as possible. In this embodiment, the speed of the scheduling process directly affects whether the CAN message can reach the receiving end before the deadline, and this process is controllable. Therefore, in this embodiment, the remaining delay of the CAN message from the deadline is evaluated by calculating the time left for the scheduling process, that is, the scheduling process needs to complete the scheduling within at least a certain time to ensure that the message can reach the receiving end before the deadline, thereby meeting the real-time requirements of the application for the message. Therefore, if the time left for the scheduling process is less, the corresponding CAN message should be scheduled first, otherwise it may be difficult to meet the real-time requirements.

[0056] Step S56: Schedule each CAN message according to the remaining delay obtained in step S54. The scheduling in this step may refer to Figure 4 The distribution operation of the distributor 22, and / or Figure 4 The scheduling operation of the scheduler 24. In some preferred examples, the scheduling in this step mainly refers to the distribution operation of the distributor 22, so the speed of distribution has a greater impact on the real-time performance of the message.

[0057] In the embodiment of the present invention, the remaining delay of the CAN message may be evaluated based on the following method.

[0058] like Figure 3 and 4 As shown, the total delay of CAN message m from the transmitting ECU to the receiving ECU can be divided into four parts, namely t1 to t4. Among them, t1 refers to the delay of ECU sending CAN message m to TSN-CAN gateway 1, that is, the sending delay of the source end. t2 refers to the delay of the entire process of CAN message encapsulation in TSN-CAN gateway 1 and sending to TSN-CAN gateway 2 and decapsulation, that is, the delay of CAN message from encapsulation to decapsulation. t3 refers to the delay of CAN message waiting for scheduling in TSN-CAN gateway 2. t4 refers to the delay of TSN-CAN gateway 2 sending CAN message to the receiving ECU, that is, the sending delay of the destination. Among them, the remaining delay of the CAN message from the deadline can, for example, refer to the above-mentioned t3, which can be evaluated in the following way.

[0059] Assume that the deadline of CAN message m is D, where D can be 90% of the message period. In order to ensure that the CAN message is successfully received by the receiver before the deadline, the sum of t1 to t4 should be less than or equal to D, that is:

[0060] t1+t2+t3+t4≤D

[0061] Further we can get:

[0062] t3≤D-t1-t2-t4

[0063] In the above, D is a known quantity, so only t1, t2, and t4 need to be calculated to estimate t3.

[0064] Both t1 and t4 represent the communication delay between CAN nodes in the domain, and their calculation rules are the same. The following only takes t1 as an example for illustration. There are many evaluation methods for t1 in the industry, and the following only takes one of them for illustration.

[0065] Specifically, according to the CAN message sending process and arbitration rules, the sending delay t1 of CAN message m includes: queuing delay t1 wait And transmission delay t1 transmit ,Right now:

[0066] t1=t1 wait +t1 transmit .

[0067] Taking the standard format CAN-FD message as an example, the transmission delay t1 transmit It can be expressed as:

[0068]

[0069] This formula is derived based on the "worst case response time analysis" and considering the byte stuffing in the CAN-FD message. Among them, R-arbitration and R-data refer to the arbitration transmission rate and data transmission rate in the CAN-FD message, respectively, and are fixed values ​​set by the CAN controller. si represents the data segment length of the CAN-FD message m, and its unit is byte. It represents the rounding up function, that is, when si>16, the value is 1, and when si≤16, the value is 0.

[0070] According to the CAN message arbitration rules, the waiting delay t1 of CAN message m is wait Includes: waiting for the transmission delay t1 of the low-priority message that has won arbitration before m but has not yet completed sending wait_lower ; and m needs to wait for all CAN messages with a priority higher than its priority to be sent before it can be sent. The waiting time for this part is t1 wait_higher .

[0071] Among them, according to the worst case response time analysis, t1 wait_lower It can be expressed as:

[0072]

[0073] In this formula, lp(i) represents the set of all CAN messages with a priority lower than m.

[0074] Among them, t1 wait_higher It can be expressed as:

[0075]

[0076] In this formula, hp(i) represents the set of all CAN messages with a priority higher than m. The message gap between CAN messages is represented by the time of transmitting a 1-bit arbitration field, that is, R_arbitration.

[0077] Therefore, t1 wait It can be expressed as:

[0078]

[0079] For t2, its composition includes: encapsulation delay, network protocol stack processing of TSN-CAN gateway 1 (such as adding Ethernet header information and buffer storage operation) delay, Ethernet message sending delay of TSN-CAN gateway 1, forwarding processing delay of TSN switch (message queuing delay can be ignored) and protocol stack processing of gateway 2 (such as decapsulating Ethernet message back to the original CAN message and storing it in the specified buffer) delay. Among them, encapsulation delay refers to the delay of CAN message waiting to be packaged into application layer data. The size of encapsulation delay is related to the encapsulation strategy. Different encapsulation strategies have different encapsulation delays.

[0080] In some solutions, each module in the transmission path (such as encapsulation, transmission, forwarding, and decapsulation) can be modeled for delay analysis. However, there are problems such as high modeling difficulty, complex model solving, and possible unsatisfactory results. For example, taking the forwarding processing delay of a TSN switch as an example, although the queuing delay of the message can be ignored due to the existence of a gating mechanism, the forwarding delay itself is affected by the length of the Ethernet message and the port bandwidth, especially the message length is directly related to the number of CAN messages contained, and the number of CAN messages is random. Therefore, even if modeling analysis is performed, only static analysis results can be obtained and the actual delay situation cannot be reflected. In addition, when a variety of encapsulation strategies are adopted in combination, it is obviously difficult to calculate the encapsulation delay.

[0081] Therefore, in the embodiment of the present invention, a more accurate Ethernet message transmission delay is obtained by comprehensively defining the entire Ethernet message transmission delay.

[0082] Specifically, t2 is calculated based on the following formula:

[0083] t2=t f_current_time -t f_receive_timestamp

[0084] Among them, t f_current_time The time when the Ethernet packet is decapsulated. Figure 4 After receiving the Ethernet message, the TSN-CAN gateway 2 triggers the receiving interrupt service, reads and decapsulates the Ethernet message, extracts the application layer data in the Ethernet message and stores it in the first cache 21. After the application layer data is stored in the first cache 21, the TSN-CAN gateway 2 calls the time service function to obtain the current time as t f_current_time .

[0085] Among them, t f_receive_timestamp The time when the first frame of CAN message is received when the CAN message is encapsulated as an Ethernet message, that is, the CAN message receiving timestamp, that is, eth(i) represents the set of all CAN messages contained in the currently encapsulated Ethernet message. f_receive_timestamp Carried in the Ethernet message, TSN-CAN gateway 2 extracts t f_receive_timestamp It should be noted that, since the receiving timestamps of other CAN messages in the Ethernet message must be smaller than the receiving timestamp of the first frame CAN message, in order to simplify the complexity, the receiving timestamp of the first frame CAN message is used uniformly. In addition, in this embodiment, the E0F (End Of Frame) field of the CAN message is used as the capture point of the timestamp. The timestamp is obtained after EOF, which can accurately reflect the moment when the CAN message is completely received, which is exactly connected with the CAN message sending delay t1.

[0086] Therefore, the remaining delay is evaluated in step S54, because t1, t4 and D are all known values ​​in advance, t2 can be calculated when decapsulating the Ethernet message, and thus t3 can be evaluated.

[0087] In step S56, scheduling may refer to, for example, Figure 4 The distribution operation of the distributor 22, and / or Figure 4 The following is combined with the scheduling operation of the scheduler 24. Figure 7 and 8 Explain them separately.

[0088] like Figure 7 As shown, Figure 4 2 is a flow chart of an embodiment of the distribution operation of the distributor 22. The distributor 22 is used to distribute the CAN messages in the first buffer 21 to different transmission queues in the second buffer 23. For example, Figure 4As shown, the distributor 22 distributes the messages m1-5 to the two transmission queues in the second buffer 23. When distributing, the distributor 22 can distribute based on the t3 of each CAN message. Generally, the CAN message with a smaller t3 is distributed with higher priority.

[0089] In some embodiments, Figure 7 The distribution process may include: Step S70: reading the data in the first cache 21. Step S71: calculating t3 of each CAN message. In this step, t1 and t4 are fixed values / static values, which can be analyzed and calculated in advance and stored in the TSN-CAN gateway 2. t2 can be obtained by Figure 4 The decapsulation module 20 in the decapsulation module 20 is calculated, such as the decapsulation module 20 is calculated in the process of decapsulating the Ethernet message. t3 can be evaluated by the distributor 22. Step S72: Determine whether the CAN message at the end (last) of the first cache 21 is an emergency message. When the encapsulation strategy includes an emergency trigger strategy, because the encapsulation will be triggered when the emergency message is received, the emergency message will only be at the end. Therefore, in the distributor 22, it is only necessary to determine whether the message at the end is an emergency message. When the judgment result is yes, execute steps S74 and S75, that is, give priority to distributing emergency messages. Otherwise, execute step S73: Step S73: Select the CAN message with the smallest t3. In other words, give priority to scheduling CAN messages with smaller remaining delays. Step S74: Select a transmission queue based on routing rules. Step S75: Distribute the CAN message to the second cache 23, that is, distribute the CAN message to the selected transmission queue. For example, such as Figure 4 As shown, m1, m2 and m4 are distributed to a transmission queue in the second buffer 23, and m3 and m5 are distributed to another transmission queue. Step S76: Determine whether the first buffer 21 is empty, that is, whether the CAN messages in the first buffer 21 have been distributed. If it is empty, execute step S77: wait for a new CAN message in the first buffer 21, and then execute step S70. Otherwise, execute step S73: select the message with the smallest t3 among the remaining CAN messages for distribution.

[0090] In this embodiment, the message distribution is based on the residual delay of the CAN message, which is easier to meet the real-time requirements of the application and improve the message processing efficiency than the method based on the encapsulation order or CAN ID of the message. In addition, when evaluating the residual delay, the delay of the encapsulation-decapsulation process is calculated in the overall delay manner, so different encapsulation strategies can be applied.

[0091] like Figure 8 As shown, Figure 4The flow chart of the embodiment in which the scheduler 24 in the second buffer 23 schedules the CAN message to the CAN controller to send it to the CAN bus. When scheduling the CAN message, the scheduler 24 can jointly determine the scheduling order of the message based on the remaining delay t3 of the message and the CAN ID of the message. For example, according to the remaining delay t3 and the CAN ID, the local priority of the CAN message is calculated, and the scheduling order of the message is determined according to the local priority. In some embodiments, the local priority may include a first part and a second part, the first part is obtained based on t3, and the second part is the CAN ID. Among them, an example of the conversion relationship between t3 and priority is shown in Table 1 below. For example, assuming that the t3 of a CAN message is between [0,10), and its CAN ID = 000 0000 0000, it can be determined that the local priority of this CAN message is: 000 000 00000000, where the first three bits are determined according to t3 and Table 1, and the last 11 are CAN ID. When determining the priority relationship based on the local priority, the comparison can be performed bit by bit in order from left to right, and the one with the smaller value wins.

[0092] Table 1:

[0093] t3 (unit: ms) Priority [0,10) 000 [10,20) 001 …… …… [100,200) 110 [200,+∞) 111

[0094] In some embodiments, Figure 8 As shown, the scheduling process of the scheduler 24 may include: Step S80: Read the data in the second cache 23. For example, each transmission queue may be read and processed separately. Step S81: Determine whether the first CAN message is an emergency message, refer to Figure 7 , emergency messages will be distributed first, so if there is an emergency message, it will be the first CAN message. If the judgment result is yes, execute step S84. Otherwise, execute step S82: calculate the local priority of each CAN message, and the calculation method can refer to the above content. Step S83: select the CAN message with the highest local priority. Step S84: determine whether the CAN message sending buffer is idle. In this step, it can be determined whether the sending buffer in the CAN controller to which the CAN message is to be scheduled is idle. If it is idle, execute step S85: schedule the CAN message to the sending buffer of the CAN controller, waiting for the CAN controller to send the CAN message to the destination ECU. Otherwise, execute step S83: select the CAN message with the second highest priority for scheduling. Step S86: determine whether the second buffer is empty, that is, whether all CAN messages have completed scheduling. If the judgment result is yes, execute step S87: wait for new CAN messages in the second buffer. Otherwise, return to execute step S83 and continue scheduling.

[0095] In this embodiment, the order of message scheduling is determined by the local priority. For example, assuming that the t3 value of the CAN6 message with a CAN ID of 0x34F (binary: 011 0100 1111) is 20, its local priority is: 010 0110100 1111. The t3 value of the CAN 7 message with a CAN ID of 0x38D (binary: 011 10001101) is 10, so its local priority is 001 011 1000 1101. The t3 value of the CAN 8 message with a CAN ID of 0x54F (binary: 101 0100 1111) is 10, so its local priority is 001 101 0100 1111. When only based on the CAN ID arbitration comparison, the order of message scheduling is: CAN6, CAN7, CAN8. When arbitration comparison is performed based on local priority, the order of message scheduling is: CAN7, CAN8, CAN6. Therefore, this embodiment can prioritize scheduling of time-critical CAN messages, and when the time urgency of CAN messages is similar, prioritize scheduling of CAN messages with higher importance (such as smaller CAN ID).

[0096] like Fig. 9 , which is a schematic diagram of the structure of an embodiment of a computer device / equipment / system 9 of the present invention. The computer device / equipment / system 9 of this embodiment may be a gateway, a domain controller, a regional controller, a central controller, an ECU, a vehicle, etc. having a TSN-CAN function. The computer device / equipment / system 9 includes: a memory 90, a processor 92, and a computer program / instruction stored in the memory. The processor 92 executes the computer program / instruction in the memory 90, thereby implementing the various methods described in the above embodiments, such as a method for scheduling CAN messages.

[0097] In addition, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. The computer program includes executable instructions. When the executable instructions are executed by a processor, the various methods described in the above embodiments, such as the method for scheduling CAN messages, are implemented.

[0098] In addition, a computer program product according to an embodiment of the present invention includes a computer program / instruction, which implements the various methods described in the above embodiments when executed by a processor, such as a method for scheduling CAN messages.

[0099] The description of the above device / equipment / system, storage medium and program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device / equipment / system, storage medium and program product embodiments of this application, please refer to the description of the method embodiment of this application for understanding.

[0100] The processor may be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, a microprocessor, etc. It is understandable that the electronic device that implements the function of the processor may also be other, and the embodiments of the present application are not specifically limited.

[0101] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0102] It should be noted that the above description is only for example and not for limitation of the present invention. In other embodiments of the present invention, the method may have more, fewer or different steps, and the order, inclusion and function of each step may be different from that described and illustrated. For example, generally multiple steps can be combined into a single step, and a single step can also be divided into multiple steps. For those of ordinary skill in the art, without paying creative work, the sequential changes of each step are also within the scope of protection of the present invention.

[0103] The technical solution of the present invention, in essence or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor or a microcontroller to perform all or part of the steps of the method described in each embodiment of the present invention.

[0104] Those skilled in the art will appreciate that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed.

[0105] Although the present invention has been disclosed as above with preferred embodiments, the present invention is not limited thereto. Any changes and modifications made by any person skilled in the art without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention, and therefore the protection scope of the present invention should be subject to the scope defined by the claims.

Claims

1. A CAN message scheduling method, used in a TSN-CAN network, characterized in that: include: Receiving an Ethernet message from a source end, wherein the Ethernet message includes a plurality of CAN messages encapsulated by the source end; Decapsulating the Ethernet message to obtain the multiple CAN messages; Evaluate the remaining delay of each CAN message from the deadline; and The multiple CAN messages are scheduled according to the remaining delay.

2. The method for scheduling CAN messages according to claim 1, characterized in that: The step of evaluating the remaining delay of each CAN message from the deadline comprises: According to the reception time information of the CAN message carried in the Ethernet message, the overall delay of the CAN message from encapsulation to decapsulation is determined, and according to the overall delay, the residual delay is evaluated.

3. The method for scheduling CAN messages as claimed in claim 2, characterized in that: The receiving time information in the Ethernet message is the time when the source end completely receives the first frame of the CAN message in the Ethernet message; And / or, the overall delay is the time difference between the time when the Ethernet message is decapsulated and the receiving time information.

4. The method for scheduling CAN messages according to claim 1, characterized in that: The remaining delay is further evaluated based on the deadline of the CAN message and the sending delay of the CAN message at the source end and the destination end.

5. The method for scheduling CAN messages according to claim 1, characterized in that: The step of scheduling the plurality of CAN messages according to the remaining delay comprises: When distributing the multiple CAN messages, CAN messages with smaller residual delays are distributed preferentially.

6. The method for scheduling CAN messages according to claim 1, characterized in that: The step of scheduling the plurality of CAN messages according to the remaining delay comprises: Distributing the multiple CAN messages; Determine the local priority of each CAN message based on the remaining delay and CAN ID of each CAN message; and The distributed CAN messages are scheduled according to the local priority.

7. The method for scheduling CAN messages according to claim 1, characterized in that: Before the step of scheduling the plurality of CAN messages according to the remaining delay, the method further includes: preferentially scheduling emergency messages among the CAN messages.

8. The method for scheduling CAN messages according to claim 1, characterized in that: The method further comprises: At the source end, the multiple CAN messages are encapsulated into the Ethernet message according to at least one of a buffer timing strategy, a buffer capacity strategy, a CAN message quantity strategy, and an emergency trigger strategy.

9. A TSN-CAN gateway, for decapsulating Ethernet messages into CAN messages, characterized in that: include: First cache; Second cache; A decapsulation module, used for decapsulating the received Ethernet message to obtain a plurality of CAN messages, and caching the plurality of CAN messages into the first cache; A distributor, configured to distribute the plurality of CAN messages in the first buffer to a plurality of transmission queues in the second buffer; as well as A scheduler, configured to schedule the plurality of CAN messages in the second buffer to a corresponding CAN controller, so as to send the plurality of CAN messages to a CAN network through the CAN controller; In which, in the distributor and / or scheduler, distribution and / or scheduling are performed according to the remaining delay of the CAN message from the deadline; the remaining delay is evaluated based on at least the overall delay of the CAN message from encapsulation to decapsulation, and the overall delay is determined based on at least the reception time information of the CAN message carried in the Ethernet message on the encapsulation side.

10. The TSN-CAN gateway according to claim 9, characterized in that: The remaining delay is determined based on the following formula: t3≤D-t1-t2-t4 Among them, t3 is the remaining delay, D is the deadline of the CAN message, t1 is the sending delay of the CAN message at the source end, t4 is the sending delay of the CAN message at the destination end, and t2 is the overall delay.

11. The TSN-CAN gateway according to claim 9 or 10, characterized in that: The receiving time information is the time when the encapsulation side completely receives the first frame CAN message in the Ethernet message, and the overall delay is the time difference between the time when the Ethernet message is decapsulated and the receiving time information.

12. The TSN-CAN gateway according to claim 9, characterized in that: The scheduler is specifically used to: determine the priority of message scheduling according to the remaining delay and the CAN ID of the CAN message; and schedule the CAN message according to the determined priority.

13. A computer device / equipment / system comprising a memory, a processor and a computer program / instruction stored in the memory, characterized in that: The processor executes the computer program / instructions to implement the method of any one of claims 1 to 8.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program comprises executable instructions, and when the executable instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.

15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.