CAN message timeout calculation method, device, equipment and readable storage medium

By creating a timeline and managing CAN messages based on timeout moments, the problem of low CAN message timeout calculation efficiency and high system overhead in the existing technology is solved, and efficient CAN message processing in a variety of scenarios is achieved, which is suitable for various applications. CAN message cycle and frequency.

CN114826974BActive Publication Date: 2024-09-10DONGFENG AUTOMOBILE ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210476785.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2024-09-10
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

The CAN message timeout calculation method in the existing technology has problems such as low efficiency, high system overhead, and limited applicable scenarios. Especially in scenarios with a large number of messages, short cycles, and high frequencies, it is difficult to meet strict response accuracy requirements.

Method used

Use the method of creating a timeline to determine the timeout moment based on the preset timeout time of each CAN message, insert the CAN message into the timeline in advance, and perform calculations based on the timeout moment and reception time during timeout detection to determine whether the message has timed out. , dynamically manage the status of messages on the timeline to avoid polling all messages.

Benefits of technology

It improves the efficiency of CAN message timeout calculation, reduces system overhead, and expands the scope of applicable scenarios. It can efficiently process CAN messages in various scenarios, reduce the number of timers, and reduce the system burden.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114826974B
    Figure CN114826974B
Patent Text Reader

Abstract

The present application relates to a CAN message timeout calculation method, device, equipment and readable storage medium, and relates to the field of automotive electronic control technology, including creating a timeline, and determining the timeout moment of the CAN message based on the preset timeout time of each CAN message, and pre-inserting each CAN message in the CAN network into the corresponding position on the timeline according to the timeout moment; recording the receiving time of each CAN message on the timeline; when the first moment on the timeline is triggered for timeout detection, based on the first moment, the timeout moment and the last receiving moment of the CAN message received before the first moment, the timeout calculation is performed on each CAN message on the timeline before the first moment, and the CAN message in the timeout state is determined according to the calculation result. The present application can not only effectively improve the efficiency of CAN message timeout calculation, but also reduce the system overhead, and has a wide range of applicable scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automotive electronic control technology, and in particular to a CAN message timeout calculation method, device, equipment and readable storage medium. Background Art

[0002] As the functions of current cars are becoming more and more abundant, the number of ECUs (Electronic Control Units) on vehicles is also increasing, resulting in a significant increase in the number of CAN (Controller Area Network) network messages that carry communication between ECUs, which in turn leads to increasing work pressure on vehicle-mounted devices that need to process CAN information, and higher and higher requirements for CAN message processing algorithms for vehicle-mounted instruments. The CAN message timeout algorithm is an important part of the CAN message processing algorithm.

[0003] Among them, the main problems faced by the timeout algorithm of the vehicle-mounted CAN network message are the following characteristics: (1) the number of messages is large, the cycle is short and the frequency is high; (2) the message cycle length varies greatly, for example, the shortest can be as short as 10ms, and the longest can be as long as 5s or even 10s; (3) there are strict response accuracy requirements, and the allowable error range of the timeout response is generally within ±10%. For example, for a message with a cycle of 10ms, its timeout time is generally 5 times the cycle, that is, 50ms. Then, based on a 10% error, its timeout response must be issued within ±5ms of the timeout moment.

[0004] In the related art, the following two methods are mainly used for CAN message timeout calculation: periodic polling and timer. Among them, periodic polling refers to recording the receiving time of each message ID (Identity document) when receiving the message, and periodically polling all message IDs, comparing the time difference between the current time and the receiving time, and considering the timeout when the time difference is greater than the set timeout value; the advantages of this method are that the code logic is relatively simple, the operation is stable and reliable, and it takes up very little space; however, it is only suitable for scenarios where the message sending cycle is close; in addition, since it checks all message IDs in each cycle, when the number of IDs is large, there is still a problem of low efficiency.

[0005] The timer refers to setting a timer for each message ID, and updating the trigger time of the corresponding timer every time a message is received. Therefore, if the message is received normally, the timer trigger time will be continuously updated, but it will not actually be triggered. Once the timer is triggered, it means that the corresponding ID has timed out. The advantages of this method are that the code structure is clear and easy to understand, and the control accuracy of the timeout time is high. However, it is only applicable to scenarios with low message frequency, and because the timer needs to be updated when receiving messages, the timer is updated very frequently. Therefore, when the number of messages to be processed is large, the system overhead will be very large. In addition, since each message ID needs to maintain a separate timer, when the number of message IDs is large, a large number of timers will bring additional space overhead, which will cause a large burden on the system. It can be seen that the current method for calculating CAN message timeout has the problems of low efficiency, high system overhead and large restrictions on applicable scenarios. Summary of the invention

[0006] The present application provides a CAN message timeout calculation method, device, equipment and readable storage medium to solve the problems of low efficiency, high system overhead and large application scenario limitations in CAN message timeout calculation in related technologies.

[0007] In a first aspect, a CAN message timeout calculation method is provided, comprising the following steps:

[0008] Creating a timeline, and determining a timeout moment of the CAN message based on a preset timeout moment of each CAN message, and pre-inserting each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment;

[0009] Record the receiving time of each CAN message on the timeline;

[0010] When the first moment on the timeline is triggered for timeout detection, a timeout calculation is performed on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment, and the CAN message in the timeout state is determined based on the calculation result.

[0011] In some embodiments, the step of pre-inserting each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment includes:

[0012] The timeout time of each CAN message and its corresponding message ID are stored in the form of a key-value pair, wherein the timeout time is the key value in the key-value pair, and the message ID is the value value in the key-value pair;

[0013] All CAN messages in the CAN network are pre-inserted into corresponding positions on the timeline in ascending order of key values.

[0014] In some embodiments, the performing timeout calculation on each CAN message located before the first moment on the time axis based on the first moment, the timeout moment and the last receiving moment of the last CAN message received before the first moment, and determining the CAN message in the timeout state according to the calculation result includes:

[0015] Adding the last receiving time of the first CAN message before the first time on the time axis to the timeout time of the first CAN message to obtain a second time;

[0016] Determine whether the second moment is greater than the first moment;

[0017] If yes, the first CAN message is in a non-timeout state;

[0018] If not, the first CAN message is in a timeout state.

[0019] In some embodiments, after the step of the first CAN message being in a non-timeout state, the method further includes:

[0020] Adding the last receiving time of the first CAN message to the preset timeout period of the first CAN message to obtain a third time;

[0021] The first CAN message is moved to a position on the time axis corresponding to the third moment.

[0022] In some embodiments, after the step of the first CAN message being in a timeout state, the method further includes:

[0023] Sending a timeout response to a timeout processing module, and removing the first CAN message from the timeline;

[0024] When the first CAN message is received again, the first receiving time of receiving the first CAN message is added to the preset timeout time of the first CAN message to obtain a fourth time;

[0025] The first CAN message is inserted into a position on the time axis corresponding to the fourth moment.

[0026] In some embodiments, the method further comprises:

[0027] Any moment after the first moment on the trigger timeline is used as a new first moment for timeout detection, and the step of performing timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment is executed.

[0028] In some embodiments, the mechanism by which the first moment is triggered is periodic triggering or timer triggering.

[0029] In a second aspect, a CAN message timeout calculation device is provided, comprising:

[0030] An initialization unit, which is used to create a timeline, and determine the timeout moment of the CAN message based on the preset timeout time of each CAN message, and pre-insert each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment;

[0031] A recording unit, which is used to record the receiving time of each CAN message on the time axis;

[0032] A detection unit, which is used to, when a first moment on the timeline is triggered for timeout detection, perform timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last reception moment of the last CAN message received before the first moment, and determine the CAN message in the timeout state according to the calculation result.

[0033] In a third aspect, a CAN message timeout calculation device is provided, comprising: a memory and a processor, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the aforementioned CAN message timeout calculation method.

[0034] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, the aforementioned CAN message timeout calculation method is implemented.

[0035] The beneficial effects brought about by the technical solution provided in this application include: it can effectively improve the efficiency of CAN message timeout calculation, reduce system overhead, and has a wide range of applicable scenarios.

[0036] The present application provides a CAN message timeout calculation method, apparatus, device and readable storage medium, including creating a timeline, and determining the timeout moment of the CAN message based on the preset timeout time of each CAN message, and pre-inserting each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment; when a first moment on the timeline is triggered for timeout detection, based on the first moment, the timeout moment and the last receiving moment of the CAN message received for the last time before the first moment, timeout calculation is performed on each CAN message on the timeline before the first moment, and the CAN message in the timeout state is determined according to the calculation result. Through the present application, each time a timeout detection is performed, it is only necessary to perform timeout calculation on the CAN messages before a certain moment on the timeline, and since the CAN messages after a certain moment have not timed out, there is no need for timeout calculation on them, thereby ensuring that timeout calculation is performed only on CAN messages whose status may change each time, that is, there is no need to poll all CAN messages in the system, thereby achieving the purpose of minimizing the number of CAN messages that require timeout calculation in each detection cycle, thereby improving the efficiency of CAN message timeout calculation; in addition, the present application dynamically obtains the timing of CAN message timeout detection and the CAN messages that require timeout calculation from the timeline, and has nothing to do with the number of CAN messages, the length of the CAN message cycle, the frequency of CAN messages, etc., and is not only applicable to timeout calculations in various scenarios, but also does not require setting a large number of timers to implement timeout calculations, effectively reducing system overhead. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0038] Figure 1 A flow chart of a CAN message timeout calculation method provided in an embodiment of the present application;

[0039] Figure 2 A schematic diagram of timeline initialization provided in an embodiment of the present application;

[0040] Figure 3 A schematic diagram of a timeout detection process provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of the structure of a CAN message timeout calculation device provided in an embodiment of the present application;

[0042] Figure 5A schematic diagram of the structure of a CAN message timeout calculation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0044] The embodiments of the present application provide a CAN message timeout calculation method, device, equipment and readable storage medium, which can solve the problems of low efficiency, high system overhead and large application scenario limitations in CAN message timeout calculation in related technologies.

[0045] Figure 1 A CAN message timeout calculation method provided in an embodiment of the present application comprises the following steps:

[0046] Step S10: creating a timeline, and determining a timeout moment of the CAN message based on a preset timeout moment of each CAN message, and pre-inserting each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment;

[0047] Further, the pre-inserting each CAN message in the CAN network into a corresponding position on the time axis according to the timeout moment includes:

[0048] The preset timeout time of each CAN message and its corresponding message ID are stored in the form of a key-value pair, wherein the preset timeout time is the key value in the key-value pair, and the message ID is the value value in the key-value pair;

[0049] All CAN messages in the CAN network are pre-inserted into corresponding positions on the timeline in ascending order of key values.

[0050] For example, in the embodiment of the present application, the timeline can be simply implemented using a common ordered data structure. For example, the Map structure in the standard library (Map is a collection of mapping key objects and value objects) can meet the requirements, that is, the Map structure uses the key+value method to store data, and the key values ​​are automatically arranged from small to large. Therefore, in this embodiment, the CAN message can be inserted into the Map in the combination of "timeout time" + "message ID" to complete the insertion of the timeline.

[0051] Before receiving the CAN message, the time axis is initialized. Since the number of CAN messages included in the CAN network, the specific CAN messages, the timeout time of each CAN message and the message ID are known in advance when the time axis is initialized, all CAN messages that need to be received and processed can be inserted into the time axis at the timeout time corresponding to the timeout time before receiving the CAN message, and the initial receiving time of each CAN message is set to 0.

[0052] Take the CAN network including CAN message 1, CAN message 2, CAN message 3, CAN message 4 and CAN message 5, and the message IDs corresponding to CAN message 1, CAN message 2, CAN message 3, CAN message 4 and CAN message 5 are ID1, ID2, ID3, ID4 and ID5 respectively as an example: Assume that the preset timeout time of ID1, ID2, ID3, ID4 and ID5 is 5ms, 7ms, 10ms, 13ms and 14ms respectively, and the initial receiving time corresponding to ID1, ID2, ID3, ID4 and ID5 is set to 0 (that is, the system has not started CAN message 1, CAN message 2, CAN message 3, CAN message 4 and CAN message 5). Message 2, CAN message 3, CAN message 4 and CAN message 5 are received), the initial timeout moments of ID1, ID2, ID3, ID4 and ID5 are the 5th ms, 7th ms, 10th ms, 13th ms and 14th ms respectively; wherein, the representation of any moment on the time axis should actually be: xx hours, xx minutes, xx seconds, xx milliseconds. For example, if the initial time of the time axis is 0 hours, 0 minutes, 0 seconds, 0 milliseconds, then the initial timeout moment of ID1 should be 0 hours, 0 minutes, 0 seconds, 5 milliseconds. However, for the sake of simplicity of description, this embodiment simplifies 0 hours, 0 minutes, 0 seconds, 5 milliseconds to the 5th ms, and the same treatment is performed on other moments.

[0053] At this time, the data of each CAN message can be stored in the form of a key-value pair, that is, the key value of CAN message 1 is the timeout moment "5ms" and the value value is ID1, the key value of CAN message 2 is the timeout moment "7ms" and the value value is ID2, the key value of CAN message 3 is the timeout moment "10ms" and the value value is ID3; the key value of CAN message 4 is the timeout moment "13ms" and the value value is ID4; the key value of CAN message 5 is the timeout moment "14ms" and the value value is ID5.

[0054] In this embodiment, CAN message 1, CAN message 2, CAN message 3, CAN message 4 and CAN message 5 are inserted into the Figure 2The time axis shown in FIG. 1 (the start time of the time axis is 0). Subsequent timeout checks will be performed based on the time axis, and only the CAN messages inserted into the time axis will be included in the timeout calculation, that is, if there are only CAN message 1, CAN message 2, CAN message 3, CAN message 4 and CAN message 5 on the time axis, then this embodiment will only perform timeout detection and calculation on the above five CAN messages, and will not perform timeout detection and calculation on other CAN messages outside the time axis.

[0055] The purpose of creating a timeline is to establish an ordered structure to maintain the order of CAN message timeout checks. <time_t,list <id>>, etc.) structures are common data structures in standard libraries that have been proven to be stable and efficient. Therefore, this embodiment uses a common ordered Map structure to create a timeline, which has the advantages of simple and reliable structure. Of course, you can also use a linked list or array that maintains its own order to implement the function of the timeline, which is not limited here.

[0056] Step S20: Record the receiving time of each CAN message on the time axis;

[0057] For example, in the embodiment of the present application, as the receiving process of the CAN message with the highest frequency in the actual timeout detection work, the fewer operations in the receiving process, the better. Therefore, in the present embodiment, only the receiving time needs to be recorded when receiving the message, so as to achieve the purpose of as few operations as possible when receiving the CAN message, that is, when each CAN message is initialized to the time axis, the receiving time of each CAN message on the time axis needs to be recorded. For example, if CAN message 1 is received at the 1st ms and the 3rd ms before the 5th ms, then the receiving time of CAN message 1 needs to be recorded as the 3rd ms.

[0058] Step S30: When the first moment on the timeline is triggered for timeout detection, a timeout calculation is performed on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment, and the CAN message in the timeout state is determined according to the calculation result.

[0059] Further, the performing timeout calculation on each CAN message before the first moment on the time axis based on the first moment, the timeout moment and the last receiving moment of the last CAN message received before the first moment, and determining the CAN message in the timeout state according to the calculation result, includes:

[0060] Adding the last receiving time of the first CAN message before the first time on the time axis to the timeout time of the first CAN message to obtain a second time;

[0061] Determine whether the second moment is greater than the first moment;

[0062] If yes, the first CAN message is in a non-timeout state;

[0063] If not, the first CAN message is in a timeout state.

[0064] Further, after the step of the first CAN message being in a non-timeout state, the method further includes:

[0065] Adding the last receiving time of the first CAN message to the preset timeout period of the first CAN message to obtain a third time;

[0066] The first CAN message is moved to a position on the time axis corresponding to the third moment.

[0067] Further, after the step of the first CAN message being in a timeout state, the method further includes:

[0068] Sending a timeout response to a timeout processing module, and removing the first CAN message from the timeline;

[0069] When the first CAN message is received again, the first receiving time of receiving the first CAN message is added to the preset timeout time of the first CAN message to obtain a fourth time;

[0070] The first CAN message is inserted into a position on the time axis corresponding to the fourth moment.

[0071] Exemplarily, in the embodiment of the present application, if the current moment is triggered, it means that the current moment is the detection moment (for example, see Figure 2 As shown, the first detection moment can be set to the timeout moment corresponding to ID1), and a message timeout detection is required, so the current time corresponding to the current moment is obtained, and all CAN messages with timeout moments before the current moment are retrieved in the timeline to obtain a set of CAN messages that need to be updated. Specifically, when the timeout detection is triggered, all key values ​​are traversed from the beginning, and the CAN message with a key value less than the current moment is the message that needs to be updated. Therefore, all CAN messages that need to be updated can be obtained based on the size relationship between the key value and the current moment, and because the key value on the timeline has an ordered characteristic from small to large, it is only necessary to start the comparison of the key value and the current moment from the initial part of the timeline until a key value greater than the current moment is encountered, and it can be stopped without traversing all CAN messages.

[0072] See also Figure 3 As shown, taking the first moment as the 12th ms being triggered as an example, the timeline is traversed. Since the key values ​​of ID1 and ID2 are less than the first moment, that is, the timeout moments of ID1 and ID2 are earlier than the detection moment, and the timeout moments of ID3 to ID5 are all later than the detection moment, that is, ID3 to ID5 have not timed out at the current moment, and no timeout calculation is required, so the messages that need to be calculated for timeout are CAN message 1 and CAN message 2. Since the timeline is not updated when CAN message 1 and CAN message 2 are received, and multiple CAN messages 1 and CAN messages 2 may have been received before the timeout moment of CAN message 1 and CAN message 2 (the receiving time of each CAN message has been recorded), it is impossible to confirm whether CAN message 1 and CAN message 2 are in a timeout state, but further inspection is required.

[0073] Assume that the timeout moment of CAN message 1 (if the timeout detection at this time is the first timeout detection performed after the time axis is initialized, the timeout moment at this time is equal to the initial timeout moment) is the 9th ms, and CAN message 1 is received at the 1st ms, 3rd ms, 5th ms and 8th ms before the 12th ms. Similarly, assume that the timeout moment of CAN message 2 is the 10th ms, and CAN message 2 is received only at the 1st ms before the 12th ms.

[0074] At this time, for CAN message 1: add the last receiving time of CAN message 1 received for the last time before the 12th ms (i.e., the 8th ms) and the timeout time of CAN message 1 (i.e., the 9th ms), and judge whether CAN message 1 is in the timeout state according to the addition result and the first time (i.e., the 12th ms), i.e., 8+9=17, and since 17 is greater than 12 corresponding to the first time, it means that CAN message 1 is in the non-timeout state. Therefore, this embodiment will further calculate the next timeout time of CAN message 1, that is, add the last receiving time (i.e., the 8th ms) and the preset timeout time of CAN message 1 (i.e., 5ms), and obtain the new timeout time of CAN message 1 (i.e., the 13th ms), and move CAN message 1 to the position of the 13th ms on the time axis, obtain a new time axis and wait for the next detection.

[0075] For CAN message 2: add the last receiving time of CAN message 2 received before the 12th ms (i.e., the 1st ms) to the timeout time of CAN message 2 (i.e., the 10th ms), and judge whether CAN message 2 is in the timeout state according to the addition result and the first time (i.e., the 12th ms), i.e., 1+10=11. Since 11 is less than 12 corresponding to the first time, it means that CAN message 2 is in the timeout state. Therefore, this embodiment will send a timeout response to the timeout processing module in the system and remove CAN message 2 from the timeline; however, if the timeout response problem of CAN message 2 is solved, the system will continue to send CAN message 2. Therefore, when CAN message 2 is received again, the first receiving time corresponding to the CAN message 2 received again and the preset timeout time of CAN message 2 are added to obtain the fourth time, and CAN message 2 is inserted into the position corresponding to the fourth time on the timeline. For example, when CAN message 2 is received at the 19th ms, 19 is added to the preset timeout time of CAN message 2 (i.e. 7ms) to obtain the new timeout time of CAN message 2 (i.e. 26ms), and CAN message 2 is reinserted at the 26th ms position on the time axis to obtain a new time axis and wait for the next detection. It can be seen that this embodiment only operates the time axis during the detection process, and the time axis is static at other times, which can reduce the change of the ordered structure; in addition, in various scenarios such as the number of CAN messages, the length of the message cycle, and the density or sparseness of the message frequency, there is no need to modify the timeout calculation algorithm of this embodiment, and it can achieve high operating efficiency and space efficiency.

[0076] Furthermore, the method further comprises:

[0077] Any moment after the first moment on the trigger timeline is used as a new first moment for timeout detection, and the step of performing timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment is executed.

[0078] For example, in the embodiment of the present application, after the timeout calculation and processing of CAN message 1 and CAN message 2 are completed, any time after 12ms in the new time axis can be used as the next check time, for example Figure 3 The timeout time of ID3 in the CAN is calculated, and then the timeout of the CAN message before ID3 is calculated.

[0079] Furthermore, the mechanism by which the first moment is triggered is periodic triggering or timer triggering.

[0080] Exemplarily, in the embodiment of the present application, the triggering of the CAN message timeout detection can be either periodic or timer-triggered. Among them, when performing timeout detection by polling in the related art, there is a problem that the polling cycle is difficult to select, such as if the polling cycle is short, the performance overhead is unbearable, and if the cycle is long, the response accuracy is too low, and if the message cycle length is large, it will also lead to more performance waste; however, the timeout calculation in this embodiment is not related to the number of CAN messages, the length of the CAN message cycle, the frequency of the CAN message, etc., so it can be triggered by periodicity (the detection cycle should be less than the allowable response error range), and its structure is simple and reliable, and due to the characteristics of the time axis, even if it is frequently triggered, it will not detect CAN messages that do not need to be detected, so it will not cause additional performance waste.

[0081] The timer method triggering can bring higher response accuracy and smaller performance overhead (for example, the present embodiment only needs one timer, and there is no need to set a timer for each CAN message). For example, after each detection is completed, the most recent timeout moment can be re-acquired, and this timeout moment can be used as the next detection moment; of course, the detection moment can also be shifted backward within the allowable error range to further improve the performance, that is, the timing of each message status detection is automatically postponed to the necessary extreme moment based on the time axis. For example, after a detection is completed at the 12th ms, there are still CAN messages corresponding to the 15th ms, the 18th ms, the 20th ms, the 23rd ms, the 28th ms, etc. after the 12th ms. At this time, the 23rd ms can be selected as the next detection moment. Then, when the next timeout detection is performed, the CAN message corresponding to the 15th ms, the 18th ms, and the 20th ms can be detected to further improve the timeout detection efficiency.

[0082] It can be seen that the present embodiment uses an ordered data structure to form a time axis for message management, and provides a message timeout algorithm that has excellent performance in performance occupancy, space occupancy and response accuracy, and has a simple and reliable structure and is easy to implement. Therefore, through this application, each timeout detection only requires the CAN message before a certain moment on the time axis to be timed out, and the CAN message after a certain moment does not time out, so it is not necessary to perform a timeout calculation on it, thereby ensuring that only the CAN message whose state may change is timed out each time, that is, there is no need to poll all CAN messages in the system, so as to achieve the purpose of minimizing the number of CAN messages that need to be timed out in each detection cycle, and make the frequency of timeout detection reach the lowest theoretically, thereby improving the efficiency of CAN message timeout calculation; in addition, the present application dynamically obtains the timing of CAN message timeout detection and the CAN message that needs to be timed out from the time axis, and has nothing to do with the number of CAN messages, the length of the CAN message cycle, the frequency of the CAN message, etc., which is not only applicable to timeout calculations in various scenarios, but also does not need to set a large number of timers to achieve timeout calculations, effectively reducing system overhead.

[0083] See also Figure 4 As shown, the embodiment of the present application also provides a CAN message timeout calculation device, including:

[0084] An initialization unit, which is used to create a timeline, and determine the timeout moment of the CAN message based on the preset timeout time of each CAN message, and pre-insert each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment;

[0085] A recording unit, which is used to record the receiving time of each CAN message on the time axis;

[0086] A detection unit, which is used to, when a first moment on the timeline is triggered for timeout detection, perform timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last reception moment of the last CAN message received before the first moment, and determine the CAN message in the timeout state according to the calculation result.

[0087] Furthermore, the initialization unit is specifically used for:

[0088] The timeout time of each CAN message and its corresponding message ID are stored in the form of a key-value pair, wherein the timeout time is the key value in the key-value pair, and the message ID is the value value in the key-value pair;

[0089] All CAN messages in the CAN network are pre-inserted into corresponding positions on the timeline in ascending order of key values.

[0090] Furthermore, the detection unit is specifically used for:

[0091] Adding the last receiving time of the first CAN message before the first time on the time axis to the timeout time of the first CAN message to obtain a second time;

[0092] Determine whether the second moment is greater than the first moment;

[0093] If yes, the first CAN message is in a non-timeout state;

[0094] If not, the first CAN message is in a timeout state.

[0095] Furthermore, the detection unit is also specifically used for:

[0096] Adding the last receiving time of the first CAN message to the preset timeout period of the first CAN message to obtain a third time;

[0097] The first CAN message is moved to a position on the time axis corresponding to the third moment.

[0098] Furthermore, the detection unit is also specifically used for:

[0099] Sending a timeout response to a timeout processing module, and removing the first CAN message from the timeline;

[0100] When the first CAN message is received again, the first receiving time of receiving the first CAN message is added to the preset timeout time of the first CAN message to obtain a fourth time;

[0101] The first CAN message is inserted into a position on the time axis corresponding to the fourth moment.

[0102] Furthermore, the detection unit is also used for:

[0103] Any moment after the first moment on the trigger timeline is used as a new first moment for timeout detection, and the step of performing timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment is executed.

[0104] Furthermore, the mechanism by which the first moment is triggered is periodic triggering or timer triggering.

[0105] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each unit can refer to the corresponding process in the aforementioned CAN message timeout calculation method embodiment, and will not be repeated here.

[0106] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 5 The CAN message timeout calculation shown is running on the device.

[0107] An embodiment of the present application also provides a CAN message timeout calculation device, comprising: a memory, a processor and a network interface connected via a system bus, wherein at least one instruction is stored in the memory, and at least one instruction is loaded and executed by the processor to implement all or part of the steps of the aforementioned CAN message timeout calculation method.

[0108] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0109] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc. The processor is the control center of the computer device, and uses various interfaces and lines to connect various parts of the entire computer device.

[0110] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the computer device by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a video playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as video data, image data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device or other volatile solid-state storage device.

[0111] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, all or part of the steps of the aforementioned CAN message timeout calculation method are implemented.

[0112] The embodiment of the present application implements all or part of the aforementioned process, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of each of the above methods when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0113] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, servers or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0114] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0115] It should be noted that, in this article, the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or system 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 system. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0116] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.< / id>

Claims

1. A CAN message timeout calculation method, characterized in that: The following steps are involved: Creating a timeline, and determining a timeout moment of the CAN message based on a preset timeout moment of each CAN message, and pre-inserting each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment; Record the receiving time of each CAN message on the timeline; When the first moment on the time axis is triggered to perform timeout detection, a timeout calculation is performed on each CAN message on the time axis before the first moment based on the first moment, the timeout moment and the last receiving moment of the last CAN message received before the first moment, and a CAN message in a timeout state is determined according to the calculation result; The step of performing timeout calculation on each CAN message located before the first moment on the time axis based on the first moment, the timeout moment and the last receiving moment of the last CAN message received before the first moment, and determining the CAN message in the timeout state according to the calculation result includes: Adding the last receiving time of the first CAN message before the first time on the time axis to the timeout time of the first CAN message to obtain a second time; Determine whether the second moment is greater than the first moment; If yes, the first CAN message is in a non-timeout state; If not, the first CAN message is in a timeout state.

2. The CAN message timeout calculation method according to claim 1, characterized in that: The step of pre-inserting each CAN message in the CAN network into a corresponding position on the time axis according to the timeout moment includes: The timeout time of each CAN message and its corresponding message ID are stored in the form of a key-value pair, wherein the timeout time is the key value in the key-value pair, and the message ID is the value value in the key-value pair; All CAN messages in the CAN network are pre-inserted into corresponding positions on the timeline in ascending order of key values.

3. The CAN message timeout calculation method according to claim 1, characterized in that: After the step of the first CAN message being in a non-timeout state, the method further includes: Adding the last receiving time of the first CAN message to the preset timeout period of the first CAN message to obtain a third time; The first CAN message is moved to a position on the time axis corresponding to the third moment.

4. The CAN message timeout calculation method according to claim 1, characterized in that: After the step of the first CAN message being in a timeout state, the method further includes: Sending a timeout response to a timeout processing module, and removing the first CAN message from the timeline; When the first CAN message is received again, the first receiving time of receiving the first CAN message is added to the preset timeout time of the first CAN message to obtain a fourth time; The first CAN message is inserted into a position on the time axis corresponding to the fourth moment.

5. The CAN message timeout calculation method according to claim 3 or 4, characterized in that: The method further comprises: Any moment after the first moment on the trigger timeline is used as a new first moment for timeout detection, and the step of performing timeout calculation on each CAN message before the first moment on the timeline based on the first moment, the timeout moment and the last receiving moment of the last received CAN message before the first moment is executed.

6. The CAN message timeout calculation method according to claim 1, wherein: The mechanism of triggering the first moment is periodic triggering or timer triggering.

7. A CAN message timeout calculation device, characterized in that: include: An initialization unit, which is used to create a timeline, and determine the timeout moment of the CAN message based on the preset timeout time of each CAN message, and pre-insert each CAN message in the CAN network into a corresponding position on the timeline according to the timeout moment; A recording unit, which is used to record the receiving time of each CAN message on the time axis; A detection unit, which is used to, when a first moment on the timeline is triggered for timeout detection, perform timeout calculation on each CAN message on the timeline before the first moment based on the first moment, the timeout moment and the last reception moment of the CAN message received for the last time before the first moment, and determine the CAN message in the timeout state according to the calculation result; wherein the detection unit is specifically used to: add the last reception moment of the first CAN message on the timeline before the first moment to the timeline The timeout moment of the first CAN message is added to obtain a second moment; determine whether the second moment is greater than the first moment; if so, the first CAN message is in a non-timeout state; if not, the first CAN message is in a timeout state.

8. A CAN message timeout calculation device, characterized in that: include: A memory and a processor, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the CAN message timeout calculation method according to any one of claims 1 to 6.

9. 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 CAN message timeout calculation method according to any one of claims 1 to 6 is implemented.