CAN message timeout processing method and device, equipment and medium

By finding the highest priority message in the CAN controller and stopping sending when the timeout or timeout time exceeds expectations, the problem of high processor load in CAN bus communication is solved, reducing system complexity and avoiding unexpected timeout messages send.

CN119210929APending Publication Date: 2024-12-27CCORE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411458116.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In CAN bus communication in automotive ECUs, the processor has a high load when processing timeout messages, and lacks an effective solution, resulting in increased system complexity and timeout messages that may be sent within unexpected times.

Method used

By finding the highest priority message in the CAN controller, and stop sending the message and notifying the processor for timeout processing when the timeout is detected or the actual sending time exceeds the expected time, avoiding the processor's cumbersome timer operation.

Benefits of technology

It significantly reduces processor load and system complexity, avoids the phenomenon of timeout messages being sent to the CAN bus within unexpected times, and simplifies the processing flow.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119210929A_ABST
    Figure CN119210929A_ABST
Patent Text Reader

Abstract

The invention discloses a CAN message timeout processing method and device, equipment and a medium, and belongs to the technical field of communication, the method is applied to a CAN controller of a target node, and the method comprises the following steps: when a message to be sent to a CAN bus exists in the target node, searching a message with the highest priority to obtain a target message; if a timeout message sent in a timeout mode is detected in the process of searching the message with the highest priority, a processor in the target node is notified to carry out timeout processing on the timeout message; obtaining the expected time required for sending the target message to the CAN bus, and obtaining the target expected time; and when it is determined that the actual duration required for sending the target message to the CAN bus is greater than the target expected duration, stopping sending the target message to the CAN bus, and notifying a processor in the target node to perform timeout processing on the target message. Through the method, the load of the processor in the target node can be remarkably 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 a timeout processing method, device, equipment and medium for CAN message. Background Art

[0002] The various ECUs (Electronic Control Units) in a car usually communicate using the CAN (Controller Area Network) bus. Figure 1 , Figure 1 The figure is a schematic diagram of mounting CAN nodes on the CAN bus, where each CAN node mounted on the CAN bus represents an ECU with CAN communication capability.

[0003] Assume that the target node is any CAN node mounted on the CAN bus. When the target node sends a message to the CAN bus, it usually stores the message to be sent to the CAN bus in its internal message cache area. Each message cache unit in the message cache area stores a message to be sent to the CAN bus. Among them, each message to be sent to the CAN bus will correspond to an ID (Identity Document, identifier). The smaller the ID, the higher the priority corresponding to the message. The target node will send messages to the CAN bus in order according to the priority of the message to be sent to the CAN bus.

[0004] When the target node sends a message to the CAN bus, the target node also needs to determine whether the priority of its own message is higher than the priority of other nodes sending messages to the CAN bus. If the priority of the message to be sent to the CAN bus on the target node is lower than the priority of other nodes to be sent to the CAN bus, the target node can only wait until the priority of its own message becomes the highest priority before it can send the message to the CAN bus. During the waiting process, it is possible that the duration of the message to be sent to the CAN bus has exceeded the sending cycle of the message, but the message continues to be sent to the CAN bus. If the CAN controller cannot cancel the timed-out message to be sent in time, the sending cycle of the message to be sent will be inaccurate, and the CAN bus will receive the message at an unexpected time.

[0005] In this case, if you want to find out which messages in the target node have timed out in time, you need to use the processor in the target node to set a corresponding timeout for each message to be sent, so that when the message to be sent times out, the processor can notify the relevant software program to process the timed message to be sent. However, under this control logic, the processor needs to use multiple timer functions inside it to perform timing, timeout processing and other operations on different messages to be sent, which will greatly increase the load of the processor. At present, there is no more effective solution to this technical problem. Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide a CAN message timeout processing method, device, equipment and medium to solve the technical problem of heavy load on the processor when processing the timeout message in the prior art. The specific scheme is as follows:

[0007] In order to solve the above technical problems, the present invention provides a CAN message timeout processing method, which is applied to a CAN controller of a target node, wherein the target node is any node mounted on a CAN bus; the method comprises:

[0008] When there is a message to be sent to the CAN bus in the target node, the message with the highest priority is searched to obtain the target message;

[0009] If a timeout message that has been sent overtime has been detected in the process of searching for the message with the highest priority, the processor in the target node is notified to perform timeout processing on the timeout message;

[0010] Obtain the expected time required to send the target message to the CAN bus to obtain the target expected time;

[0011] When it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, the sending of the target message to the CAN bus is stopped, and the processor in the target node is notified to perform timeout processing on the target message.

[0012] Preferably, when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, stopping sending the target message to the CAN bus, and notifying the processor in the target node to perform timeout processing on the target message, comprises:

[0013] Determine the time required for the target message to compete for the highest priority message to be sent to the CAN bus in the target node, and obtain a target competition time;

[0014] Determine whether the target competition duration is greater than the target expected duration;

[0015] If so, it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, and the sending of the target message to the CAN bus is stopped, and the processor is notified to perform timeout processing on the target message.

[0016] Preferably, after determining whether the target contention duration is greater than the target expected duration, the method further includes:

[0017] If not, determining whether the time required to send the target message to the CAN bus is greater than the target expected time;

[0018] If yes, stop sending the target message to the CAN bus, and notify the processor to perform timeout processing on the target message;

[0019] If not, determining whether the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node;

[0020] If yes, sending the target message to the CAN bus;

[0021] If not, continue to execute the step of determining whether the time required to send the target message to the CAN bus is greater than the target expected time.

[0022] Preferably, it also includes:

[0023] Preliminarily binding the setting state of each storage bit in the request register with the sending request state of each message buffer unit in the message buffer area to be sent to the CAN bus, so that each storage bit of the request register corresponds to a sending request state of a message to be sent to the CAN bus in the message buffer unit;

[0024] The CAN controller is provided with the request register, the timeout register and the message buffer area; the message buffer area includes a plurality of message buffer units; each of the message buffer units stores a message to be sent, an expected time required to send the message to be sent to the CAN bus, and a starting time for sending the message to be sent to the CAN bus; the message to be sent is any message in the target node to be sent to the CAN bus;

[0025] The set state of each storage bit in the timeout register is bound in advance to the sending timeout state of the message to be sent to the CAN bus in each message cache unit in the message cache area, so that each storage bit in the timeout register corresponds to a sending timeout state of the message to be sent to the CAN bus in the message cache unit.

[0026] Preferably, when there is a message to be sent to the CAN bus in the target node, searching for a message with the highest priority to obtain the target message includes:

[0027] Reading the set state of each storage bit in the request register;

[0028] If there is a storage bit set to 1 in the storage bits of the request register, it is determined that there is a message to be sent to the CAN bus in the target node;

[0029] Determine the message cache unit corresponding to when the storage bit of the request register is set to 1, and obtain a cache unit set;

[0030] The IDs of the messages cached in the message cache units in the cache unit set are arbitrated to find out the message with the highest priority and obtain the target message.

[0031] Preferably, when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, stopping sending the target message to the CAN bus, and notifying the processor in the target node to perform timeout processing on the target message, comprises:

[0032] Determine the start time corresponding to sending the target message to the CAN bus according to the data cached in the message cache area, and obtain the target start time;

[0033] If the sum of the target start time and the target expected duration is greater than the current time, it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected duration, then the target message is stopped from being sent to the CAN bus, and the processor in the target node is notified to perform timeout processing on the target message.

[0034] Preferably, the stopping of sending the target message to the CAN bus and notifying the processor in the target node to perform timeout processing on the target message includes:

[0035] Stop sending the target message to the CAN bus;

[0036] clearing the storage bit corresponding to the target message in the request register, and setting the storage bit corresponding to the target message in the timeout register to 1;

[0037] The processor in the target node is notified to perform timeout processing on the target message.

[0038] In order to solve the above technical problems, the present invention also provides a CAN message timeout processing device, which is applied to a CAN controller of a target node, wherein the target node is any node mounted on a CAN bus; the device comprises:

[0039] A message search module, used for searching for a message with the highest priority to obtain a target message when there is a message to be sent to the CAN bus in the target node;

[0040] A timeout processing module, configured to notify a processor in the target node to perform timeout processing on the timeout message if a timeout message that has been sent overtime has been detected in the process of searching for the message with the highest priority;

[0041] A duration determination module is used to obtain the expected duration required to send the target message to the CAN bus, and obtain the target expected duration;

[0042] The message processing module is used to stop sending the target message to the CAN bus and notify the processor to perform timeout processing on the target message when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time.

[0043] In order to solve the above technical problem, the present invention further provides an electronic device, comprising:

[0044] Memory for storing computer programs;

[0045] A processor is used to implement the steps of a CAN message timeout processing method disclosed above when executing the computer program.

[0046] In order to solve the above technical problem, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of a CAN message timeout processing method disclosed above are implemented.

[0047] Beneficial effect: The method for processing a timeout of a CAN message provided by the present invention is applied to a CAN controller of a target node, wherein the target node is any node mounted on a CAN bus. When there is a message to be sent to the CAN bus in the target node, the message with the highest priority is searched to obtain the target message; if a timeout message that has been sent overtime is detected during the process of searching for the message with the highest priority, the processor in the target node is notified to perform timeout processing on the timeout message;

[0048] Afterwards, the expected time required to send the target message to the CAN bus is obtained to obtain the target expected time; when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, the target message is stopped from being sent to the CAN bus, and the processor in the target node is notified to perform timeout processing on the target message.

[0049] Compared with the prior art, when the CAN controller in the target node finds that there is a target message that has been sent out of time in the message to be sent to the CAN bus, it directly stops sending the target message to the CAN bus, and notifies the processor in the target node to perform timeout processing on the target message. Under this setting mode, the cumbersome process of the processor in the prior art to search for the timeout message can be avoided, which can not only significantly reduce the load of the processor in the target node, but also reduce the complexity of the system. In addition, when the method is used, the phenomenon of sending the timeout message to the CAN bus will not occur when it is determined that there is a timeout message in the message to be sent to the CAN bus.

[0050] Correspondingly, a CAN message timeout processing device, equipment and medium provided by the present invention also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0052] Figure 1 This is a schematic diagram of mounting a CAN node on the CAN bus;

[0053] Figure 2 A flowchart of a CAN message timeout processing method provided by an embodiment of the present invention;

[0054] Figure 3 This is a schematic diagram of the target node when interacting with the CAN bus;

[0055] Figure 4 A flowchart of another CAN message timeout processing method provided by an embodiment of the present invention;

[0056] Figure 5 An internal structure diagram of a CAN controller provided by an embodiment of the present invention;

[0057] Figure 6 A structural diagram of a CAN message timeout processing device provided by an embodiment of the present invention;

[0058] Figure 7 A structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] See also Figure 2 , Figure 2 A flowchart of a CAN message timeout processing method provided by an embodiment of the present invention, the method is applied to a CAN controller of a target node, the target node is any node mounted on a CAN bus; the method comprises:

[0061] Step S11: When there is a message to be sent to the CAN bus in the target node, the message with the highest priority is searched to obtain the target message;

[0062] Step S12: if a timeout message that has been sent overtime has been detected in the process of searching for the message with the highest priority, then the processor in the target node is notified to perform timeout processing on the timeout message;

[0063] Step S13: Obtain the expected time required to send the target message to the CAN bus, and obtain the target expected time;

[0064] Step S14: When it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, the sending of the target message to the CAN bus is stopped, and the processor in the target node is notified to perform timeout processing on the target message.

[0065] In this embodiment, a method for processing a timeout of a CAN message is provided. By using this method to process a timeout message, the load of a processor in a target node can be significantly reduced. Moreover, when this method is used, the phenomenon of sending a timeout message to the CAN bus will not occur when it is determined that there is a timeout message among the messages to be sent to the CAN bus.

[0066] In order to enable those skilled in the art to better understand the implementation principle of the present invention. Figure 1 The communication principle shown in the figure is briefly explained. The CAN bus consists of two lines, namely the CAN_H line and the CAN-L line. Each CAN node mounted on the CAN bus represents an ECU with CAN communication capabilities. The ECU is the core component of automobile control, mainly responsible for processing and controlling the engine, transmission system, chassis system, safety system, etc. The ECU can control the windows, doors, wipers, etc. on the car. CAN communication is a broadcast communication. When a node sends a message to the CAN bus, other nodes cannot send messages to the CAN bus. They must wait until the CAN bus is in an idle state before other nodes can send messages to the CAN bus.

[0067] See also Figure 3 , Figure 3 The following is a schematic diagram of the target node when interacting with the CAN bus. The target node is provided with a processor, a CAN controller and a CAN transceiver. The processor is used to execute software programs. The CAN controller is used to control the sending and receiving of CAN messages. In practical applications, the CAN controller and the processor can be integrated into the same microcontroller chip. The CAN transceiver is used to convert logic levels and physical signals. The CAN transceiver is generally a separate device.

[0068] The CAN message timeout processing method provided in this embodiment is specifically described with the CAN controller in the target node as the execution subject. In this method, when the CAN controller in the target node determines that there are messages to be sent to the CAN bus in the target node, the first step is to determine the message with the highest priority among the messages to be sent to the CAN bus, and obtain the target message. That is, the target message is the message with the highest priority in the target node and is the first message in the target node that can be sent to the CAN bus.

[0069] It should be noted that, when the CAN controller in the target node is searching for the highest priority message in the target node, if it detects that other messages that are not of the highest priority have timed out, the CAN controller in the target node will also notify the processor in the target node to handle the timeout message.

[0070] After that, the expected time required to send the target message to the CAN bus is obtained to obtain the target expected time. Among them, the target expected time is usually set by the user, and the target expected time includes the time required for the target message to compete for the highest priority, and the time required for the CAN controller to send the target message to the CAN bus after the target message competes for the highest priority. When the CAN controller finds the highest priority message from the target node and obtains the target message, the CAN controller also needs to determine the actual time required to send the target message to the CAN bus. If the CAN controller determines that the actual time required to send the target message to the CAN bus is greater than the target expected time, the CAN controller will stop sending the target message to the CAN bus and notify the processor in the target node to timeout the target message.

[0071] It is not difficult to imagine that the actual time required by the CAN controller to send the target message to the CAN bus may be different from the target expected time, because in the process of the CAN controller sending the target message to the CAN bus, the target message not only needs to compete for the highest priority of the target node to be sent to the CAN bus, but also needs to compete for the highest priority of the messages sent to the CAN bus by other nodes except the target node. In these two competition processes, the target message may experience message sending timeout.

[0072] When the CAN controller determines that the actual time required to send the target message to the CAN bus is longer than the target expected time, it means that the target message has timed out. In this case, the CAN controller will stop sending the target message to the CAN bus and notify the processor in the target node to handle the target message timeout. In this setting, it is equivalent to directly associating the CAN message with the timeout event. The CAN controller directly processes the timed CAN message without the software running on the processor in the target node executing the relevant control logic, and the processing flow is more concise.

[0073] Obviously, compared with the prior art, when the CAN controller in the target node finds that there is a target message that has been sent out of time in the message to be sent to the CAN bus, it directly stops sending the target message to the CAN bus, and notifies the processor in the target node to perform timeout processing on the target message. Under this setting mode, the cumbersome process of the processor in the prior art to search for the timeout message can be avoided, which can not only significantly reduce the load of the processor in the target node, but also reduce the complexity of the system. In addition, when the method is used, there will be no phenomenon that the timeout message is sent to the CAN bus when it is determined that there is a timeout message in the message to be sent to the CAN bus.

[0074] Based on the above embodiments, this embodiment further illustrates and optimizes the technical solution. Figure 4 , Figure 4 The present invention is a flowchart of another method for processing a timeout of a CAN message provided by an embodiment of the present invention.

[0075] As a preferred implementation, the above step S14: when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, stop sending the target message to the CAN bus, and notify the processor in the target node to perform timeout processing on the target message, including:

[0076] Step S141: determining the time required for the target message to compete for the highest priority message to be sent to the CAN bus in the target node, and obtaining the target competition time;

[0077] Step S142: determine whether the target competition duration is greater than the target expected duration; if so, execute step S143; if not, execute step S144;

[0078] Step S143: determine that the actual time required to send the target message to the CAN bus is greater than the target expected time, stop sending the target message to the CAN bus, and notify the processor to perform timeout processing on the target message.

[0079] In this embodiment, when the CAN controller determines whether a timeout will occur in the process of sending the target message to the CAN bus, it first determines the time required for the target message to compete for the highest priority message to be sent to the CAN bus in the target node, and obtains the target competition time.

[0080] It is understandable that, before the CAN controller sends the target message to the CAN bus, it must ensure that the target message is the message with the highest priority among the messages to be sent to the CAN bus in the target node, and when the target message becomes the message with the highest priority, it also needs to compete with other messages in the target node. Therefore, the CAN controller needs to determine the time required for the target message to compete for the highest priority message to be sent to the CAN bus in the target node, and obtain the target competition time.

[0081] After that, it is determined whether the target contention duration is greater than the target expected duration. If the target contention duration is greater than the target expected duration, it means that the actual time required for the CAN controller to send the target message to the CAN bus is greater than the target expected duration. In this case, the CAN controller needs to stop sending the target message to the CAN bus and notify the processor in the target node to handle the timeout of the target message.

[0082] Obviously, through the technical solution provided by this embodiment, it is possible to accurately determine whether a sending timeout phenomenon will occur when the target message competes for the highest priority in the target node.

[0083] As a preferred embodiment, the method further comprises:

[0084] Step S144: determine whether the actual time required to send the target message to the CAN bus is greater than the target expected time; if so, execute step S145; if not, execute step S146;

[0085] Step S145: stop sending the target message to the CAN bus, and notify the processor to perform timeout processing on the target message;

[0086] Step S146: determine whether the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node; if so, execute step S147; if not, execute step S144 again;

[0087] Step S147: Send the target message to the CAN bus.

[0088] If the target contention duration is less than the target expected duration, it is necessary to continue to determine whether the actual duration required to send the target message to the CAN bus is greater than the target expected duration. If the actual duration required to send the target message to the CAN bus is greater than the target expected duration, it means that the target message has timed out. At this time, the target node needs to stop sending the target message to the CAN bus and notify the processor to handle the timeout of the target message.

[0089] If the actual time required for the target node to send the target message to the CAN bus is less than or equal to the target expected time, it is necessary to continue to determine whether the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node; if the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node, send the target message to the CAN bus; if the priority of the target message is lower than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node, continue to execute step S144.

[0090] In order to enable those skilled in the art to better understand the implementation principle of the above execution process, the bus arbitration principle of the CAN node is briefly explained here. In practical applications, the target node does not have a special communication channel to learn the priority of other nodes mounted on the CAN bus to send messages, so the target node can only determine whether the priority of its message is the highest by detecting the state of the CAN bus.

[0091] When the target node detects that the CAN bus is in an idle state, it means that the message it wants to send is the highest priority, and the target node can send a message to the CAN bus. If two nodes detect that the CAN bus is in an idle state at the same time, then the two nodes will send messages to the CAN bus at the same time. In the process of sending messages, the two nodes will arbitrate the priority based on the CAN ID. The node with a higher priority will continue to send messages to the CAN bus, and the node with a lower priority will stop sending messages to the CAN bus. Among them, the node with a lower priority will wait until the CAN bus is in an idle state before sending messages to the CAN bus again.

[0092] That is, when the target node knows that the priority of the message it is sending is the highest, it only needs to continue sending the message without making a timeout judgment. When the target node knows that the priority of the message it is sending is not the highest, it can make a timeout judgment.

[0093] Obviously, through the technical solution provided in this embodiment, it is possible to accurately determine whether a sending timeout phenomenon occurs when the CAN controller sends the target message to the CAN bus.

[0094] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. As a preferred implementation, the above method further includes:

[0095] Bind the set state of each storage bit in the request register with the send request state of each message buffer unit in the message buffer area to be sent to the CAN bus in advance, so that each storage bit of the request register corresponds to the send request state of a message buffer unit to be sent to the CAN bus;

[0096] The CAN controller is provided with a request register, a timeout register and a message buffer area; the message buffer area includes a plurality of message buffer units; each message buffer unit stores a message to be sent, an expected time required to send the message to be sent to the CAN bus, and a start time for sending the message to be sent to the CAN bus; the message to be sent is any message in the target node to be sent to the CAN bus;

[0097] The set state of each storage bit in the timeout register is bound in advance to the sending timeout state of the message to be sent to the CAN bus in each message cache unit in the message cache area, so that each storage bit in the timeout register corresponds to the sending timeout state of the message to be sent to the CAN bus in a message cache unit.

[0098] See also Figure 5 , Figure 5 The internal structure diagram of a CAN controller provided by an embodiment of the present invention. The CAN controller includes a message buffer area, a request register, a timeout register and a sending control module. The message buffer area includes a plurality of message buffer units (Message Buffer). Each message buffer unit has a corresponding cache of a message to be sent, an expected time required to send the message to be sent to the CAN bus, and a starting time for sending the message to be sent to the CAN bus. The message to be sent is any message in the target node to be sent to the CAN bus. The message to be sent includes: ID, CAN data length and CAN data.

[0099] Before executing the CAN message timeout processing method described in the present application, it is necessary to pre-bind the set state of each storage bit in the request register with the sending request state of each message cache unit in the message cache area to be sent to the CAN bus, so that each storage bit of the request register corresponds to the sending request state of a message cache unit to be sent to the CAN bus.

[0100] Assuming that the request register is 32 bits, the 32 storage bits of the request register can correspond to the sending request states of the messages to be sent to the CAN bus stored in the message cache unit 1, message cache unit 2, message cache unit 3, ..., message cache unit 32 in the message cache area. If the message cache unit 1, message cache unit 2, and message cache unit 3 all cache messages to be sent to the CAN bus, the set states of the first storage bit, the second storage bit, and the third storage bit of the request register are 1. When the set states of the first storage bit, the second storage bit, and the third storage bit of the request register are set to 1, the start time of the message to be sent to the CAN bus will be stored in the message cache unit 1, the message cache unit 2, and the message cache unit 3. If the message cache unit 1, the message cache unit 2, and the message cache unit 3 do not cache the messages to be sent to the CAN bus, the set states of the first storage bit, the second storage bit, and the third storage bit of the request register are 0.

[0101] In addition, it is also necessary to pre-bind the set state of each storage bit in the timeout register with the sending timeout state of each message cache unit in the message cache area to be sent to the CAN bus, so that each storage bit in the timeout register corresponds to the sending timeout state of a message cache unit to be sent to the CAN bus.

[0102] Assuming that the timeout register is 32 bits, the 32 storage bits of the timeout register can correspond to the sending timeout status of the messages to be sent to the CAN bus stored in the message cache unit 1, message cache unit 2, message cache unit 3, ... message cache unit 32 in the message cache area. If the messages to be sent to the CAN bus cached by the message cache unit 1, message cache unit 2, and message cache unit 3 are all in the sending timeout status, then the set status of the first storage bit, the second storage bit, and the third storage bit of the timeout register is 1. If the messages to be sent to the CAN bus cached by the message cache unit 1, message cache unit 2, and message cache unit 3 have not timed out, then the set status of the first storage bit, the second storage bit, and the third storage bit of the timeout register is 0.

[0103] After the data in the request register and the timeout register are set, the sending control module will select the message with the smallest ID in the request message buffer area according to the setting state of each storage bit in the request register. If there is a message with a sending timeout in the message buffer area, and the message buffer unit corresponding to the message is 3, the sending control module will clear the third storage bit in the request register and set the setting state of the third storage bit in the timeout register to 1.

[0104] Obviously, through the technical solution provided by this embodiment, the actual status of the message to be sent to the CAN bus on each message buffer unit in the message buffer area can be accurately determined according to the setting status of each storage bit of the request register and the timeout register.

[0105] As a preferred implementation, the above step: when there is a message to be sent to the CAN bus in the target node, searching for the message with the highest priority to obtain the target message includes:

[0106] Read the set state of each storage bit in the request register;

[0107] If there is a storage bit set to 1 in the storage bit of the request register, it is determined that there is a message to be sent to the CAN bus in the target node;

[0108] Determine the message cache unit corresponding to when the storage bit of the request register is set to 1, and obtain a cache unit set;

[0109] The IDs of the messages cached in each message cache unit in the cache unit set are arbitrated to find out the message with the highest priority and obtain the target message.

[0110] In this embodiment, when the CAN controller searches for the target message with the highest priority from the target node, it first reads the setting status of each storage bit in the request register. If there is a storage bit set to 1 in the storage bit of the request register, it means that there is a message to be sent to the CAN bus in the target node.

[0111] After that, the CAN controller also needs to determine the message cache unit corresponding to the storage bit of the request register being set to 1, and obtain a cache unit set. At this time, the messages cached in each message cache unit in the cache unit set need to be sent to the CAN bus. In this case, the CAN controller needs to arbitrate the IDs of the messages cached in each message cache unit in the cache unit set, so as to find the message with the highest priority and obtain the target message.

[0112] Obviously, through the technical solution provided by this embodiment, the CAN controller can accurately find the target message with the highest priority from the target node.

[0113] As a preferred implementation, the above step: when it is determined that the time required to send the target message to the CAN bus is longer than the target expected time, stopping sending the target message to the CAN bus and notifying the processor in the target node to perform timeout processing on the target message includes:

[0114] Determine the starting time corresponding to sending the target message to the CAN bus according to the data cached in the message cache area, and obtain the target starting time;

[0115] If the sum of the target start time and the target expected duration is greater than the current time, it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected duration, then the target message is stopped from being sent to the CAN bus, and the processor in the target node is notified to perform timeout processing on the target message.

[0116] In this embodiment, when the CAN controller determines whether the target message has a sending timeout phenomenon, it needs to first determine the starting time corresponding to sending the target message to the CAN bus based on the data cached in the message cache area to obtain the target starting time. Because the message cache area stores all identification data of each message to be sent to the CAN bus, the message cache unit corresponding to the target message can be found from the message cache area, and the starting time corresponding to sending the target message to the CAN bus can be found from the message cache unit to obtain the target starting time.

[0117] If the sum of the target start time and the target expected duration is greater than the current time, it means that the actual time required by the CAN controller to send the target message to the CAN bus is greater than the target expected duration, and the CAN controller failed to send the target message to the CAN bus within the target expected duration. In this case, the CAN controller needs to stop sending the target message to the CAN bus and notify the processor in the target node to handle the timeout of the target message.

[0118] Obviously, through the technical solution provided in this embodiment, the CAN controller can accurately and reliably determine whether the target message can be sent to the CAN bus within the target expected time.

[0119] As a preferred implementation, the above step of stopping sending the target message to the CAN bus and notifying the processor in the target node to perform timeout processing on the target message includes:

[0120] Stop sending target messages to the CAN bus;

[0121] Clear the storage bit corresponding to the target message in the request register, and set the storage bit corresponding to the target message in the timeout register to 1;

[0122] Notify the processor in the target node to perform timeout processing on the target message.

[0123] In this embodiment, when the CAN controller determines that a sending timeout has occurred for a target message, in addition to stopping sending the target message to the CAN bus and notifying the processor in the target node to perform a timeout process on the target message, it is also necessary to clear the storage bit corresponding to the target message in the request register and set the storage bit corresponding to the target message in the timeout register to 1.

[0124] Through such a setting, the setting state of each storage bit on the request register and the timeout register can correspond in real time to the request sending state and sending timeout state of each message buffer unit in the message buffer area to be sent to the CAN bus.

[0125] Obviously, through the technical solution provided by this embodiment, the request register and the timeout register can represent the actual status of each message to be sent to the CAN bus in real time and accurately.

[0126] See also Figure 6 , Figure 6 A structural diagram of a CAN message timeout processing device provided by an embodiment of the present invention, the device is applied to a CAN controller of a target node, and the target node is any node mounted on a CAN bus; the device includes:

[0127] A message search module 21 is used to search for a message with the highest priority to obtain a target message when there is a message to be sent to the CAN bus in the target node;

[0128] A timeout processing module 22 is used to notify the processor in the target node to perform timeout processing on the timeout message if a timeout message that has been sent overtime has been detected during the process of searching for the message with the highest priority;

[0129] The duration determination module 23 is used to obtain the expected duration required to send the target message to the CAN bus, and obtain the target expected duration;

[0130] The message processing module 24 is used to stop sending the target message to the CAN bus and notify the processor to perform timeout processing on the target message when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time.

[0131] Preferably, the message processing module 24 includes:

[0132] A first competition unit is used to determine the time required for the target message to compete with the highest priority message to be sent to the CAN bus in the target node, so as to obtain a target competition time;

[0133] A first judging unit, configured to judge whether the target competition duration is greater than the target expected duration;

[0134] The first determination unit is used to determine that the actual time required to send the target message to the CAN bus is greater than the target expected time when the determination result of the first determination unit is yes, and at the same time stop sending the target message to the CAN bus and notify the processor to perform timeout processing on the target message.

[0135] Preferably, it also includes:

[0136] A second judgment unit, configured to judge whether the time required to send the target message to the CAN bus is greater than the target expected time when the judgment result of the first judgment unit is no;

[0137] A second determination unit, configured to stop sending the target message to the CAN bus and notify the processor to perform timeout processing on the target message when the determination result of the second determination unit is yes;

[0138] a third judgment unit, configured to judge, when the judgment result of the second judgment unit is no, whether the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node;

[0139] The third determination unit is used to send the target message to the CAN bus when the determination result of the third determination unit is yes; or to continue to execute the second determination unit when the determination result of the third determination unit is no.

[0140] Preferably, it also includes:

[0141] A first setting module is used to pre-bind the setting state of each storage bit in the request register with the sending request state of each message buffer unit in the message buffer area to be sent to the CAN bus, so that each storage bit of the request register corresponds to a sending request state of a message to be sent to the CAN bus in the message buffer unit;

[0142] The CAN controller is provided with the request register, the timeout register and the message buffer area; the message buffer area includes a plurality of message buffer units; each of the message buffer units stores a message to be sent, an expected time required to send the message to be sent to the CAN bus, and a starting time for sending the message to be sent to the CAN bus; the message to be sent is any message in the target node to be sent to the CAN bus;

[0143] The second setting module is used to pre-bind the set state of each storage bit in the timeout register with the sending timeout state of each message cache unit in the message cache area to be sent to the CAN bus, so that each storage bit in the timeout register corresponds to a sending timeout state of a message to be sent to the CAN bus in the message cache unit.

[0144] Preferably, the message search module 21 includes:

[0145] A data reading unit, used for reading the setting state of each storage bit in the request register;

[0146] a message determination unit, configured to determine that there is a message to be sent to the CAN bus in the target node if there is a storage bit set to 1 in the storage bits of the request register;

[0147] A set acquisition unit, used to determine the message cache unit corresponding to when the storage bit of the request register is set to 1, and obtain a cache unit set;

[0148] The message search unit is used to arbitrate the IDs of the messages cached in each message cache unit in the cache unit set to find out the message with the highest priority and obtain the target message.

[0149] Preferably, the message processing module 24 includes:

[0150] A time search unit, used to determine the starting time corresponding to sending the target message to the CAN bus according to the data cached in the message cache area, so as to obtain the target starting time;

[0151] A message processing unit is used to determine that the actual time required to send the target message to the CAN bus is greater than the target expected time if the sum of the target start time and the target expected time is greater than the current time, then stop sending the target message to the CAN bus, and notify the processor in the target node to perform timeout processing on the target message.

[0152] Preferably, the message processing module 24 includes:

[0153] A message stopping unit, used for stopping sending the target message to the CAN bus;

[0154] a state adjustment unit, configured to clear a storage bit corresponding to the target message in the request register, and set a storage bit corresponding to the target message in the timeout register to 1;

[0155] A timeout processing unit is used to notify the processor in the target node to perform timeout processing on the target message.

[0156] A CAN message timeout processing device provided by an embodiment of the present invention has the beneficial effects of the aforementioned CAN message timeout processing method disclosed above.

[0157] See also Figure 7 , Figure 7 A structural diagram of an electronic device provided by an embodiment of the present invention, the electronic device comprising:

[0158] A memory 31, used for storing computer programs;

[0159] The processor 32 is used to implement the steps of the method for timeout processing of CAN messages disclosed above when executing the computer program.

[0160] An electronic device provided by an embodiment of the present invention has the beneficial effects of the above-disclosed method for timeout processing of CAN messages.

[0161] Correspondingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of a timeout processing method for a CAN message disclosed above are implemented.

[0162] A computer-readable storage medium provided by an embodiment of the present invention has the beneficial effects of the aforementioned method for timeout processing of a CAN message disclosed above.

[0163] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0164] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0165] The above is a detailed introduction to a CAN message timeout processing method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for processing a timeout of a CAN message, characterized in that: A CAN controller applied to a target node, wherein the target node is any node mounted on a CAN bus; the method comprises: When there is a message to be sent to the CAN bus in the target node, the message with the highest priority is searched to obtain the target message; If a timeout message that has been sent overtime has been detected in the process of searching for the message with the highest priority, the processor in the target node is notified to perform timeout processing on the timeout message; Obtain the expected time required to send the target message to the CAN bus to obtain the target expected time; When it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, the sending of the target message to the CAN bus is stopped, and the processor in the target node is notified to perform timeout processing on the target message.

2. A method for processing a CAN message timeout according to claim 1, characterized in that: When it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, stopping sending the target message to the CAN bus, and notifying the processor in the target node to perform timeout processing on the target message, including: Determine the time required for the target message to compete for the highest priority message to be sent to the CAN bus in the target node, and obtain a target competition time; Determine whether the target competition duration is greater than the target expected duration; If so, it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, and the sending of the target message to the CAN bus is stopped, and the processor is notified to perform timeout processing on the target message.

3. A method for processing a timeout of a CAN message according to claim 2, characterized in that: After determining whether the target contention duration is greater than the target expected duration, the method further includes: If not, determining whether the time required to send the target message to the CAN bus is greater than the target expected time; If yes, stop sending the target message to the CAN bus, and notify the processor to perform timeout processing on the target message; If not, determining whether the priority of the target message is higher than the priority of messages to be sent to the CAN bus by other nodes on the CAN bus except the target node; If yes, sending the target message to the CAN bus; If not, continue to execute the step of determining whether the time required to send the target message to the CAN bus is greater than the target expected time.

4. A method for processing a timeout of a CAN message according to claim 1, characterized in that: Also includes: Preliminarily binding the setting state of each storage bit in the request register with the sending request state of each message buffer unit in the message buffer area to be sent to the CAN bus, so that each storage bit of the request register corresponds to a sending request state of a message to be sent to the CAN bus in the message buffer unit; The CAN controller is provided with the request register, the timeout register and the message buffer area; the message buffer area includes a plurality of message buffer units; each of the message buffer units stores a message to be sent, an expected time required to send the message to be sent to the CAN bus, and a starting time for sending the message to be sent to the CAN bus; the message to be sent is any message in the target node to be sent to the CAN bus; The set state of each storage bit in the timeout register is bound in advance to the sending timeout state of the message to be sent to the CAN bus in each message cache unit in the message cache area, so that each storage bit in the timeout register corresponds to a sending timeout state of the message to be sent to the CAN bus in the message cache unit.

5. A method for processing a timeout of a CAN message according to claim 4, characterized in that: When there is a message to be sent to the CAN bus in the target node, searching for the message with the highest priority to obtain the target message includes: Reading the set state of each storage bit in the request register; If there is a storage bit set to 1 in the storage bits of the request register, it is determined that there is a message to be sent to the CAN bus in the target node; Determine the message cache unit corresponding to when the storage bit of the request register is set to 1, and obtain a cache unit set; The IDs of the messages cached in the message cache units in the cache unit set are arbitrated to find out the message with the highest priority and obtain the target message.

6. A method for processing a timeout of a CAN message according to claim 4, characterized in that: When it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time, stopping sending the target message to the CAN bus, and notifying the processor in the target node to perform timeout processing on the target message, including: Determine the start time corresponding to sending the target message to the CAN bus according to the data cached in the message cache area, and obtain the target start time; If the sum of the target start time and the target expected duration is greater than the current time, it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected duration, then the target message is stopped from being sent to the CAN bus, and the processor in the target node is notified to perform timeout processing on the target message.

7. A method for processing a timeout of a CAN message according to claim 4, characterized in that: The stopping of sending the target message to the CAN bus and notifying the processor in the target node to perform timeout processing on the target message includes: Stop sending the target message to the CAN bus; clearing the storage bit corresponding to the target message in the request register, and setting the storage bit corresponding to the target message in the timeout register to 1; The processor in the target node is notified to perform timeout processing on the target message.

8. A CAN message timeout processing device, characterized in that: A CAN controller applied to a target node, wherein the target node is any node mounted on a CAN bus; the device comprises: A message search module, used for searching for a message with the highest priority to obtain a target message when there is a message to be sent to the CAN bus in the target node; A timeout processing module, configured to notify a processor in the target node to perform timeout processing on the timeout message if a timeout message that has been sent overtime has been detected in the process of searching for the message with the highest priority; A duration determination module is used to obtain the expected duration required to send the target message to the CAN bus, and obtain the target expected duration; The message processing module is used to stop sending the target message to the CAN bus and notify the processor to perform timeout processing on the target message when it is determined that the actual time required to send the target message to the CAN bus is greater than the target expected time.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of a CAN message timeout processing method as claimed in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for timeout processing of a CAN message as claimed in any one of claims 1 to 7 are implemented.