CAN message scheduling method and device, electronic equipment and computer program product

By dynamically adjusting the sending time and task scheduling of CAN messages, the problems of uneven sending messages and network congestion in traditional methods are solved, and the balanced sending of messages is achieved and the real-time and reliability of the system is improved.

CN119892547APending Publication Date: 2025-04-25BEIJING AUTOMOBILE RES GENERAL INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411862533.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The traditional CAN message scheduling method has problems such as uneven message sending time and network congestion, which affects the real-time and stability of the system.

Method used

By dynamically adjusting the message sending time and task scheduling, obtaining the number of messages processed at the time point in the schedule table during the sending cycle and during the task period, determining the target message sending offset value and target task scheduling offset value, and generating scheduling results to achieve balanced sending of messages.

Benefits of technology

It realizes the equalized transmission of packets, avoids network congestion and communication delay, and improves the real-time and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892547A_ABST
    Figure CN119892547A_ABST
Patent Text Reader

Abstract

The invention relates to a CAN message scheduling method and device, electronic equipment and a computer program product. The CAN message scheduling method comprises the steps that the number of messages processed at a time point in a scheduling table corresponding to any time point in a sending period of a current CAN message and the number of messages processed at a time point in a scheduling table corresponding to any time point in a task period of the current CAN message are acquired; determining a target message sending offset value according to the number of messages processed at the time point in the scheduling table corresponding to any time point in the sending period of the current CAN message, and determining a target task scheduling offset value according to the number of messages processed at the time point in the scheduling table corresponding to any time point in the task period of the current CAN message; and generating a scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value. Therefore, the problems of non-uniform message sending time, network congestion and the like of a traditional CAN message scheduling method are solved, balanced sending of messages is realized, and the real-time performance and reliability of a system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a CAN message scheduling method, device, electronic device and computer program product. Background Art

[0002] As the functions of automotive electronic systems continue to increase, the application of CAN (Controller Area Network) networks is becoming more and more widespread. CAN networks allow multiple electronic control units (ECUs) to transmit data through a shared bus, ensuring real-time communication between control units. However, with the rapid increase in the number and types of messages, the CAN bus is prone to problems such as overload, communication delay and packet loss, which seriously affect the real-time performance and stability of the system.

[0003] Traditional CAN message scheduling methods usually use simple polling or fixed time interval transmission methods, which cannot dynamically adjust the message transmission time to cope with complex communication needs. This method is prone to multiple messages being sent at a certain time point when processing a large number of messages, causing network congestion. Therefore, there is an urgent need for a scheduling method that can optimize the message transmission time to balance the network load and ensure that the number of messages processed at each time point remains within an acceptable range, thereby improving the overall performance of the system. Summary of the invention

[0004] The present application provides a CAN message scheduling method, device, electronic device and computer program product to solve the problems of uneven message sending time and network congestion in the traditional CAN message scheduling method. By dynamically adjusting the message sending time and task scheduling, balanced message sending is achieved, network congestion and communication delay are avoided, and the real-time performance and reliability of the system are improved.

[0005] The first aspect of the present application provides a CAN message scheduling method, comprising the following steps: obtaining the number of messages processed at a time point in a scheduling table corresponding to any time point in a sending cycle of a current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in a task cycle of the current CAN message; determining a target message sending offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and determining a target task scheduling offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; generating a scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value.

[0006] Optionally, the current CAN message has a message sending offset, and determining the target message sending offset value based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message includes: judging whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to a first preset value; if the number of messages in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, then using the current message sending offset value of the current CAN message as the target message sending offset value.

[0007] Optionally, after determining whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, it includes: if the number of messages at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is less than the first preset value, then increasing the current message sending offset value of the current CAN message according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, thereby obtaining the target message sending offset value.

[0008] Optionally, there is a task scheduling offset for the current CAN message, and the target task scheduling offset value is determined based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message, including: judging whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to a second preset value; if the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, then the current task scheduling offset of the current CAN message is used as the target task scheduling offset value; otherwise, the current task scheduling offset value of the current CAN message is increased according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, thereby obtaining the target message sending offset value.

[0009] Optionally, after generating the scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value, it includes: based on a preset visualization tool, generating a relationship graph between the sending cycle and the target message sending offset value, a relationship graph between the task cycle and the target task scheduling offset value, and a graph of the number of messages processed at each time point.

[0010] Optionally, after taking the current message sending offset value of the current CAN message as the target message sending offset value, the method includes: adding the current CAN message to the message processed at the time point in the scheduling table corresponding to the target message sending offset value.

[0011] The second aspect of the present application provides a CAN message scheduling device, including: an acquisition module, used to obtain the number of messages processed at a time point in the scheduling table corresponding to any time point in a sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in a task cycle of the current CAN message; a determination module, used to determine a target message sending offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and determine a target task scheduling offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; a scheduling module, used to generate a scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value.

[0012] Optionally, the determination module is also used to: determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to a first preset value; if the number of messages in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, then the current message sending offset value of the current CAN message is used as the target message sending offset value.

[0013] Optionally, after determining whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, the determination module is also used to: if the number of messages at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is less than the first preset value, then increase the current message sending offset value of the current CAN message according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, thereby obtaining the target message sending offset value.

[0014] Optionally, there is a task scheduling offset for the current CAN message, and the target task scheduling offset value is determined based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message. The determination module is also used to: determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to a second preset value; if the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, then the current task scheduling offset of the current CAN message is used as the target task scheduling offset value; otherwise, the current task scheduling offset value of the current CAN message is increased according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, thereby obtaining the target message sending offset value.

[0015] Optionally, after generating the scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value, the scheduling module is also used to: generate a relationship diagram between the sending cycle and the target message sending offset value, a relationship diagram between the task cycle and the target task scheduling offset value, and a diagram of the number of messages processed at each time point based on a preset visualization tool.

[0016] Optionally, when using the current message sending offset value of the current CAN message as the target message sending offset value, the determination module is further used to: add the current CAN message to the message processed at the time point in the scheduling table corresponding to the target message sending offset value.

[0017] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the CAN message scheduling method as described in the above embodiment.

[0018] A fourth aspect of the present application provides a computer program product, which includes a computer program, which is executed by a processor to implement the CAN message scheduling method as described in the above embodiment.

[0019] In the above implementation, the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message are obtained, the target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, the target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message, and the scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value. Thus, the problems of uneven message sending time and network congestion existing in the traditional CAN message scheduling method are solved, and the balanced sending of messages is achieved by dynamically adjusting the message sending time and task scheduling, avoiding network congestion and communication delay, and improving the real-time performance and reliability of the system.

[0020] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0022] Figure 1 A flowchart of a CAN message scheduling method provided according to an embodiment of the present application;

[0023] Figure 2 This is a flow chart of a CAN message scheduling method according to an embodiment of the present application;

[0024] Figure 3 A schematic diagram of importing data and initializing parameters according to an embodiment of the present application;

[0025] Figure 4 A schematic diagram of reading CAN message data according to an embodiment of the present application;

[0026] Figure 5 A schematic diagram of a scheduling scatter point according to an embodiment of the present application;

[0027] Figure 6 This is a schematic diagram of an interface of a tool according to an embodiment of the present application;

[0028] Figure 7 is a schematic diagram of a scheduling result according to an embodiment of the present application;

[0029] Figure 8 Schematic diagram of a CAN message scheduling device according to an embodiment of the present application;

[0030] Fig. 9 Schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0031] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0032] The following describes the CAN message scheduling method, device, electronic device and computer program product of the embodiment of the present application with reference to the accompanying drawings. In view of the problems of uneven message sending time and network congestion existing in the traditional CAN message scheduling method mentioned in the above background technology, the present application provides a CAN message scheduling method, in which the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message are obtained, and the target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and the target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message, and the scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value. Thus, the problems of uneven message sending time and network congestion existing in the traditional CAN message scheduling method are solved, and the balanced sending of messages is achieved by dynamically adjusting the message sending time and task scheduling, avoiding network congestion and communication delay, and improving the real-time performance and reliability of the system.

[0033] Specifically, Figure 1 A flow chart of a CAN message scheduling method provided in an embodiment of the present application.

[0034] like Figure 1 As shown, the CAN message scheduling method includes the following steps:

[0035] In step S101, the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message are obtained.

[0036] In step S102, the target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and the target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message.

[0037] Optionally, in some embodiments, there is a message sending offset for the current CAN message, and the target message sending offset value is determined based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message, including: judging whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to a first preset value; if the number of messages in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, then the current message sending offset value of the current CAN message is used as the target message sending offset value.

[0038] Optionally, in some embodiments, after determining whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to a first preset value, it includes: if the number of messages at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is less than the first preset value, then increasing the current message sending offset value of the current CAN message according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, thereby obtaining the target message sending offset value.

[0039] Optionally, in some embodiments, there is a task scheduling offset for the current CAN message, and a target task scheduling offset value is determined based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message, including: judging whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to a second preset value; if the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, the current task scheduling offset value of the current CAN message is used as the target task scheduling offset value; otherwise, the task scheduling offset value of the current CAN message is increased according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, thereby obtaining the target message sending offset value.

[0040] Optionally, in some embodiments, after taking the current message sending offset value of the current CAN message as the target message sending offset value, it includes: adding the current CAN message to the message processed at the time point in the scheduling table corresponding to the target message sending offset value.

[0041] The first preset value and the second preset value may be thresholds preset by a user, thresholds obtained through a limited number of experiments, or thresholds obtained through a limited number of computer simulations, which are not specifically limited here.

[0042] Specific as Figure 2 As shown in the figure, before obtaining the target task scheduling offset value and the target message sending offset value of the CAN message, the parameters need to be initialized, including reading the sending cycle (MsgCycle) of each CAN message, initializing the task cycle (TaskCycle) to the message cycle (MsgCycle), and setting the task offset (TaskOffset) and message offset (MsgOffset) to 0. And build a schedule table by creating a time slot array (schedule) to record the number of messages processed at each time point, and the time range is set to 10 times the maximum sending cycle MsgCycle to cover the sending cycle of all messages.

[0043] Further, a message sending offset (MsgOffset) is assigned to the current CAN message: for each message, different MsgOffset values ​​are tried in turn, starting from 0 and gradually increasing according to the preset value increase strategy. Check whether the message sending offset value MsgOffset at any time point in its sending cycle (msg_offset, msg_offset+cycle, ...) causes the number of messages at that time point in the schedule table to exceed the first preset value (such as 10).

[0044] If the conditions are met, the message sending offset value MsgOffset is accepted as the target message sending offset value of the CAN message, otherwise the next message sending offset value is tried.

[0045] The scheduling table is further updated. Once a suitable message sending offset value MsgOffset is found, the message is added to the scheduling table at the corresponding time point.

[0046] Further, assign a task scheduling offset (TaskOffset): for each task, try different TaskOffset values ​​in turn, starting from 0 and gradually increasing. Check whether the task scheduling offset value TaskOffset at any time point in the task cycle (task_offset, task_offset+task_cycle, ...) will cause the number of messages at that time point in the schedule to exceed a second preset value (such as 10).

[0047] If the condition is met, the task scheduling offset value TaskOffset is accepted as the target task scheduling offset value, otherwise continue to try the next task scheduling offset value.

[0048] Further update the task schedule: After finding the appropriate target task schedule offset value TaskOffset, record it and apply it to the task schedule.

[0049] In step S103, a scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value.

[0050] Optionally, in some embodiments, after generating the scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value, it includes: based on a preset visualization tool, generating a relationship graph between the sending cycle and the target message sending offset value, a relationship graph between the task cycle and the target task scheduling offset value, and a graph of the number of messages processed at each time point.

[0051] Specifically, the final scheduling result is generated according to the target message sending offset value MsgOffset, the task cycle TaskCycle and the target task scheduling offset value TaskOffset.

[0052] To further visualize the scheduling results, use visualization tools such as matplotlib to draw graphs showing the relationship between message cycle and offset, the relationship between task cycle and offset, and the number of messages processed at each time point.

[0053] In order to enable those skilled in the art to further understand the CAN message scheduling method of the embodiment of the present application, the following is described in detail in conjunction with specific embodiments. Figure 3-5 shown.

[0054] Step 1: Import data and initialize parameters, such as Figure 3 As shown:

[0055] (1) Read input data:

[0056] Read the name (MessageName) and sending cycle (MsgCycle) of each CAN message from the input data table, such as Figure 4 shown.

[0057] Initialize the task cycle (TaskCycle) to the message cycle (MsgCycle), and set the task offset (TaskOffset) and message offset (MsgOffset) to 0.

[0058] (2) Create a time slot array:

[0059] Create a time slot array (schedule) to record the number of messages processed at each time point.

[0060] Assume that the maximum time range is 10 times the maximum MsgCycle to ensure that the sending cycles of all messages are covered.

[0061] Step 2: Allocate message sending offset (MsgOffset)

[0062] (1) Traverse each message: For each message, try different MsgOffset values ​​in turn, starting from 0 and gradually increasing.

[0063] (2) Checking the rationality of the offset: Checking whether the message sending offset value MsgOffset at any time point within its sending cycle (msg_offset, msg_offset+cycle, ...) causes the number of messages at that time point in the scheduling table to exceed a first preset value (e.g., 10).

[0064] If the conditions are met, the message sending offset value MsgOffset is accepted; otherwise, the next message sending offset value is tried.

[0065] (3) Update the schedule: Once a suitable MsgOffset is found, add the message to the schedule at the corresponding time point.

[0066] Step 3: Assign Task Offset

[0067] (1) Traverse each task: For each task, try different TaskOffset values ​​in turn, starting from 0 and gradually increasing.

[0068] (2) Checking the rationality of the offset: Checking whether the task scheduling offset value TaskOffset at any time point in the task cycle (task_offset, task_offset+task_cycle, ...) will cause the number of messages at that time point in the scheduling table to exceed a second preset value (such as 10).

[0069] If the condition is met, the task scheduling offset value TaskOffset is accepted; otherwise, the next task scheduling offset value is tried.

[0070] (3) Update task scheduling: After finding the appropriate TaskOffset, record it and apply it to the task scheduling.

[0071] Step 4: Output scheduling results

[0072] (1) Generate scheduling data: Generate the final scheduling result based on the optimized MsgOffset, TaskCycle and TaskOffset.

[0073] (2) Visualization of scheduling results: By using visualization tools such as matplotlib, we can draw a graph showing the relationship between the message cycle and the offset, the relationship between the task cycle and the offset, and the number of messages processed at each time point.

[0074] In order to more intuitively evaluate the optimized scheduling results, the present application embodiment designs a host computer program as shown in the following figure, which can import an Excel table containing periodic message information, and generate a scheduling scatter plot after executing the optimization algorithm, such as Figure 5 shown.

[0075] Construct timeline data: For each message, calculate its sending time point in each cycle in the schedule table, and combine these time points and message names to form a data table.

[0076] Draw a scheduling scatter plot: Use matplotlib's horizontal bar chart or scatter plot to draw a timeline to show the scheduling status of each message on the timeline.

[0077] Instructions for use of tools used in the examples of this application

[0078] In the CAN network message scheduling optimization tool, users can import data and initialize parameters through a simple and intuitive graphical user interface (GUI). The following are detailed steps:

[0079] 1) Open the software

[0080] After the user starts the CAN network message scheduling optimization tool, the following will be seen: Figure 6 The main interface is shown in the figure. The middle of the interface is the real-time log display area, and the left side is the task cycle setting area and parameter configuration area.

[0081] 2) Import data

[0082] Steps: In the menu bar, click the "File" menu and select "Import Configuration".

[0083] Operation: A file selection dialog box pops up, and the user can select an Excel file containing CAN message data for import.

[0084] Note: The imported Excel file must contain two columns of data: message name (MessageName) and message cycle (MsgCycle).

[0085] Feedback: After the import is successful, the system will display a prompt message "File imported successfully" in the log window. If the file is missing necessary columns, an error message will pop up.

[0086] 3) Initialize the task cycle

[0087] Steps: In the "Task Cycle Settings" area on the left, users can select the task cycle they want to use by checking different task cycle check boxes.

[0088] Options: The optional task periods include: 5ms, 10ms, 20ms, 50ms, 100ms, 200ms, 500ms, 1000ms.

[0089] Note: Users can select multiple task cycles according to actual needs, and the system will use these selected task cycles during the scheduling optimization process.

[0090] 4) Set the maximum number of messages to be processed

[0091] Steps: In the input box below "Maximum number of processed messages per millisecond", enter an integer value to set the maximum number of processed messages per millisecond.

[0092] Operation: Click the "Finish Settings" button, the system will record the value entered by the user and display it in the log window.

[0093] Description: This parameter is used to limit the number of messages processed per millisecond to ensure that there is no overload during the scheduling process.

[0094] 5) Startup optimization

[0095] Steps: Click the "Start Optimization" button, and the system will execute the scheduling optimization algorithm based on the data imported by the user and the parameters set.

[0096] Feedback: Real-time information and final results during the optimization process will be displayed in the log window on the right. After the scheduling optimization is completed, the system will pop up the result chart and prompt the user to save the scheduling results.

[0097] 6) Optimize data export

[0098] Steps: The tool will automatically pop up a dialog box for exporting data to a CSV file. The user selects the save path and file name, and clicks OK to complete the data saving.

[0099] Feedback: Data is saved in a CSV file with a user-defined file name in the format Figure 7 shown.

[0100] According to the CAN message scheduling method proposed in the embodiment of the present application, the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message are obtained, and a target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and a target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message, and a scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value. As a result, the problems of uneven message sending time and network congestion existing in the traditional CAN message scheduling method are solved. By reasonably allocating the message sending offset of the message and the scheduling offset of the task, it is ensured that the number of messages processed at each time point does not exceed the specified maximum value, thereby achieving uniform scheduling of CAN network messages, avoiding network congestion, and improving the real-time and reliability of the system. Compared with the prior art, the embodiments of the present application have significant advantages in dynamic scheduling, message sending offset calculation, task scheduling offset calculation, dynamic update of scheduling table, scheduling data generation, scheduling result visualization and input data flexibility.

[0101] Next, the CAN message scheduling device proposed according to the embodiment of the present application is described with reference to the accompanying drawings.

[0102] Figure 8 It is a block diagram of a CAN message scheduling device according to an embodiment of the present application.

[0103] like Figure 8 As shown, the CAN message scheduling device 10 includes: an acquisition module 100 , a determination module 200 and a scheduling module 300 .

[0104] Among them, the acquisition module 100 is used to obtain the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; the determination module 200 is used to determine the target message sending offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and determine the target task scheduling offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; the scheduling module 300 is used to generate the scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value.

[0105] Optionally, in some embodiments, the determination module 200 is also used to: determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to a first preset value; if the number of messages in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, then the current message sending offset value of the current CAN message is used as the target message sending offset value.

[0106] Optionally, in some embodiments, after determining whether the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to a first preset value, the determination module 200 is also used to: if the number of messages at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is less than the first preset value, then increase the current message sending offset value of the current CAN message according to a preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to the first preset value, so as to obtain the target message sending offset value.

[0107] Optionally, in some embodiments, there is a task scheduling offset in the current CAN message, and the target task scheduling offset value is determined based on the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message. The determination module 200 is also used to: determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to a second preset value; if the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, the current task scheduling offset value of the current CAN message is used as the target task scheduling offset value; otherwise, the current task scheduling offset value of the current CAN message is increased according to the preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the task cycle of the current CAN message is greater than or equal to the second preset value, so as to obtain the target message sending offset value.

[0108] Optionally, in some embodiments, after generating the scheduling result of the current CAN message based on the target task scheduling offset value and the target message sending offset value, the scheduling module 300 is also used to: generate a relationship diagram between the sending cycle and the target message sending offset value, a relationship diagram between the task cycle and the target task scheduling offset value, and a diagram of the number of messages processed at each time point based on a preset visualization tool.

[0109] Optionally, in some embodiments, when the current message sending offset value of the current CAN message is used as the target message sending offset value, the determination module 200 is also used to: add the current CAN message to the message processed at the time point in the scheduling table corresponding to the target message sending offset value.

[0110] It should be noted that the aforementioned explanation of the CAN message scheduling method embodiment is also applicable to the CAN message scheduling device of this embodiment, and will not be repeated here.

[0111] According to the CAN message scheduling device proposed in the embodiment of the present application, the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message are obtained, the target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, the target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message, and the scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value. Thus, the problems of uneven message sending time and network congestion existing in the traditional CAN message scheduling method are solved, and the balanced sending of messages is achieved by dynamically adjusting the message sending time and task scheduling, avoiding network congestion and communication delay, and improving the real-time performance and reliability of the system.

[0112] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:

[0113] A memory 901 , a processor 902 , and a computer program stored in the memory 901 and executable on the processor 902 .

[0114] When the processor 902 executes the program, the CAN message scheduling method provided in the above embodiment is implemented.

[0115] Furthermore, the electronic device further comprises:

[0116] The communication interface 903 is used for communication between the memory 901 and the processor 902 .

[0117] The memory 901 is used to store computer programs that can be executed on the processor 902 .

[0118] The memory 901 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0119] If the memory 901, the processor 902 and the communication interface 903 are implemented independently, the communication interface 903, the memory 901 and the processor 902 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0120] Optionally, in a specific implementation, if the memory 901, the processor 902 and the communication interface 903 are integrated on a chip, the memory 901, the processor 902 and the communication interface 903 can communicate with each other through an internal interface.

[0121] The processor 902 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0122] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above CAN message scheduling method when executed by a processor.

[0123] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0124] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0125] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0126] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer program product for use with an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, a "computer program product" can be any device that can contain, store, communicate, propagate or transmit a program for use with an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer program products (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). Furthermore, the computer program product may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example by optically scanning the paper or other medium and then editing, interpreting or, if necessary, processing in another suitable manner, and then storing it in a computer memory.

[0127] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0128] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer program product, which, when executed, includes one or a combination of the steps of the method embodiment.

[0129] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer program product.

[0130] The computer program product mentioned above may be a read-only memory, a disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A CAN message scheduling method, characterized in that: The following steps are involved: Obtain the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; Determine the target message sending offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and determine the target task scheduling offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; The scheduling result of the current CAN message is generated according to the target task scheduling offset value and the target message sending offset value.

2. The method according to claim 1, characterized in that The current CAN message has a message sending offset, and the target message sending offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, including: Determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to a first preset value; If the number of messages at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to the first preset value, the current message sending offset value of the current CAN message is used as the target message sending offset value.

3. The method according to claim 2, characterized in that After determining whether the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to the first preset value, the method includes: If the number of messages at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is less than the first preset value, the current message sending offset value of the current CAN message is increased according to the preset numerical increase strategy until the number of messages processed at a time point in the scheduling table corresponding to any time point within the sending cycle of the current CAN message is greater than or equal to the first preset value, so as to obtain the target message sending offset value.

4. The method according to claim 1, characterized in that The current CAN message has a task scheduling offset, and the target task scheduling offset value is determined according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message, including: Determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message is greater than or equal to a second preset value; If the number of messages processed by the current CAN message at a time point in the scheduling table corresponding to any time point within the task cycle is greater than or equal to a second preset value, the current task scheduling offset value of the current CAN message is used as the target task scheduling offset value; otherwise, the current task scheduling offset value of the current CAN message is increased according to a preset numerical increase strategy until the number of messages processed by the current CAN message at a time point in the scheduling table corresponding to any time point within the task cycle is greater than or equal to the second preset value, thereby obtaining the target message sending offset value.

5. The method according to claim 1, characterized in that After generating the scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value, the method further comprises: Based on a preset visualization tool, a relationship diagram between the sending period and the target message sending offset value, a relationship diagram between the task period and the target task scheduling offset value, and a diagram of the number of messages processed at each time point are generated.

6. The method according to claim 1, characterized in that After the current message sending offset value of the current CAN message is used as the target message sending offset value, the method further comprises: Add the current CAN message to the message processed at the time point in the scheduling table corresponding to the target message sending offset value.

7. A CAN message scheduling device, characterized in that: include: An acquisition module, used to acquire the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message and the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; A determination module, used to determine a target message sending offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message, and determine a target task scheduling offset value according to the number of messages processed at a time point in the scheduling table corresponding to any time point in the task cycle of the current CAN message; The scheduling module is used to generate a scheduling result of the current CAN message according to the target task scheduling offset value and the target message sending offset value.

8. The device according to claim 7, characterized in that The determining module is further used for: Determine whether the number of messages processed at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to a first preset value; If the number of messages at a time point in the scheduling table corresponding to any time point in the sending cycle of the current CAN message is greater than or equal to the first preset value, the current message sending offset value of the current CAN message is used as the target message sending offset value.

9. An electronic device, characterized in that: It comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the CAN message scheduling method as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the CAN message scheduling method according to any one of claims 1 to 6 is implemented.