A can message cache processing architecture based on an AUTOSAR protocol stack

By introducing a caching module and a time-sharing processing function interface into the AUTOSAR protocol stack, the received CAN messages are cached and processed periodically in the task, which solves the problem of excessive interrupt load, realizes a stable and efficient message processing flow, and improves system performance.

CN116708075BActive Publication Date: 2026-04-17BEIJING YINWO AUTOMOBILE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING YINWO AUTOMOBILE TECH CO LTD
Filing Date
2023-07-03
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In the AUTOSAR protocol stack, as the number of received Ethernet packets increases, the interrupt load intensifies, leading to excessive CPU resource consumption, affecting system stability and task scheduling, and potentially causing frame loss and errors in critical variables.

Method used

Design a CAN message caching and processing architecture based on the AUTOSAR protocol stack, including a caching module and a time-sharing processing function interface. By caching messages when the CAN is interrupted and processing them periodically in the task, the interruption response time is reduced and the task scheduling is prevented from being frequently interrupted.

Benefits of technology

By caching message processing, interruption time is reduced, high-speed transmission requirements are met, task crashes are prevented, and system stability and CPU resource utilization efficiency are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708075B_ABST
    Figure CN116708075B_ABST
Patent Text Reader

Abstract

This application provides a CAN message caching and processing architecture based on the AUTOSAR protocol stack, including: a caching module for caching received CAN messages during CAN interrupts, wherein the CAN messages include network management messages, application messages, and diagnostic messages; and a time-sharing processing function interface for execution in Tasks to implement time-sharing reading and processing of the CAN messages cached in the caching module. This architecture satisfies the time requirements for message processing while reducing processing time during CAN interrupts, preventing frequent interrupts from affecting the microcontroller's task scheduling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to automotive electronic control technology, and more particularly to a CAN message caching processing architecture based on the AUTOSAR protocol stack. Background Technology

[0002] Currently, most vehicles use AUTOSAR (Automotive Open System Architecture) for their Electronic Control Unit (ECU). In AUTOSAR, peripheral devices of the network equipment receive a large number of Ethernet packets. Each time a peripheral device receives an Ethernet packet, it generates an interrupt to notify the host CPU (Central Processing Unit) to process the packet.

[0003] As the number of received messages increases, the interrupt load intensifies. The CPU needs to handle a large number of interrupt requests, leading to excessive CPU resource consumption and making it unable to meet the requirements of high-speed Ethernet data transmission. In addition, too many interrupts may also affect system stability, such as causing frame drops and disrupting normal task scheduling. Furthermore, if some critical programs do not have interrupt protection enabled, errors in certain critical variable values ​​may occur, causing the program to crash. Summary of the Invention

[0004] The purpose of this invention is to provide a CAN message buffering processing architecture based on the AUTOSAR protocol stack, which can reduce interrupt time and prevent frequent interrupts from affecting the task scheduling of the microcontroller.

[0005] The following provides a brief overview of one or more aspects to offer a basic understanding of them. This overview is not an exhaustive summary of all conceived aspects, nor is it intended to identify key or decisive elements of all aspects, nor to define the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form to prepare for the more detailed descriptions that follow.

[0006] According to one aspect of the present invention, a CAN message caching processing architecture based on the AUTOSAR protocol stack is provided, comprising:

[0007] The caching module is used to cache the received CAN messages when the CAN is interrupted. The CAN messages include network management messages, application messages, and diagnostic messages.

[0008] The time-sharing processing function interface is used to execute in a Task to implement time-sharing reading and processing of CAN messages cached in the caching module.

[0009] In one embodiment, the caching module includes a message cache array, which stores the email address, CanID, timestamp, data length, and payload of the received message.

[0010] In one embodiment, the message cache array allocates storage start positions for network management messages, application messages, and diagnostic messages, respectively.

[0011] In one embodiment, the cache module is provided with an encapsulation array, in which each element of the encapsulation array encapsulates a pointer to the message cache array and a control variable together to form a cache unit.

[0012] In one embodiment, the control variables include cache message type, cache array enable flag, and overflow flag.

[0013] In one embodiment, the cache module is provided with a mapping array, and each element in the mapping array contains only two variables, one of which is a message count, and the other is a pointer array pointing to the encapsulation array.

[0014] In one embodiment, the caching module has an ordered storage function interface. The ordered storage function performs a calculation on the CanID in the received message, and the result is used as an index for accessing the mapping array. The message cache array stores the message at the corresponding starting position, assigns the storage address to the mapping, and moves the storage position to the next position after setting the message validity flag.

[0015] In one embodiment, the caching module also has an ordered read function interface, which is used to read the cached messages in the order of their timestamps in a task, and call the CanIf layer interface CanIf_RxIndication() to upload the messages to other modules in the protocol stack for processing.

[0016] The beneficial effects of this invention are: by caching the received messages instead of processing them directly when the CAN interrupts, and periodically polling the cached messages in the task to complete the system function, the time requirements for processing messages are met, the interrupt response time is reduced, and other tasks are prevented from being frequently interrupted and running out of control. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0018] The above-described features and advantages of the present invention will be better understood after reading the following detailed description of embodiments of the present disclosure in conjunction with the accompanying drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related characteristics or features may have the same or similar reference numerals.

[0019] Figure 1 This is a schematic diagram of the system architecture of an embodiment of this application;

[0020] Figure 2 This is a schematic diagram of the message cache array according to an embodiment of this application;

[0021] Figure 3 This is a schematic diagram of the encapsulation array according to an embodiment of this application;

[0022] Figure 4 This is a schematic diagram of the mapping array in an embodiment of this application;

[0023] Figure 5 This is a schematic diagram of the message processing flow according to an embodiment of this application;

[0024] Figure 6 This is a schematic diagram of the code structure of the caching module CanCom in an embodiment of this application. Detailed Implementation

[0025] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should be noted that the aspects described below with reference to the accompanying drawings and specific embodiments are merely exemplary and should not be construed as limiting the scope of protection of the present invention in any way.

[0026] Figure 1 This embodiment illustrates a CAN packet caching and processing architecture based on the AUTOSAR protocol stack. This architecture, as part of the AUTOSAR protocol stack, includes a caching module CanCom and a time-division processing function interface CanCom_MainFunction(). The caching module is used to cache received CAN packets when a CAN interrupt occurs. These CAN packets include network management packets, application packets, and diagnostic packets. The time-division processing function interface is executed within a Task to periodically read and process the CAN packets cached in the caching module.

[0027] The CanCom caching module includes a message cache array stRxMsgBuff, which is of type tRxMessage. The stRxMsgBuff array stores the mailbox number, CanID, timestamp, data length, and payload (valid data bytes) of the received message.

[0028] The message cache array stRxMsgBuff allocates storage start positions for network management messages, application messages, and diagnostic messages, respectively. Figure 2 It shows the starting storage location of various messages, such as Figure 2 As shown, the starting location for storing network management packets is &stRxMsgBuff[0], the starting location for storing application packets is &stRxMsgBuff[NMCnt], and the starting location for storing diagnostic packets is &stRxMsgBuff[NMCnt+DcmCnt]. Where NMCnt = the number of network management packets that need to be cached, and DcmCnt = the number of application packets that need to be cached.

[0029] Furthermore, to facilitate message encapsulation and data retrieval, the CanCom buffer module includes an encapsulation array `stRxBuff` of type `tRxBuffer`. Each element in the `tRxBuffer` array encapsulates a pointer to the message buffer array `stRxMsgBuff` along with some control variables (such as the buffer message type, buffer array enable flag, and overflow flag) to form a buffer unit, such as... Figure 3 As shown.

[0030] The cache module CanCom also has a mapping array stRxBuffMap, which is of type tRxBufferMap. Each element in the mapping array stRxBuffMap contains only two variables, one of which is the message count ucIdNum, and the other is a pointer array tRxBuffer*pstBuffer[8].

[0031] By setting up the encapsulation array `stRxBuff` and the mapping array `stRxBuffMap`, top-down encapsulation can be achieved, and by adding control variables, data access becomes more convenient. After setting up these two arrays, the pointers need to be initialized. In this embodiment, three pointers of type `tRxMessage` are set to locate the actual storage location of three different types of messages; then, the actual storage location `tRxMessage` pointers are assigned to variables in `stRxBuff` according to the message type; and finally, the pointers of `stRxBuff` are assigned to variables in `stRxBuffMap` according to the ID of the CAN message.

[0032] Furthermore, the caching module CanCom has a sequential storage function interface CanCom_SetRxMsg(). The sequential storage function performs calculations on the CanID in the received message, and the result is used as the index of the access mapping array stRxBuffMap. Then, the message is placed into the memory pointed to by the corresponding pointer. For example, if a message with CanID 0x54 is received, uiMapIdx = 0 is first calculated, and then the message is stored in the memory pointed to by stRxMsgBuffMap[0].pstBuffer[0]. If the CanID is 0x234, it is calculated to be 2, and the message is stored in the memory pointed to by Map with index 2; if the CanID is 0x456, it is calculated to be 4, and the message is stored in the array pointed to by Map with index 4. When caching messages, the message buffer array stores the message at the corresponding starting position and assigns the storage address to stRxBuffMap[index].pstBuffer->stMsgBuff. After setting the message validity flag, the storage position is moved to the next position to store new data.

[0033] In addition, the caching module CanCom has an ordered read function interface, get_oldest_message(). This function reads cached messages in the order of their timestamps within a task and calls the CanIf layer's interface, CanIf_RxIndication(), to forward the messages to other modules in the protocol stack for processing. Processed messages are invalidated and can be overwritten by new messages.

[0034] The time-sharing processing function interface CanCom_MainFunction() is used to execute in a Task, and reads and processes application packets, diagnostic packets and network management packets cached in the CanCom cache module according to a set period.

[0035] Figure 5 The message processing flow of this architecture is illustrated, such as... Figure 5 As shown, when the CAN interrupts, the message is cached in the cache module CanCom. When in a Task, the message is read and processed through a time-sharing function. The processing flow for different types of messages is as follows:

[0036] Application message: Task->CanCom->CanIf->PduR->Com;

[0037] Diagnostic message: Task->CanCom->CanIf->CanTp->PduR->Dcm;

[0038] Network management message: Task->CanCom->CanIf->CanNM.

[0039] Figure 6 The example code for the caching module CanCom in this embodiment is shown. It defines three structures: a message cache array stRxMsgBuff, a wrapper array stRxBuff, and a mapping array stRxBuffMap. It should be noted that this code is merely a structure example and not the actual running code.

[0040] In summary, this application provides a CAN message caching processing architecture based on the AUTOSAR protocol stack. By adding a CanCom module to cache received CAN messages and creating a periodically scheduled Mainfunction to process the cached CAN messages, the processing time in CAN interrupts is reduced, and frequent interrupts are prevented from affecting the microcontroller's task scheduling.

[0041] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0042] The prior description of this disclosure is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to this disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0043] The above description is merely a preferred example of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application shall be included within the scope of protection of this application.

Claims

1. A CAN message caching and processing architecture based on the AUTOSAR protocol stack, characterized in that, include: A caching module is used to cache received CAN messages when a CAN interrupt occurs. These CAN messages include network management messages, application messages, and diagnostic messages. The caching module includes a message cache array, which stores the mailbox number, CAN ID, timestamp, data length, and valid data bytes of the received messages. The message cache array allocates starting positions for network management messages, application messages, and diagnostic messages, respectively. The caching module also includes an encapsulation array, where each element encapsulates a pointer to the message cache array and a control variable together to form a cache unit. The control variable includes a buffer... The system stores message type, cache array enable flag, and overflow flag. The cache module includes a mapping array, where each element contains two variables: a message count and an array of pointers to the encapsulation array. Three pointers of type tRxMessage are set in the message cache array to locate the actual storage location of three different message types. Then, according to the message type, the pointers of the actual storage location (tRxMessage type) are assigned to the pointers in the encapsulation array pointing to the message cache array. Finally, the pointers in the encapsulation array are assigned to the variables in the mapping array according to the ID of the CAN message. The time-sharing processing function interface is used to execute in Tasks to implement time-sharing reading and processing of CAN messages cached in the cache module. The processing paths corresponding to different types of CAN messages output by the cache module are as follows: application type CAN messages are sequentially transmitted through the cache module, CAN interface layer CanIf, protocol data unit routing layer PduR to the communication layer Com; diagnostic type CAN messages are sequentially transmitted through the cache module, CanIf, CAN transport layer CanTp, PduR to the diagnostic communication management layer Dcm; and network management type CAN messages are sequentially transmitted through the cache module and CanIf to the CAN network management layer CanNM.

2. The CAN message caching and processing architecture based on the AUTOSAR protocol stack according to claim 1, characterized in that: The cache module has a sequential storage function interface, which performs a calculation on the CanID in the received message, and the result is used as an index to access the mapping array. The message cache array stores messages at the corresponding starting position, assigns a mapping to the storage address, and moves the storage position forward after setting the message validity flag.

3. The CAN message caching and processing architecture based on the AUTOSAR protocol stack according to claim 2, characterized in that: The caching module also has an ordered read function interface. The ordered read function is used to read the cached messages in the order of their timestamps in a task, and call the CanIf layer interface CanIf_RxIndication() to upload the messages to other modules in the protocol stack for processing.

Citation Information

Patent Citations

  • Multipath CAN message real time reception software realization method

    CN107241251A

  • Power supply monitoring high-speed CAN message processing method and system

    CN112769816A

  • High speed communication system based on CAN bus

    CN202178776U