Efficient vehicle-mounted MCU communication method
By implementing the cache, encapsulation and retransmission mechanism of data frames at the protocol layer, combined with asynchronous processing of user registration interfaces, the problem of lack of unified specifications between on-board MCU communication protocols is solved, and the stability and reliability of data transmission are improved. It is suitable for Complex vehicle application scenarios.
Patent Information
- Application Number
- CN202310607614.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-26
- Publication Date
- 2024-11-26
AI Technical Summary
The lack of unified specifications for existing on-board MCU communication protocols, which makes it difficult to ensure the stability and reliability of data transmission in the automotive application field, especially when facing unstable factors, the system robustness and real-time nature are affected.
An efficient on-vehicle MCU communication method is designed to realize the cache, encapsulation, parsing and retransmission mechanism of data frames at the protocol layer, and the reliable transmission of messages is ensured by using ACK_EN, VALID, ACK_LOSS_COUNT and EN fields, and the user registration interface is implemented. Asynchronous processing and subscription services to enhance the fault tolerance and recovery of protocols.
It significantly improves the stability and reliability of data transmission, avoids unstable factors, and achieves efficient message interaction and real-time performance, which is suitable for complex signal transmission scenarios in on-board applications.
Smart Images

Figure CN119031045A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of communication technology, and in particular relates to an efficient vehicle-mounted MCU communication method. Background Art
[0002] With the continuous deepening of industrialization and informatization, there are basically few single systems in the application market. Most of them are the integration of multiple systems and multiple components. There must be information interaction between different system components. Due to the differences in the system components themselves, the interaction protocols between the components are diverse. Secondly, the design of the interaction protocol can be complex or simple, and depends on the specific application scenario and hardware facilities. The two can play a complementary role. For example, under fixed application scenarios and stable hardware infrastructure, the interaction protocol can be very simple, without considering fault-tolerant processing, and can achieve the most efficient communication. However, the actual scenario is not ideal, and there are still some abnormal situations that cannot be predicted, especially in the field of automotive applications, where safety and stability are crucial.
[0003] In the automotive application field, the vehicle sensor signals and industrial safety production control signals are basically based on MCUs. Therefore, the efficiency and stability of the communication protocol based on information interaction between MCUs directly affect the robustness of the entire system. At present, there is no unified specification requirement for the design of interactive communication protocols between MCUs, which often depends on the developer's own design and implementation, and there are large differences. Those that are slightly more standardized are based on the OSI 7-layer reference model for tailoring and adaptation to meet the needs of their own products.
[0004] For example, Chinese patent CN113422738A discloses an MCU communication service method for an intelligent host, which is also a design of the communication protocol architecture between the vehicle-mounted MCU and the SOC. It maps multiple virtual channels to a single physical communication link, classifies the transmitted data, and sends or receives the communication data of the same category through the same virtual channel. It can parse the user data at the bottom layer to avoid the generation of redundant data; it can also realize the communication between the MCU and the SOC, but the focus is still on the sending and receiving, parsing, verification, deduplication, and virtual multi-channel merging of data, which are all common practices. For example, Chinese patent CN112468513A discloses a terminal management communication protocol architecture for an enterprise network. The unique message format is set for the type and importance of the communication data between the management end and the terminal. It is well adapted to the various data messages when the management end issues policies and the terminal reports log data, and different BUCC message types can be selected according to the importance of its data messages, providing a good communication foundation for the communication of application data; it adopts the 7-layer reference model of OSI, layered design, and interface isolation to decouple complexity and achieve stability.
[0005] Secondly, when using products matched with the market, the communication protocol of the supplier's adapted products should be adopted. Currently, Autosar is widely popular in the field of vehicle-mounted applications, and the development based on the Autosar architecture has penetrated into various ECUs. However, the complexity and hugeness of Autosar also restrict its rapid development.
[0006] Due to the particularity of the automotive industry, it has very high requirements for safety, stability, and efficiency. In addition to the characteristics of the vehicle's own hardware, the stability and efficiency of the software performance directly affect the performance of the entire vehicle. Therefore, an efficient communication protocol architecture plays a key role in the stability and real-time performance of the software. Summary of the invention
[0007] The purpose of the present invention is to provide an efficient vehicle-mounted MCU communication method, which fully utilizes specific application scenarios and takes into account the particularity of general MCUs through subsequent processing when a frame of data is received or when data is to be sent, avoids unstable factors, and greatly improves the stability and reliability of data transmission.
[0008] To solve the above technical problems, the present invention is achieved through the following technical solutions:
[0009] The present invention is an efficient vehicle-mounted MCU communication method, wherein the vehicle-mounted MCU communication protocol architecture works at the protocol layer and includes the following steps:
[0010] The data sent by the sender is transmitted to the protocol layer after the protocol frame type is identified by routing processing at the application layer;
[0011] The protocol layer receives the protocol frame: sends the data buffer, encapsulates the data buffer into a frame of data, and then sends the frame buffer to the driver layer;
[0012] The protocol layer sends the protocol frame: the protocol layer receives the frame buffer and extracts a frame of data before receiving the data buffer. The protocol layer transmits the data buffer to the application layer.
[0013] The data is cached at the application layer and sent to the receiver after being processed by routing and identifying the protocol frame type.
[0014] Furthermore, the fields in the protocol architecture of the vehicle-mounted MCU communication are planned as follows:
[0015] MAIN_ID: main message ID;
[0016] SUB_ID: secondary message ID; a message is uniquely identified by MAIN_ID and SUB_ID;
[0017] ACK_EN: message acknowledgment enable; supports reliable transmission of messages, the ACK_EN field is set to TRUE or FALSE;
[0018] VALID: Indicates that a data frame has been successfully received or sent, providing a query interface for users;
[0019] ACK_LOSS_COUNT: protocol message sending response loss count;
[0020] EN: Whether the protocol is valid; if EN is TRUE, the corresponding message needs to be sent and received; if EN is FALSE, it is ignored;
[0021] LEN: The length of the data corresponding to a protocol. Because the data content of each interactive protocol has been determined at the beginning of its formulation, the length of the data is known. This length value can be used to determine whether the data is valid when parsing the data frame.
[0022] DATA_PTR: The address for sending and receiving data. For the sender, this pointer points to the data buffer to be sent, and for the receiver, it points to the buffer where the received data is to be saved.
[0023] FUNC_PTR: pointer to the function for parsing sent and received data; the function pointer is stored here, and the sender and receiver can freely implement their own data processing. Changes in the function content do not affect the definition of the message interaction method.
[0024] Furthermore, the method for the protocol layer to receive the protocol frame is:
[0025] Step 1: extract a frame of data from the frame queue of the received frame buffer;
[0026] Step 2: Parse the data frame and extract MAIN_ID, SUB_ID, LEN, and DATA_PTR;
[0027] Step 3: Index the corresponding protocol in the protocol array according to MAIN_ID and SUB_ID;
[0028] Step 4: If no corresponding protocol is found, discard it and jump to step 11;
[0029] Step 5: If the corresponding protocol is found, identify whether the data length is consistent. If not, discard it and jump to step 11;
[0030] Step 6: Identify the data frame type;
[0031] Step 7: If it is an acknowledgment frame, set the sending frame ACK_LOSS_COUNT = 0, VALID = FALSE, EN = TRUE, and jump to step 9;
[0032] Step 8: If it is a message frame and ACK_EN is TRUE, set the send response to be valid;
[0033] Step 9: Call the FUNC_PTR function in the protocol and transfer the data segment as a parameter;
[0034] Step 10: Set VALID in the protocol to TRUE and call the user registered interface;
[0035] Step 11: End.
[0036] Furthermore, in step 8, when setting the sending response to be valid, MAIN_ID and SUB_ID are filled in the response protocol in the corresponding sending protocol array, and MAIN_ID and SUB_ID are filled to indicate which protocol the response corresponds to. In step 10, VALID is set to TRUE, indicating that there is a response to be sent.
[0037] Furthermore, the method for the protocol layer to send a protocol frame is:
[0038] Step 11: traverse the protocol array to find out whether there is a sending requirement for the sending frame. If VALID is FALSE, jump to step 110;
[0039] Step 12: If EN is FALSE and timeout has occurred, jump to step 14;
[0040] Step 13: If EN is FALSE and not timed out, jump to step 110;
[0041] Step 14: Determine whether ACK_LOSS_COUNT exceeds the threshold;
[0042] Step 15: If ACK_LOSS_COUNT exceeds the threshold, the corresponding protocol is shielded, EN=FALSE, ACK_LOSS_COUNT=0 is set, and the process goes to step 110;
[0043] Step 16: If ACK_LOSS_COUNT does not exceed the threshold, jump to step 17;
[0044] Step 17: ACK_LOSS_COUNT increases by 1;
[0045] Step 18: Call the send frame FUNC_PTR to prepare to send data;
[0046] Step 19: Call the sending interface registered by the user;
[0047] Step 110: End.
[0048] Furthermore, in step 14, if ACK_LOSS_COUNT indicates acknowledgment loss, ACK_LOSS_COUNT is increased by 1, and the corresponding data frame is cyclically retransmitted; only when the acknowledgment ACK is received, the ACK_LOSS_COUNT of the corresponding protocol is cleared to 0, and VALID is set to FLASE, and the corresponding data frame is no longer sent; wherein, when no acknowledgment is received after the sending of a frame of protocol acknowledgment times out, it indicates that the acknowledgment is lost.
[0049] Furthermore, in step 15:
[0050] If ACK_LOSS_COUNT exceeds the threshold, the sending enable of the corresponding protocol is turned off, and EN is set to FALSE, that is, the corresponding protocol is not sent within a certain period of time. Even if the corresponding protocol has data, it is ignored until the EN closing time expires and EN is reopened to TRUE, and the corresponding protocol is tried again.
[0051] Furthermore, it also includes: adding a user registration interface for each protocol, receiving user subscriptions to messages, and automatically calling the user's callback function when a message arrives, triggering the user's receiving application at the first time, which has higher real-time performance for asynchronous data processing.
[0052] Furthermore, the fields of the registration interface are planned as follows:
[0053] MAIN_ID: main message ID;
[0054] SUB_ID: sub-message ID;
[0055] ARRAY_CALLBACK: An array for storing user-registered callback functions. The capacity of the array can be flexibly configured.
[0056] Furthermore, by using ACK_EN, the receiver gives a reception acknowledgement after receiving the data. If the data is lost, ACK_LOSS_COUNT accumulates and the sender will periodically resend the data. If ACK_LOSS_COUNT accumulates to a certain value, it means that the communication link or the receiver has failed. If it is meaningless to send this protocol later, the EN flag will be set at this time to block the corresponding protocol.
[0057] The present invention has the following beneficial effects:
[0058] The present invention makes full use of specific application scenarios through the fault tolerance and recovery mechanism in the message protocol and the subscription and publishing services in the message protocol, and takes into account the particularity of general MCUs, avoids unstable factors, and greatly improves the stability and reliability of data transmission.
[0059] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0061] Figure 1 It is a structural diagram of the communication protocol of the present invention;
[0062] Figure 2 A flow chart for receiving a protocol frame of the present invention;
[0063] Figure 3 A flow chart is used for sending protocol frames of the present invention. DETAILED DESCRIPTION
[0064] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0065] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0066] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0067] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0068] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0069] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0070] The present invention is an efficient vehicle-mounted MCU communication method. The vehicle-mounted MCU communication protocol architecture works at the protocol layer. For details about the vehicle-mounted MCU communication protocol architecture, please refer to Figure 1 As shown, the protocol architecture of the vehicle-mounted MCU communication works at the protocol layer, in which the sending, receiving, parsing and CRC check of frames are common practices. This embodiment mainly focuses on how to ensure high efficiency and reliability from the subsequent processing when a frame of data is received or when data is to be sent, and specifically includes the following steps:
[0071] The data sent by the sender is transmitted to the protocol layer after the protocol frame type is identified by routing processing at the application layer;
[0072] The protocol layer receives the protocol frame: sends the data buffer, encapsulates the data buffer into a frame of data, and then sends the frame buffer to the driver layer;
[0073] The protocol layer sends the protocol frame: the protocol layer receives the frame buffer and extracts a frame of data before receiving the data buffer. The protocol layer transmits the data buffer to the application layer.
[0074] The data is cached at the application layer and sent to the receiver after being processed by routing and identifying the protocol frame type.
[0075] As an embodiment provided by the present invention, preferably, the planning of each field in the protocol architecture of the vehicle-mounted MCU communication is shown in Table 1:
[0076] Table 1
[0077]
[0078] in:
[0079] MAIN_ID: main message ID;
[0080] SUB_ID: secondary message ID; a message can be uniquely identified by MAIN_ID and SUB_ID; specifically, a system may have multiple modules, and each module may have multiple sub-modules. Therefore, the two-level combination can basically manage various messages in groups, which is suitable for most application scenarios. In addition, a message can be uniquely identified by MAIN_ID and SUB_ID;
[0081] ACK_EN: message acknowledgment enable; supports reliable transmission of messages, the ACK_EN field is set to TRUE or FALSE; specifically: supports reliable transmission of messages, this field is set to TRUE, it can ensure that the message must be reliably sent to the other party, and it will be resent if it fails; if this message is sent, it can be set to FALSE, and the user can flexibly configure it according to needs; as an embodiment provided by the present invention, preferably, for example, in an actual scenario, the temperature value is transmitted periodically, the temperature keeps changing, and it is acceptable to occasionally lose one or two frames of data, and it is meaningless to retransmit old data;
[0082] VALID: Indicates that a data frame has been successfully received or sent, providing a query interface for users;
[0083] ACK_LOSS_COUNT: protocol message sending acknowledgment loss count; to ensure reliable data transmission, if ACK_EN is used, the receiver will give a receiving acknowledgment after receiving the data. If the data is lost, ACK_LOSS_COUNT will accumulate, and the sender will periodically resend the data. If ACK_LOSS_COUNT accumulates to a certain value, it means that the communication link or the receiver has failed. If this protocol is sent later, it will be meaningless. At this time, the EN flag will be set to block this protocol.
[0084] EN: Whether the protocol is valid; if EN is TRUE, the corresponding message needs to be sent and received; if EN is FALSE, it is ignored;
[0085] LEN: The length of the data corresponding to a protocol. Because the data content of each interactive protocol has been determined at the beginning of its formulation, the length of the data is known. This length value can be used to determine whether the data is valid when parsing the data frame.
[0086] DATA_PTR: The address of sending and receiving data; for the sender, this pointer points to the data buffer to be sent, and for the receiver, it points to the buffer where the received data is to be saved;
[0087] FUNC_PTR: pointer to the function for parsing sent and received data; the function pointer is stored here, and the sender and receiver can freely implement their own data processing. Changes in the function content do not affect the definition of the message interaction method.
[0088] like Figure 2 As shown, as an embodiment provided by the present invention, preferably, the method for the protocol layer to receive the protocol frame is:
[0089] Step 1: extract a frame of data from the frame queue of the received frame buffer;
[0090] Step 2: Parse the data frame and extract MAIN_ID, SUB_ID, LEN, and DATA_PTR;
[0091] Step 3: Index the corresponding protocol in the protocol array according to MAIN_ID and SUB_ID;
[0092] Step 4: If no corresponding protocol is found, discard it and jump to step 11;
[0093] Step 5: If the corresponding protocol is found, identify whether the data length is consistent. If not, discard it and jump to step 11;
[0094] Step 6: Identify the data frame type;
[0095] Step 7: If it is an acknowledgment frame, set the sending frame ACK_LOSS_COUNT = 0, VALID = FALSE, EN = TRUE, and jump to step 9;
[0096] Step 8: If it is a message frame and ACK_EN is TRUE, set the send response to be valid;
[0097] Step 9: Call the FUNC_PTR function in the protocol and transfer the data segment as a parameter;
[0098] Step 10: Set VALID in the protocol to TRUE and call the user registered interface;
[0099] Step 11: End.
[0100] As an embodiment provided by the present invention, preferably, in the step 8, when setting the sending response to be valid, MAIN_ID and SUB_ID are filled in the response protocol in the corresponding sending protocol array, and the corresponding protocol of the response is indicated by filling in MAIN_ID and SUB_ID. In the step 10, VALID is set to TRUE, indicating that there is a response to be sent.
[0101] like Figure 3 As shown, as an embodiment provided by the present invention, preferably, the method for the protocol layer to send a protocol frame is:
[0102] Step 11: traverse the protocol array to find out whether there is a sending requirement for the sending frame. If VALID is FALSE, jump to step 110;
[0103] Step 12: If EN is FALSE and timeout has occurred, jump to step 14;
[0104] Step 13: If EN is FALSE and not timed out, jump to step 110;
[0105] Step 14: Determine whether ACK_LOSS_COUNT exceeds the threshold;
[0106] Step 15: If ACK_LOSS_COUNT exceeds the threshold, the corresponding protocol is shielded, EN=FALSE, ACK_LOSS_COUNT=0 is set, and the process goes to step 110;
[0107] Step 16: If ACK_LOSS_COUNT does not exceed the threshold, jump to step 17;
[0108] Step 17: ACK_LOSS_COUNT increases by 1;
[0109] Step 18: Call the send frame FUNC_PTR to prepare to send data;
[0110] Step 19: Call the sending interface registered by the user;
[0111] Step 110: End.
[0112] As an embodiment provided by the present invention, preferably, in step 14, if ACK_LOSS_COUNT indicates acknowledgment loss, ACK_LOSS_COUNT is increased by 1, and the corresponding data frame is cyclically retransmitted; only when the acknowledgment ACK is received, the ACK_LOSS_COUNT of the corresponding protocol is cleared to 0, and VALID is set to FLASE, and the corresponding data frame is no longer sent; wherein, when no acknowledgment is received after the sending of a frame of protocol acknowledgment timeout, it indicates that the acknowledgment is lost.
[0113] As another embodiment provided by the present invention, preferably, ACK_LOSS_COUNT is the response loss. For example, a frame protocol is sent and a response needs to be received. After the response times out, for example, a 50ms timeout is set. If no response is received within 50ms, it means that the response is lost. ACK_LOSS_COUNT is increased by 1, and then the data frame will be retransmitted cyclically. Only when the response ACK is received, the ACK_LOSS_COUNT of the protocol is cleared to 0, and VALID is set to FLASE, that is, there is no need to send the data again.
[0114] As an embodiment provided by the present invention, preferably, in step 15:
[0115] If ACK_LOSS_COUNT exceeds the threshold, the sending enable of the corresponding protocol is turned off, and EN is set to FALSE, that is, the corresponding protocol is not sent within a certain period of time. Even if the corresponding protocol has data, it is ignored until the EN closing time expires and EN is reopened to TRUE, and the corresponding protocol is tried again.
[0116] As another embodiment provided by the present invention, preferably, if ACK_LOSS_COUNT accumulates to a threshold, for example, the number of retransmissions is set to 5 times, if it exceeds 5 times, the transmission enable EN of the protocol is turned off to FALSE, that is, the protocol is not sent within a certain period of time, even if the protocol has data, it is ignored until the EN closing time times out, for example, 10s, then EN will be reopened to TRUE and retry to send. ACK_LOSS_COUNT is accurate to each protocol.
[0117] As another embodiment provided by the present invention, preferably, if a communication link fails, all protocol frames will be stopped at last, which can be used to assist in locating whether the content of the protocol frame is wrong or the entire communication link fails.
[0118] As an embodiment provided by the present invention, preferably, it also includes: adding a user registration interface for each protocol, receiving user subscription to messages, and automatically calling the user's callback function when the message arrives, triggering the user's receiving application at the first time, and having higher real-time performance for asynchronous processing of data.
[0119] As an embodiment provided by the present invention, preferably, the fields of the registration interface are planned as shown in Table 2: Table 2
[0120] MAIN_ID SUB_ID ARRAY_CALLBACK
[0121] in:
[0122] MAIN_ID: main message ID;
[0123] SUB_ID: sub-message ID;
[0124] ARRAY_CALLBACK: The array where the user registration callback functions are stored. The capacity of the array can be flexibly configured, and the number of subscriptions supported can be determined in advance.
[0125] As an embodiment provided by the present invention, preferably, by using ACK_EN, the receiver gives a reception response after receiving the data. If the data is lost, ACK_LOSS_COUNT accumulates and the sender will periodically resend the data. If ACK_LOSS_COUNT accumulates to a certain value, it means that the communication link or the receiver has failed, and it is meaningless to send this protocol later. At this time, the EN flag will be set to shield the corresponding protocol.
[0126] As an embodiment provided by the present invention, preferably, the protocol layer has message response, failure retransmission, error closure, timeout recovery, and user message registration and subscription, which basically meet the needs of most applications, and the architecture achieves layered isolation and low coupling, and is particularly suitable for message transmission in vehicle-mounted applications. Because there are many types of vehicle-mounted signals, but the amount of data in each signal is small, the protocol can achieve real-time and reliability.
[0127] As an embodiment provided by the present invention, preferably, the reception and transmission of the frame protocol can all be implemented in the application layer, which can still achieve similar effects and more functions, but the real-time performance is not good enough and still depends on the stability of the protocol layer.
[0128] An efficient vehicle-mounted MCU communication method, through the fault tolerance and recovery mechanism in the message protocol, the subscription and publishing services in the message protocol, makes full use of specific application scenarios, and takes into account the particularity of general MCUs, avoids unstable factors, and greatly improves the stability, flexibility and reliability of data transmission. Specifically, the communication protocol of the present invention can achieve the following points:
[0129] 1. Low coupling: It provides standard data receiving and sending interfaces, and can be used as a black box by the outside world;
[0130] 2. Strong versatility: There are no special requirements for the usage scenarios, and it can be used for reference for interactive communication between general MCUs;
[0131] 3. High real-time performance: supports variable data frame length, minimizes data volume, and achieves efficient transmission;
[0132] 4. High fault tolerance: Supports protocol layer transceiver response mechanism. If the protocol transceiver is abnormal and the cumulative value reaches a critical value, it will be automatically shielded from the protocol to reduce interference;
[0133] 5. Strong robustness: after abnormal transmission and reception, there is a timeout retry recovery mechanism;
[0134] 6. Easy to maintain: The protocol framework adopts a layered modular design, and the responsibilities of each module are clear;
[0135] 7. Easy to transplant: Written in C language, with strong applicability;
[0136] 8. Easy to expand: supports user agreement registration, publishing, and subscription functions, with good flexibility.
[0137] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", 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 invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0138] The preferred embodiments of the present invention disclosed above are only used to help illustrate the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. An efficient vehicle-mounted MCU communication method, characterized in that: The protocol architecture of the vehicle-mounted MCU communication works at the protocol layer and includes the following steps: The data sent by the sender is transmitted to the protocol layer after the protocol frame type is identified by routing processing at the application layer; The protocol layer receives the protocol frame: sends the data buffer, encapsulates the data buffer into a frame of data, and then sends the frame buffer to the driver layer; The protocol layer sends the protocol frame: the protocol layer receives the frame buffer and extracts a frame of data before receiving the data buffer. The protocol layer transmits the data buffer to the application layer. The data is cached at the application layer and sent to the receiver after being processed by routing and identifying the protocol frame type.
2. According to claim 1, an efficient vehicle-mounted MCU communication method is characterized in that: The fields in the protocol architecture of the vehicle-mounted MCU communication are planned as follows: MAIN_ID: main message ID; SUB_ID: secondary message ID; a message is uniquely identified by MAIN_ID and SUB_ID; ACK_EN: message acknowledgment enable; supports reliable transmission of messages, the ACK_EN field is set to TRUE or FALSE; VALID: Indicates that a data frame has been successfully received or sent; ACK_LOSS_COUNT: protocol message sending response loss count; EN: Whether the protocol is valid; if EN is TRUE, the corresponding message needs to be sent and received; if EN is FALSE, it is ignored; LEN: the length of data corresponding to a protocol; DATA_PTR: the address for sending and receiving data; FUNC_PTR: Function pointer for parsing send and receive data.
3. An efficient vehicle-mounted MCU communication method according to claim 2, characterized in that: The method for the protocol layer to receive the protocol frame is: Step 1: extract a frame of data from the frame queue of the received frame buffer; Step 2: Parse the data frame and extract MAIN_ID, SUB_ID, LEN, and DATA_PTR; Step 3: Index the corresponding protocol in the protocol array according to MAIN_ID and SUB_ID; Step 4: If no corresponding protocol is found, discard it and jump to step 11; Step 5: If the corresponding protocol is found, identify whether the data length is consistent. If not, discard it and jump to step 11; Step 6: Identify the data frame type; Step 7: If it is an acknowledgment frame, set the sending frame ACK_LOSS_COUNT = 0, VALID = FALSE, EN = TRUE, and jump to step 9; Step 8: If it is a message frame and ACK_EN is TRUE, set the send response to be valid; Step 9: Call the FUNC_PTR function in the protocol and transfer the data segment as a parameter; Step 10: Set VALID in the protocol to TRUE and call the user registered interface; Step 11: End.
4. The efficient vehicle-mounted MCU communication method according to claim 3, characterized in that: In step 8, when setting the sending response to be valid, MAIN_ID and SUB_ID are filled in the response protocol in the corresponding sending protocol array, and the corresponding protocol response is indicated by filling in MAIN_ID and SUB_ID. In step 10, VALID is set to TRUE, indicating that there is a response to be sent.
5. The efficient vehicle-mounted MCU communication method according to claim 4, characterized in that: The method for the protocol layer to send a protocol frame is: Step 1: Traverse the protocol array to find out whether there is a need to send the frame. If VALID is FALSE, jump to step 10. Step 2: If EN is FALSE and timeout has occurred, jump to step 4; Step 3: If EN is FALSE and it has not timed out, jump to step 10; Step 4: Determine whether ACK_LOSS_COUNT exceeds the threshold; Step 5: If ACK_LOSS_COUNT exceeds the threshold, the corresponding protocol is shielded, EN=FALSE, ACK_LOSS_COUNT=0 is set, and the process goes to step 10; Step 6: If ACK_LOSS_COUNT does not exceed the threshold, jump to step 7; Step 7: ACK_LOSS_COUNT increases by 1; Step 8: Call the sending frame FUNC_PTR to prepare to send data; Step 9: Call the sending interface registered by the user; Step 10: End.
6. The efficient vehicle-mounted MCU communication method according to claim 5, characterized in that: In step 14, if ACK_LOSS_COUNT indicates acknowledgment loss, ACK_LOSS_COUNT is increased by 1, and the corresponding data frame is cyclically retransmitted; only when the acknowledgment ACK is received, the ACK_LOSS_COUNT of the corresponding protocol is cleared to 0, and VALID is set to FLASE, and the corresponding data frame is no longer sent; wherein, when a frame of protocol response is sent and no response is received after the timeout, it indicates that the response is lost.
7. The efficient vehicle-mounted MCU communication method according to claim 5, characterized in that: In step 15: If ACK_LOSS_COUNT exceeds the threshold, the sending enable of the corresponding protocol is turned off, and EN is set to FALSE, that is, the corresponding protocol is not sent within a certain period of time. Even if the corresponding protocol has data, it is ignored until the EN closing time expires and EN is reopened to TRUE, and the corresponding protocol is tried again.
8. The efficient vehicle-mounted MCU communication method according to claim 1, characterized in that: Also includes: Add a user registration interface for each protocol to receive user subscriptions to messages. When a message arrives, the user's callback function is automatically called to trigger the user's receiving application as soon as possible.
9. An efficient vehicle-mounted MCU communication method according to claim 8, characterized in that: The fields of the registration interface are planned as follows: MAIN_ID: main message ID; SUB_ID: sub-message ID; ARRAY_CALLBACK: An array for storing user-registered callback functions. The capacity of the array can be flexibly configured.
10. The efficient vehicle-mounted MCU communication method according to claim 2, characterized in that: By using ACK_EN, the receiver gives a reception acknowledgment after receiving the data. If the data is lost, ACK_LOSS_COUNT accumulates and the sender resends the data periodically. If ACK_LOSS_COUNT accumulates to a certain value, indicating that the communication link or the receiver has failed, the EN flag is set to shield the corresponding protocol.
Citation Information
Patent Citations
Terminal management communication protocol architecture of enterprise network
CN112468513A
MCU communication service method of intelligent host
CN113422738A
