Message period optimization method and device, electronic equipment and storage medium
By dividing CAN messages into queues with different periodic offset values and setting integer multiples of the offset value, the CAN channel congestion problem is solved, the accuracy of message sending time is improved, and the vehicle control accuracy and safety are enhanced.
Patent Information
- Application Number
- CN202410295676.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-14
- Publication Date
- 2025-09-16
AI Technical Summary
With the trend of concentrating vehicle functions on a small number of controllers, the number of CAN messages on the CAN channel increases, causing network congestion, affecting the accuracy of message sending time, and thus affecting vehicle control accuracy and safety.
The CAN messages on the target CAN channel are divided into queues with different period offset values. By setting the period offset value of each CAN message to an integer multiple of the preset offset value, the start sending time of CAN messages in the same queue is ensured to be different, the number of simultaneous transmissions is reduced, and the message period is optimized.
By optimizing the CAN message cycle, channel congestion is reduced, the accuracy of message sending time is improved, and vehicle control accuracy and safety are enhanced.
Smart Images

Figure CN120658688A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of vehicle-mounted communication technology, and in particular to a message cycle optimization method, device, electronic device, and storage medium. Background Art
[0002] The Automotive Open System Architecture (AUTOSAR) standardizes the underlying software layers of automotive electronic control units (ECUs), standardizing the interface features of ECUs of varying architectures. This improves the scalability and portability of application software, decoupling hardware and software, allowing for hardware-independent application development. The communication module (COM) is a key component of the communication abstraction layer within the AUTOSAR software architecture. It provides basic communication services for various buses, including conversion between vehicle signals and protocol data units (PDUs), and mechanisms for sending and receiving messages. The COM module frees application developers from the specific details of communication protocols when handling internal vehicle communications, reducing development and integration complexity. The Controller Area Network (CAN) message cycle refers to the time interval between the initial transmission and the retransmission of a specific CAN message.
[0003] As vehicles concentrate more and more functions on a small number of controllers, the number of CAN messages on the CAN channel is also increasing. Consequently, the number of CAN messages with the same period is also increasing, leading to an increasing number of messages being sent simultaneously on the CAN channel, which may cause network congestion. At this time, subsequent CAN messages need to wait until the previous CAN message is transmitted before they can continue to be sent. This cumulative delay effect will seriously affect the transmission time of subsequent CAN messages, resulting in inaccurate CAN message transmission time. When CAN message transmission time is inaccurate, it will affect the real-time performance of the control system and reduce vehicle control accuracy. If the vehicle safety system message is inaccurate, components related to vehicle safety cannot respond in a timely manner, resulting in increased system safety risks. If the infotainment system message is inaccurate, the display screen information will update slowly, resulting in a reduced user experience. Summary of the Invention
[0004] The present disclosure provides a message cycle optimization method, device, electronic device and storage medium.
[0005] According to a first aspect of the present disclosure, a message cycle optimization method is provided, comprising:
[0006] Acquire message information of each CAN message of at least two CAN messages corresponding to the target CAN channel; the message information includes at least a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0007] In response to the presence of at least two CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending in the target CAN channel, target CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending in the CAN messages are filtered out;
[0008] Dividing at least two target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period;
[0009] The period offset value of each CAN message in each CAN message queue is set to an integer multiple of a preset offset value; wherein, the period offset values of at least two CAN messages in the same CAN message queue are different.
[0010] In some embodiments of the present disclosure, setting the periodic offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value includes:
[0011] Traverse each CAN message in the current CAN message queue, and set the offset base of the current CAN message to the sum of the preset offset base and the traversal order according to the traversal order of the current CAN message;
[0012] Determine whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value;
[0013] If the judgment result is yes, reset the offset base of the current CAN message to the preset offset base;
[0014] The periodic offset value of the current CAN message is set to the offset base multiple of the preset offset value.
[0015] In some embodiments of the present disclosure, after dividing at least two target CAN messages into at least one CAN message queue, the message cycle optimization method provided by the present disclosure further includes:
[0016] Calculate the median value of the message period corresponding to the CAN message queue;
[0017] Filter out target CAN message queues whose message period is greater than the median value from the CAN message queues;
[0018] The periodic offset value of each CAN message in each CAN message queue is set to an integer multiple of the preset offset value, including:
[0019] The periodic offset value of each CAN message in each target CAN message queue is set to an integer multiple of the preset offset value.
[0020] In some embodiments of the present disclosure, obtaining message information of each CAN message of at least two CAN messages corresponding to a target CAN channel includes:
[0021] Get the target DBC file corresponding to the target CAN channel;
[0022] Parse the target DBC file to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel.
[0023] In some embodiments of the present disclosure, the message information further includes the CAN ID of the corresponding CAN message;
[0024] After acquiring the message information of each CAN message of at least two CAN messages corresponding to the target CAN channel, the message cycle optimization method provided by the present disclosure further includes:
[0025] Obtain the weight base and weight coefficient corresponding to the sending / receiving type, sending mode and message period of each CAN message;
[0026] Determine that the product value of the weight base and the weight coefficient is the weight value of the corresponding CAN message;
[0027] According to the preset mapping relationship between the weight value and the PDU ID, the PDU ID corresponding to the weight value of the CAN message is determined.
[0028] In some embodiments of the present disclosure, the sending / receiving type of the CAN message includes a sending type and a receiving type; wherein the first weight coefficients of the sending type and the receiving type of the CAN message are the same, and the weight base of the sending type of the CAN message is greater than the weight base of the receiving type of the CAN message;
[0029] The CAN message transmission mode includes a periodic transmission mode, an event transmission mode, and a mixed transmission mode; wherein the second weight coefficients of the CAN messages in the periodic transmission mode, the event transmission mode, and the mixed transmission mode are the same, and the second weight coefficient is less than the first weight coefficient; the weight base of the CAN message in the periodic transmission mode is greater than the weight base of the CAN message in the mixed transmission mode; the weight base of the CAN message in the mixed transmission mode is greater than the weight base of the CAN message in the event transmission mode;
[0030] If the sending mode of the CAN message is a periodic sending mode or a mixed sending mode, the third weight coefficient corresponding to the message period of the CAN message is smaller than the second weight coefficient.
[0031] In some embodiments of the present disclosure, determining the product value of the weight base and the weight coefficient as the weight value of the corresponding CAN message includes:
[0032] If a CAN message includes multiple CAN messages with the same message period, then:
[0033] Sort multiple CAN messages with the same message period from large to small according to the size of CAN ID;
[0034] The sorting sequence number of the CAN message is used as the weight base of the corresponding CAN message;
[0035] The product value of the weight base and the fourth weight coefficient is determined to be the weight value of the corresponding CAN message.
[0036] According to a second aspect of the present disclosure, a message cycle optimization device is provided, comprising:
[0037] An acquiring unit, configured to acquire message information of each CAN message of at least two CAN messages corresponding to a target CAN channel; the message information at least includes a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0038] a screening unit configured to, in response to the presence of at least two CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending in the target CAN channel, screen out target CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending from the CAN messages;
[0039] A division unit, configured to divide at least two target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period;
[0040] The setting unit is used to set the period offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value; wherein, at least two CAN messages in the same CAN message queue have different period offset values.
[0041] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0042] at least one processor; and
[0043] a memory communicatively connected to at least one processor; wherein,
[0044] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of the first aspect.
[0045] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method of the aforementioned first aspect.
[0046] The present disclosure provides a message cycle optimization method, device, electronic device and storage medium. The message cycle optimization method includes: obtaining message information of each CAN message in at least two CAN messages corresponding to a target CAN channel; the message information includes at least the sending / receiving type, sending mode and message cycle of the corresponding CAN message; in response to the presence of at least two CAN messages in the target CAN channel whose sending / receiving type is the sending type and whose sending mode is periodic sending, screening out target CAN messages in the CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending; dividing the at least two target CAN messages into at least one CAN message queue; wherein the message cycles of the CAN messages contained in the same CAN message queue are the same; setting the cycle offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value; wherein the cycle offset values of at least two CAN messages in the same CAN message queue are different.
[0047] According to the solution disclosed in the present invention, the message information of each CAN message in at least two CAN messages corresponding to the target CAN channel is obtained; the message information includes at least the sending / receiving type, sending mode and message period of the corresponding CAN message; it is judged whether the CAN message is a sending type CAN message, and if the CAN message is a sending type CAN message, then it is further judged whether the CAN message is a CAN message sent according to a period; in response to the presence of at least two CAN messages in the target CAN channel whose sending / receiving type is the sending type and whose sending mode is periodic sending, the target CAN messages of the sending type with a periodic sending mode are screened out; the at least two target CAN messages are divided into at least one CAN message queue; wherein, the CAN messages contained in the same CAN message queue have the same message period; for CAN messages with the same message period, the starting sending time in the CAN channel is the same. If there are a large number of CAN messages sent simultaneously in the CAN channel, it will cause congestion in the CAN channel and bring about the problem of inaccurate CAN message period. In the present disclosure, the period offset value of each CAN message in each CAN message queue is set to an integer multiple of a preset offset value. Furthermore, at least two CAN messages in the same CAN message queue have different period offset values. This means that at least two CAN messages in the same CAN message queue have different start transmission times. This can reduce the number of CAN messages sent simultaneously on the CAN channel and address the issue of inaccurate CAN message periods caused by CAN channel congestion.
[0048] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0050] Figure 1 A flow chart of a method for optimizing message cycles according to an embodiment of the present disclosure;
[0051] Figure 2 A flow chart of a method for setting a period offset value for each CAN message provided in an embodiment of the present disclosure;
[0052] Figure 3 A flowchart of a method for obtaining message information of each CAN message provided by an embodiment of the present disclosure;
[0053] Figure 4 A flowchart of a method for determining a PDU ID corresponding to a weight value of a CAN message provided by an embodiment of the present disclosure;
[0054] Figure 5 A flow chart of a method for determining a weight value of a CAN message provided in an embodiment of the present disclosure;
[0055] Figure 6 A flowchart of a message cycle optimization method provided by an application example of the present disclosure;
[0056] Figure 7 A flowchart of another method for optimizing message cycle provided by an application example of the present disclosure;
[0057] Figure 8 A schematic diagram of the structure of the message cycle optimization device provided in an embodiment of the present disclosure;
[0058] Figure 9 A schematic block diagram of an exemplary electronic device provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0059] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0060] An embodiment of the present disclosure provides a message cycle optimization method, which can be applied to a vehicle equipped with a real-time communication system, and the execution subject of the method can be an ECU.
[0061] like Figure 1 As shown, the message cycle optimization method provided by the embodiment of the present disclosure includes the following steps:
[0062] Step 101: Acquire message information of each CAN message of at least two CAN messages corresponding to a target CAN channel; the message information includes at least a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0063] In one embodiment, message information of each CAN message in at least two CAN messages corresponding to the target CAN channel in the plurality of CAN channels is obtained.
[0064] In one embodiment, a CAN channel refers to a physical communication line or logical communication channel in a CAN network. A CAN network includes CAN channels and ECU nodes participating in CAN communication. CAN channels ensure efficient transmission and reception of message information between ECU nodes distributed on the CAN network.
[0065] In one embodiment, CAN messages are used to transmit information between various ECU nodes in a CAN network.
[0066] In one embodiment, the message information of each CAN message may be obtained from a DBC file corresponding to the target CAN channel.
[0067] In one embodiment, a Python program or other interpretive languages may be used to parse the DBC file corresponding to the target CAN channel to obtain the message information of each CAN message.
[0068] In one embodiment, the message information may further include information such as a CAN ID, a cyclic redundancy check (CRC), and an acknowledgment bit (ACK).
[0069] In one embodiment, if there is no CAN message in the CAN channel whose send / receive type is send type and whose sending mode is periodic sending, that is, there is no simultaneous sending message on the CAN channel, then there is no possibility of network congestion on the CAN channel.
[0070] In one embodiment, if there are CAN messages in the CAN channel whose send / receive type is the send type and whose sending mode is periodic sending, and if the message periods of the periodically sent CAN messages are the same, it means that there are CAN messages sent simultaneously on the CAN channel. The more CAN messages sent simultaneously, the more likely it is to cause network congestion.
[0071] Step 102: In response to the presence of at least two CAN messages whose send / receive type is send type and whose sending mode is periodic sending in the target CAN channel, target CAN messages whose send / receive type is send type and whose sending mode is periodic sending in the CAN messages are filtered out;
[0072] In one embodiment, in response to the presence of a CAN message in the target CAN channel whose send / receive type is the send type and whose sending mode is periodic sending, if the period of the periodically sent CAN messages is the same, there is a possibility of network congestion in the CAN channel. Therefore, it is necessary to adjust the sending time of the CAN messages with the same period to alleviate the network congestion.
[0073] In one embodiment, CAN messages whose sending / receiving type is a sending type may be filtered out from the DBC file corresponding to the target CAN channel.
[0074] In one embodiment, the sending / receiving types in all CAN messages are traversed, and CAN messages whose sending / receiving type is the sending type are filtered. Then, all CAN messages whose sending / receiving type is the sending type are traversed, and target CAN messages whose sending mode is periodic sending are filtered.
[0075] Step 103: Divide the at least two target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period;
[0076] In one embodiment, if the message periods in the message information of all CAN messages are the same, all CAN messages are grouped into one CAN message queue.
[0077] In one embodiment, if the message periods in the message information of all CAN messages are not the same, CAN messages with the same message period are grouped into the same CAN message queue to obtain multiple CAN message queues.
[0078] In one embodiment, a target CAN message belongs to only one CAN message queue.
[0079] In one embodiment, a CAN message queue may have one or more target CAN messages.
[0080] Step 104 : setting the period offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value; wherein, in the same CAN message queue, at least two CAN messages have different period offset values.
[0081] In one embodiment, the cycle offset value is used to distinguish the offset steps of the sending start times of different CAN messages in the same cycle.
[0082] In one embodiment, the preset offset value refers to the initial offset step length of the start time of sending different CAN messages in the same cycle.
[0083] In one embodiment, all periodic message transmissions are implemented using the main function sent by the COM module. For example, if the main function period is 10ms and the CAN message period is 50ms, the COM module will have a timer that calls the main function every 50ms to send a CAN message. Therefore, the message transmission period must be an integer multiple of the main function period.
[0084] In one embodiment, there is a main function for sending CAN messages and a main function for receiving CAN messages, that is, the periodic sending and receiving of CAN messages can be achieved through the corresponding main functions.
[0085] In one embodiment, the preset offset value may be determined according to the main function period sent by the COM module. For example, if the main function period is 10 ms, the preset offset value may be 10 ms or 20 ms.
[0086] In one embodiment, the preset offset value may be determined by the number of CAN messages of the same period in the CAN channel;
[0087] Specifically, if there are a large number of CAN messages with the same period in the CAN channel, a smaller preset offset value can be set to make the CAN message sending times as different as possible; if there are a small number of CAN messages with the same period in the CAN channel, a larger preset offset value can be set to ensure that the CAN message sending times are different.
[0088] In one embodiment, the preset offset value may also be determined by a desired sending time interval.
[0089] In one embodiment, the periodic offset value of each CAN message in each CAN message queue is set to an integer multiple of a preset offset value; for example, if there are three CAN messages in a CAN message queue, namely CAN message 1, CAN message 2, and CAN message 3, the periodic offset value of CAN message 1 can be set to 0 times the preset offset value, the periodic offset value of CAN message 2 can be set to 1 times the preset offset value, and the periodic offset value of CAN message 3 can be set to 2 times the preset offset value; when the periodic offset value of a CAN message is greater than the message period of the CAN message, the periodic offset value of the CAN message is reset to 0 times the preset offset value.
[0090] In one embodiment, the period offset values of different CAN messages in the same CAN message queue may be the same or different.
[0091] In one embodiment, the period offset values of CAN messages in different CAN message queues may be the same or different.
[0092] In one embodiment, if Figure 2 As shown, step 104 includes:
[0093] Step 201, traverse each CAN message in the current CAN message queue, and set the offset base of the current CAN message to the sum of the preset offset base and the traversal order according to the traversal order of the current CAN message;
[0094] In one embodiment, the preset offset base refers to an initial value of the aforementioned integer multiple, such as setting the preset offset base to 0 or other positive integers.
[0095] In one embodiment, the offset base of the current CAN message is set to the sum of the preset offset base and the traversal order. For example, if message 1 is the first CAN message in the current CAN message queue and the preset offset base is 0, the offset base of the current CAN message is set to the sum of 0 and 1, that is, the offset base of the current CAN message is 1.
[0096] Step 202, determining whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value;
[0097] In one embodiment, it is determined whether the offset base of the current CAN message is greater than the product of the ratio of the message period corresponding to the current CAN message queue to the preset offset value and the preset coefficient.
[0098] In one embodiment, the preset coefficient may be any non-zero positive number.
[0099] In one embodiment, determining whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value is to avoid the problem of transmission delay caused by the period offset value of the current CAN message exceeding the period of the CAN message.
[0100] Step 203: If the result of the judgment is yes, the offset base of the current CAN message is reset to the preset offset base;
[0101] In one embodiment, when the period offset value of a CAN message exceeds the message period of the CAN message, the offset base of the current CAN message is reset to a preset offset base. If the preset offset base is 0, the period offset value of the current CAN message is 0, i.e., the period of the current CAN message remains unchanged, and there are at least two CAN messages in the current CAN message queue with the same transmission time.
[0102] Step 204: Set the periodic offset value of the current CAN message to an offset base multiple of the preset offset value.
[0103] In one embodiment, the periodic offset value of each CAN message in the current CAN message queue is set to a corresponding offset base multiple of the preset offset value.
[0104] In one embodiment, in the current CAN message queue, at least two CAN messages have different period offset values.
[0105] In one embodiment, in the current CAN message queue, there may be multiple CAN messages with the same sending time.
[0106] In one embodiment, the periodic offset value of each CAN message in the CAN message queue is set to a corresponding offset base multiple of a preset offset value. The preset offset values in the CAN message queue may be the same or different.
[0107] In one embodiment, after step 103, the message cycle optimization method further includes:
[0108] Calculate the median value of the message period corresponding to the CAN message queue;
[0109] In one embodiment, the message periods corresponding to the CAN message queues are obtained, the message periods are sorted from small to large, and the median value of the message periods is determined.
[0110] Filter out target CAN message queues whose message period is greater than the median value from the CAN message queues;
[0111] In one embodiment, the target CAN message queue is a CAN message queue whose message period of CAN messages is greater than a median value.
[0112] In one embodiment, the message periods of the CAN messages in each CAN message queue in the CAN message queue are the same or different.
[0113] The periodic offset value of each CAN message in each CAN message queue is set to an integer multiple of the preset offset value, including:
[0114] The periodic offset value of each CAN message in each target CAN message queue is set to an integer multiple of the preset offset value.
[0115] In one embodiment, at least two target CAN messages in the same target CAN message queue have different period offset values.
[0116] In one embodiment, target CAN messages in the same target CAN message queue may have the same period offset value.
[0117] In one embodiment, if Figure 3 As shown, step 101 includes:
[0118] Step 301, obtaining a target DBC file corresponding to a target CAN channel;
[0119] In one embodiment, a large controller may include multiple CAN channels, and information such as the CAN channels is recorded in corresponding DBC files, so there may be multiple DBC files at the same time.
[0120] In one embodiment, a target DBC file corresponding to each target CAN channel among a plurality of target CAN channels is obtained.
[0121] Step 302: Parse the target DBC file to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel.
[0122] In one embodiment, the target DBC file may be parsed using Python or other interpretive languages to obtain the message information of each CAN message in at least one CAN message corresponding to the target CAN channel.
[0123] In one embodiment, the message information further includes a CAN ID of the corresponding CAN message;
[0124] In one embodiment, the CAN ID of the CAN message is used to identify the messages in each CAN message in the CAN channel and to determine which ECU nodes should receive and respond to the messages contained in these CAN messages.
[0125] In one embodiment, the sending / receiving type of the CAN message is used to indicate whether the current CAN message is of the sending type or the receiving type.
[0126] In one embodiment, the CAN message sending mode includes a periodic sending mode, a mixed sending mode and an event sending mode.
[0127] In one embodiment, the message period of a CAN message refers to the time interval between the start of sending a CAN message and the next sending of the CAN message in a CAN channel.
[0128] In one embodiment, if Figure 4 As shown, after step 101, the message cycle optimization method further includes:
[0129] Step 401, obtaining a weight base and a weight coefficient corresponding to the sending / receiving type, sending mode and message period of each CAN message;
[0130] In one embodiment, the weight base of the sending type of the CAN message is used to measure the proportion of the sending type of the CAN message in the sending / receiving type, such as the weight base of the sending type of the CAN message is 2.
[0131] In one embodiment, the weight base of the reception type of the CAN message is used to measure the proportion of the reception type of the CAN message in the transmission / reception type, such as the weight base of the reception type of the CAN message is 1.
[0132] In one embodiment, the weight coefficient of the sending / receiving type of the CAN message is used to measure the proportion of the sending / receiving type of the CAN message in the CAN message information, such as the weight coefficient of the sending / receiving type of the CAN message is 10000.
[0133] In one embodiment, the weight base of the periodic sending mode in the sending mode of CAN messages is used to measure the proportion of the periodic sending mode in all sending modes, the weight base of the mixed sending mode in the sending mode of CAN messages is used to measure the proportion of the mixed sending mode in all sending modes, and the weight base of the event sending mode in the sending mode of CAN messages is used to measure the proportion of the event sending mode in all sending modes; for example, the weight base of the periodic sending mode in the sending mode of CAN messages is 3, the weight base of the mixed sending mode in the sending mode of CAN messages is 2, and the weight base of the event sending mode in the sending mode of CAN messages is 1.
[0134] In one embodiment, the weight coefficient of the CAN message sending mode is used to measure the proportion of the CAN message sending mode in the CAN message information, for example, the weight coefficient of the CAN message sending mode is 1000.
[0135] In one embodiment, the weight base of the message period of the CAN message is used to measure the proportion of the CAN message in all messages. For example, the CAN messages can be sorted from small to large according to the message period, and the sorting sequence number is used as the weight base of the corresponding message period.
[0136] In one embodiment, the weight coefficient of the message period of the CAN message is used to measure the proportion of the message period of the CAN message in the CAN message information. For example, the weight coefficient of the message period of the CAN message is 100.
[0137] Step 402, determining the product of the weight base and the weight coefficient as the weight value of the corresponding CAN message;
[0138] In one embodiment, if the message information of a CAN message includes only one of the sending / receiving type, sending mode and message period, the product value of the corresponding weight base and weight coefficient in the CAN message information can be determined as the weight value of the corresponding CAN message.
[0139] In one embodiment, if the message information of a CAN message includes the sending / receiving type, sending mode and message period at the same time, the sum of the product values of the weight base and weight coefficient corresponding to the sending / receiving type, sending mode and message period can be determined as the weight value of the corresponding CAN message.
[0140] Step 403: Determine the PDU ID corresponding to the weight value of the CAN message according to the preset mapping relationship between the weight value and the PDU ID.
[0141] In one embodiment, the default PDU ID in the AUTOSAR architecture is a PDU ID assigned with the first letter of the name of the corresponding CAN message.
[0142] In one embodiment, the PDU ID is a unique identifier for identifying a CAN message in the AUTOSAR architecture.
[0143] In one embodiment, the PDU ID is an integer starting from 0.
[0144] In one embodiment, the values of the PDU IDs are all different.
[0145] In one embodiment, the mapping relationship between the preset weight value and the PDU ID may be embodied in the form of a mapping relationship table or in the form of a mapping relationship array.
[0146] In one embodiment, if there are five CAN messages with weight values of 100, 90, 80, 70, and 60 respectively, the CAN message with the largest weight is assigned the smallest PDU ID value, which can be 0 or other positive integers, that is, the other CAN messages are assigned PDU ID values by incrementing 1 in descending order of weight value.
[0147] In one embodiment, according to a preset mapping relationship between weight values and PDU IDs, a PDU ID corresponding to the weight value of each CAN message is screened out.
[0148] In one embodiment, if the weight values of CAN messages are the same, the default PDU ID is used for the weight assignment. Typically, the weight coefficients corresponding to the send / receive type, send mode, and message period of CAN messages are not of the same order of magnitude, so the probability of CAN messages having the same weight values is low.
[0149] In one embodiment, PDU IDs may be assigned to CAN messages in multiple CAN channels simultaneously.
[0150] In one embodiment, the sending / receiving type of the CAN message includes a sending type and a receiving type; wherein the first weight coefficients of the sending type and the receiving type of the CAN message are the same, and the weight base of the sending type of the CAN message is greater than the weight base of the receiving type of the CAN message;
[0151] In one embodiment, the weight base of the sending type CAN message is greater than the weight base of the receiving type CAN message, which means that the proportion of the sending type CAN message in the sending / receiving type of CAN messages is greater than the proportion of the receiving type CAN message in the sending / receiving type of CAN messages.
[0152] In one embodiment, the CAN message transmission mode includes a periodic transmission mode, an event transmission mode, and a mixed transmission mode; wherein the second weight coefficients of the CAN messages in the periodic transmission mode, the event transmission mode, and the mixed transmission mode are the same, and the second weight coefficient is less than the first weight coefficient; the weight base of the CAN message in the periodic transmission mode is greater than the weight base of the CAN message in the mixed transmission mode; the weight base of the CAN message in the mixed transmission mode is greater than the weight base of the CAN message in the event transmission mode;
[0153] In one embodiment, the periodic transmission mode refers to sending CAN messages according to a fixed period.
[0154] In one embodiment, the event sending mode means that a CAN message is sent only when an event occurs.
[0155] In one embodiment, the mixed sending mode means that CAN messages are usually sent according to a fixed period, but when a specific event occurs, CAN messages are also sent, and then messages are continued to be sent according to the fixed period.
[0156] In one embodiment, the second weight coefficient being smaller than the first weight coefficient means that the proportion of the CAN message sending mode in the CAN message information is smaller than the proportion of the CAN message sending / receiving type in the CAN message information.
[0157] In one embodiment, if the CAN message is sent in a periodic sending mode or a mixed sending mode, the third weight coefficient corresponding to the message period of the CAN message is smaller than the second weight coefficient.
[0158] In one embodiment, if the CAN message is sent in a hybrid mode, the time when the event triggers the sending of the CAN message is ignored, that is, when the CAN message is sent in a hybrid mode, the message period of the CAN message is the periodic sending time in the hybrid mode.
[0159] In one embodiment, the third weight coefficient corresponding to the message period of the CAN message is less than the second weight coefficient, which means that the proportion of the CAN message sending mode being a periodic sending mode or a mixed sending mode in the CAN message information is less than the proportion of the CAN message sending mode in the CAN message information.
[0160] In one embodiment, if Figure 5 As shown, step 402 includes:
[0161] Step 501: If the CAN message includes multiple CAN messages with the same message period, then:
[0162] Sort multiple CAN messages with the same message period from large to small according to the size of CAN ID;
[0163] In one embodiment, the multiple CAN messages with the same message period include CAN messages sent in a periodic manner or a mixed manner.
[0164] In one embodiment, if there are 10 CAN messages with a message period of 10 ms, these 10 CAN messages are sorted from large to small according to the size of the CAN ID; if there are 5 CAN messages with a message period of 20 ms, these 5 CAN messages are also sorted from large to small according to the size of the CAN ID.
[0165] Step 502: Using the sorting number of the CAN message as the weight base of the corresponding CAN message;
[0166] In one embodiment, as mentioned above, there are 10 CAN messages with a message period of 10ms. These 10 CAN messages are sorted from large to small according to the size of the CAN ID. The CAN message with the largest CAN ID is sorted with a sequence number of 1, and 1 is used as the weight base of the CAN message. The CAN message with the smallest CAN ID is sorted with a sequence number of 10, and 10 is used as the weight base of the CAN message.
[0167] Step 503: Determine the product value of the weight base and the fourth weight coefficient as the weight value of the corresponding CAN message.
[0168] In one embodiment, the fourth weight coefficient refers to the proportion of the CAN ID of the CAN message in the message information of the CAN message.
[0169] In one embodiment, a product value of a weight base and a fourth weight coefficient corresponding to each CAN message among a plurality of CAN messages with the same message period is determined as the weight value of the corresponding CAN message.
[0170] The message period optimization method provided by the embodiment of the present disclosure includes: obtaining message information of each CAN message in at least two CAN messages corresponding to a target CAN channel; the message information includes at least the sending / receiving type, the sending mode and the message period of the corresponding CAN message; in response to the presence of at least two CAN messages in the target CAN channel whose sending / receiving type is the sending type and whose sending mode is periodic sending, screening out target CAN messages in the CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending; dividing the at least two target CAN messages into at least one CAN message queue; wherein, the message periods of the CAN messages contained in the same CAN message queue are the same; setting the period offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value; wherein, the period offset values of at least two CAN messages in the same CAN message queue are different.
[0171] According to the solution of this disclosure:
[0172] First, by obtaining the message information of each CAN message in at least two CAN messages corresponding to the target CAN channel; the message information at least includes the sending / receiving type, sending mode and message period of the corresponding CAN message; in response to the presence of at least two CAN messages in the target CAN channel whose sending / receiving type is the sending type and whose sending mode is periodic sending, it is judged whether the CAN message is a CAN message of the sending type, and if the CAN message is a CAN message of the sending type, then it is continued to be judged whether the CAN message is a CAN message sent according to the period; the target CAN messages of the sending type with the periodic sending mode are screened out; the at least two target CAN messages are divided into at least one CAN message queue; wherein, the message period of the CAN messages contained in the same CAN message queue is the same; for CAN messages with the same message period, the starting sending time in the CAN channel is the same. If there are a large number of CAN messages sent simultaneously in the CAN channel, it will cause congestion in the CAN channel and bring about the problem of inaccurate CAN message period. In the present disclosure, the period offset value of each CAN message in each CAN message queue is set to an integer multiple of a preset offset value. Furthermore, at least two CAN messages in the same CAN message queue have different period offset values. This means that at least two CAN messages in the same CAN message queue have different start transmission times. This can reduce the number of CAN messages sent simultaneously on the CAN channel and address the issue of inaccurate CAN message periods caused by CAN channel congestion.
[0173] Secondly, it is determined whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value, effectively avoiding the problem of reduced real-time performance of the control system caused by the period offset value of the current CAN message exceeding the period of the CAN message.
[0174] Next, based on the mapping relationship between the preset weight values and PDU IDs, the PDU ID corresponding to the CAN message weight value is determined. Sorting the PDU IDs helps the COM module quickly process CAN message transmission. The COM module processes CAN messages with smaller PDU IDs first, which speeds up the operating system's processing time and enables the driver layer to send CAN messages that need to be sent first, thus optimizing the CAN message cycle to a certain extent.
[0175] The message cycle optimization method disclosed in the present disclosure is further illustrated below with reference to specific application examples.
[0176] Figure 6 A flow chart of a message cycle optimization method provided for an application example of the present disclosure is shown as follows: Figure 6 As shown, the message cycle optimization method provided by the application example of the present disclosure includes the following steps:
[0177] Step 601, obtaining a target DBC file corresponding to a target CAN channel;
[0178] Step 602 , importing the target DBC file corresponding to the target CAN channel into the AUTOSAR tool chain to generate an ARXML file for generating specific code;
[0179] In one embodiment, the tool chain may be a DaVinci tool, an EB Tresos Studio tool, or other tools capable of generating code compliant with AUTOSAR specifications.
[0180] Step 603: Parse the target DBC file corresponding to the target CAN channel to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel;
[0181] In one embodiment, the execution order of step 602 and step 603 can be adjusted, which is not limited in this disclosure.
[0182] Step 604: Acquire message information of each of the at least two CAN messages corresponding to the target CAN channel; the message information includes at least a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0183] Step 605: In response to the presence of at least two CAN messages whose send / receive type is send type and whose sending mode is periodic sending in the target CAN channel, target CAN messages whose send / receive type is send type and whose sending mode is periodic sending in the CAN messages are filtered out;
[0184] Step 606: Divide the at least two target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period;
[0185] Step 607, calculating the median value of the message period corresponding to at least one CAN message queue;
[0186] Step 608: traverse the message cycles corresponding to at least one CAN message queue to obtain the message cycle corresponding to the current CAN message queue;
[0187] Step 609: Whether the message period corresponding to the current CAN message queue is greater than the median value of the message period corresponding to the CAN message queue;
[0188] If the judgment result is yes, then go to step 610;
[0189] If the judgment result is no, return to step 608;
[0190] Step 610, traverse each CAN message in the current CAN message queue, and set the offset base of the current CAN message to the sum of the preset offset base and the traversal order according to the traversal order of the current CAN message;
[0191] Step 611: Whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value;
[0192] If the judgment result is yes, then go to step 612;
[0193] If the judgment result is no, return to step 610;
[0194] Step 612, reset the offset base of the current CAN message to a preset offset base;
[0195] Step 613, setting the periodic offset value of the current CAN message to an offset base multiple of a preset offset value;
[0196] Step 614: Check whether all CAN messages in the current CAN message queue have been traversed.
[0197] If the judgment result is yes, then go to step 615;
[0198] If the judgment result is no, return to step 610;
[0199] Step 615: Check whether all CAN messages in all CAN message queues have been traversed.
[0200] If the judgment result is yes, then go to step 616;
[0201] If the judgment result is no, return to step 608;
[0202] Step 616, modify the periodic offset value of the CAN message into the ARXML file;
[0203] Step 617: Generate code using the AUTOSAR tool chain, integrate and compile the generated code, and download it to the controller to test and verify the function.
[0204] Figure 7 A flow chart of another method for optimizing message cycle provided by the application example of the present disclosure is as follows: Figure 7 As shown, the message cycle optimization method provided by the application example of the present disclosure includes the following steps:
[0205] Step 701, obtaining a target DBC file corresponding to a target CAN channel;
[0206] Step 702 , importing the target DBC file corresponding to the target CAN channel into the AUTOSAR tool chain to generate an ARXML file for generating specific code;
[0207] Step 703: Parse the target DBC file corresponding to the target CAN channel to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel;
[0208] In one embodiment, the execution order of step 702 and step 703 can be adjusted, which is not limited in this disclosure.
[0209] Step 704: Acquire message information of each CAN message of at least two CAN messages corresponding to the target CAN channel; the message information includes at least a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0210] Step 705: Obtain a weight base and a weight coefficient corresponding to a sending / receiving type of each CAN message, where the sending / receiving type of the CAN message includes a sending type and a receiving type; wherein the first weight coefficients of the sending type and the receiving type of the CAN message are the same, and the weight base of the sending type CAN message is greater than the weight base of the receiving type CAN message;
[0211] Step 706: Obtain a weight base and a weight coefficient corresponding to a transmission mode of each CAN message. The transmission modes of CAN messages include a periodic transmission mode, an event transmission mode, and a mixed transmission mode. The second weight coefficients of the CAN messages in the periodic transmission mode, the event transmission mode, and the mixed transmission mode are the same, and the second weight coefficient is less than the first weight coefficient. The weight base of the CAN message in the periodic transmission mode is greater than the weight base of the CAN message in the mixed transmission mode. The weight base of the CAN message in the mixed transmission mode is greater than the weight base of the CAN message in the event transmission mode.
[0212] Step 707: If the sending mode of the CAN message is a periodic sending mode or a mixed sending mode, the third weight coefficient corresponding to the message period of the CAN message is smaller than the second weight coefficient.
[0213] Step 708: If the CAN messages include multiple CAN messages with the same message period, then: sort the multiple CAN messages with the same message period from largest to smallest according to the size of the CAN ID; use the sorting sequence number of the CAN message as the weight base of the corresponding CAN message, and the fourth weight coefficient of the multiple CAN messages with the same message period is the same;
[0214] Step 709, determining the product of the weight base and the weight coefficient as the weight value of the corresponding CAN message;
[0215] Step 710: Determine the PDU ID corresponding to the weight value of the CAN message according to the preset mapping relationship between the weight value and the PDU ID.
[0216] Step 711, modify the PDU ID of the current CAN message into the ARXML file;
[0217] Step 712: Generate code using the AUTOSAR tool chain, integrate and compile the generated code, and download it to the controller to test and verify the function.
[0218] Corresponding to the above-mentioned message cycle optimization method, the present invention also provides a message cycle optimization device. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment and will not be repeated in the present invention.
[0219] Figure 8 A schematic diagram of the structure of a message cycle optimization device provided by an embodiment of the present disclosure, such as Figure 8 As shown, the message cycle optimization device 800 includes:
[0220] An acquiring unit 801 is configured to acquire message information of each CAN message of at least two CAN messages corresponding to a target CAN channel; the message information includes at least a sending / receiving type, a sending mode, and a message period of the corresponding CAN message;
[0221] a screening unit 802 configured to, in response to the presence of at least two CAN messages whose send / receive type is the send type and whose sending mode is periodic sending in the target CAN channel, screen out target CAN messages whose send / receive type is the send type and whose sending mode is periodic sending from the CAN messages;
[0222] The dividing unit 803 is configured to divide the at least two target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period;
[0223] The setting unit 804 is configured to set the period offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value; wherein, at least two CAN messages in the same CAN message queue have different period offset values.
[0224] In one embodiment, the setting unit 804 is specifically configured to:
[0225] Traverse each CAN message in the current CAN message queue, and set the offset base of the current CAN message to the sum of the preset offset base and the traversal order according to the traversal order of the current CAN message;
[0226] Determine whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value;
[0227] If the judgment result is yes, reset the offset base of the current CAN message to the preset offset base;
[0228] The periodic offset value of the current CAN message is set to the offset base multiple of the preset offset value.
[0229] In one embodiment, the message cycle optimization device 800 further includes a message screening unit, which is configured to:
[0230] Calculate the median value of the message period corresponding to the CAN message queue;
[0231] Filter out target CAN message queues whose message period is greater than the median value from the CAN message queues;
[0232] Accordingly, the setting unit 804 is specifically configured to:
[0233] The periodic offset value of each CAN message in each target CAN message queue is set to an integer multiple of the preset offset value.
[0234] In one embodiment, the acquiring unit 801 is specifically configured to:
[0235] Get the target DBC file corresponding to the target CAN channel;
[0236] Parse the target DBC file to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel.
[0237] In one embodiment, the message information further includes a CAN ID of the corresponding CAN message;
[0238] In one embodiment, the message period optimization device 800 further includes a PDU ID determination unit, which is configured to:
[0239] Obtain the weight base and weight coefficient corresponding to the sending / receiving type, sending mode and message period of each CAN message;
[0240] Determine that the product value of the weight base and the weight coefficient is the weight value of the corresponding CAN message;
[0241] According to the preset mapping relationship between the weight value and the PDU ID, the PDU ID corresponding to the weight value of the CAN message is determined.
[0242] In one embodiment, the sending / receiving type of the CAN message includes a sending type and a receiving type; wherein the first weight coefficients of the sending type and the receiving type of the CAN message are the same, and the weight base of the sending type of the CAN message is greater than the weight base of the receiving type of the CAN message;
[0243] The CAN message transmission mode includes a periodic transmission mode, an event transmission mode, and a mixed transmission mode; wherein the second weight coefficients of the CAN messages in the periodic transmission mode, the event transmission mode, and the mixed transmission mode are the same, and the second weight coefficient is less than the first weight coefficient; the weight base of the CAN message in the periodic transmission mode is greater than the weight base of the CAN message in the mixed transmission mode; the weight base of the CAN message in the mixed transmission mode is greater than the weight base of the CAN message in the event transmission mode;
[0244] If the sending mode of the CAN message is a periodic sending mode or a mixed sending mode, the third weight coefficient corresponding to the message period of the CAN message is smaller than the second weight coefficient.
[0245] In one embodiment, the PDU ID determining unit is further configured to:
[0246] If a CAN message includes multiple CAN messages with the same message period, then:
[0247] Sort multiple CAN messages with the same message period from large to small according to the size of CAN ID;
[0248] The sorting sequence number of the CAN message is used as the weight base of the corresponding CAN message;
[0249] The product value of the weight base and the fourth weight coefficient is determined to be the weight value of the corresponding CAN message.
[0250] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principles are the same, which is not limited in this embodiment.
[0251] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device and a non-transitory computer-readable storage medium storing computer instructions.
[0252] Specifically, an embodiment of the present disclosure provides an electronic device, including:
[0253] at least one processor; and
[0254] a memory communicatively connected to at least one processor; wherein,
[0255] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the aforementioned message cycle optimization method.
[0256] An embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the steps of the aforementioned message cycle optimization method.
[0257] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, in-vehicle devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0258] like Figure 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 902 or a computer program loaded from a storage unit 908 into a RAM (Random Access Memory) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An I / O (Input / Output) interface 905 is also connected to the bus 904.
[0259] Various components in the device 900 are connected to the I / O interface 905, including an input unit 904, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a magnetic disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0260] The computing unit 901 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Unit), various specialized AI (Artificial Intelligence) computing chips, various computing units that run machine learning model algorithms, a DSP (Digital Signal Processor), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as the message cycle optimization method. For example, in some embodiments, the message cycle optimization method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the method described above can be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute the aforementioned message cycle optimization method in any other appropriate manner (for example, by means of firmware).
[0261] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System on Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0262] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0263] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0264] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.
[0265] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A message cycle optimization method, characterized in that: include: Obtaining message information of each CAN message of at least two CAN messages corresponding to a target CAN channel; The message information includes at least the sending / receiving type, sending mode and message period of the corresponding CAN message; In response to the presence of at least two CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending in the target CAN channel, the target CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending are selected; Dividing at least two of the target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period; The periodic offset value of each CAN message in each of the CAN message queues is set to an integer multiple of a preset offset value; wherein, the periodic offset values of at least two CAN messages in the same CAN message queue are different.
2. The method according to claim 1, characterized in that The step of setting the periodic offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value includes: Traversing each of the CAN messages in the current CAN message queue, and setting the offset base of the current CAN message to the sum of a preset offset base and the traversal order according to the traversal order of the current CAN message; Determine whether the offset base of the current CAN message is greater than the ratio of the message period corresponding to the current CAN message queue to the preset offset value; If the judgment result is yes, reset the offset base of the current CAN message to the preset offset base; The periodic offset value of the current CAN message is set to the offset base multiple of the preset offset value.
3. The method according to claim 1, characterized in that After dividing the at least two target CAN messages into at least one CAN message queue, the method further includes: Calculating the median value of the message period corresponding to the CAN message queue; Filtering out a target CAN message queue whose message period is greater than the median value from the CAN message queue; The step of setting the periodic offset value of each CAN message in each CAN message queue to an integer multiple of a preset offset value includes: The periodic offset value of each CAN message in each target CAN message queue is set to an integer multiple of a preset offset value.
4. The method according to claim 1, wherein The acquiring message information of each CAN message of at least two CAN messages corresponding to the target CAN channel includes: Obtain a target DBC file corresponding to the target CAN channel; The target DBC file is parsed to obtain message information of each CAN message in at least two CAN messages corresponding to the target CAN channel.
5. The method according to claim 1, wherein The message information also includes the CANID of the corresponding CAN message; After acquiring the message information of each CAN message in at least two CAN messages corresponding to the target CAN channel, the method further includes: Obtaining a weight base and a weight coefficient corresponding to the sending / receiving type, the sending mode, and the message period of each of the CAN messages; Determine a product value of the weight base and the weight coefficient as the weight value of the corresponding CAN message; According to the mapping relationship between the preset weight value and the PDUID, the PDUID corresponding to the weight value of the CAN message is determined.
6. The method according to claim 5, characterized in that The sending / receiving type of the CAN message includes a sending type and a receiving type; wherein the first weight coefficients of the CAN messages of the sending type and the receiving type are the same, and the weight base of the CAN message of the sending type is greater than the weight base of the CAN message of the receiving type; The sending mode of the CAN message includes a periodic sending mode, an event sending mode and a mixed sending mode; wherein the second weight coefficients of the CAN messages in the periodic sending mode, the event sending mode and the mixed sending mode are the same, and the second weight coefficient is less than the first weight coefficient; the weight base of the CAN message in the periodic sending mode is greater than the weight base of the CAN message in the mixed sending mode; the weight base of the CAN message in the mixed sending mode is greater than the weight base of the CAN message in the event sending mode; If the sending mode of the CAN message is a periodic sending mode or a mixed sending mode, the third weight coefficient corresponding to the message period of the CAN message is smaller than the second weight coefficient.
7. The method according to claim 6, characterized in that Determining the product value of the weight base and the weight coefficient as the weight value of the corresponding CAN message includes: If the CAN message includes multiple CAN messages with the same message period, then: Sort multiple CAN messages with the same message period from large to small according to the size of the CAN ID; Using the sorting sequence number of the CAN message as the weight base of the corresponding CAN message; Determine a product value of the weight base and the fourth weight coefficient as the weight value of the corresponding CAN message.
8. A message cycle optimization device, characterized in that: include: an acquiring unit, configured to acquire message information of each CAN message of at least two CAN messages corresponding to a target CAN channel; The message information includes at least the sending / receiving type, sending mode and message period of the corresponding CAN message; a screening unit configured to, in response to the presence of at least two CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending in the target CAN channel, screen out target CAN messages whose sending / receiving type is the sending type and whose sending mode is periodic sending from the CAN messages; A dividing unit, configured to divide at least two of the target CAN messages into at least one CAN message queue; wherein the CAN messages contained in the same CAN message queue have the same message period; The setting unit is used to set the period offset value of each CAN message in each of the CAN message queues to an integer multiple of a preset offset value; wherein, the period offset values of at least two CAN messages in the same CAN message queue are different.
9. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.