Communication method, medium, chip and vehicle

By allocating message task information in the processor of the multi-core chip and performing parallel processing, the problems of high load rate and low communication efficiency in the prior art are solved, and more efficient and stable communication processing is achieved.

CN119766588AActive Publication Date: 2025-04-04BYD CO LTD

Patent Information

Application Number
CN202410765592.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2025-04-04
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

When existing multi-core chips process multi-channel communication buses, they lead to high processor load rate, low communication efficiency, and easy communication failures such as transmission timeouts.

Method used

By determining the message task information in the processor and assigning it to multiple cores for processing, parallel sending and receiving packets for different communication buses are realized.

Benefits of technology

It effectively reduces the load rate of the processor, improves the resource utilization rate of the communication bus, and improves communication efficiency and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766588A_ABST
    Figure CN119766588A_ABST
Patent Text Reader

Abstract

The invention relates to a communication method, a medium, a chip and a vehicle, comprising: determining message task information of a processor, the processor comprising a plurality of cores, the message task information comprising message tasks corresponding to different cores; the message task is processed through the kernel corresponding to the message task, and the message task comprises receiving and / or sending the message through the communication bus, so that the load rate of a processor is effectively reduced, the resource utilization rate of the communication bus is improved, and the resource utilization rate of the communication bus is increased. And the communication efficiency and the communication stability based on the communication bus are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of vehicle-mounted communication technology, and in particular, to a communication method, a medium, a chip, and a vehicle. Background Art

[0002] Currently, multi-core chips in vehicles are widely used in electric vehicle fields such as chassis domain control systems, braking systems, and motor control systems. The chip often integrates multiple systems of the vehicle, so the chip needs to be connected to multiple communication buses to achieve communication interaction.

[0003] In the prior art, a single core in a chip is usually used to uniformly manage messages on all communication buses. For example, a core is connected to two communication buses to manage messages. Since each communication bus needs to occupy the core when processing the message, one of the two communication buses will always be idle, which seriously affects the communication efficiency. When the number of messages to be processed is large, the processor load rate of the chip is large, and communication failures such as message sending timeouts are prone to occur. Summary of the invention

[0004] The purpose of the present disclosure is to provide a communication method, a medium, a chip and a vehicle.

[0005] In order to achieve the above object, the present disclosure provides a communication method, the method comprising: Determining message task information of a processor, wherein the processor includes multiple cores, and the message task information includes message tasks corresponding to different cores; The message task is processed by a kernel corresponding to the message task, wherein the message task includes receiving and / or sending a message through a communication bus.

[0006] Optionally, the message task information further includes different communication buses corresponding to different cores; and processing the message task by the core corresponding to the message task includes: The message corresponding to the message task is received and / or sent via the target communication bus corresponding to the core.

[0007] Optionally, the message task includes a sending task, the message task information also includes a task state corresponding to the sending task, and sending the message corresponding to the message task through a target communication bus corresponding to the kernel includes: Determining tasks to be sent from the sending tasks based on the task status of the sending tasks; The message corresponding to the task to be sent is loaded into the corresponding sending queue of the core, so that the core sends the message in the sending queue through the corresponding target communication bus.

[0008] Optionally, the message task information further includes a task type corresponding to the message task, and the task type includes at least one of a periodic task, an event task, and a periodic event task; wherein, For the periodic task, the task state includes a task cycle, and the task to be sent includes a periodic task whose cycle count satisfies a task cycle condition; For the event-type task, the task status includes an event flag, and the task to be sent includes an event-type task whose event flag is a target value; For the periodic event task, the task status includes a task cycle and an event flag, and the task to be sent includes an event task whose cycle count meets the task cycle condition and whose event flag is a target value.

[0009] Optionally, loading the message corresponding to the task to be sent into a corresponding sending queue of the kernel so that the kernel sends the message in the sending queue through the corresponding target communication bus includes: Each of the cores loads the corresponding messages to be sent into the sending queue of the core in order from small to large according to the task cycle size; Each of the cores polls the messages in the sending queue of the core, and sends each polled message through the corresponding target communication bus, wherein the core polls the messages in the sending queue from first to last in the order in which the messages are loaded into the sending queue.

[0010] Optionally, the message task further includes a receiving task, and receiving a message corresponding to the message task through a target communication bus corresponding to the kernel includes: Acquire a to-be-received message transmitted by a target communication bus, and add the to-be-received message to a message pool of the target communication bus; Each of the cores polls a message pool of a corresponding target communication bus to obtain from the message pool a message transmitted by the target communication bus corresponding to the core.

[0011] Optionally, the method further comprises: When the kernel polls any message to be received from the message pool, verifying whether the message to be received belongs to the receiving task corresponding to the kernel; In the case that the message to be received belongs to the receiving task corresponding to the kernel, the message to be received is acquired, and the receiving task corresponding to the kernel is updated in the message task information.

[0012] Optionally, the method further comprises: Recording the timestamp and flag bit during the message task processing in the message task information; The processing process of the message task is diagnosed according to the timestamp and the flag bit.

[0013] Optionally, the determining the message task information of the processor includes: defining a message data structure of each communication bus connected to the processor for communication as a common data structure; The message task information of the processor is determined according to the common data structure.

[0014] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which implements the method provided by the present disclosure when the program is executed by a processor.

[0015] The present disclosure also provides a chip, which includes a processor for executing the method provided by the present disclosure.

[0016] The present disclosure also provides a vehicle, which includes the chip provided by the present disclosure.

[0017] Through the above technical solution, multiple cores are used to process the sent and received messages of different communication buses in parallel, which can effectively reduce the processor load rate, improve the resource utilization of the communication bus, and thus effectively improve the communication efficiency and communication stability based on the communication bus.

[0018] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings: Figure 1 It is a flow chart of a communication method proposed by an exemplary embodiment of the present disclosure.

[0020] Figure 2 It is a schematic diagram of a queue management for sending tasks proposed by an exemplary embodiment of the present disclosure.

[0021] Figure 3 It is a flowchart of sending a message proposed by an exemplary embodiment of the present disclosure.

[0022] Figure 4 It is a flowchart of receiving a message proposed by an exemplary embodiment of the present disclosure.

[0023] Figure 5 It is a block diagram of a communication device proposed by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0024] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0025] Before introducing the communication method, medium, chip and vehicle provided by the present disclosure, the application scenarios of the present disclosure are first introduced.

[0026] With the development of multi-core technology, single-chip microcomputers have gradually developed from single-core to multi-core chips. For example, a chip with a Tricore architecture designed for an embedded operating system integrates an all-in-one powertrain system with a motor control system, a braking system, and a vehicle controller. The assembly system communicates with multiple ECUs (Electronic Control Units) through multiple communication buses. The chip includes multiple processors. When any processor runs a program segment, it will copy the program segment from PFLx (program flash memory interface) to the local PCACHE (program cache) of the processor through the XBAR0 single bus, and temporary variables will be dynamically allocated at runtime and stored in the local DCACHE (data cache) of the processor. Therefore, any modifications made by each processor to the program segment or temporary variables will not affect other processors running the same program segment.

[0027] In view of this, the present disclosure provides a communication method that can be applied to a multi-core chip of a vehicle, the chip including at least one processor and a message management module for centrally managing the messages to be processed of all processors, and each processor in the chip can run the same set of codes that implement the method of the present disclosure, so as to improve the portability of the code and reduce the code duplication rate, memory occupancy rate and processor load rate when the multi-core chip is applied.

[0028] Figure 1 FIG. 1 is a flow chart of a communication method provided by an exemplary embodiment. Figure 1 As shown, the method may include the following steps: Step S11, determining the message task information of the processor.

[0029] The processor includes multiple cores, and the message task information includes message tasks corresponding to different cores.

[0030] In one embodiment, whenever there are messages to be processed in the communication bus within the chip, the message management module will summarize these messages to be processed in the form of message tasks as message task information, and based on the number of messages to be processed in the communication bus, the load rate of the processor, the load rate of the core, and at least one of the real-time requirements of the messages to be processed, the message tasks will be evenly distributed to at least one core of at least one processor in the chip, so that the processor can process the message corresponding to the processor through the message task information.

[0031] Among them, the message task information is a data structure used to manage or schedule message tasks. The representation form of the message task information can be a list, that is, a message task list. The message task list includes message information, kernel information and diagnostic information. The message task list can also be divided into a sending task list and a receiving task list based on different message processing methods. Among them, the message information includes a message index value, a message count value, message data, and a message ID (Identity Document). The processor can determine the message task to be processed through the message information; the kernel information includes a kernel index value, an index value of the communication bus driver assigned by the kernel, and an interrupt disable / enable interface. The processor can determine the kernel and communication bus corresponding to the message task to be processed through the kernel information; the diagnostic information includes timeout diagnostic information, data packet abnormality diagnostic information, and verification diagnostic information. The processor can perform fault diagnosis on the message task through the diagnostic information.

[0032] It is worth noting that the processor may be a CPU (Central Processing Unit) including multiple cores, wherein each core corresponds to a core ID, such as Core0, Core1, Core2, ..., CoreN. In the following examples, the core IDs are used to represent different cores.

[0033] For example, each message task in the message task list corresponds to at least one core. The processor can determine the message task corresponding to each core by polling the message task list. For example, the first processor (CPU0) includes a first core (Core0), a second core (Core1) and a third core (Core2). When the first processor (CPU0) polls the message task list, each core in CPU0 will poll the message task list. If a message task that the processor does not need to process is polled, it will not be processed by default and will continue to poll the next message task. If a message task corresponding to a core is polled, the corresponding core is used as the running core to process the message task. For example, the core corresponding to message task 1 is Core0. When message task 1 is polled, Core0 is used as the running core to process message task 1.

[0034] Step S12: Processing the message task through the kernel corresponding to the message task.

[0035] The message task includes receiving and / or sending messages via a communication bus.

[0036] In one embodiment, the communication bus is a CAN (Controller Area Network) bus, and the communication of the CAN bus also supports the CANFD (CAN with Flexible Data rate) protocol and the CANVT (Virtual CAN communication) protocol. In addition, the communication bus can also be a LIN (Local Interconnect Network) bus, a FlexRay bus, and a MOST (Media Oriented System Transport) bus.

[0037] In one embodiment, the vehicle's chip, through a message management module, organizes and summarizes the message signals that need to be processed on the communication bus into a message task list based on the functional requirements of the vehicle's service layer software for multiple ECUs connected to the CAN bus. Each message task in the message task list includes the kernel ID corresponding to the message task, the message task ID, the task cycle, the task signal, and the communication bus corresponding to the message task, wherein each kernel is pre-matched with at least one communication bus, and whenever there is a message task in the message task list, each kernel in each processor polls the receiving task list to determine the running kernel corresponding to each message task, and then the running kernel processes the corresponding message task through the communication bus corresponding to the message task.

[0038] By using multiple cores to process the received and sent messages of different communication buses in parallel, the processor load rate can be effectively reduced, the resource utilization of the communication bus can be improved, and the communication efficiency and communication stability based on the communication bus can be effectively improved.

[0039] Optionally, the message task information further includes different communication buses corresponding to different cores, and the processing of the message task by the core corresponding to the message task includes: The message corresponding to the message task is received and / or sent via the target communication bus corresponding to the core.

[0040] In one implementation, the kernel and the communication bus may be matched in advance. After the kernel corresponding to the message task is determined, the kernel processes the message task through the target communication bus that matches it.

[0041] Take the receiving task list shown below as an example. The second core (Core1) in CPU0 polls the sending task list. When the second core polls message task 1, the core ID corresponding to message task 1 is Core0. The second core does not execute the message task by default and continues to execute the next message task. When the second core polls message task 2, the core ID corresponding to message task 2 is Core1. The second core is determined to be the running core of message task 2. Then, message task 2 is executed through the second core and the target communication bus CAN B corresponding to the second core, that is, the message corresponding to message task 2 is received.

[0042]

[0043] Optionally, the message task includes a sending task, the message task information also includes a task state corresponding to the sending task, and sending the message corresponding to the message task through a target communication bus corresponding to the kernel includes: First, based on the task status of the sending task, a task to be sent is determined from the sending tasks.

[0044] Then, the message corresponding to the task to be sent is loaded into the corresponding sending queue of the core, so that the core sends the message in the sending queue through the corresponding target communication bus.

[0045] It is worth noting that the task status of the sending task can be used to determine whether the sending task needs to be sent immediately, and the task to be sent is a message task that needs to be sent immediately.

[0046] In one embodiment, the kernel polls the sending task list, and when polling the sending task it is responsible for processing, it determines whether the sending task needs to be sent immediately based on the task status of the sending task. If necessary, a queueable flag is added to the sending task. If not, the queueable flag in the sending task is cleared. After the kernel finishes polling the sending task list, the sending tasks corresponding to the kernel that have a queueable flag are determined as tasks to be sent, and the messages corresponding to the tasks to be sent are loaded into the sending queue of the kernel.

[0047] Optionally, the message task information further includes a task type corresponding to the message task, and the task type includes at least one of a periodic task, an event task, and a periodic event task.

[0048] For the periodic task, the task status includes a task cycle, and the task to be sent includes a periodic task whose cycle count meets a task cycle condition.

[0049] Among them, the periodic task is a message task that needs to perform a sending operation according to a preset period, and the task period condition includes that the period value is not 0 and the count value of the period counter reaches the corresponding preset count duration.

[0050] For the event-type task, the task status includes an event flag, and the task to be sent includes an event-type task whose event flag is a target value.

[0051] Among them, event-type tasks are message tasks whose sending operations are triggered by preset trigger events or trigger conditions.

[0052] For the periodic event task, the task status includes a task cycle and an event flag, and the task to be sent includes an event task whose cycle count meets the task cycle condition and whose event flag is a target value.

[0053] In one embodiment, see Figure 2 As shown, when the kernel polls the corresponding sending task in the sending task column, it first needs to determine the task type of the sending task. When the task type of the sending task is a periodic task, determine whether the corresponding period value is 0. If the period value is 0, the message task is not a task to be sent, so clear the queueable flag in the message task. If the period value is not 0, check the count value of the period counter corresponding to the message task, where the period counter is an internal timer used to track the time since the last sending of the message task. If the count value of the period counter reaches or exceeds the preset count duration corresponding to the message task, add a queueable flag to the message task.

[0054] For event-type tasks, the processor's operating system will monitor in real time the trigger events or trigger conditions corresponding to each event-type task in the sending task list. When the trigger event or trigger condition corresponding to the message task occurs, the corresponding event flag will be enabled, and the event flag will be the target value. When the kernel polls the corresponding event-type task, if the event flag of the message task is enabled, the kernel will add a queue-entry mark to the event-type task. If it is not enabled, the queue-entry mark in the event-type task will be cleared.

[0055] For periodic event tasks, you first need to determine whether the event flag of the message task is enabled. If not, clear the queue-entry mark in the message task. If enabled, start the period counter corresponding to the message task. When the period value is not 0 and the count value of the period counter reaches or exceeds the preset count duration corresponding to the message task, add a queue-entry mark to the message task, and determine it as a task to be sent.

[0056] Optionally, loading the message corresponding to the task to be sent into a corresponding sending queue of the kernel so that the kernel sends the message in the sending queue through the corresponding target communication bus includes: First, each of the cores loads the corresponding messages to be sent into the sending queue of the core in order from small to large according to the task cycle size.

[0057] The period of the message task is used to represent the processing priority of the message task. The smaller the period, the higher the priority.

[0058] Then, each core polls the messages in the sending queue of the core, and sends each polled message through the corresponding target communication bus, wherein the core polls the messages in the sending queue from first to last in the order in which the messages are loaded into the sending queue.

[0059] In one embodiment, the kernel polls the sending task list to determine the pending tasks that it is responsible for processing and needs to be sent immediately, and loads these pending tasks into the kernel's message sending queue in order from small to large according to the size of the task cycle. Each kernel sends messages through its corresponding target communication bus in the order in which they are loaded into the message sending queue.

[0060] For example, see the schematic diagram of the sending queue shown below, where the first sending queue is the sending queue of the first core (Core0), and the second sending queue is the sending queue of the third core (Core2). After the first core polls the message sending list, it determines that message task 1 (TXTASK1) and message task 4 (TXTASK4) are the to-be-sent messages that the first core is responsible for processing and needs to send immediately. Since the cycle of message task 1 is greater than the cycle of message task 4, it means that the task priority of message task 4 is higher than that of message task 1. Therefore, the first core first loads the message task 4 with a high task priority into its corresponding first sending queue, and then loads the message task 1 with a low task priority into the first sending queue. Further, the first core polls the first sending queue and sends the messages corresponding to the message tasks in sequence according to the first-in-first-out principle through the target communication bus CAN A corresponding to the first core. Similarly, after the third kernel polls the message sending list, it determines that message task 5 (TXTASK5) and message task 6 (TXTASK6) are the pending messages that the third kernel is responsible for processing and needs to send immediately. Since the cycle of message task 6 is greater than the cycle of message task 5, it means that the task priority of message task 5 is higher than that of message task 6. Therefore, the third kernel first loads the message task 5 with a high task priority into its corresponding second sending queue, and then loads the message task 6 with a low task priority into the second sending queue. Further, the third kernel polls the second sending queue and sends the messages corresponding to the message tasks in sequence according to the first-in-first-out principle through the target communication bus CANFD C corresponding to the third kernel.

[0061]

[0062] In one embodiment, see Figure 3 As shown, for each core in the processor, the message to be sent can be processed in the following manner.

[0063] S301, polling and sending task list.

[0064] S302: Determine the sending task corresponding to the kernel in the sending task list.

[0065] For example, each core in the processor polls the sending task list, compares the core ID pre-bound to each sending task in the sending task list in turn, and determines the sending task that the core needs to process. If the core does not match its corresponding sending task after polling the sending task list, step S305 is executed.

[0066] S303: Add / clear a queueable flag to the sending task according to the task status of the sending task.

[0067] For example, when the kernel polls the corresponding sending task, it adds or clears the queue-enterable flag to the sending task according to the task status corresponding to the task type of the sending task, and after adding / clearing the queue-enterable flag, continues to poll the next sending task until the sending task list is polled. The method for determining the task status of the sending task according to different task types has been described above and will not be repeated here.

[0068] S304: Determine whether the polling of the sending task list is completed.

[0069] If the polling is completed, execute S305; if the polling is not completed, return to execute S301.

[0070] S305: Determine whether there is a task to be sent with a queue-enabled flag in the target communication bus corresponding to the running kernel.

[0071] If it exists, execute S306; if it does not exist, execute S309.

[0072] It is worth noting that the kernels corresponding to the sending tasks in the sending task list are the running kernels of these sending tasks, that is, the running kernels are responsible for the sending and management of these sending tasks.

[0073] S306. According to the cycle size of the task to be sent, the message corresponding to the task to be sent is loaded into the sending queue of the target communication bus corresponding to the running kernel.

[0074] S307: message task information processing.

[0075] It is worth noting that after the message is sent, the running kernel will process the message task information corresponding to the sent message, such as updating the message status and releasing memory resources.

[0076] S308 , polling the sending queue of the target communication bus corresponding to the running kernel, and sending the messages corresponding to the tasks to be sent in the order in which they are loaded into the sending queue.

[0077] S309: Message fault management.

[0078] For example, after the message is sent, according to the flag bit and timestamp recorded during the message sending process, the message timeout detection, checksum detection, life frame detection and other message diagnostic information are fed back in real time.

[0079] Optionally, the message task further includes a receiving task, and receiving a message corresponding to the message task through a target communication bus corresponding to the kernel includes: Acquire the to-be-received message transmitted by the target communication bus, and add the to-be-received message to the message pool of the target communication bus.

[0080] Each of the cores polls a message pool of a corresponding target communication bus to obtain from the message pool a message transmitted by the target communication bus corresponding to the core.

[0081] It is worth mentioning that whenever there is a message to be received in the communication bus, the CPU will trigger the ISR (Interrupt Service Routine) and poll and compare all the message tasks in the receiving task list, including a large number of comparison processes for receiving tasks that are not of the communication bus. Therefore, when the number of received messages in the communication bus is large, each communication bus will frequently trigger the ISR, in which tasks such as task polling and comparison, ID verification, data analysis, data verification and time recording are performed. The CPU has a large amount of calculation and the running time is too long, which can easily affect the running cycle of other tasks. When the CPU load rate is large, basic diagnostic functions such as send / receive timeout diagnosis, data verification diagnosis and message life frame verification cannot be used normally.

[0082] In view of this, for the receiving task, the to-be-received messages in the communication bus can be stored in the message pool (FIFO pool) based on the FIFO (First In First Out) data structure, but the messages are not received. Then, in the regular tasks or main loop of the system, the kernel polls the message pool of the target communication bus corresponding to the kernel at a fixed period (for example, 10ms), and performs receiving processing on the to-be-received messages in the message pool, so as to quickly release the interrupt service program and avoid the real-time performance of long-term interrupt processing hard-wired processing.

[0083] Each receiving task corresponds to a different core, each core corresponds to a different target communication bus, and each target communication bus corresponds to a different message pool.

[0084] For example, taking the communication bus as a CAN bus as an example, the message to be received in the communication bus can be processed through the following steps.

[0085] In the first step, the processor inspects the status register of the CAN controller to determine whether there is an interrupt flag in each CAN bus. If so, it means that the CAN bus has triggered the interrupt service program. If not, it means that the CAN bus has not triggered the interrupt service program, and the inspection continues.

[0086] The second step is that when a receive interrupt is detected, the interrupt flag corresponding to the CAN bus that triggered the interrupt must be cleared in the interrupt service routine to avoid repeated processing of the same interrupt.

[0087] The third step is to read the message in the CAN bus from the receiving buffer area of ​​the CAN controller. The read message includes the message ID, message data field and other message information. At the same time, the current system time is obtained to provide a basis for the subsequent management and data diagnosis of the message as a timestamp.

[0088] The fourth step is to pack the acquired message and system time into the tail of the FIFO pool corresponding to the CAN bus, wherein the FIFO pool is used to temporarily store the received message until the main program or task scheduler of the processor processes them.

[0089] It is worth noting that due to the characteristics of the FIFO data structure, the first received message will be taken out and processed first.

[0090] Through the above method, the interrupt can be released quickly to avoid long-term interrupt processing affecting the real-time performance of the system.

[0091] In one embodiment, participating Figure 4 As shown, the messages in the message pool can be processed through the following steps.

[0092] S401 , polling a received task list to determine a running kernel corresponding to each received task.

[0093] It is worth noting that, whenever there are messages to be received in the communication bus, the message management module will summarize and organize the receiving tasks corresponding to the messages to be received into a receiving task list.

[0094] For example, each core of the processor polls the receive task list. The first core (Core0) is used for explanation. When there are receive tasks corresponding to Core0 in the receive task list, Core0 is the running core of these receive tasks. These receive tasks are subsequently processed by Core0. When Core0 finishes polling the receive task list, a receive queue of Core0 is generated according to the receive priorities of all receive tasks that Core0 is responsible for processing. The receive priority of the receive task is determined by the period size of the receive task. The smaller the period, the higher the priority.

[0095] S402, polling the message pool of the target communication bus corresponding to the receiving queue of the running kernel, and taking out the head message in the message pool when there is a new message stored in the message pool.

[0096] It is worth noting that each communication bus corresponds to a message pool in advance, and each core corresponds to at least one communication bus.

[0097] For example, during the polling of the message pool, the kernel is run to check whether there are any messages to be processed in the message pool. If the message pool is not empty, the message at the head of the message pool is taken out. For example, the target communication bus corresponding to Core0 is CAN A. Core0 polls the first message pool corresponding to CAN A. If there are newly stored messages in the first message pool, the messages at the heads of the newly stored messages are taken out.

[0098] S403: Perform data verification on the retrieved message, and process the retrieved message according to the result of the data verification.

[0099] The message to be received is a message whose data verification result is passed.

[0100] S404: Determine whether the newly added messages in the message pool have been completely rotated.

[0101] If the round-robin is completed, S405 is executed; if the round-robin is not completed, S406 is executed.

[0102] S405: Determine whether the receiving tasks in the receiving task list have been processed.

[0103] If the processing is completed, execute S406; if the processing is not completed, return to execute S401.

[0104] S406: Determine the fault diagnosis result of the received task according to the flag bit and timestamp recorded during the processing of the received task.

[0105] Through the above method, it can be ensured that the messages on the communication bus are effectively managed and processed, avoiding the impact of frequent interrupts triggered by the receiving task on the running cycle of other tasks of the processor, effectively reducing the load of the processor, and ensuring the stability of fault diagnosis of message tasks.

[0106] Optionally, the method further comprises: When the kernel polls any message to be received from the message pool, it verifies whether the message to be received belongs to the receiving task corresponding to the kernel.

[0107] In the case that the message to be received belongs to the receiving task corresponding to the kernel, the message to be received is acquired, and the receiving task corresponding to the kernel is updated in the message task information.

[0108] By way of example, for the messages taken out in turn from the message pool, the above step S403 can be implemented through the following sub-steps.

[0109] The first step is to poll the receiving queue of the communication bus corresponding to the message pool, and compare the message IDs of the taken messages with the receiving tasks in the receiving queue one by one.

[0110] The schematic diagram of the receiving queue shown below is used for exemplary explanation. The first receiving queue is the receiving queue of the first core (Core0), and the target communication bus corresponding to Core0 is CAN B. When taking out a message from the message pool corresponding to CAN B, Core0 compares and verifies the taken out message with the message tasks in the first receiving queue one by one, that is, determines whether there is a message task matching the message ID of the message in the task signal shown in the diagram, so as to determine whether the taken out message is correct.

[0111] If the comparison is successful, the next step is executed. If the comparison is unsuccessful, the message is returned to the message pool and the fourth step is executed.

[0112]

[0113] The second step is to perform data verification on the message matching the receiving task through the message task information of the receiving task to determine the verification result.

[0114] The data check of the message may be a cyclic redundancy check (CRC) to ensure the integrity and correctness of the message.

[0115] If the verification result passes, the third and fourth steps are executed in sequence. If the verification result fails, the message will be processed according to the processing strategy corresponding to the verification result and the fourth step will be executed, wherein the processing strategy corresponding to the verification result includes at least one of releasing the message to the message pool, discarding the message, recording the error, and sending an error report.

[0116] The third step is to update the message task information corresponding to the message task and record the update time of the message task information.

[0117] The fourth step is to determine whether the sending queue of the communication bus corresponding to the message pool has been polled.

[0118] If the polling is completed, the data verification process is terminated, and the message that has passed the data verification process is determined as the message to be received. If the polling is not completed, return to the first step.

[0119] Optionally, the method further comprises: The timestamp and flag bit during the message task processing are recorded in the message task information.

[0120] The processing process of the message task is diagnosed according to the timestamp and the flag bit.

[0121] In one embodiment, based on the flag bit recorded during the processing of the message task, it can be determined whether a data anomaly or error occurs. Based on the timestamp recorded during the processing of the message task, it can be determined whether the message task is completed within the preset processing time, that is, whether a communication timeout occurs. If the fault diagnosis result represents a sending failure, a fault report is generated based on the fault type, fault time, and related system information affected by the fault, and the generated fault report is sent to the fault handling module of the processor.

[0122] Optionally, the determining the message task information of the processor includes: The message data structure of each communication bus connected to the processor for communication is defined as a common data structure.

[0123] The message task information of the processor is determined according to the common data structure.

[0124] It is worth noting that the union data structure has a char data type variable a, an int data type variable array i, and a double data type variable b. In the chip's memory address allocation, the union structure members a, i, and b share a memory space that is equal to the longest length of the members. When the union is assigned to a specific member, the value of the member will be stored in the shared memory space, and the values ​​of other members will be overwritten. In other words, the union data structure can only store the value of one member.

[0125] By defining the message data structure of each communication bus through the union data structure, the data field of each signal, such as the bit field size and bit field name, can be easily and intuitively configured, reducing the risk of data parsing anomalies or data address allocation anomalies caused by human operations, and can improve the efficiency of separating high and low bytes, location operations, bit or operations, and shift operations in data processing, and can greatly reduce the data calculation amount of the CPU, while also avoiding data anomalies caused by manual data operations.

[0126] In one embodiment, a message task list is a data structure for storing message task information, and the message task list includes a union defined based on a union data structure and message-related metadata, such as the metadata including the message type, message priority, and timestamp. Whenever there is message data to be processed in the target communication bus corresponding to the processor, the message data is parsed and stored in the union, and then the task type, the kernel to which it belongs, the communication bus to which it belongs, and the task cycle of each message to be processed are determined based on the message data and metadata in the union, and the determined message task information is added to the message task list to generate a corresponding sending task list and receiving task list, so that the processor can process the messages to be processed by polling the sending task list or the receiving task list.

[0127] For example, the "CAN Service Protocol Stack Generation Tool" can be used to quickly and effectively generate all message data fields of multiple CAN buses in batches, and at the same time, the data memory size of the generated data fields can be verified to avoid the problem that the total size of the data field of standard CAN messages exceeds 8 bytes or the total size of the data field of CANFD messages exceeds 64 bytes. After completing the generation of the data structure defined by the signal related to the reception and transmission of the CAN bus, a message task list is generated according to the message type, cycle, message ID, bus to which the message belongs, and message signal data.

[0128] In addition, after the message task list is generated, the message task list needs to be initialized as shown below.

[0129] For the sending task list, the list data and flag bits of the sending task list, the period value of the message to be sent and the count value of the counter, the sending priority of the message to be sent, the core corresponding to the message to be sent, the communication bus, and the sending queue of the communication bus are initialized in turn.

[0130] For the receiving task list, the list data of the receiving task list, the message signal of the message to be received, the priority of the message to be received, the core corresponding to the message to be received and the communication bus are initialized in sequence, and according to the priority of the message to be received and the communication bus to which it belongs, the receiving queue and message pool corresponding to each communication bus are initialized.

[0131] See also Figure 5 As shown, the present disclosure further provides a communication device 500, the communication device 500 comprising: The determination module 510 is configured to determine message task information of a processor, wherein the processor includes multiple cores, and the message task information includes message tasks corresponding to different cores.

[0132] The processing module 520 is configured to process the message task through a kernel corresponding to the message task, wherein the message task includes receiving and / or sending a message through a communication bus.

[0133] Optionally, the message task information further includes different communication buses corresponding to different cores, and the processing module 520 is configured to: The message corresponding to the message task is received and / or sent via the target communication bus corresponding to the core.

[0134] Optionally, the message task includes a sending task, the message task information also includes a task state corresponding to the sending task, and the processing module 520 is configured to: Based on the task status of the sending task, a task to be sent is determined from the sending tasks.

[0135] The message corresponding to the task to be sent is loaded into the corresponding sending queue of the core, so that the core sends the message in the sending queue through the corresponding target communication bus.

[0136] Optionally, the message task information further includes a task type corresponding to the message task, and the task type includes at least one of a periodic task, an event task, and a periodic event task.

[0137] For the periodic task, the task status includes a task cycle, and the task to be sent includes a periodic task whose cycle count meets a task cycle condition.

[0138] For the event-type task, the task status includes an event flag, and the task to be sent includes an event-type task whose event flag is a target value.

[0139] For the periodic event task, the task status includes a task cycle and an event flag, and the task to be sent includes an event task whose cycle count meets the task cycle condition and whose event flag is a target value.

[0140] Optionally, the processing module 520 is configured to: Each of the cores loads the corresponding messages to be sent into the sending queue of the core in order from small to large according to the task cycle size.

[0141] Each of the cores polls the messages in the sending queue of the core, and sends each polled message through the corresponding target communication bus, wherein the core polls the messages in the sending queue from first to last in the order in which the messages are loaded into the sending queue.

[0142] Optionally, the message task further includes a receiving task, and the processing module 520 is configured to: Acquire the to-be-received message transmitted by the target communication bus, and add the to-be-received message to the message pool of the target communication bus.

[0143] Each of the cores polls a message pool of a corresponding target communication bus to obtain from the message pool a message transmitted by the target communication bus corresponding to the core.

[0144] Optionally, the processing module 520 is configured to: When the kernel polls any message to be received from the message pool, it verifies whether the message to be received belongs to the receiving task corresponding to the kernel.

[0145] In the case that the message to be received belongs to the receiving task corresponding to the kernel, the message to be received is acquired, and the receiving task corresponding to the kernel is updated in the message task information.

[0146] Optionally, the processing module 520 is configured to: The timestamp and flag bit during the message task processing are recorded in the message task information.

[0147] The processing process of the message task is diagnosed according to the timestamp and the flag bit.

[0148] Optionally, the determining module 510 is configured to: The message data structure of each communication bus connected to the processor for communication is defined as a common data structure.

[0149] The message task information of the processor is determined according to the common data structure.

[0150] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which implements the method provided by the present disclosure when the program is executed by a processor.

[0151] The present disclosure also provides a chip, which includes a processor for executing the method provided by the present disclosure.

[0152] The present disclosure also provides a vehicle, which includes the chip provided by the present disclosure.

[0153] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0154] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0155] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A communication method, characterized in that: include: Determining message task information of a processor, wherein the processor includes multiple cores, and the message task information includes message tasks corresponding to different cores; The message task is processed by a kernel corresponding to the message task, wherein the message task includes receiving and / or sending a message through a communication bus.

2. The method according to claim 1, characterized in that: The message task information also includes different communication buses corresponding to different cores; The processing of the message task by a kernel corresponding to the message task includes: The message corresponding to the message task is received and / or sent via the target communication bus corresponding to the core.

3. The method according to claim 1, characterized in that The message task includes a sending task, the message task information also includes a task state corresponding to the sending task, and sending the message corresponding to the message task through a target communication bus corresponding to the kernel includes: Determining tasks to be sent from the sending tasks based on the task status of the sending tasks; The message corresponding to the task to be sent is loaded into the corresponding sending queue of the core, so that the core sends the message in the sending queue through the corresponding target communication bus.

4. The method according to claim 3, characterized in that The message task information also includes a task type corresponding to the message task, and the task type includes at least one of a periodic task, an event task, and a periodic event task; wherein, For the periodic task, the task state includes a task cycle, and the task to be sent includes a periodic task whose cycle count satisfies a task cycle condition; For the event-type task, the task status includes an event flag, and the task to be sent includes an event-type task whose event flag is a target value; For the periodic event task, the task status includes a task cycle and an event flag, and the task to be sent includes an event task whose cycle count meets the task cycle condition and whose event flag is a target value.

5. The method according to claim 3, characterized in that: The step of loading the message corresponding to the task to be sent into the corresponding sending queue of the kernel so that the kernel sends the message in the sending queue through the corresponding target communication bus comprises: Each of the cores loads the corresponding messages to be sent into the sending queue of the core in order from small to large according to the task cycle size; Each of the cores polls the messages in the sending queue of the core, and sends each polled message through the corresponding target communication bus, wherein the core polls the messages in the sending queue from first to last in the order in which the messages are loaded into the sending queue.

6. The method according to claim 2, characterized in that The message task also includes a receiving task, which receives a message corresponding to the message task through a target communication bus corresponding to the kernel, including: Acquire a to-be-received message transmitted by a target communication bus, and add the to-be-received message to a message pool of the target communication bus; Each of the cores polls a message pool of a corresponding target communication bus to obtain from the message pool a message transmitted by the target communication bus corresponding to the core.

7. The method according to claim 6, characterized in that The method further comprises: When the kernel polls any message to be received from the message pool, verifying whether the message to be received belongs to the receiving task corresponding to the kernel; In the case that the message to be received belongs to the receiving task corresponding to the kernel, the message to be received is acquired, and the receiving task corresponding to the kernel is updated in the message task information.

8. The method according to claim 1, characterized in that The method further comprises: Recording the timestamp and flag bit during the message task processing in the message task information; The processing process of the message task is diagnosed according to the timestamp and the flag bit.

9. The method according to claim 1, characterized in that: The message task information of the processor determined includes: defining a message data structure of each communication bus connected to the processor for communication as a common data structure; The message task information of the processor is determined according to the common data structure.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 9 are implemented.

11. A chip, characterized in that: The chip comprises a processor for executing the method according to any one of claims 1-9.

12. A vehicle, characterized in that: Comprising the chip according to claim 11.

Citation Information

Patent Citations

  • Information processing method and apparatus

    CN104994032A

  • Method and device for message processing

    CN105511954A

  • Method and device used for scheduling task

    CN107943577A

  • Data processing method and electronic device

    CN109672575A

  • Message processing method, device and system

    CN112152940A

Cited By

  • Communication method, medium and vehicle

    WO2025256466A1