CN117221037A - Message sending method and device, electronic equipment and storage medium - Google Patents

Message sending method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117221037A
CN117221037A CN202311001418.XA CN202311001418A CN117221037A CN 117221037 A CN117221037 A CN 117221037A CN 202311001418 A CN202311001418 A CN 202311001418A CN 117221037 A CN117221037 A CN 117221037A
Authority
CN
China
Prior art keywords
message
arbitration
current message
sending
period
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311001418.XA
Other languages
Chinese (zh)
Inventor
李冠佳
姚昂
何烈炎
黄光健
梁其辉
郭永杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Automobile Group Co Ltd
Original Assignee
Guangzhou Automobile Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Automobile Group Co Ltd filed Critical Guangzhou Automobile Group Co Ltd
Priority to CN202311001418.XA priority Critical patent/CN117221037A/en
Publication of CN117221037A publication Critical patent/CN117221037A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Bus Control (AREA)

Abstract

The application provides a message sending method, a message sending device, an electronic device and a storage medium, wherein the method comprises the steps of determining an arbitration period of a current message through arbitration information when the current message of a target node corresponds to arbitration information, and determining a target sending period of a next message through the arbitration period of the current message so as to send the next message in the target sending period; by adopting 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, and the periodic message originally having the same arbitration period as the current message can skip the arbitration period due to the change of the sending period of the next message, so that the arbitration times of the periodic message are reduced, even the arbitration of the periodic message is avoided, the occurrence frequency of bus competition is further reduced, the period delay caused by frequent bus competition of the periodic message is effectively avoided, and the instantaneity of the message is improved.

Description

Message sending method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of bus communications, and in particular, to a method and apparatus for sending a message, an electronic device, and a storage medium.
Background
Bus (Bus) is a common communication trunk for transmitting information between various functional components of a computer, and is a transmission harness consisting of wires, and a competing Bus allows any node on the Bus the opportunity to take control of the Bus and send data out. If 2 or more nodes require to transmit data at the same time, bus conflicts are generated, and the buses can detect the conflicts in real time and arbitrate the conflicts, so that the data with high priority are transmitted without any damage, and the data with low priority are arbitrated, and waiting for the buses to be idle for retransmission.
When a plurality of nodes send data messages simultaneously, an arbitration mechanism ensures the data priority transmission of high priority, so that the real-time performance of the low priority messages cannot be guaranteed, and once a competition phenomenon is formed for periodic messages, the competition phenomenon can continuously and periodically appear, and the real-time performance of the network and the messages is greatly influenced.
Disclosure of Invention
In view of the above problems, the present application provides a method, an apparatus, an electronic device, and a storage medium for sending a message, which can dynamically adjust a sending period of a next message according to arbitration information of a current message, reduce a frequency of bus contention, and improve real-time performance of the message.
The embodiment of the application is realized by adopting the following technical scheme:
in a first aspect, the present application provides a method for sending a message, applied to a target node connected by a bus, where the method includes: if the current message currently sent by the target node corresponds to arbitration information, acquiring the arbitration information of the current message on the target node, wherein the arbitration information is generated when the messages sent by the target node and other nodes connected with the bus collide; based on the arbitration information of the current message on the target node, obtaining an arbitration period of the current message, wherein the arbitration period is used for representing delay time of the current message on the target node due to arbitration; based on the arbitration period, obtaining a target sending period of a next message of the current message; and sending the next message to the bus based on the target sending period.
In a second aspect, the present application provides a message sending device, where the device includes: the acquisition module is used for acquiring arbitration information of the current message on the target node if the current message currently transmitted by the target node corresponds to arbitration information, wherein the arbitration information is generated when messages transmitted by the target node and other nodes connected with the bus collide; the arbitration cycle calculation module is used for obtaining the arbitration cycle of the current message based on the arbitration information of the current message on the target node, wherein the arbitration cycle is used for representing the delay time of the current message on the target node due to arbitration; the target sending period calculation module is used for obtaining the target sending period of the next message of the current message based on the arbitration period; and the sending module is used for sending the next message to the bus based on the target sending period.
In some embodiments, the arbitration cycle calculation module includes an acquisition unit and a calculation unit, where the acquisition unit is configured to acquire arbitration failure times from arbitration information of a current packet on a target node; the computing unit is used for obtaining the arbitration cycle of the current message based on the first arbitration failure time and the arbitration success time in the arbitration information of the current message when the arbitration failure times are smaller than the preset arbitration times; at this time, the target sending period calculating module is further configured to obtain a target sending period of a next message of the current message based on a preset message sending period corresponding to the current message in the arbitration period.
In other embodiments, the computing unit is further configured to cancel sending of the current message if the number of arbitration failures is greater than a preset number of arbitration failures, and take a preset recovery time as an arbitration period of the current message, where the preset recovery time is a waiting time for the target node to cancel sending of the current message and resume sending again; at this time, the target sending period calculating module is further configured to take the arbitration period as a target sending period of a next message of the current message.
In some modes, the message sending device further comprises a sending moment confirming module; the sending time confirming module is used for acquiring initial message sending time of each node on the bus, which is determined based on the designated time, the preset forwarding time and the priority information of the messages sent by each node; the appointed time is a preset time for preparing to send a first message to the bus, and the preset forwarding time is an interval time for continuously forwarding two messages by the bus; at this time, the sending module is further configured 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.
In some embodiments, the sending module is further configured to send a next packet of the current packet to the bus based on a preset packet sending period corresponding to the current packet if the current packet currently sent by the target node does not have corresponding arbitration information.
In a third aspect, the present application provides an electronic device comprising one or more processors; a 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 configured to perform the methods described above.
In a fourth aspect, the present application provides a computer readable storage medium storing program code that is callable by a processor to perform the method described above.
When the current message of the target node corresponds to arbitration information, determining an arbitration period of the current message, and determining a target sending period of a next message according to the arbitration period of the current message, so as to send the next message in the target sending period; by adopting 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, and for the periodic message which originally appears and has the same arbitration period as the current message, the actual sending time of the periodic message is changed due to the change of the sending period of the next message, namely the actual sending time of the periodic message can skip the arbitration period of the periodic message, thereby reducing the arbitration times of the periodic message and even avoiding the arbitration of the periodic message, further reducing the occurrence frequency of bus contention, effectively avoiding the periodic delay caused by frequent bus contention of the periodic message, and improving the real-time property of the message.
These and other aspects of the application will be more readily apparent from the following description of the embodiments.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a bus transfer.
Fig. 2 is a flow chart of a message sending method according to an embodiment of the present application.
Fig. 3 is a flowchart of step S120 in fig. 2 according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a target node in an embodiment of the present application.
Fig. 5 is a schematic flow chart of a message sending method according to an embodiment of the present application.
Fig. 6 is a schematic diagram of message transmission provided in an embodiment of the present application.
Fig. 7 is a schematic diagram of a message sending device according to an embodiment of the present application.
Fig. 8 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for explaining the present application and are not to be construed as limiting the present application.
In order to enable those skilled in the art to better understand the present application, a clear and complete description of the technical solution in the present embodiment will be provided below with reference to the accompanying drawings in the present embodiment. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The bus transmission is a common data transmission mode, and the principle of the bus transmission is shown in fig. 1, and the bus transmission comprises a bus 10 and a plurality of nodes 20, wherein the nodes 20 can all transmit data to the bus 10, if 2 or more nodes 20 require to transmit data at the same time, bus collision can be generated, the bus 10 can detect the collision in real time and arbitrate the collision, so that the data with high priority can be transmitted without any damage, and the data with low priority is arbitrated, and the bus 10 waits for idle retransmission.
In some embodiments, as shown in fig. 2, fig. 2 shows a flow chart of a message sending method provided by the embodiment of the present application, where the message sending method provided by the present application is applied to a target node connected by a bus, and the method includes:
s110, if the current message currently sent by the target node corresponds to the arbitration information, the arbitration information of the current message on the target node is obtained.
The arbitration information is generated when the target node collides with messages sent by other nodes connected with the bus.
Wherein the target node represents a communication endpoint or terminal device; the nodes in the bus system generally comprise a control unit and bus auxiliary equipment, wherein the control unit consists of a controller, a transceiver and two data transmission terminals. Compared with the controller ECU of the traditional automobile microcomputer control system, the control unit is provided with a special bus interface device (such as a CAN bus interface) in hardware, and has corresponding software, namely support of a communication standard.
A message (message) refers to a data unit exchanged and transmitted in a network, i.e. a data block to be sent at a time by a station (or node). The message contains the complete data information to be sent, and the length of the message is not consistent, and the length of the message is unlimited and variable. In the embodiment of the application, the current message is the message being sent.
Arbitration (or bus arbitration) refers to a process of selecting one master device to obtain bus control priority in some way when multiple master devices compete for the bus control simultaneously; arbitration may be implemented by a bus arbiter deployed on the bus.
Further, the arbitration information may include one or more of arbitration times, arbitration states, arbitration time, etc. of the current message, where the arbitration states may include arbitration success and arbitration failure; further, the arbitration information of the current message may be only the arbitration information generated by the current message in the last arbitration, or may be a set of arbitration information generated by the current message in each arbitration.
In the embodiment of the application, the target node is each node on the bus, and each target node periodically transmits a message to the bus according to a corresponding preset message transmission period.
Further, the message sent by one target node can be one or more; when a target node sends multiple messages, the multiple messages are sent one by one, i.e., a target node will only send one message to the bus at a time.
It should be noted that, when one target node sends multiple messages, the multiple messages may be sent according to the same preset message sending period, or the corresponding preset message sending periods may be set for each message respectively.
It should be noted that, when the arbitration of the current message fails, the target node may continuously send the current message to the bus under a preset condition to perform multiple arbitration, where the preset condition may be continuous sending in a preset time range or continuous sending in a preset arbitration frequency range.
S120, based on the arbitration information of the current message on the target node, the arbitration period of the current message is obtained.
The arbitration cycle is used for representing delay time of the current message on the target node due to arbitration.
In some embodiments, if the current message is successfully sent after arbitration, the arbitration period may be a time difference between an actual sending time and an expected sending time of the current message; if the current message still fails to be sent after arbitration, the arbitration period may be a time difference between a sending failure time and an expected sending time of the current message, or may be a recovery waiting time preset by the target node for restarting the sending of the message.
In some embodiments, as shown in fig. 3, fig. 3 shows a schematic flow chart of step S120 in fig. 2 provided by an embodiment of the present application, where step S120 specifically includes:
s121, acquiring the arbitration failure times from the arbitration information of the current message on the target node.
The obtaining of the arbitration failure times in the arbitration information may be achieved by disposing a counter on the target node, where the counter may be a synchronous counter or an asynchronous counter, and is not limited herein.
And S122, if the number of arbitration failures is smaller than the preset arbitration number, obtaining the arbitration cycle of the current message based on the time of the first arbitration failure and the time of the arbitration success in the arbitration information of the current message.
Specifically, in the embodiment of the application, the time of the first arbitration failure is subtracted from the time of the successful arbitration to obtain the arbitration cycle of the current message.
It can be understood that when the arbitration failure times of the current message on the target node are obtained from the arbitration information, the time of the first arbitration failure of the current message and the time of the successful arbitration need to be obtained; in the embodiment of the application, the time of the first arbitration failure of the message is registered through the message first arbitration failure time register, and the time of the successful message arbitration is registered through the message arbitration success time register.
Considering that the arbitration times of the message before the arbitration success can represent the advantages and disadvantages of the bus layout to a certain extent, namely the shorter the arbitration times of the message before the arbitration success is, the shorter the message delay time is, and the better the bus layout is; therefore, in the embodiment of the present application, the number of arbitration alarms is also preset, the number of arbitration alarms is smaller than the preset number of arbitration alarms, and when the number of arbitration failures of the current message is greater than the number of arbitration alarms and smaller than the preset number of arbitration alarms, an arbitration failure alarm is generated and recorded, wherein the arbitration failure alarm includes arbitration time information, so as to determine whether the bus layout needs to be optimized through the recorded arbitration failure alarm. For example, when the occurrence frequency of the arbitration failure warning is greater than a preset threshold value, judging that the bus layout needs to be optimized; or when the ratio of the occurrence frequency of the arbitration failure warning to the preset message sending period of the current message is greater than a preset threshold value, judging that the bus layout needs to be optimized, and setting a specific judging mode according to actual requirements.
And S123, if the number of arbitration failures is greater than the preset arbitration number, canceling the transmission of the current message, and taking the preset recovery time as the arbitration period of the current message.
The preset recovery time is waiting time for the target node to resume transmission after canceling transmission of the current message.
It should be noted that, for each target node, the preset recovery time may be uniform, or may be set corresponding to each target node respectively; further, when the same target node needs to send multiple messages, the preset recovery time may be uniform for each message on the target node, or may be set corresponding to each message respectively, which is not limited herein.
In order to perform subsequent optimization on the bus layout, in the embodiment of the present application, after the transmission of the current message is canceled, a transmission result of the current message is also generated, where the transmission result is an arbitration failure error, and the transmission result includes time information.
S130, obtaining a target sending period of a next message of the current message based on the arbitration period.
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.
Further, when the same target node contains multiple messages, the next message of the current message refers to the next message of the same message as the current message on the target node where the current message is located; for example, if the message sending sequence of the target node is that a1-B1-B2-a2 are sent sequentially, where a1 and a2 belong to a class message, B1 and B2 belong to a class B message, and in the case that a1 is the current message, the next message of the current message is a2.
In some embodiments, under the condition of step S122, step S130 specifically includes:
s131, obtaining a target sending period of a next message of the current message based on a preset message sending period corresponding to the current message in the arbitration period.
The preset message sending period refers to a preset expected sending time interval of a front message and a back message when the target node continuously sends the message.
Specifically, in the embodiment of the present application, the arbitration period is accumulated with the preset message sending period corresponding to the current message, so as to obtain the target sending period of the next message of the current message.
It should be noted that, in the prior art, since the messages are all sent periodically, after the current message is arbitrated, a periodic message must appear due to the periodicity of the message, and the arbitration condition is the same as that of the current message, that is, the arbitration period of the periodic message is the same as that of the current message; by adopting the method of the 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 of the current message, and as the target sending period of the next message is increased by one arbitration period compared with the preset message period, the sending time of the periodic message is also relatively increased by at least one arbitration period, namely the periodic message can skip the arbitration period, thereby reducing the arbitration times of the periodic message and even avoiding arbitration, further reducing the occurrence frequency of bus competition, effectively avoiding the period delay caused by frequent bus competition of the message, and improving the real-time property of the message.
In some embodiments, under the condition of step S123, step S130 specifically includes:
s132, taking the arbitration cycle as a target sending cycle of a next message of the current message.
It should be noted that, because the current message is already cancelled to send, the time delayed in arbitration has no reference meaning to the periodic message, so the preset recovery time is set as the arbitration period, and the arbitration period is directly used as the target sending period of the next message of the current message to adjust the sending time of the periodic message, thereby reducing the arbitration times of the periodic message and even avoiding arbitration, further reducing the occurrence frequency of bus contention, effectively avoiding the period delay caused by frequent bus contention of the message, and improving the real-time performance of the message.
Further, the preset recovery time may be preset in the case of a transmission failure in artificial simulation.
And S140, transmitting a next message to the bus based on the target transmission period.
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 period, that is, timing is started from the arbitration success time (that is, the actual sending time) of the current message, and after waiting for a target sending period, the target node sends the next message of the current message to the bus.
When the current message is cancelled to be sent after arbitration, the next message is sent to the bus based on the target sending period, namely, timing is started from the moment of the last arbitration failure of the current message, and after waiting for a target sending period, the target node sends the next message of the current message to the bus.
When the current message of the target node corresponds to arbitration information, determining an arbitration period of the current message through the arbitration information, and determining a target sending period of a next message through the arbitration period of the current message, thereby sending the next message in the target sending period; by adopting 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, so that the sending period of the next message is delayed by one arbitration period, and for the periodic message which originally has the same arbitration period as the current message, the actual sending time of the periodic message is also changed due to the change of the sending period of the next message, namely the actual sending time of the periodic message can skip the arbitration period, thereby reducing the arbitration times of the periodic message and even avoiding the occurrence of arbitration of the periodic message, further reducing the occurrence frequency of bus competition, effectively avoiding the period delay caused by frequent bus competition of the message, and improving the real-time property of the message.
It should be noted that, in some embodiments, when the same target node sends multiple messages, due to the change of the target sending period of the next message, multiple messages that are originally sent at intervals on the same target node need to be sent simultaneously, at this time, the messages that need to be sent simultaneously may be cached by setting a cache area on the target node, and then the sending sequence is determined according to the specific information of each message.
In order to facilitate understanding of the present solution, as shown in fig. 4, fig. 4 shows a schematic structural diagram of a target node in an embodiment of the present application, where in the embodiment of the present application, each target node includes a read-back unit, an operation unit, a configuration unit, and a sending unit.
The method comprises the steps that a readback unit is used for reading a current message sent to a bus by a target node, obtaining arbitration information of the current message, wherein the arbitration information comprises current message arbitration conditions and sending conditions, and recording arbitration time and sending time; the operation unit is used for calculating a target sending period of the next message sending of the current message; the configuration unit is used for packaging the next message ready for transmission according to a specific message packaging format (packaging, namely adding header information corresponding to each layer in the network reference model, wherein the header information is mainly used for helping an intermediate transmission system to transmit the message to a correct destination); the sending unit is used for sending the encapsulated next message.
Specifically, in the embodiment of the present application, the read-back unit and the operation unit are provided with a counter and a register, where the message arbitration failure counter is used to record the number of arbitration failures when the current message is sent; the message first arbitration failure time register is used for registering the first arbitration failure time when the current message is sent; the message arbitration success time register is used for registering the time of arbitration success when the current message is sent; the message arbitration failure warning error register is used for registering the current message arbitration failure warning and message failure arbitration error, recording the format as arbitration state and time, wherein the arbitration state comprises the arbitration failure warning and the arbitration failure error; and the next message sending time register is used for registering a target sending period of the next message sending.
In other embodiments, in order to avoid Flooding (Flooding, a data flow transmission technique used by a switch and a bridge) of each target node after initialization, all messages are sent out by sending data flows received from a certain interface to all interfaces except the interface, so that buses compete for a long time, as shown in fig. 5, fig. 5 shows a further flow diagram of a message sending method provided by an embodiment of the present application, where the method includes:
s210, acquiring initial message sending time of each node on the bus, which is determined by the bus based on the designated time, preset forwarding time and priority information of messages sent by each node.
The designated time is a preset time for preparing to send the first message to the bus, and the preset forwarding time is an interval time for continuously forwarding the two messages by the bus.
It can be understood that, the transmission time interval of two messages continuously transmitted on the bus must be a multiple of the preset forwarding time length, and the preset forwarding time length determines that the two messages continuously transmitted on the bus must not have arbitration condition.
In some embodiments, the designated time may be obtained based on the initialization time of all the nodes on the bus, that is, the time when all the nodes complete initialization is determined as the designated time; the initialization is a transitional state after the slave node is powered on, reset and wakes up during sleep, and the node is ready for communication in the initialization process, and cannot send and receive messages at this time.
In some embodiments, the priority information of the message on each node may be determined by the name of the message, or may be determined by the identifier of the message.
In some embodiments, when a target node needs to send multiple messages, the initial message sending time of the node includes the initial sending time corresponding to each message.
To facilitate understanding of the present scheme, the following transmission timing table is taken as an example to illustrate:
the initialization time of each node on the bus is set to be 200ms, namely the designated time is set to be 200ms, namely 0ms is set as the initial time, and the sending time of the first message of each node is greater than +200ms.
The preset forwarding duration of the bus is 0.5ms, so that the time interval between two messages continuously sent to the bus by each node is an integer multiple of 0.5 ms.
The priority information of the messages on each node is message identifier information, specifically, the smaller the message identifier is, the higher the priority of the corresponding message is.
Therefore, when determining the initial message sending time of the message, for the message msg_a_01, the corresponding message identifier is the smallest and the priority is the highest, and the specified time and the preset forwarding time length can be added to obtain the initial message sending time of the message msg_a_01, namely 200.5ms, namely 200+0.5=200.5; for the message msg_b_01, the priority is only inferior to that of the message msg_a_01, and after the message msg_a_01 is sent, the bus waits for a preset forwarding time period to forward again, so that the initial message sending time of the message msg_b_01 is 201ms, namely 200.5+0.5=201 ms; for the message msg_a_02, since the preset message periods of the message msg_a_01 and the message msg_b_01 are both 10ms, when 201.5ms is used, the message msg_a_01 needs to be sent again, and when 202ms is used, the message msg_b_01 needs to be sent again, so that the initial message sending time of the message msg_a_02 is 202.5ms, that is, 202+0.5=202.5.
S220, 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 moment corresponding to the target node.
Before sending the current message, the preset message period of the current message is also required to be obtained, so that the periodic sending of the message is realized; the preset message period can be defined for each message on each target node through a communication protocol.
The initial message transmission is performed at the initial message transmission time of each node confirmed by the table, and a corresponding message transmission schematic diagram is shown in fig. 6, where the horizontal axis is the message transmission time, and the vertical axis is each transmitting node.
According to the method provided by the embodiment of the application, the bus takes the designated time as the basic time, at this time, all nodes are in a state capable of sending messages, on the basis of the designated time, the messages with high priority are sequentially sent from the messages with high priority to the messages with low priority according to the priority information of the messages on all nodes, then the interval time between the messages is determined according to the preset forwarding time length, the initial message sending time of all the nodes is confirmed by combining the preset message sending period, and the target nodes send the messages to the bus according to the corresponding initial message sending time, so that the problem that all the messages are flooded by all the target nodes after initialization, and long-time competition of the bus is avoided.
S230, if the current message currently sent by the target node does not have the corresponding arbitration information, sending the next message of the current message to the bus based on the preset message sending period corresponding to the current message.
The current message currently sent by the target node does not have corresponding arbitration information, that is, the target node successfully sends the current message when sending for the first time.
It can be understood that the current message is successfully sent for the first time, which means that the sending time of the current message is reasonable, so that the sending period of the next message does not need to be adjusted, that is, the next message of the current message is continuously sent in the preset message period.
S240, if the current message currently sent by the target node corresponds to the arbitration information, the arbitration information of the current message on the target node is obtained.
The arbitration information is generated when the target node collides with messages sent by other nodes connected with the bus.
S250, based on the arbitration information of the current message on the target node, the arbitration period of the current message is obtained.
The arbitration cycle is used for representing delay time of the current message on the target node due to arbitration.
S260, obtaining the target sending period of the next message of the current message based on the arbitration period.
S270, transmitting a next message to the bus based on the target transmission period.
The process of step S240 to step S270 is the same as or similar to the process of step S110 to step S140 in the foregoing embodiment, and thus, the detailed description of step S240 to step S270 may refer to the detailed description of step S110 to step S140 in the foregoing embodiment, and will not be repeated here.
According to the message sending method provided by the application, after initialization, the initial message sending time determined by the bus according to the designated time, the preset forwarding time and the priority information of the messages on each node is obtained, and the messages are sequentially sent to the bus according to the initial message sending time, so that the situation that the bus is in competition for a long time and the messages cannot be sent in time due to the fact that all the messages on each node are sent in a flooding mode after initialization is avoided, and the real-time performance of the messages is improved.
In some embodiments, as shown in fig. 7, fig. 7 shows a schematic diagram of a message sending apparatus provided by an embodiment of the present application, where the message sending apparatus 300 includes:
the obtaining module 310 is configured to obtain arbitration information of a current message on the target node if the current message currently sent by the target node corresponds to arbitration information, where the arbitration information is generated when messages sent by other nodes connected by the target node and the bus collide.
The arbitration cycle calculation module 320 is configured to obtain an arbitration cycle of the current message based on the arbitration information of the current message on the target node, where the arbitration cycle is used to characterize a delay time of the current message on the target node due to arbitration.
The target sending period calculating module 330 is configured to obtain a target sending period of a next message of the current message based on the arbitration period.
The sending module 340 is configured to send a next message to the bus based on the target sending cycle.
In some embodiments, the arbitration cycle calculation module 320 includes an acquisition unit and a calculation unit, where the acquisition unit is configured to acquire the number of arbitration failures from the arbitration information of the current packet on the target node; the computing unit is used for obtaining the arbitration cycle of the current message based on the first arbitration failure time and the arbitration success time in the arbitration information of the current message when the arbitration failure times are smaller than the preset arbitration times; at this time, the target sending period calculating module 330 is further configured to obtain a target sending period of a next message of the current message based on the preset message sending period corresponding to the current message in the arbitration period.
In other embodiments, the computing unit is further configured to cancel sending of the current message if the number of arbitration failures is greater than a preset number of arbitration failures, and take a preset recovery time as an arbitration period of the current message, where the preset recovery time is a waiting time for the target node to cancel sending of the current message and resume sending again; at this time, the target sending period calculating module 330 is further configured to take the arbitration period as the target sending period of the next message of the current message.
In some aspects, the message sending apparatus 300 further includes a sending time confirmation module; the sending time confirming module is used for acquiring initial message sending time of each node on the bus, which is determined based on the designated time, the preset forwarding time and the priority information of the messages sent by each node; the appointed time is a preset time for preparing to send a first message to the bus, and the preset forwarding time is an interval time for continuously forwarding two messages by the bus; at this time, the sending module 340 is further configured 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.
In some embodiments, the sending module 340 is further configured to send a next packet of the current packet to the bus based on a preset packet sending period corresponding to the current packet if the current packet currently sent by the target node does not have corresponding arbitration information.
In some embodiments, the present application further provides an electronic device, and an electronic device provided by the present application will be described below with reference to fig. 8. Taking an electronic device as an example, node 410 includes one or more processors 420; a memory 430; one or more programs. Wherein one or more programs are stored in the memory 430 and configured to be executed by the one or more processors 420, the one or more programs configured to perform the methods described above.
The node 410 may be a terminal device, and the terminal device may be a mobile phone, a computer, a tablet computer, a vehicle-mounted terminal, etc.
Processor 420 may include one or more processing cores. The processor 420 connects various portions within the overall wearable device using various interfaces and lines to perform various functions of the wearable device and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 430, and invoking data stored in the memory 430. Alternatively, the processor 420 may be implemented in hardware in at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 420 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing the content to be displayed; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 420 and may be implemented solely by a single communication chip.
The Memory 430 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory). Memory 430 may be used to store instructions, programs, code sets, or instruction sets. The memory 430 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described below, etc. The storage data area may also store data created by the node 410 in use.
In some embodiments, a computer readable storage medium is provided in an embodiment of the present application, where the computer readable storage medium has a program code stored therein, and the program code may be invoked by a processor to perform the method described in the above method embodiments.
The computer readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium comprises a non-volatile computer readable medium (non-transitory computer-readable storage medium). The computer readable storage medium has storage space for program code to perform any of the method steps described above. The program code can be read from or written to one or more computer program products. The program code may be compressed in a suitable form.
Although the present application has been described in terms of the preferred embodiments, it should be understood that the present application is not limited to the specific embodiments, but is capable of numerous modifications and equivalents, and alternative embodiments and modifications of the embodiments described above, without departing from the spirit and scope of the present application.

Claims (10)

1. A method for sending a message, applied to a target node connected by a bus, comprising:
if the current message currently sent by the target node corresponds to arbitration information, acquiring the arbitration information of the current message on the target node, wherein the arbitration information is generated when the messages sent by the target node and other nodes connected with the bus collide;
based on the arbitration information of the current message on the target node, obtaining an arbitration period of the current message, wherein the arbitration period is used for representing delay time of the current message on the target node due to arbitration;
based on the arbitration period, obtaining a target sending period of a next message of the current message;
and sending the next message to the bus based on the target sending period.
2. The method according to claim 1, wherein the obtaining the arbitration cycle of the current message based on the arbitration information of the current message on the target node includes:
acquiring arbitration failure times from arbitration information of a current message on the target node;
and if the arbitration failure times are smaller than preset arbitration times, obtaining the arbitration cycle of the current message based on the first arbitration failure time and the arbitration success time in the arbitration information of the current message.
3. The method according to claim 2, wherein the obtaining, based on the arbitration cycle, a target transmission cycle of a next message of the current message includes:
and obtaining a target sending period of a next message of the current message based on the preset message sending period corresponding to the current message in the arbitration period.
4. The method according to claim 2, wherein the obtaining the arbitration cycle of the current message based on the arbitration information of the current message on the target node includes:
and if the number of arbitration failures is greater than the preset arbitration number, canceling the transmission of the current message, and taking a preset recovery time as an arbitration period of the current message, wherein the preset recovery time is the waiting time for the target node to cancel the transmission of the current message and then resume the transmission again.
5. The method of claim 4, wherein the obtaining the target transmission period of the next message of the current message based on the arbitration period comprises:
and taking the arbitration cycle as a target sending cycle of a message next to the current message.
6. The method according to claim 1, wherein, if the current message currently sent by the target node corresponds to arbitration information, before obtaining the arbitration information of the current message on the target node, the method includes:
acquiring initial message sending time of each node on the bus, which is determined by the bus based on the designated time, preset forwarding time and priority information of messages sent by each node; the appointed time is a preset time for preparing to send a first message to a bus, and the preset forwarding time is an interval time for continuously forwarding two messages by the bus;
and determining the first message in the target node as a current message, and sending the current message to the bus at the initial message sending moment corresponding to the target node.
7. The method of claim 6, wherein the determining that the first message in the target node is a current message, and after sending the current message to the bus at an initial message sending time corresponding to the target node, the method further comprises:
and if the current message currently sent by the target node does not have the corresponding arbitration information, sending a next message of the current message to the bus based on a preset message sending period corresponding to the current message.
8. A bus messaging apparatus, comprising:
the acquisition module is used for acquiring arbitration information of the current message on the target node if the current message currently transmitted by the target node corresponds to arbitration information, wherein the arbitration information is generated when messages transmitted by the target node and other nodes connected with the bus collide;
the arbitration cycle calculation module is used for obtaining the arbitration cycle of the current message based on the arbitration information of the current message on the target node, wherein the arbitration cycle is used for representing the delay time of the current message on the target node due to arbitration;
the target sending period calculation module is used for obtaining the target sending period of the next message of the current message based on the arbitration period;
and the sending module is used for sending the next message to the bus based on the target sending period.
9. An electronic device, comprising:
one or more processors;
a 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 configured to perform the method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a program code, which is callable by a processor for performing the method according to any one of claims 1-7.
CN202311001418.XA 2023-08-09 2023-08-09 Message sending method and device, electronic equipment and storage medium Pending CN117221037A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311001418.XA CN117221037A (en) 2023-08-09 2023-08-09 Message sending method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311001418.XA CN117221037A (en) 2023-08-09 2023-08-09 Message sending method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117221037A true CN117221037A (en) 2023-12-12

Family

ID=89050099

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311001418.XA Pending CN117221037A (en) 2023-08-09 2023-08-09 Message sending method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117221037A (en)

Similar Documents

Publication Publication Date Title
US20200205115A1 (en) Wireless positioning method and system using the same
US7801173B2 (en) Communication message conversion apparatus and communication message conversion method
KR101885935B1 (en) Method and apparatus for serial data transmission at a switchable data rate
JP4766160B2 (en) Communication system and communication node
CN111328148B (en) Data transmission method and device
JP6251886B2 (en) Relay device and control method of relay device
CN112261142B (en) RDMA network data retransmission method, device and FPGA
US11715337B2 (en) Controller diagnostic device and method thereof
CN114077568A (en) Inter-core communication method and device, electronic assembly and electronic equipment
CN115733849A (en) Flash method, device, system, equipment and storage medium of electronic control unit
CN112217701A (en) Bus collision avoidance method and device
CN117221037A (en) Message sending method and device, electronic equipment and storage medium
JP2007243239A (en) Communication apparatus and communication method
CN112039835B (en) Adaptive polling time estimation method, device, equipment and storage medium
CN113595669A (en) Time synchronization method and device of network node, electronic equipment and storage medium
CN116321253A (en) Ad hoc network simulation test method and device, terminal equipment and readable storage medium
US8918130B2 (en) Method for transmitting a communication signal
CN112383458B (en) Responsive communication method and system
CN114095306A (en) LIN message passing between LIN partitions separated by backbone communication network
CN114650194B (en) Data communication method, device, electronic equipment and storage medium
CN116723064A (en) CAN message transmission optimization method, device, equipment and storage medium
CN114584630B (en) Communication method and device based on field bus protocol
CN117472810A (en) Vehicle control signal transmission method, device, equipment and storage medium
CN116633876A (en) Vehicle-mounted Ethernet data frame transmission method and device and electronic equipment
CN117560756A (en) Data transmission synchronization method and device, chip, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination