Message sending method and device, electronic equipment and storage medium

CN117221037BActive Publication Date: 2026-08-21GUANGZHOU AUTOMOBILE GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311001418.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-09
Publication Date
2026-08-21
Estimated Expiration
2043-08-09

AI Technical Summary

Technical Problem

[0003]在多个节点同时发送数据报文时,仲裁机制保证了高优先级的数据优先传输,会导致低优先级报文实时性得不到保证,对于周期型报文,一旦形成竞争现象,则竞争现象会持续周期性的出现,对网络和报文实时性影响较大

Benefits of technology

[0014]本申请实施例提供的报文发送方法、装置、电子设备及存储介质,在目标节点的当前报文对应有仲裁信息时,通过仲裁信息确定当前报文的仲裁周期,通过当前报文的仲裁周期确定下一报文的目标发送周期,从而以目标发送周期发送下一报文;通过采用本申请提供的报文发送方法,根据当前报文的仲裁周期动态调整下一报文的目标发送周期,对于原本会出现的且与当前报文具有相同仲裁周期的周期性报文,由于下一报文的发送周期的改变,使周期性报文的实际发送时间也发生改变,即周期性报文的实际发送时间可以跳过其仲裁周期,从而减少周期性报文的仲裁次数甚至避免周期性报文的仲裁,进而降低总线竞争发生的频率,有效避免周期性报文因为频繁的总线竞争导致周期延迟,提高报文的实时性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117221037B_ABST
    Figure CN117221037B_ABST
Patent Text Reader

Abstract

The application provides a message sending method and device, electronic equipment and storage medium. The method comprises the following steps: when the current message of a target node corresponds to arbitration information, determining the arbitration period of the current message through the arbitration information, determining the target sending period of the next message through the arbitration period of the current message, and sending the next message in the target sending period. By using the message sending method provided by the application, the target sending period of the next message is dynamically adjusted according to the arbitration period of the current message. Due to the change of the sending period of the next message, the periodic message originally having the same arbitration period as the current message can skip its arbitration period, thereby reducing the arbitration times of the periodic message or even avoiding the arbitration of the periodic message, further reducing the frequency of bus competition, effectively avoiding the periodic delay of the periodic message caused by frequent bus competition, and improving the real-time performance of the message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of bus communication, specifically to message transmission methods, apparatus, electronic devices, and storage media. Background Technology

[0002] A bus is a common communication trunk line for transmitting information between various functional components of a computer. It is a transmission line bundle composed of wires. A contentionable bus allows any node on the bus to have the opportunity to gain control of the bus and send data. If two or more nodes request to send data at the same time, a bus conflict will occur. The bus can detect these conflicts in real time and arbitrate them, so that high-priority data is transmitted without any damage, while low-priority data is arbitrated and waits for the bus to become idle before being sent.

[0003] When multiple nodes send data packets simultaneously, the arbitration mechanism ensures that high-priority data is transmitted first, which may lead to the inability to guarantee the real-time performance of low-priority packets. For periodic packets, once a contention occurs, the contention will continue to occur periodically, which has a significant impact on the network and packet real-time performance. Summary of the Invention

[0004] In view of the above problems, this application provides a message transmission method, apparatus, electronic device and storage medium, which can dynamically adjust the transmission cycle of the next message according to the arbitration information of the current message, reduce the frequency of bus contention and improve the real-time performance of the message.

[0005] The embodiments of this application are implemented using the following technical solutions:

[0006] In a first aspect, this application provides a message transmission method applied to a target node connected to a bus. The method includes: if the target node is currently transmitting a message that corresponds to arbitration information, obtaining the arbitration information of the current message on the target node, wherein the arbitration information is generated when the target node conflicts with messages transmitted by other nodes connected to the bus; obtaining the arbitration period of the current message based on the arbitration information of the current message on the target node, wherein the arbitration period is used to characterize the delay time of the current message on the target node due to arbitration; obtaining the target transmission period of the next message based on the arbitration period; and transmitting the next message to the bus based on the target transmission period.

[0007] Secondly, this application provides a message sending apparatus, comprising: an acquisition module, configured to acquire arbitration information of the current message on the target node if the current message currently sent by the target node corresponds to arbitration information, wherein the arbitration information is generated when a message sent by the target node conflicts with a message sent by another node connected to the bus; an arbitration period calculation module, configured to obtain an arbitration period of the current message based on the arbitration information of the current message on the target node, wherein the arbitration period is used to characterize the delay time of the current message on the target node due to arbitration; a target sending period calculation module, configured to obtain a target sending period of the next message of the current message based on the arbitration period; and a sending module, configured to send the next message to the bus based on the target sending period.

[0008] In some implementations, the arbitration cycle calculation module includes a data acquisition unit and a calculation unit. The data acquisition unit is used to obtain the number of arbitration failures from the arbitration information of the current message on the target node. The calculation unit is used to obtain the arbitration cycle of the current message based on the time of the first arbitration failure and the time of arbitration success in the arbitration information of the current message if the number of arbitration failures is less than the preset number of arbitration failures. At this time, the target transmission cycle calculation module is also used to obtain the target transmission cycle of the next message of the current message based on the arbitration cycle and the preset message transmission cycle corresponding to the current message.

[0009] In other implementations, the calculation unit is also used to cancel the transmission of the current message if the number of arbitration failures exceeds the preset number of arbitrations, and to use the preset recovery time as the arbitration period of the current message. The preset recovery time is the waiting time for the target node to resume transmission after canceling the transmission of the current message. At this time, the target transmission period calculation module is also used to use the arbitration period as the target transmission period of the next message of the current message.

[0010] In some embodiments, the message sending device further includes a sending time confirmation module; the sending time confirmation module is used to obtain the initial message sending time of each node on the bus, which is determined by the bus based on a specified time, a preset forwarding duration, and the priority information of messages on each node; the specified time is a pre-set time to prepare to send the first message to the bus, and the preset forwarding duration is the interval between two consecutive forwarding of messages by the bus; at this time, the sending module is also used to determine that the first message in the target node is the current message, and send the current message to the bus at the initial message sending time corresponding to the target node.

[0011] In some implementations, the sending module is also used to send the next message of the current message to the bus based on the preset message sending period corresponding to the current message if the current message sent by the target node does not have corresponding arbitration information.

[0012] Thirdly, this application provides an electronic device including one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to perform the methods described above.

[0013] Fourthly, this application provides a computer-readable storage medium storing program code that can be invoked by a processor to execute the above-described method.

[0014] The message sending method, apparatus, electronic device, and storage medium provided in this application, when the current message of the target node corresponds to arbitration information, determine the arbitration period of the current message through the arbitration information, determine the target sending period of the next message through the arbitration period of the current message, and send the next message with the target sending period. By adopting the message sending method provided in this application, the target sending period of the next message is dynamically adjusted according to the arbitration period of the current message. For periodic messages that would normally appear and have the same arbitration period as the current message, the actual sending time of the periodic message also changes due to the change in the sending period of the next message. That is, the actual sending time of the periodic message can skip its arbitration period, thereby reducing the number of arbitrations of periodic messages or even avoiding the arbitration of periodic messages, thereby reducing the frequency of bus contention, effectively avoiding periodic message delays caused by frequent bus contention, and improving the real-time performance of messages.

[0015] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a schematic diagram illustrating the principle of bus transmission.

[0018] Figure 2 This is a flowchart illustrating the message sending method provided in the embodiments of this application.

[0019] Figure 3 This is provided in the embodiments of this application. Figure 2 A flowchart of step S120.

[0020] Figure 4 This is a schematic diagram of the target node in the embodiments of this application.

[0021] Figure 5 This is another flowchart illustrating the message sending method provided in the embodiments of this application.

[0022] Figure 6 This is a schematic diagram of message transmission provided in an embodiment of this application.

[0023] Figure 7 This is a schematic diagram of the message sending device provided in the embodiments of this application.

[0024] Figure 8 This is a schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0025] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0027] Bus transmission, as a commonly used data transmission method, operates on the following principle: Figure 1 As shown, the bus includes a bus 10 and multiple nodes 20. All nodes 20 can send data to the bus 10. If two or more nodes 20 request to send data at the same time, a bus conflict will occur. The bus 10 can detect these conflicts in real time and arbitrate them, so that high-priority data can be transmitted without any damage, while low-priority data is arbitrated and waits for the bus 10 to be idle before being sent.

[0028] In some embodiments, such as Figure 2 , Figure 2 A flowchart illustrating a message transmission method provided in this application is given. This message transmission method is applied to a target node connected to a bus, and the method includes:

[0029] S110. If the current message sent by the target node corresponds to arbitration information, obtain the arbitration information of the current message on the target node.

[0030] Arbitration information is generated when a message sent by the target node conflicts with a message sent by another node connected to the bus.

[0031] In this context, the target node represents a communication endpoint or terminal device. Nodes in a bus system typically include control units and bus auxiliary devices. A control unit consists of a controller, a transceiver, and two data transmission terminals. Compared to the ECU (Electronic Control Unit) of a traditional automotive microcomputer control system, the control unit has a dedicated bus interface device (such as a CAN bus interface) in its hardware and corresponding software support for communication standards.

[0032] A message is a data unit exchanged and transmitted in a network, that is, a data block that a station (or node) sends at one time. A message contains complete data information to be sent, and its length varies greatly, being unlimited and variable. In this embodiment, the current message is the message being sent.

[0033] Arbitration (or bus arbitration) refers to the process of selecting a master device to gain priority in obtaining bus control when multiple master devices compete for control of the main line simultaneously; arbitration can be implemented through a bus arbitrator deployed on the bus.

[0034] Furthermore, the arbitration information may include one or more of the following: the number of arbitrations, arbitration status, arbitration time, etc. of the current message. The arbitration status may include arbitration success or arbitration failure. Furthermore, the arbitration information of the current message may be only the arbitration information generated by the current message in the last arbitration, or it may be a collection of the arbitration information generated by the current message in each arbitration.

[0035] In this embodiment of the application, the target node is each node on the bus, and each target node periodically sends messages to the bus according to the corresponding preset message sending period.

[0036] Furthermore, a target node can send one type of message or multiple types of messages; when a target node sends multiple messages, the multiple messages are sent one by one, that is, a target node will only send one type of message to the bus at a time.

[0037] It should be noted that when a target node sends multiple messages, the multiple messages can be sent according to the same preset message sending period, or a separate preset message sending period can be set for each type of message.

[0038] It should be noted that when the current message arbitration fails, the target node will continue to send the current message to the bus for multiple arbitrations under preset conditions. The preset conditions can be to send continuously within a preset time range or to send continuously within a preset number of arbitrations.

[0039] S120. Based on the arbitration information of the current message on the target node, obtain the arbitration period of the current message.

[0040] The arbitration period is used to characterize the delay time of the current message on the target node due to arbitration.

[0041] In some embodiments, if the current message is successfully sent after arbitration, the arbitration period can be the time difference between the actual sending time and the expected sending time of the current message; if the current message still fails to be sent after arbitration, the arbitration period can be the time difference between the sending failure time and the expected sending time of the current message, or it can be the recovery waiting time for restarting message sending preset by the target node.

[0042] In some embodiments, such as Figure 3 , Figure 3 The embodiments provided in this application are given Figure 2 A flowchart of step S120 is shown. Step S120 specifically includes:

[0043] S121. Obtain the number of arbitration failures from the arbitration information of the current message on the target node.

[0044] The number of arbitration failures in the arbitration information can be obtained by deploying a counter on the target node. The counter can be a synchronous counter or an asynchronous counter, and no specific restrictions are made here.

[0045] S122. If the number of arbitration failures is less than the preset number of arbitrations, the arbitration cycle of the current message is obtained based on the time of the first arbitration failure and the time of the arbitration success in the arbitration information of the current message.

[0046] Specifically, in this embodiment of the application, the arbitration period of the current message is obtained by subtracting the time of the first arbitration failure from the time of successful arbitration.

[0047] It is understandable that when obtaining the number of arbitration failures of the current message on the target node from the arbitration information, it is also necessary to obtain the time of the first arbitration failure and the time of arbitration success of the current message; in this embodiment of the application, the time of the first arbitration failure of the message is stored in the message first arbitration failure time register, and the time of arbitration success of the message is stored in the message arbitration success time register.

[0048] Considering that the number of arbitrations before a message succeeds can characterize the quality of the bus layout to some extent—that is, the fewer the number of arbitrations before a message succeeds, the shorter the message delay and the better the bus layout—this embodiment of the application also presets an arbitration warning count. When the number of arbitration warnings is less than the preset number of arbitrations, and the number of arbitration failures for the current message is greater than the number of arbitration warnings but less than the preset number of arbitrations, an arbitration failure warning is generated and recorded. The arbitration failure warning includes arbitration time information, so as to determine whether the bus layout needs optimization based on the recorded arbitration failure warnings. For example, the bus layout may need optimization when the frequency of arbitration failure warnings exceeds a preset threshold; or the bus layout may need optimization when the ratio of the frequency of arbitration failure warnings to the preset message transmission period of the current message exceeds a preset threshold. The specific judgment method can be set according to actual needs.

[0049] S123. If the number of arbitration failures exceeds the preset number of arbitrations, cancel the transmission of the current message and use the preset recovery time as the arbitration period for the current message.

[0050] The preset recovery time is the waiting time for the target node to resume sending the current message after canceling it.

[0051] It should be noted that the preset recovery time for each target node can be uniform or set separately for each target node. Furthermore, when the same target node needs to send multiple messages, the preset recovery time for each type of message on that target node can be uniform or set separately for each type of message; no specific restrictions are imposed here.

[0052] In order to further optimize the bus layout, in this embodiment of the application, after canceling the transmission of the current message, a transmission result of the current message will also be generated. The transmission result is an arbitration failure error and includes time information.

[0053] S130. Based on the arbitration period, obtain the target transmission period for the next message of the current message.

[0054] It should be noted that the next message of the current message refers to the next message on the target node where the current message is located.

[0055] Furthermore, when the same target node contains multiple types of messages, the next message of the current message refers to the next message on the target node that belongs to the same type of message as the current message. For example, if the message sending order of the target node is a1-b1-b2-a2, where a1 and a2 belong to type A messages and b1 and b2 belong to type B messages, then when a1 is the current message, the next message of the current message is a2.

[0056] In some implementations, under the conditions of step S122, step S130 specifically includes:

[0057] S131. Based on the arbitration period and the preset message sending period corresponding to the current message, obtain the target sending period of the next message of the current message.

[0058] The preset message sending period refers to the expected time interval between consecutive messages that the target node sets in advance when continuously sending messages.

[0059] Specifically, in this embodiment of the application, the arbitration period is added to the preset message sending period corresponding to the current message to obtain the target sending period of the next message of the current message.

[0060] It should be noted that in the prior art, since messages are sent periodically, after the current message undergoes arbitration, due to the periodicity of the messages, a periodic message will inevitably appear with the same arbitration status as the current message. That is, the arbitration period of the periodic message is the same as that of the current message. However, by using the method of this embodiment, the arbitration period is accumulated with the preset message sending period corresponding to the current message to obtain the target sending period of the next message. Since the target sending period of the next message adds an arbitration period compared to the preset message period, the sending time of the periodic message also increases by at least one arbitration period. In other words, the periodic message can skip its arbitration period, thereby reducing the number of arbitrations for the periodic message or even avoiding arbitration altogether. This reduces the frequency of bus contention, effectively avoids message period delays caused by frequent bus contention, and improves the real-time performance of the messages.

[0061] In some implementations, under the conditions of step S123, step S130 specifically includes:

[0062] S132. Set the arbitration period as the target sending period for the next message of the current message.

[0063] It should be noted that since the current message has been cancelled, the time delay in arbitration is not relevant to periodic messages. Therefore, by setting the preset recovery time to the arbitration period and directly using the arbitration period as the target sending period for the next message of the current message, the sending time of periodic messages can be adjusted, thereby reducing the number of arbitrations for periodic messages or even avoiding arbitration altogether. This reduces the frequency of bus contention, effectively preventing message delays caused by frequent bus contention and improving message real-time performance.

[0064] Furthermore, the preset recovery time can be pre-set under the condition of artificially simulating a sending failure.

[0065] S140: Send the next message to the bus based on the target transmission cycle.

[0066] It should be noted that when the current message is successfully sent after arbitration, the next message is sent to the bus based on the target sending cycle. That is, the timer starts from the moment the current message is successfully arbitrated (that is, the actual sending time). After waiting for one target sending cycle, the target node sends the next message of the current message to the bus.

[0067] When the current message is canceled after arbitration, the next message is sent to the bus based on the target transmission cycle. That is, the timer starts from the moment when the current message fails the last arbitration. After waiting for one target transmission cycle, the target node sends the next message of the current message to the bus.

[0068] The message sending method provided in this application determines the arbitration period of the current message when there is arbitration information corresponding to the current message of the target node, and determines the target sending period of the next message through the arbitration information. The next message is then sent according to the target sending period. By adopting the message sending method provided in this application, the target sending period of the next message is dynamically adjusted according to the arbitration period of the current message, delaying the sending period of the next message by one arbitration period. For periodic messages that originally had the same arbitration period as the current message, the actual sending time of the periodic message also changes due to the change in the sending period of the next message. That is, the actual sending time of the periodic message can skip its arbitration period, thereby reducing the number of arbitrations for periodic messages or even avoiding arbitration altogether. This reduces the frequency of bus contention, effectively preventing message delays caused by frequent bus contention and improving message real-time performance.

[0069] It should be noted that in some embodiments, when the same target node sends multiple messages, due to the change in the target sending period of the next message, multiple messages that were originally sent at intervals on the same target node may need to be sent simultaneously. In this case, a buffer can be set on the target node to buffer the messages that need to be sent simultaneously, and then the sending order can be determined according to the specific information of each message.

[0070] To facilitate understanding of this solution, as follows: Figure 4 , Figure 4 A schematic diagram of the target node structure in the embodiments of this application is provided. In the embodiments of this application, each target node includes a readback unit, a calculation unit, a configuration unit, and a sending unit.

[0071] The readback unit is used by the target node to read the current message it sends to the bus, obtain the arbitration information of the current message, including the arbitration status and transmission status of the current message, and record the arbitration time and transmission time; the calculation unit is used to calculate the target transmission period for the next message to be sent; the configuration unit is used to encapsulate the next message to be transmitted according to a specific message encapsulation format (encapsulation is to add the header information corresponding to each layer of the network reference model, the main function of which is to help the intermediate transmission system transmit the message to the correct destination); the sending unit is used to send the encapsulated next message.

[0072] Specifically, in this embodiment, the readback unit and the arithmetic unit are provided with the following counters and registers: a message arbitration failure counter, used to record the number of arbitration failures when the current message is sent; a message first arbitration failure time register, used to store the time of the first arbitration failure when the current message is sent; a message arbitration success time register, used to store the time of successful arbitration when the current message is sent; a message arbitration failure warning and error register, used to store the current message arbitration failure warning and message failure arbitration error, the recording format being arbitration status and time, the arbitration status including arbitration failure warning and arbitration failure error; and a next message sending time register, used to store the target sending period for the next message.

[0073] In other embodiments, to avoid flooding (a data flow transmission technique used by switches and bridges that sends data received from a certain interface to all other interfaces) of all target nodes after initialization, which would lead to prolonged bus contention, such as... Figure 5 , Figure 5 Another flowchart of the message sending method provided in the embodiments of this application is given, the method including:

[0074] S210. Obtain the initial message transmission time of each node on the bus, which is determined based on the specified time, preset forwarding duration, and priority information of messages on each node.

[0075] The specified time is the pre-set time when the first message is prepared to be sent to the bus, and the preset forwarding time is the interval between two consecutive forwarding of messages by the bus.

[0076] It is understandable that the time interval between two consecutively transmitted messages on the bus must be a multiple of the preset forwarding duration. The preset forwarding duration determines that there will be no arbitration situation between two consecutively transmitted messages on the bus.

[0077] In some implementations, the specified time can be obtained based on the initialization time of all nodes on the bus, that is, the time when all nodes complete initialization is determined as the specified time; wherein, initialization is a transitional state after the slave node is powered on, reset, or wakes up from sleep. During the initialization process, the node prepares for communication, and at this time, the node cannot send or receive messages.

[0078] In some implementations, the priority information of messages on each node can be determined by the message name or by the message identifier.

[0079] In some implementations, when a target node needs to send multiple messages, the node's initial message sending time includes the initial sending time corresponding to each type of message.

[0080] To facilitate understanding of this scheme, the following transmission timing table will be used as an example:

[0081]

[0082] The initialization time for each node on the bus is specified as 200ms, meaning the specified time is 200ms, which is the initial time of 0ms. The first message sent by each node must be greater than +200ms.

[0083] The default forwarding time of the bus is 0.5ms, so the time interval between two consecutive messages sent by each node to the bus is an integer multiple of 0.5ms.

[0084] The priority information of messages on each node is also known as message identifier information. Specifically, the smaller the message identifier, the higher the priority of the corresponding message.

[0085] Therefore, when determining the initial message transmission time of the above messages, for message MSG_A_01, its corresponding message identifier is the smallest and its priority is the highest. The initial message transmission time of MSG_A_01 can be obtained by adding a preset forwarding duration to the specified time, which is 200.5ms, or 200 + 0.5 = 200.5. For message MSG_B_01, its priority is second only to message MSG_A_01. After message MSG_A_01 is transmitted, the bus waits for a preset forwarding duration before forwarding it again. Therefore, message MSG... The initial message transmission time of message _B_01 is 201ms, i.e., 200.5 + 0.5 = 201ms. For message MSG_A_02, since the preset message period of both message MSG_A_01 and message MSG_B_01 is 10ms, message MSG_A_01 needs to be transmitted again at 201.5ms, and message MSG_B_01 needs to be transmitted again at 202ms. Therefore, the initial message transmission time of message MSG_A_02 is 202.5ms, i.e., 202 + 0.5 = 202.5ms.

[0086] S220. Determine the first message in the target node as the current message, and send the current message to the bus at the initial message sending time corresponding to the target node.

[0087] It should be noted that before sending the current message, it is also necessary to obtain the preset message period of the current message, so as to realize the periodic sending of messages; the preset message period can be defined for each type of message on each target node through the communication protocol.

[0088] For example, the initial message is sent at the time specified in the table above for each node, and the corresponding message sending diagram is shown below. Figure 6 As shown, the horizontal axis represents the message sending time, and the vertical axis represents each sending node.

[0089] The method provided in this application uses a specified time as the base time for the bus. At this time, each node is in a state where it can send messages. Based on the specified time, messages are sent sequentially from high priority to low priority according to the priority information of messages on each node. Then, the interval between messages is determined according to the preset forwarding duration. The initial message sending time of each node is determined by combining the preset message sending period. The target node sends messages to the bus according to the corresponding initial message sending time, thereby avoiding the flooding of all messages by each target node after initialization, which would lead to long-term bus contention.

[0090] S230. If the target node does not have corresponding arbitration information for the current message it is currently sending, it sends the next message of the current message to the bus based on the preset message sending period corresponding to the current message.

[0091] In this case, the target node's current message does not have corresponding arbitration information, meaning that the target node successfully sent the current message on its first attempt.

[0092] It is understandable that the current message was successfully sent on the first attempt, indicating that the timing of the current message transmission is reasonable. Therefore, there is no need to adjust the transmission period of the next message, that is, continue to send the next message of the current message according to the preset message period.

[0093] S240. If the current message sent by the target node corresponds to arbitration information, obtain the arbitration information of the current message on the target node.

[0094] Arbitration information is generated when a message sent by the target node conflicts with a message sent by another node connected to the bus.

[0095] S250. Based on the arbitration information of the current message on the target node, obtain the arbitration period of the current message.

[0096] The arbitration period is used to characterize the delay time of the current message on the target node due to arbitration.

[0097] S260. Based on the arbitration period, obtain the target transmission period for the next message of the current message.

[0098] S270: Send the next message to the bus based on the target transmission cycle.

[0099] The processes of steps S240-S270 are the same as or similar to those of steps S110-S140 in the previous embodiments. Therefore, for a detailed description of steps S240-S270, please refer to the detailed description of steps S110-S140 in the previous embodiments, and will not be repeated here.

[0100] The message sending method provided in this application, after initialization, obtains the initial message sending time determined by the bus based on a specified time, a preset forwarding duration, and the priority information of messages on each node. Messages are then sent to the bus sequentially according to the initial message sending time, thereby avoiding the flooding of all messages on each node after initialization, which would lead to prolonged bus contention and messages not being sent in a timely manner, thus improving the real-time performance of messages.

[0101] In some embodiments, such as Figure 7 , Figure 7 A schematic diagram of a message sending apparatus provided in an embodiment of this application is given. The message sending apparatus 300 includes:

[0102] The acquisition module 310 is used to acquire the arbitration information of the current message sent by the target node if there is arbitration information. The arbitration information is generated when the target node conflicts with the messages sent by other nodes connected to the bus.

[0103] The arbitration period calculation module 320 is used to obtain the arbitration period of the current message based on the arbitration information of the current message on the target node. The arbitration period is used to characterize the delay time of the current message on the target node due to arbitration.

[0104] The target transmission period calculation module 330 is used to obtain the target transmission period of the next message based on the arbitration period.

[0105] The sending module 340 is used to send the next message to the bus based on the target sending cycle.

[0106] In some implementations, the arbitration cycle calculation module 320 includes a collection unit and a calculation unit. The collection unit is used to obtain the number of arbitration failures from the arbitration information of the current message on the target node. The calculation unit is used to obtain the arbitration cycle of the current message based on the time of the first arbitration failure and the time of arbitration success in the arbitration information of the current message if the number of arbitration failures is less than the preset number of arbitrations. At this time, the target transmission cycle calculation module 330 is also used to obtain the target transmission cycle of the next message of the current message based on the arbitration cycle and the preset message transmission cycle corresponding to the current message.

[0107] In other embodiments, the calculation unit is also used to cancel the transmission of the current message if the number of arbitration failures is greater than the preset number of arbitrations, and to use the preset recovery time as the arbitration period of the current message. The preset recovery time is the waiting time for the target node to resume transmission after canceling the transmission of the current message. At this time, the target transmission period calculation module 330 is also used to use the arbitration period as the target transmission period of the next message of the current message.

[0108] In some embodiments, the message sending device 300 further includes a sending time confirmation module; the sending time confirmation module is used to obtain the initial message sending time of each node on the bus, which is determined by the bus based on a specified time, a preset forwarding duration, and the priority information of messages on each node; the specified time is a preset time to prepare to send the first message to the bus, and the preset forwarding duration is the interval between two consecutive forwarding of messages by the bus; at this time, the sending module 340 is also used to determine that the first message in the target node is the current message, and send the current message to the bus at the initial message sending time corresponding to the target node.

[0109] In some implementations, the sending module 340 is further configured to send the next message of the current message to the bus based on the preset message sending period corresponding to the current message if the current message sent by the target node does not have corresponding arbitration information.

[0110] In some embodiments, this application also provides an electronic device, which will be described below in conjunction with Figure 8 An electronic device provided in this application will be described. Taking the electronic device as an example, node 410 includes one or more processors 420; memory 430; and one or more programs. The one or more programs are stored in memory 430 and configured to be executed by one or more processors 420, and the one or more programs are configured to perform the methods described above.

[0111] Among them, node 410 can be a terminal device, such as a mobile phone, computer, tablet computer, vehicle terminal, etc.

[0112] Processor 420 may include one or more processing cores. Processor 420 connects to various parts of the wearable device using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 430, and by calling data stored in memory 430. Optionally, processor 420 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 420 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 420 and may be implemented separately through a communication chip.

[0113] The memory 430 may include random access memory (RAM) or read-only memory (ROM). The memory 430 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 430 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by node 410 during use.

[0114] In some embodiments, the present application provides a computer-readable storage medium storing program code that can be called by a processor to execute the methods described in the above method embodiments.

[0115] Computer-readable storage media can be electronic storage devices such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, computer-readable storage media includes non-transitory computer-readable storage media. The computer-readable storage medium has storage space for program code that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code can be compressed in an appropriate form.

[0116] The above are merely preferred embodiments of this application and are not intended to limit this application in any way. Although this application has disclosed preferred embodiments as above, it is not intended to limit this application. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the technical solution of this application. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of this application without departing from the scope of the technical solution of this application shall still fall within the scope of the technical solution of this application.

Claims

1. A message transmission method, applied to a target node connected to a bus, characterized in that, include: If the current message sent by the target node corresponds to arbitration information, obtain the arbitration information of the current message on the target node. The arbitration information is generated when the target node conflicts with the messages sent by other nodes connected to the bus. Based on the arbitration information of the current message on the target node, the arbitration period of the current message is obtained. The arbitration period is used to characterize the delay time of the current message on the target node due to arbitration. Based on the arbitration period, the target transmission period for the next message of the current message is obtained; The next message is sent to the bus based on the target transmission period; The process of obtaining the arbitration period of the current message based on the arbitration information of the current message on the target node includes: Obtain the number of arbitration failures from the arbitration information of the current message on the target node; If the number of arbitration failures is less than the preset number of arbitration failures, the arbitration cycle of the current message is obtained based on the time of the first arbitration failure and the time of the arbitration success in the arbitration information of the current message. The step of obtaining the target transmission period for the next message of the current message based on the arbitration period includes: The arbitration period is added to the preset message sending period corresponding to the current message to obtain the target sending period of the next message of the current message.

2. The method according to claim 1, characterized in that, The process of obtaining the arbitration period of the current message based on the arbitration information of the current message on the target node includes: If the number of arbitration failures exceeds the preset number of arbitrations, the transmission of the current message is cancelled, and the preset recovery time is used as the arbitration period for the current message. The preset recovery time is the waiting time for the target node to resume transmission after cancelling the transmission of the current message.

3. The method according to claim 2, characterized in that, The step of obtaining the target transmission period for the next message of the current message based on the arbitration period includes: The arbitration period is used as the target sending period for the next message of the current message.

4. The method according to claim 1, characterized in that, Before obtaining the arbitration information of the current message sent by the target node if the current message corresponds to arbitration information, the method includes: The initial message transmission time of each node on the bus is determined based on a specified time, a preset forwarding duration, and the priority information of messages on each node; the specified time is a preset time to prepare to send the first message to the bus, and the preset forwarding duration is the interval between two consecutive forwarding of messages by the bus. The first message in the target node is determined as the current message, and the current message is sent to the bus at the initial message sending time corresponding to the target node.

5. The method according to claim 4, characterized in that, After determining the first message in the target node as the current message and sending the current message to the bus at the initial message sending time corresponding to the target node, the method further includes: If the target node does not have corresponding arbitration information for the current message it is currently sending, it sends the next message of the current message to the bus based on the preset message sending period corresponding to the current message.

6. A bus message transmitting device, characterized in that, include: The acquisition module is used to acquire the arbitration information of the current message sent by the target node if there is arbitration information. The arbitration information is generated when the target node conflicts with the message sent by other nodes connected to the bus. The arbitration period calculation module is used to obtain the arbitration period of the current message based on the arbitration information of the current message on the target node. The arbitration period is used to characterize the delay time of the current message on the target node due to arbitration. The target transmission period calculation module is used to obtain the target transmission period of the next message of the current message based on the arbitration period; The sending module is used to send the next message to the bus based on the target sending period; The process of obtaining the arbitration period of the current message based on the arbitration information of the current message on the target node includes: Obtain the number of arbitration failures from the arbitration information of the current message on the target node; If the number of arbitration failures is less than the preset number of arbitration failures, the arbitration cycle of the current message is obtained based on the time of the first arbitration failure and the time of the arbitration success in the arbitration information of the current message. The step of obtaining the target transmission period for the next message of the current message based on the arbitration period includes: The arbitration period is added to the preset message sending period corresponding to the current message to obtain the target sending period of the next message of the current message.

7. An electronic device, characterized in that, include: One or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code that can be invoked by a processor to execute the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • CAN message sending method, control unit, CAN node and network thereof

    CN112671512A