Periodic message sending method and electrical system
By using a method of sending messages in a staggered manner based on message priority and adjusting the transmission time on the CAN bus, the delay problem caused by the overlap of multiple periodic messages was solved, thereby improving the real-time performance and processing efficiency of messages.
Patent Information
- Application Number
- CN202410157626.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-04
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2044-02-04
AI Technical Summary
When sending messages on the CAN bus, the reporting cycles of multiple periodic messages may overlap, causing severe delays or even transmission failures for lower-priority messages, which is difficult to solve effectively with existing technologies.
By delaying and staggering the transmission of each message based on its priority, the periodic transmission conditions and transmission times are adjusted to ensure that only the highest priority message is transmitted within the same preset processing period. The transmission times of each message are then fixed and adjusted in subsequent moments to avoid overlap.
It effectively reduces the sending delay of low-priority periodic messages, ensures the real-time performance and processing efficiency of each message, and reduces the cache space requirement.
Smart Images

Figure CN118018348B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of bus communication technology, and in particular to a method and electrical system for transmitting periodic messages. Background Technology
[0002] Controller Area Network (CAN) bus is a serial communication protocol bus used for real-time applications. It uses twisted-pair cables to transmit signals and is one of the most widely used fieldbuses in the world. It is an effective serial communication network that supports distributed and real-time control. The application scope of CAN bus is no longer limited to the automotive industry; it is widely used in various fields such as automatic control, building automation, and medical equipment.
[0003] However, when the message sender and receiver use the CAN bus for vertical data exchange, the message sender typically reports multiple periodic messages to the CAN bus. It's difficult to avoid overlap in the reporting periods of multiple messages at any given moment, meaning multiple messages need to be uploaded to the CAN bus simultaneously. However, due to the limited resources of the CAN bus, and the limited message processing capabilities of both the message sender and receiver, it's impossible to report multiple messages to the CAN bus simultaneously. The message sender will prioritize sending higher-priority periodic messages, while lower-priority periodic messages will be delayed, resulting in significant delays for lower-priority messages, or even message transmission failures. Summary of the Invention
[0004] This invention provides a method and electrical system for sending periodic messages to solve the problem of severe delay in sending lower-priority messages when the reporting periods of multiple messages overlap at a certain time.
[0005] In a first aspect, embodiments of the present invention provide a method for sending periodic messages, applied to a processor at a message sending end; the sending method includes:
[0006] If multiple messages that meet the corresponding periodic sending conditions exist within the same preset processing period, then each message is sent in a delayed and staggered manner based on its priority.
[0007] The periodic transmission conditions of each message are adjusted based on the preset transmission period and the time information of each transmission, so as to solidify the subsequent transmission time of each message; wherein, the time information includes the current delay time or the current transmission time.
[0008] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0009] Every preset processing cycle, each message is processed according to its priority, and based on the previous sending time and the preset sending cycle, it is determined whether each message meets its periodic sending conditions at the current time. When a message that meets the periodic sending conditions is found, the message that meets the conditions is sent. The previous sending time is the closest historical sending time of the corresponding message to the current time.
[0010] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0011] Every preset processing cycle, based on the previous sending time of each message and the preset sending cycle, all messages that meet the periodic sending conditions at the current time are determined, and only the first target message is sent within each preset processing cycle; wherein, the previous sending time is the historical sending time of the corresponding message that is closest to the current time, and the first target message is the message with the highest priority among all messages that meet the periodic sending conditions.
[0012] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0013] Every preset processing cycle, for each message not located in the message buffer queue, based on the previous sending time of each message and the preset sending cycle, all messages that meet the periodic sending conditions at the current time are determined, and the message buffer queue is updated according to the priority order of each message that meets the periodic sending conditions within the current preset processing cycle. In each preset processing cycle, only the message at the head of the message buffer queue is sent; where the previous sending time is the historical sending time of the corresponding message that is closest to the current time.
[0014] In one possible implementation, the periodic transmission condition is:
[0015] The difference between the current time and the previous time of the corresponding message is greater than or equal to the preset transmission period of the message;
[0016] The time information refers to the moment this message was sent.
[0017] The periodic transmission conditions of each message are adjusted based on the preset transmission period and the time information of each transmission, including:
[0018] After each message is sent, the previous sending time of the message is updated based on the current sending time. In subsequent times, the message is judged to meet the periodic sending conditions based on the preset sending period of the message and the updated previous sending time.
[0019] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0020] Every preset processing cycle, each message is processed according to its priority and based on its planned transmission time. If a message is found to meet the periodic transmission conditions, it is sent. The planned transmission time is determined based on the cumulative delay time, cumulative transmission count, and preset transmission cycle of each message.
[0021] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0022] Every preset processing cycle, based on the planned transmission time of each message, all messages that meet the periodic transmission conditions at the current time are determined, and only the first target message is transmitted within each preset processing cycle; wherein, the planned transmission time is determined based on the cumulative delay time, cumulative transmission count and preset transmission cycle of each message, and the first target message is the message with the highest priority among all messages that meet the periodic transmission conditions.
[0023] In one possible implementation, messages are sent sequentially with delays and staggered order based on their priority, including:
[0024] Every preset processing cycle, for each message not located in the message buffer queue, based on the planned transmission time of each message, all messages that meet the periodic transmission conditions at the current time are determined, and each message that meets the periodic transmission conditions within the current preset cycle is updated to the message buffer queue according to its priority order. In each preset processing cycle, only the message at the head of the message buffer queue is transmitted. The planned transmission time is determined based on the cumulative delay time, cumulative transmission count, and preset transmission cycle of each message.
[0025] In one possible implementation, the periodic transmission condition is that the current time is equal to or later than the planned transmission time;
[0026] The planned transmission time is calculated as follows:
[0027] T p =t 总 +(m+1)×T r ; where t 总 T represents the cumulative delay time of the message, m represents the cumulative number of messages sent, and T represents the cumulative delay time of the message. r This is the preset sending period for the message;
[0028] The time information is the current delay time, which is determined based on the difference between the current transmission time and the planned transmission time.
[0029] The periodic transmission conditions of each message are adjusted based on the preset transmission period and the time information of each transmission, including:
[0030] After each message is sent, the cumulative delay time of the message is updated based on the current delay time, and the cumulative number of transmissions is also updated. This allows us to determine whether the message meets the periodic transmission condition at subsequent times based on the updated cumulative delay time and cumulative number of transmissions.
[0031] Secondly, embodiments of the present invention provide a device for transmitting periodic messages, applied to a processor at a message transmitting end; the transmitting device includes:
[0032] The sending module is used to send multiple messages that meet the corresponding periodic sending conditions within the same preset processing period, based on the priority of each message, with delays and staggered timing.
[0033] The update module is used to adjust the periodic transmission conditions of each message based on the preset transmission period of each message and the time information of each transmission, so as to fix the subsequent transmission time of each message; wherein, the time information includes the current delay time or the current transmission time.
[0034] Thirdly, embodiments of the present invention provide an electrical device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method as described in the first aspect or any possible implementation of the first aspect.
[0035] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in the first aspect or any possible implementation thereof.
[0036] Fifthly, embodiments of the present invention provide an electrical system, including at least one electrical device of the third aspect and a monitoring device for monitoring the operating status of the electrical device.
[0037] This invention provides a method and electrical system for sending periodic messages. First, if multiple messages satisfying corresponding periodic sending conditions exist within the same preset processing period, they are sent sequentially with delayed and staggered transmissions based on their priorities. Then, the periodic sending conditions of each message are adjusted based on its preset sending period and the time information of each transmission, thus fixing the subsequent transmission times of each message. To reduce the possibility of continuous periodic overlap among multiple messages satisfying the sending conditions within the same preset processing period, this invention first delays and staggers the transmissions of overlapping messages based on their priorities within the same preset processing period, causing the transmission times of overlapping messages to be staggered. To further address the problem of periodic overlap, the periodic sending conditions of each message are adjusted based on the time information of each transmission of the overlapping messages, and the subsequent transmission times are fixed, ensuring that messages that overlap in a certain preset processing period will not overlap again in subsequent preset processing periods. This reduces the transmission delay time of lower-priority periodic messages, thereby ensuring the real-time transmission of each message. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating the implementation of a periodic message sending method provided in an embodiment of the present invention;
[0040] Figure 2 This is a flowchart illustrating the implementation of the second method for sending periodic messages provided in this embodiment of the invention.
[0041] Figure 3 This is a flowchart illustrating the implementation of the third method for sending periodic messages provided in this embodiment of the invention.
[0042] Figure 4 This is a flowchart illustrating the implementation of the fourth method for sending periodic messages provided in this embodiment of the invention.
[0043] Figure 5 This is a flowchart illustrating the implementation of the fifth method for sending periodic messages provided in this embodiment of the invention.
[0044] Figure 6 This is a flowchart illustrating the implementation of the sixth method for sending periodic messages provided in this embodiment of the invention.
[0045] Figure 7This is a flowchart illustrating the implementation of the seventh method for sending periodic messages provided in this embodiment of the invention.
[0046] Figure 8 This is a schematic diagram of the structure of the periodic message sending device provided in an embodiment of the present invention;
[0047] Figure 9 This is a schematic diagram of an electronic device provided in an embodiment of the present invention;
[0048] Figure 10 This is a schematic diagram of the electrical system provided in an embodiment of the present invention. Detailed Implementation
[0049] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0050] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments will be described below in conjunction with the accompanying drawings.
[0051] When multiple messages that meet the sending conditions exist within the same preset processing period, in order to ensure the transmission of high-priority messages, high-priority messages will be sent first, thus compromising the real-time performance of lower-priority messages. Furthermore, for periodic messages, once multiple messages that meet the sending conditions exist within the same preset processing period, they will continue to appear periodically, reducing the real-time performance of message transmission.
[0052] Currently, the reporting cycles of various messages are mainly staggered by manually sorting them. However, when there are a large number of messages in a cycle, it is difficult to achieve staggering manually, and manually sorting and staggering them also takes a lot of time.
[0053] To address the problems of the prior art, embodiments of the present invention provide a method and electrical system for sending periodic messages. The method provided by these embodiments is described below.
[0054] See Figure 1 This document illustrates a method for sending periodic messages according to an embodiment of the present invention, applied to a processor at a message sending end. The implementation flowchart of this sending method is detailed below:
[0055] Step S110: If there are multiple messages that meet the corresponding periodic sending conditions within the same preset processing period, then each message is sent in a delayed and staggered manner based on its priority.
[0056] The priority of each message can be determined based on its importance; the more important the message, the more important it is to ensure that the message can be sent in a timely manner.
[0057] In some embodiments, the preset transmission period of each periodic message can be configured sequentially from shortest to longest based on the order of priority of each message from high to low. Therefore, within the same time period, periodic messages with higher priority have more opportunities to be transmitted.
[0058] If there are three types of periodic messages, A, B, and C, with the preset sending period of message A being 200ms, message B being 300ms, and message C being 600ms, and the processor at the message sending end simultaneously meets the periodic sending condition when the timer is 600ms, then each message needs to be sent in a staggered manner with a delay based on its priority.
[0059] The preset processing period is determined based on the processing capability of the processor at the message sending end. For example, the preset processing period can be set to 20ms.
[0060] In each preset processing cycle, the processor at the message sending end will determine the messages that meet the periodic sending conditions at the current time, and send one of the messages that meet the periodic sending conditions to the CAN bus.
[0061] Step S120: Adjust the periodic transmission conditions of each message based on the preset transmission period of each message and the time information of each transmission, so as to solidify the subsequent transmission time of each message.
[0062] The time information includes the delay time or the time of transmission.
[0063] If multiple messages that meet the sending conditions exist within the same preset processing cycle, these messages will continue to appear periodically. If the sending time of these multiple messages does not change, the delay of low-priority periodic messages cannot be fundamentally reduced.
[0064] Therefore, in this application, to ensure that multiple messages meeting the transmission conditions are sent out in a staggered manner and to reduce the possibility of continuous periodicity, the priority of messages sent concurrently within the same preset processing cycle is first determined by sequentially delaying and staggering their transmission times, thus causing the transmission times of the concurrent messages to be out of sync. To further address the issue of periodic overlap, the periodic transmission conditions of each message are adjusted based on the transmission time information of each concurrent message, and the subsequent transmission times are fixed. This ensures that messages sent concurrently in a certain preset processing cycle will not overlap again in subsequent preset processing cycles, reducing the transmission delay time of lower-priority periodic messages and thus guaranteeing the real-time transmission of each message.
[0065] When multiple messages satisfying the corresponding periodic transmission conditions exist within the same preset processing cycle, in addition to considering the priority of each message, it is also necessary to consider the delay time of each message, as well as the processor's processing time and buffer space usage, to further improve the real-time performance of message transmission. Furthermore, for different periodic transmission conditions, parameters that need to be updated after each message transmission can be determined based on the corresponding periodic transmission conditions. This facilitates adjusting the periodic transmission conditions of each message to adjust subsequent transmission times, enabling each message to be transmitted in real time and reducing transmission latency. For example... Figure 2 As shown, the method includes:
[0066] Step S210: If there are multiple messages that meet the corresponding periodic transmission conditions within the same preset processing period, then every preset processing period, based on the previous transmission time of each message and the preset transmission period, determine all messages that meet the periodic transmission conditions at the current time, and only send the first target message within each preset processing period.
[0067] In this embodiment, the previous transmission time is the closest historical transmission time of the corresponding message to the current time. For example, if the historical transmission times of message A are 200ms, 400ms, 600ms, and 800ms, and the current time is 900ms, then the previous transmission time for message A is 800ms.
[0068] The first target message is the message with the highest priority among all messages that meet the periodic transmission conditions.
[0069] In some implementations, the periodic transmission condition can be that the difference between the current time and the previous transmission time of the corresponding message is greater than or equal to the preset transmission period of the message. For ease of explanation later, T will be used. d Indicates the current time, T l T represents the time of the previous transmission. A T represents the preset processing period for message A. B T represents the preset processing period for message B. C This indicates the preset processing cycle for message C.
[0070] In this embodiment, it is necessary to first identify all messages that meet the periodic sending conditions at the current moment, and then send only the message with the highest priority in each preset processing period.
[0071] Step S220: After each message is sent, the previous message time of the message is updated based on the current message time. In subsequent times, the message is judged based on the preset message period and the updated previous message time to determine whether the message meets the periodic message sending condition, so as to fix and adjust the subsequent message sending times of each message.
[0072] To make it easier to understand, let's illustrate with an example:
[0073] Taking the three periodic messages A, B, and C as examples, the preset transmission period of message A is 200ms, the preset transmission period of message B is 300ms, and the preset transmission period of message C is 600ms. The priority order is A>B>C. At the current time, it is 600ms. The previous transmission time of message A was 400ms, the previous transmission time of message B was 300ms, and the previous transmission time of message C was 0ms. The preset processing period of the processor is 20ms.
[0074] At 600ms, for message A:T d -T lA =200ms=T A For message B:T d -T lB =300ms=T B For message C:T d -T lC =600ms=T C It is evident that at 600ms, messages A, B, and C all meet the periodic transmission condition. In this case, messages A, B, and C can all be cached in memory, and only message A, with the highest priority, can be sent at 600ms. After message A is sent, the previous transmission time of message A needs to be updated to 600ms.
[0075] At 620ms, for message A:T d -T lA =20ms <T A For message B:T d -T lB =320ms>T B For message C:T d -T lC =620ms>T CIt is evident that at 620ms, both messages B and C meet the periodic transmission condition. In this case, both messages B and C can be cached in memory, and only the highest-priority message B can be sent at 620ms. After message B is sent, the previous transmission time of message B needs to be updated to 620ms.
[0076] At 640ms, for message A:T d -T lA =40ms <T A For message B:T d -T lB =20ms <T B For message C:T d -T lC =640ms>T C It is evident that message C meets the periodic transmission condition at 640ms. Therefore, message C can be cached in memory, and only the highest priority message C can be sent at 640ms. After message C is sent, the previous transmission time of message C needs to be updated to 640ms.
[0077] The historical transmission times of message A are 200ms, 400ms, 600ms, 800ms, and 1000ms; the historical transmission times of message B are 300ms, 620ms, and 920ms; and the historical transmission time of message C is 640ms. At 1200ms, for message A: T d -T lA =200ms=T A For message B:T d -T lB =280ms <T B For message C:T d -T lC =560ms <T C As can be seen, by adjusting the previous transmission times of messages B and C at 600ms, it is possible to determine whether the message meets the periodic transmission condition based on the updated previous transmission times. This allows for the fixed adjustment of the subsequent transmission times of the message, ensuring that messages A, B, and C will not conflict again within the same preset processing period. The delay times of messages B and C are delayed by 20ms and 40ms respectively compared to their original transmission times, and their respective delay times are fixed. This ensures that messages A, B, and C can all achieve staggered real-time transmission without causing long delays.
[0078] By determining whether a message meets the periodic transmission condition based on the updated previous transmission time at subsequent times, messages that would otherwise have transmission conflicts can have their subsequent transmission times changed, thereby achieving automatic misaligned transmission of messages. Only when the transmission overlaps for the first time does a partial delay occur, and in subsequent times each message will be reported stably.
[0079] However, in each preset processing cycle, it is first necessary to determine all messages that meet the cycle sending conditions at the current moment. That is, in each preset processing cycle, all messages need to be traversed to identify those that meet the cycle sending conditions at the current moment. However, in this preset processing cycle, only the highest priority message is sent, while other messages that meet the conditions are not sent. This leads to a decrease in processing efficiency, reducing both processing speed and efficiency. To improve the processor's processing efficiency, such as... Figure 3 As shown, the method includes:
[0080] Step S310: If there are multiple messages that meet the corresponding periodic sending conditions within the same preset processing period, then every preset processing period, for each message that is not in the message buffer queue, based on the previous sending time of each message and the preset sending period, determine all messages that meet the periodic sending conditions at the current time, and update the message buffer queue according to the priority order of each message that meets the periodic sending conditions within the current preset processing period, and only send the message at the head of the message buffer queue within each preset processing period.
[0081] The periodic transmission conditions are the same as those in step S210, as described in the relevant description of the periodic transmission conditions in step S210, and will not be repeated here. The previous transmission time is the same as that in step S210, as described in the relevant description of the previous transmission time in step S210, and will not be repeated here.
[0082] The message buffer queue stores messages that meet the corresponding periodic sending conditions at the current moment.
[0083] In this embodiment, compared to the processing method of step S210, for packets that are already in the packet buffer queue, there is no need to repeat the judgment at the current moment. It is only necessary to judge whether the packets that are not in the packet buffer queue meet the periodic sending conditions, and update the packet buffer queue based on priority order for the packets that meet the periodic sending conditions. Then, in each preset processing cycle, only the packets with the highest priority are sent.
[0084] Step S320: After each message is sent, the previous message time of the message is updated based on the current message time. In subsequent times, the message is judged based on the preset message period and the updated previous message time to determine whether the message meets the periodic message sending condition, so as to fix and adjust the subsequent message sending times of each message.
[0085] To make it easier to understand, let's illustrate with an example:
[0086] If messages A, B, and C exist, the transmission period T of message A is... A The sending period T of message B is 100ms. B The transmission period T of message C is 100ms. C The processing time is 120ms, the priority order of each message is A>B>C, and the preset processing period is 20ms.
[0087] At the current time of 100ms, for message A:T d -T lA =100ms=T A For message B:T d -T lB =100ms=T B For message C:T d -T lC =100ms <T C It is evident that at 100ms, both messages A and B meet the periodic transmission condition. Messages A and B can be updated in the message buffer queue, with message A at the head of the queue. Therefore, at 100ms, only message A will be sent. After message A is sent, the previous transmission time of message A needs to be updated to 100ms. At this time, message B still exists in the message buffer queue.
[0088] At 120ms, the message buffer queue contains only message B. Therefore, there is no need to check message B again; it is sufficient to check messages A and C, which are not in the buffer queue. For message A: T d -T lA =20ms <T A For message C:T d -T lC =120ms=T C It is evident that among the packets not in the packet buffer queue at 120ms, only packet C meets the periodic transmission condition. Therefore, packet C is added to the packet buffer queue. Since packet C has a lower priority than packet B, packet B is placed at the head of the packet buffer queue and then sent. At this point, packet C still exists in the packet buffer queue. After packet B is sent, the previous transmission time of packet B needs to be updated to 120ms.
[0089] At 140ms, since only packet C is in the packet buffer queue, there is no need to check packet C again; it is only necessary to check packets A and B that are not in the buffer queue. For packet A: T d -T lA =40ms <TA For message B:T d -T lB =20ms <T B It is evident that none of the packets not in the packet buffer queue at 140ms meet the periodic transmission condition, therefore, there is no need to update the packet buffer queue. Since only packet C exists in the packet buffer queue at this time, packet C is sent. After packet C is sent, the previous transmission time of packet C needs to be updated to 140ms.
[0090] By checking whether there are any packets that meet the periodic sending conditions for each packet that is not in the packet buffer queue at each preset processing period, and updating the packet buffer queue according to its priority order when there are packets that meet the conditions, only the first packet is sent. There is no need to repeat the check for packets in the packet buffer queue, thereby improving the processing speed and efficiency.
[0091] However, when processing a large number of messages, the design may not allow for pre-setting the buffer space. Pre-setting all buffers would require allocating the maximum amount of space based on the number of messages, resulting in a large buffer requirement. Therefore, it is necessary to further conserve buffer space while implementing staggered transmission, such as... Figure 4 As shown, the method includes:
[0092] Step S410: If there are multiple messages that meet the corresponding periodic transmission conditions within the same preset processing period, then every preset processing period, according to the priority of each message, and based on the previous transmission time of each message and the preset transmission period, it is determined whether each message meets its periodic transmission conditions at the current time. When a message that meets the periodic transmission conditions is determined, then the message that meets the conditions is sent.
[0093] The periodic transmission conditions are the same as those in step S210, as described in the relevant description of the periodic transmission conditions in step S210, and will not be repeated here. The previous transmission time is the same as that in step S210, as described in the relevant description of the previous transmission time in step S210, and will not be repeated here.
[0094] In this embodiment, during each preset processing cycle, the system sequentially determines whether a message that meets the cycle sending conditions exists at the current moment based on the priority of each message. Once a message that meets the cycle sending conditions is identified, the system stops further evaluation and directly sends that message. This eliminates the need to evaluate all messages in each preset processing cycle, identify all messages that meet the conditions, and then send only the highest priority message. This further improves processing speed and efficiency, and also saves cache space, as only one message needs to be cached per preset processing cycle.
[0095] Step S420: After each message is sent, the previous message time of the message is updated based on the current message time. In subsequent times, the message is judged based on the preset message period and the updated previous message time to determine whether the message meets the periodic message sending condition, so as to fix and adjust the subsequent message sending times of each message.
[0096] To make it easier to understand, let's illustrate with an example:
[0097] If messages A, B, and C exist, the transmission period T of message A is... A The sending period T of message B is 100ms. B The transmission period T of message C is 100ms. C The processing time is 120ms, the priority order of each message is A>B>C, and the preset processing period is 20ms.
[0098] At the current time of 100ms, since message A has the highest priority, we first determine whether message A meets the periodic transmission condition. For message A: T d -T lA =100ms=T A If the periodic transmission condition is met, then message A is sent. After message A is sent, the previous transmission time of message A needs to be updated to 100ms.
[0099] At the current time of 120ms, since message A has the highest priority, we first determine whether message A meets the periodic transmission condition. For message A: T d -T lA =20ms <T A Then determine whether message B meets the periodic sending condition. For message B: T d -T lB =120ms>T B If the periodic transmission condition is met, then message B is sent. After message B is sent, the previous transmission time of message B needs to be updated to 120ms.
[0100] At the current time of 140ms, since message A has the highest priority, we first determine whether message A meets the periodic transmission condition. For message A: T d -T lA =40ms <T A Then determine whether message B meets the periodic sending condition. For message B: T d -T lB =20ms <T B Finally, it is determined whether message C meets the periodic transmission condition. For message C, : T d -T lC =140ms>T CIf the periodic transmission condition is met, then message C is sent. After message C is sent, the previous transmission time of message C needs to be updated to 140ms.
[0101] By sequentially determining whether a message that meets the periodic sending conditions exists at the current time based on the priority of each message every preset processing cycle, and then directly sending the message once a message that meets the periodic sending conditions is found, the further determination is stopped. This can further improve the processing speed and efficiency, and also save cache space, as only one message needs to be cached per preset processing cycle.
[0102] Figure 2-4 The sending methods described herein are all based on the preset sending period of each message and the current sending time of each transmission, thus fixing and adjusting the subsequent sending times of each message. Furthermore, the subsequent sending times of each message can also be fixed and adjusted based on the preset sending period of each message and the current delay time of each transmission. For example... Figure 5 As shown, the sending methods include:
[0103] Step S510: If there are multiple messages that meet the corresponding periodic transmission conditions within the same preset processing period, then every preset processing period, based on the planned transmission time of each message, determine all messages that meet the periodic transmission conditions at the current time, and only send the first target message within each preset processing period.
[0104] In this embodiment, the planned transmission time is determined based on the cumulative delay time, cumulative transmission count, and preset transmission period of each message.
[0105] For example, the planned sending time is calculated as follows:
[0106] T p =t 总 +(m+1)×T r ; where t 总 T represents the cumulative delay time of the message, m represents the cumulative number of messages sent, and T represents the cumulative delay time of the message. r t is the preset sending period for the message. 总 It is the sum of the historical cumulative delay time and the current delay time.
[0107] The delay time is determined based on the difference between the current transmission time and the planned transmission time.
[0108] The first target message is the highest priority message among all messages that meet the periodic transmission conditions.
[0109] In this embodiment, the periodic transmission condition is that the current time is equal to or later than the planned transmission time.
[0110] Step S520: After each message is sent, update the cumulative delay time of the message based on the current delay time, and update the cumulative number of transmissions, so as to determine whether the message meets the periodic transmission condition based on the updated cumulative delay time and cumulative number of transmissions in subsequent moments, so as to fix and adjust the subsequent transmission time of each message.
[0111] To make it easier to understand, let's illustrate with an example:
[0112] For example, there are three messages A, B, and C, and the preset transmission period T for message A is... A The preset transmission period T for message B is 200ms. B The preset transmission period T for message C is 300ms. C The time limit is 600ms, and the priority order is A>B>C.
[0113] At the current time of 600ms, the cumulative delay time t of message A. A总 The time is 0ms, the cumulative number of times message A has been sent is 2, and the planned time T for sending message A is 0ms. pA The cumulative delay time t for message B is 600ms. B总 The cumulative number of times message B has been sent is 1, and the planned sending time T for message B is 0ms. pB The cumulative delay time t of message C is 600ms. C总 The cumulative number of times message C has been sent is 0ms, and the planned sending time T for message C is 0ms. pC The time is 600ms. It can be seen that at the current time of 600ms, messages A, B, and C all meet the periodic transmission condition. At this time, since message A has the highest priority, only message A is transmitted at 600ms. After message A is transmitted, the cumulative delay time for updating message A is 0ms, the cumulative number of transmissions is 3, and the planned transmission time is 800ms.
[0114] At the current time of 620ms, the planned transmission time for message A is 800ms, and the planned transmission time for message B is T. pB The planned transmission time T for message C is 600ms. pC The current time is later than the planned sending time of messages B and C, so only message B will be sent at 620ms. After message B is sent, the cumulative delay time for updating message B is 20ms, the cumulative number of transmissions is 2, and the planned sending time is 920ms.
[0115] At the current time of 640ms, the planned transmission time for message A is 800ms, and the planned transmission time for message B is T. pB The planned transmission time T for message C is 920ms. pCThe current time is later than the planned transmission time of message C, so only message C will be sent at 640ms. After message C is sent, the cumulative delay time for updating message C is 40ms, the cumulative number of transmissions is 1, and the planned transmission time is 1240ms.
[0116] The planned transmission times for message A are 200ms, 400ms, 600ms, 800ms, 1000ms, and 1200ms, respectively; the planned transmission times for message B are 300ms, 620ms, 920ms, and 1220ms, respectively; and the planned transmission times for message C are 640ms and 1240ms, respectively.
[0117] At 1200ms, message A meets the periodic transmission condition, while messages B and C do not. Since there are no overlapping messages, no transmission conflict will occur. Therefore, by adjusting the planned transmission times of messages B and C at 600ms, the updated cumulative delay time and cumulative transmission count can be used to determine whether a message meets the periodic transmission condition. This allows for the fixed adjustment of the subsequent transmission times of these messages, ensuring that messages A, B, and C will not conflict again within the same preset processing period. The delay times of messages B and C are delayed by 20ms and 40ms respectively compared to their original transmission times, and these delay times are fixed, ensuring that messages A, B, and C can all be transmitted in staggered real-time without causing long delays.
[0118] By determining whether a message meets the periodic transmission condition based on the updated cumulative delay time and cumulative transmission count at subsequent times, messages that would otherwise have transmission conflicts can have their subsequent transmission times changed, thereby achieving automatic misaligned transmission of messages. Only when transmission overlaps for the first time does a partial delay occur, and in subsequent times each message will be reported stably.
[0119] However, in each preset processing cycle, it is necessary to determine all messages that meet the cycle sending conditions at the current moment. This means that in each preset processing cycle, all messages need to be traversed to identify those that meet the cycle sending conditions at the current moment. However, in that preset processing cycle, only the highest priority message is sent, while other messages that meet the conditions are not sent. This leads to a decrease in processing efficiency, resulting in more redundant calculations and reducing processing speed and efficiency. To improve the processor's processing efficiency, such as... Figure 6 As shown, the method includes:
[0120] Step S610: If there are multiple messages that meet the corresponding periodic sending conditions within the same preset processing period, then every preset processing period, for each message that is not located in the message buffer queue, based on the planned sending time of each message, determine all messages that meet the periodic sending conditions at the current time, and update each message that meets the periodic sending conditions within the current preset period to the message buffer queue according to its priority order, and only send the message at the head of the message buffer queue within each preset processing period.
[0121] The periodic transmission conditions are the same as those in step S510, as described in the relevant description of the periodic transmission conditions in step S510, and will not be repeated here. The planned transmission time is the same as the previous transmission time in step S510, as described in the relevant description of the planned transmission time in step S510, and will not be repeated here.
[0122] The message buffer queue stores messages that meet the corresponding periodic sending conditions at the current moment.
[0123] In this embodiment, compared to the processing method of step S510, for packets that are already in the packet buffer queue, there is no need to repeat the judgment at the current moment. It is only necessary to judge whether the packets that are not in the packet buffer queue meet the periodic sending conditions, and update the packet buffer queue based on priority order for the packets that meet the periodic sending conditions. Then, in each preset processing cycle, only the highest priority packets are sent.
[0124] Step S620: After each message is sent, update the cumulative delay time of the message based on the current delay time, and update the cumulative number of transmissions, so as to determine whether the message meets the periodic transmission condition based on the updated cumulative delay time and cumulative number of transmissions in subsequent moments, so as to fix and adjust the subsequent transmission time of each message.
[0125] To make it easier to understand, let's illustrate with an example:
[0126] If messages A, B, and C exist, the transmission period T of message A is... A The sending period T of message B is 100ms. B The transmission period T of message C is 100ms. C The processing time is 120ms, the priority order of each message is A>B>C, and the preset processing period is 20ms.
[0127] At the current time of 100ms, message A has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 100ms. Message B has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 100ms. Message C has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 120ms. At 100ms, only messages A and B meet the periodic transmission condition, while message C does not. Messages A and B can be updated in the message buffer queue, and message A is at the head of the message buffer queue. Therefore, at 100ms, only message A will be sent. After message A is sent, its cumulative delay is 0ms, its cumulative transmission count is 1, and its planned transmission time is 200ms. At this time, message B is still in the message buffer queue.
[0128] At 120ms, the message buffer queue contains only message B. Therefore, there's no need to check message B again; it's sufficient to check messages A and C, which are not in the buffer queue. Message C's planned transmission time is 120ms, and message A's is 200ms. It's clear that at 120ms, only message C meets the periodic transmission condition among the messages not in the buffer queue. Therefore, message C is added to the buffer queue. Since message C has a lower priority than message B, message B is placed at the head of the buffer queue and sent. At this point, message C still exists in the buffer queue. After message B is sent, its cumulative transmission count needs to be updated to 1, and its cumulative delay time needs to be updated to 20ms, making its planned transmission time 220ms. At this point, the buffer queue contains only message C.
[0129] At 140ms, since the message buffer queue only contains message C, there's no need to check message C again; it's sufficient to check messages A and B that aren't in the buffer queue. Message A's planned transmission time is 200ms, and message B's is 220ms. Therefore, at 140ms, none of the messages not in the message buffer queue meet the periodic transmission condition, so there's no need to update the message buffer queue. Since the buffer queue only contains message C at this time, message C is sent. After message C is sent, the cumulative transmission count for message C needs to be updated to 1, the cumulative delay time to 20ms, and the planned transmission time to 260ms.
[0130] By checking whether there are any packets that meet the periodic sending conditions for each packet that is not in the packet buffer queue at each preset processing period, and updating the packet buffer queue according to its priority order when there are packets that meet the conditions, only the first packet is sent. There is no need to repeat the check for packets in the packet buffer queue, thereby improving the processing speed and efficiency.
[0131] However, when processing a large number of messages, the design may not allow for pre-setting the buffer space. Pre-setting all buffers would require allocating the maximum amount of space based on the number of messages, resulting in a large buffer requirement. Therefore, it is necessary to further conserve buffer space while implementing staggered transmission, such as... Figure 7 As shown, the method includes:
[0132] Step S710: If there are multiple messages that meet the corresponding periodic transmission conditions within the same preset processing period, then every preset processing period, according to the priority of each message, and based on the planned transmission time of each message, it is determined whether each message meets its periodic transmission conditions at the current time. When a message that meets the periodic transmission conditions is determined, the message that meets the conditions is sent.
[0133] The periodic transmission conditions are the same as those in step S510, as described in the relevant description of the periodic transmission conditions in step S510, and will not be repeated here. The planned transmission time is the same as the previous transmission time in step S510, as described in the relevant description of the planned transmission time in step S510, and will not be repeated here.
[0134] In this embodiment, during each preset processing cycle, the system sequentially determines whether a message that meets the cycle sending conditions exists at the current moment based on the priority of each message. Once a message that meets the cycle sending conditions is identified, the system stops further evaluation and directly sends that message. This eliminates the need to evaluate all messages in each preset processing cycle, identify all messages that meet the conditions, and then send only the highest priority message. This further improves processing speed and efficiency, and also saves cache space, as only one message needs to be cached per preset processing cycle.
[0135] Step S720: After each message is sent, update the cumulative delay time of the message based on the current delay time, and update the cumulative number of transmissions, so as to determine whether the message meets the periodic transmission condition based on the updated cumulative delay time and cumulative number of transmissions in subsequent moments, so as to fix and adjust the subsequent transmission time of each message.
[0136] To make it easier to understand, let's illustrate with an example:
[0137] If messages A, B, and C exist, the transmission period T of message A is... A The sending period T of message B is 100ms. B The transmission period T of message C is 100ms. C The processing time is 120ms, the priority order of each message is A>B>C, and the preset processing period is 20ms.
[0138] At the current time of 100ms, message A has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 100ms. Message B has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 100ms. Message C has a cumulative delay of 0ms, a cumulative transmission count of 0, and a planned transmission time of 120ms. At 100ms, since message A has the highest priority, it is first determined whether message A meets the periodic transmission condition. The planned transmission time of message A, 100ms, equals the current time, thus meeting the periodic transmission condition, and message A is transmitted. After message A is transmitted, its cumulative delay time is set to 0ms, its cumulative transmission count to 1, and its planned transmission time to 200ms.
[0139] At the current time of 120ms, since message A has the highest priority, it is first checked whether message A meets the periodic transmission condition. Message A's planned transmission time is 200ms, so it does not meet the condition. Then, it is checked whether message B meets the periodic transmission condition. Message B's planned transmission time is 100ms, so it meets the periodic transmission condition and is sent. After message B is sent, the cumulative transmission count of message B needs to be updated to 1, and the cumulative delay time needs to be updated to 20ms, so its planned transmission time is 220ms.
[0140] At the current time of 140ms, since message A has the highest priority, we first check if message A meets the periodic transmission condition. Message A's planned transmission time is 200ms, so it does not meet the condition. Then, we check if message B meets the periodic transmission condition. Message B's planned transmission time is 220ms, so it does not meet the condition. Finally, we check if message C meets the periodic transmission condition. Message C's planned transmission time is 140ms, so it meets the condition and is sent. After message C is sent, we need to update the cumulative transmission count of message C to 1, the cumulative delay time to 20ms, and the planned transmission time to 260ms.
[0141] By sequentially determining whether a message that meets the periodic sending conditions exists at the current time based on the priority of each message every preset processing cycle, and then directly sending the message once a message that meets the periodic sending conditions is found, the further determination is stopped. This can further improve the processing speed and efficiency, and also save cache space, as only one message needs to be cached per preset processing cycle.
[0142] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0143] Based on the periodic message sending method provided in the above embodiments, the present invention also provides a specific implementation of a periodic message sending apparatus applied to the periodic message sending method. Please refer to the following embodiments.
[0144] like Figure 8 As shown, a periodic message sending device 800 is provided, applied to a processor at a message sending end; the sending device includes:
[0145] The sending module 810 is used to send each message in a delayed and staggered manner based on the priority of each message if there are multiple messages that meet the corresponding periodic sending conditions within the same preset processing period.
[0146] The update module 820 is used to adjust the periodic transmission conditions of each message based on the preset transmission period of each message and the time information of each transmission, so as to fix the subsequent transmission time of each message; wherein, the time information includes the current delay time or the current transmission time.
[0147] In one possible implementation, the sending module 810 is used to determine, in turn, whether each message meets its periodic sending condition at the current time based on the priority of each message and the previous sending time of each message and the preset sending period, according to the priority of each message. When a message that meets the periodic sending condition is determined, the message that meets the condition is sent. The previous sending time is the historical sending time of the corresponding message that is closest to the current time.
[0148] In one possible implementation, the sending module 810 is used to determine, at each preset processing cycle, all messages that meet the periodic sending conditions at the current time based on the previous sending time of each message and the preset sending cycle, and to send only the first target message within each preset processing cycle; wherein, the previous sending time is the historical sending time of the corresponding message that is closest to the current time, and the first target message is the message with the highest priority among all messages that meet the periodic sending conditions.
[0149] In one possible implementation, the sending module 810 is configured to, every preset processing period, for each message not located in the message buffer queue, determine all messages that meet the periodic sending conditions at the current time based on the previous sending time of each message and the preset sending period, and update the message buffer queue according to the priority order of each message that meets the periodic sending conditions within the current preset processing period, and only send the message at the head of the message buffer queue within each preset processing period; wherein, the previous sending time is the historical sending time of the corresponding message that is closest to the current time.
[0150] In one possible implementation, the periodic transmission condition is:
[0151] The difference between the current time and the previous time of the corresponding message is greater than or equal to the preset transmission period of the message;
[0152] The time information refers to the moment this message was sent.
[0153] The update module 820 is used to update the previous transmission time of the message based on the current transmission time after each message is sent, so as to determine whether the message meets the periodic transmission condition based on the preset transmission period of the message and the updated previous transmission time in subsequent times.
[0154] In one possible implementation, the sending module 810 is used to determine, in turn, whether each message meets its periodic sending condition at the current time according to the priority of each message and based on the planned sending time of each message at every preset processing cycle. When a message that meets the periodic sending condition is determined, the message that meets the condition is sent. The planned sending time is determined based on the cumulative delay time, cumulative number of transmissions and preset sending cycle of each message.
[0155] In one possible implementation, the sending module 810 is used to determine, at each preset processing cycle, all messages that meet the periodic sending conditions at the current time based on the planned sending time of each message, and to send only the first target message within each preset processing cycle; wherein, the planned sending time is determined based on the cumulative delay time, cumulative number of sending times and preset sending cycle of each message, and the first target message is the message with the highest priority among all messages that meet the periodic sending conditions.
[0156] In one possible implementation, the sending module 810 is configured to, every preset processing cycle, determine all messages that meet the periodic sending conditions at the current time based on the planned sending time of each message, for each message not located in the message buffer queue, and update each message that meets the periodic sending conditions in the current preset cycle to the message buffer queue according to its priority order, and only send the message at the head of the message buffer queue in each preset processing cycle; wherein, the planned sending time is determined based on the cumulative delay time, cumulative number of transmissions and the preset sending cycle of each message.
[0157] In one possible implementation, the periodic transmission condition is that the current time is equal to or later than the planned transmission time;
[0158] The planned transmission time is calculated as follows:
[0159] T p =t 总 +(m+1)×T r ; where t 总 T represents the cumulative delay time of the message, m represents the cumulative number of messages sent, and T represents the cumulative delay time of the message. r This is the preset sending period for the message;
[0160] The time information is the current delay time, which is determined based on the difference between the current transmission time and the planned transmission time.
[0161] The update module 820 is used to update the cumulative delay time of the message based on the current delay time after each message is sent, and to update the cumulative number of transmissions, so as to determine whether the message meets the periodic transmission condition based on the updated cumulative delay time and cumulative number of transmissions at subsequent times.
[0162] Figure 9 This is a schematic diagram of the electrical equipment provided in an embodiment of the present invention. Figure 9 As shown, the electrical device 9 in this embodiment includes: a processor 90, a memory 91, and a computer program 92 stored in the memory 91 and executable on the processor 90. When the processor 90 executes the computer program 92, it implements the steps in the various CAN message transmission method embodiments described above, for example... Figures 1 to 7 The steps shown. Alternatively, when the processor 90 executes the computer program 92, it implements the functions of each module in the above-described device embodiments, for example... Figure 8 The functions of modules 810 to 820 are shown.
[0163] For example, the computer program 92 can be divided into one or more modules, which are stored in the memory 91 and executed by the processor 90 to complete the present invention. The one or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 92 in the electrical device 9. For example, the computer program 92 can be divided into... Figure 2 Modules 810 to 820 are shown.
[0164] The electrical device 9 may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art will understand that... Figure 9 This is merely an example of electrical device 9 and does not constitute a limitation on electrical device 9. It may include more or fewer components than shown, or combine certain components, or different components. For example, the electrical device may also include input / output devices, network access devices, buses, etc.
[0165] The processor 90 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0166] The memory 91 can be an internal storage unit of the electrical device 9, such as a hard disk or memory of the electrical device 9. The memory 91 can also be an external storage device of the electrical device 9, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electrical device 9. Furthermore, the memory 91 can include both internal storage units and external storage devices of the electrical device 9. The memory 91 is used to store the computer program and other programs and data required by the electrical device. The memory 91 can also be used to temporarily store data that has been output or will be output.
[0167] Figure 10 The electrical system 10 provided by the present invention includes at least one electrical device 9 and a monitoring device for monitoring the operating status of the electrical device 9; each electrical device 9 sends a periodic message to the monitoring device using any one of the periodic message sending methods.
[0168] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0169] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0170] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0171] In the embodiments provided by this invention, it should be understood that the disclosed devices / electrical equipment and methods can be implemented in other ways. For example, the device / electrical equipment embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0172] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0173] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0174] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above-described CAN message transmission method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0175] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for sending a periodical packet, applied to a processor of a packet sender, and characterized in that, The sending method comprises: If there are multiple messages meeting the corresponding periodic sending condition in the same preset processing period, every preset processing period, the priority of each message is sequentially followed, and whether each message meets the periodic sending condition at the current time is judged based on the previous sending time of each message and the preset sending period, when it is judged that the message meets the periodic sending condition, the message meeting the condition is sent; wherein the previous sending time is the nearest historical sending time of the corresponding message from the current time; The periodic sending condition of each message is adjusted based on the preset sending period of each message and the time information of each sending, so as to fix the subsequent sending time of each message after adjustment; wherein the time information comprises the current delay time or the current sending time.
2. The transmission method of claim 1, wherein, The sending of each message based on the priority of each message sequentially delaying and staggering comprises: Every preset processing period, all messages meeting the periodic sending condition at the current time are determined based on the previous sending time of each message and the preset sending period, and only the first target message is sent in each preset processing period; wherein the previous sending time is the nearest historical sending time of the corresponding message from the current time, and the first target message is the message with the highest priority among all messages meeting the periodic sending condition.
3. The transmission method of claim 1, wherein The sending of each message based on the priority of each message sequentially delaying and staggering comprises: Every preset processing period, for each message not in the message cache queue, all messages meeting the periodic sending condition at the current time are determined based on the previous sending time of each message and the preset sending period, and the message cache queue is updated according to the priority order of each message meeting the periodic sending condition in the current preset processing period, and only the message at the head of the message cache queue is sent in each preset processing period; wherein the previous sending time is the nearest historical sending time of the corresponding message from the current time.
4. The transmission method according to any one of claims 2-3, characterized by, The periodic sending condition is: The difference between the current time and the previous sending time of the corresponding message is greater than or equal to the preset sending period of the message; The time information is the current sending time; The adjustment of the periodic sending condition of each message based on the preset sending period of each message and the time information of each sending comprises: After sending each message, the previous sending time of the message is updated based on the current sending time, so that whether the message meets the periodic sending condition is judged based on the preset sending period of the message and the updated previous sending time at the subsequent time.
5. The transmission method of claim 1, wherein The sending of each message based on the priority of each message sequentially delaying and staggering comprises: Every preset processing period, the priority of each message is sequentially followed, and whether each message meets the periodic sending condition at the current time is judged based on the planned sending time of each message, when it is judged that the message meets the periodic sending condition, the message meeting the condition is sent; wherein the planned sending time is determined according to the cumulative delay time, the cumulative sending times and the preset sending period of each message.
6. The transmission method of claim 1, wherein The sending of each message based on the priority of each message sequentially delaying and staggering comprises: Every preset processing period, based on the planned sending time of each message, determine all messages that meet the periodic sending condition at the current time, and only send the first target message in each preset processing period; wherein, the planned sending time is determined according to the cumulative delay time, cumulative sending times and preset sending period of each message, and the first target message is the message with the highest priority among all messages that meet the periodic sending condition.
7. The transmission method of claim 1, wherein The sending of each message in turn based on the priority of each message, including: Every preset processing period, for each message not located in the message cache queue, based on the planned sending time of each message, determine all messages that meet the periodic sending condition at the current time, and update each message that meets the periodic sending condition in the preset period to the message cache queue according to its priority order, and only send the message located at the head in the message cache queue in each preset processing period; wherein, the planned sending time is determined according to the cumulative delay time, cumulative sending times and preset sending period of each message.
8. The transmission method according to any one of claims 5 to 7, characterized in that, The periodic sending condition is that the current time is equal to or later than the planned sending time; The calculation method of the planned sending time is: ; wherein t 总 is the accumulated delay time of the packet, m is the accumulated sending times of the packet, T r is the preset sending period of the packet; The time information is the current delay time, which is determined based on the difference between the current sending time and the planned sending time; The adjustment of the periodic sending condition of each message based on the preset sending period of each message and the time information of each sending, including: After sending each message, update the cumulative delay time of the message based on the current delay time, and update the cumulative sending times, so as to judge whether the message meets the periodic sending condition based on the updated cumulative delay time and cumulative sending times at the subsequent time.
9. An electrical system comprising at least one electrical device and a monitoring device for monitoring the operating state of the electrical device; characterized in that, Each of the electrical equipment sends periodic messages to the monitoring device by using the method of any one of claims 1-8.
Citation Information
Patent Citations
Communication system and communication device
CN107005449A
CAN message sending method and device, storage medium and electronic equipment
CN111106987A