Message error correction method and device and electronic equipment
By tampering with the message receiving mailbox ID of the on-board controller, the abnormal function and driving safety risks caused by the message ID being tampered with are solved, and the reliability of message reception is improved.
Patent Information
- Application Number
- CN202510066564.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-05-27
AI Technical Summary
During the operation of the on-board controller, the message ID of the message receiving mailbox may be abnormally tampered with, resulting in the upper-level application software being unable to receive the expected messages normally, which will affect driving safety.
By obtaining the message ID of the controller's message, the message ID corresponding to the mailbox is detected according to the preset detection mask. If the detection result indicates that the message ID has been tampered with, the message ID corresponding to the message receiving mailbox is rewrite based on the preset message ID.
The detection and error correction mechanism for the mailbox message receiving mailbox message ID has been added, which effectively avoids the problem of message ID tampering caused by software failure or hardware defects, improves the reliability of message reception, and ensures driving safety.
Smart Images

Figure CN120050066A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and more particularly, to a method and apparatus for message error correction and an electronic device. Background Art
[0002] Currently, after the in-vehicle controller software is developed, the message content that the controller needs to receive will be fixedly stored in the corresponding message receiving mailbox, and the upper-layer application software reads the required signals from the relevant message receiving mailbox according to the functional implementation requirements. However, when the controller software occasionally malfunctions during operation or there are defects in the microcontroller hardware design, etc., the message information (such as message ID, etc.) set in the message receiving mailbox may be abnormally tampered with, resulting in the upper-layer application software of the controller being unable to read the expected message from the relevant message receiving mailbox, causing the functions of the upper-layer application software to malfunction and even endangering driving safety. Summary of the Invention
[0003] In view of this, embodiments of the present application propose a method and apparatus for message error correction and an electronic device to improve the above problems.
[0004] In a first aspect, an embodiment of the present application provides a method for message error correction, the method including: obtaining a message ID corresponding to a message receiving mailbox of a controller; performing tampering detection on the message ID according to a preset detection mask to obtain a detection result; if the detection result indicates that the message ID is tampered with, rewriting the message ID corresponding to the message receiving mailbox based on a preset message ID.
[0005] In a second aspect, an embodiment of the present application provides a message error correction apparatus, the apparatus including: a message ID obtaining module, a tampering detection module, and a message ID rewriting module. Among them, the message ID obtaining module is used to obtain a message ID corresponding to a message receiving mailbox of a controller; the tampering detection module is used to perform tampering detection on the message ID according to a preset detection mask to obtain a detection result; the message ID rewriting module is used to, if the detection result indicates that the message ID is tampered with, rewrite the message ID corresponding to the message receiving mailbox based on a preset message ID.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, the memory being coupled to the processor, the memory storing instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which program code is stored, and the program code can be called by a processor to execute the above method.
[0008] In the solution of this application, by obtaining the message ID corresponding to the message receiving mailbox of the controller, and performing tampering detection on the message ID according to a preset detection mask, a detection result is obtained. And if the detection result indicates that the message ID has been tampered with, the message ID corresponding to the message receiving mailbox is rewritten based on a preset message ID, thereby adding a mechanism for detecting and correcting errors to the message ID corresponding to the message receiving mailbox of the controller, effectively avoiding the abnormal tampering of the message ID corresponding to the message receiving mailbox that occurs during the operation of the controller due to reasons such as occasional software operation failures of the controller or poor production batches of microcontroller hardware, and further avoiding the problem that the expected message cannot be received normally, and improving the reliability of the message ID corresponding to the message receiving mailbox. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of this application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of this application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0010] Figure 1 Shows a schematic flowchart of a message error correction method provided by an embodiment of this application;
[0011] Figure 2 Shows a schematic flowchart of a message error correction method provided by an embodiment of this application;
[0012] Figure 3 Shows a schematic diagram of an application scenario provided by an embodiment of this application;
[0013] Figure 4 Shows a schematic flowchart of a message error correction method provided by an embodiment of this application;
[0014] Figure 5 Shows a block diagram of a message error correction device provided by an embodiment of this application;
[0015] Figure 6 Shows a block diagram of an electronic device for executing the message error correction method according to the embodiment of this application;
[0016] Figure 7 Shows a storage unit for storing or carrying program codes for implementing the message error correction method according to the embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application.
[0018] To better understand the solution of the embodiments of this application, the technical terms used in the embodiments of this application will be explained below.
[0019] Message receiving mailbox. The receiving mailbox of a controller generally refers to the mailbox used to receive data in CAN (Controller Area Network) bus communication. In a CAN bus system, the message receiving mailbox (also known as the receiving FIFO) is used to store the received CAN messages. Each receiving mailbox is usually associated with a specific set of message IDs, and these IDs are determined by filter settings to identify which messages can be received and stored in the mailbox.
[0020] Bus off. In the fields of automotive electronics and network communication, "bus off" is a specific term, usually related to the CAN bus; the CAN bus is a communication protocol commonly used in automotive electronic systems to connect and control various electronic control units (ECUs). The "bus off" state is an error state defined in the CAN bus protocol. When a node (ECU) experiences a serious error on the CAN network, such as continuously sending error frames or being unable to correctly respond to other messages on the network, the node will be placed in the "bus off" state. In this state, the node will no longer be able to send or receive any messages to prevent further error propagation to the entire network.
[0021] BSW generally refers to the Basic Software Layer in the field of automotive electronics. It is an important part of the AUTOSAR (AUTomotive Open System ARchitecture) architecture.
[0022] RTE, Run-Time Environment, is the core component of the AUTOSAR architecture. It is responsible for managing and coordinating the communication between software components and provides a set of standardized services and interfaces, enabling different software components to work effectively together in an automotive electronic system.
[0023] In the AUTOSAR architecture, SWC represents Software Component, that is, a software component. It is the basic unit used to build and organize software modules in AUTOSAR.
[0024] The implementation details of the technical solutions in the embodiments of this application will be elaborated in detail below:
[0025] With the widespread application of automotive CAN communication and the need to transmit traditional hard-wired signals in the form of CAN signals after conversion, more and more CAN signals are processed among various automotive modules. In current automotive CAN chips, there are generally multiple channels, and each channel will have the same or different numbers of mailboxes. Each mailbox will have a configurable signal filtering ID and mask for configuring the signal perception of each mailbox.
[0026] In the related art, the CAN messages sent and received by in-vehicle controllers are usually fixed. The message definitions are made during the functional design phase, and the message information (ID, downloadable content, data field content, etc.) sent and received by the controller is written into the message sending and receiving mailboxes opened in the RAM through static configuration during the software development phase. That is, after the controller software development is completed, the message information that should be received in the receiving mailbox has been set. Correspondingly, after the controller software development is completed, the message content that the controller needs to receive will be fixedly stored in the corresponding message receiving mailbox, and the upper-layer application software reads the required signals from the relevant message receiving mailboxes according to the functional implementation requirements.
[0027] Generally, the controller will only rewrite the relevant message information in the receiving mailbox in cases such as initialization, bus off recovery, or software reset. However, if the controller software accidentally malfunctions during operation or there are defects in the microcontroller hardware design, etc., the message information (such as the message ID, etc.) set in the message receiving mailbox may be abnormally tampered with, resulting in the upper-layer application software of the controller being unable to read the expected message from the relevant receiving mailbox, leading to abnormal functions of the upper-layer application software and even endangering driving safety. Therefore, in the related art, there is a challenge of improving the reliability of the message ID corresponding to the message receiving mailbox of the controller.
[0028] In view of the above problems, through long-term research, the inventors have proposed the message error correction method, device, and electronic device provided in the embodiments of the present application. By adding a mechanism for detecting and correcting the message ID corresponding to the message receiving mailbox of the controller, it effectively avoids the abnormal tampering of the message ID corresponding to the message receiving mailbox during the operation of the controller caused by accidental operation failures of the controller software or poor production batches of microcontroller hardware, etc., and further avoids the problem that the expected message cannot be normally received, improving the reliability of the message ID corresponding to the message receiving mailbox. Among them, the specific message error correction method will be described in detail in the subsequent embodiments.
[0029] The embodiments of the present application will be described below with reference to the accompanying drawings.
[0030] Please refer to Figure 1 ,Figure 1 The figure shows a schematic flow chart of a message error correction method provided by an embodiment of the present application. In a specific embodiment, the message error correction method can be applied to a message error correction device 200 as shown in Figure 5 Figure and an electronic device 100 configured with the message error correction device 200 ( Figure 6 ). Hereinafter, taking the electronic device as an example, the specific process of this embodiment will be described. Of course, it can be understood that the electronic devices to which this embodiment is applied may include devices such as desktop computers, laptop computers, vehicle-mounted terminals, and in-vehicle large screens, which are not limited herein. Next, the process shown in Figure 1 Figure will be elaborated in detail. The message error correction method may specifically include the following steps:
[0031] Step S110: Obtain the message ID corresponding to the message receiving mailbox of the controller.
[0032] In some embodiments, the electronic device may be communicatively connected to the controller, and the controller may also be provided in the electronic device. Among them, the electronic device may receive a message error correction instruction and obtain the message ID corresponding to the message receiving mailbox of the controller in response to the message error correction instruction. Optionally, the electronic device may also detect the message ID corresponding to the message receiving mailbox of the controller at a preset time interval during the operation of the controller.
[0033] Among them, the preset time interval may be preset in the electronic device, which may be set by the user independently or obtained through third-party experimental data. Exemplarily, the preset time interval is set by the user independently to 50 ms, 100 ms, etc., which is not limited herein.
[0034] Among them, the number of message receiving mailboxes of the controller may be one or more, and the message IDs corresponding to each message receiving mailbox are different; correspondingly, different message receiving mailboxes may be used to store messages filtered by the message IDs corresponding to the message receiving mailboxes; correspondingly, after the controller software development is completed, the message content that the controller needs to receive will be fixedly stored in the corresponding message receiving mailbox, so that the upper-layer application software can read the required messages from the relevant message receiving mailboxes according to the function implementation requirements.
[0035] Step S120: Perform tampering detection on the message ID according to a preset detection mask to obtain a detection result.
[0036] In some embodiments, a preset detection mask may be pre-set in the electronic device; wherein, the preset detection mask may be determined according to the frame format of the CAN protocol corresponding to the message receiving mailbox. Exemplarily, if the frame format of the CAN protocol corresponding to the message receiving mailbox is a standard frame, correspondingly, the preset detection mask corresponding to the message receiving mailbox may be an 11-bit binary number with each bit being 1 (0x7FF); Exemplarily, if the frame format of the CAN protocol corresponding to the message receiving mailbox is an extended frame, correspondingly, the preset detection mask corresponding to the message receiving mailbox may be a 26-bit binary number with each bit being 1.
[0037] Wherein, after the electronic device obtains the message ID corresponding to the message receiving mailbox, it may obtain the preset detection mask corresponding to the message receiving mailbox, and may perform tampering detection on the message ID according to the preset detection mask to obtain a detection result.
[0038] Wherein, the electronic device may perform a logical AND operation on the message ID corresponding to the message receiving mailbox and the preset detection mask to obtain an operation result, and may compare the operation result with the preset message ID corresponding to the message receiving mailbox to obtain a detection result for tampering detection of the message ID.
[0039] Wherein, a preset message ID corresponding to the message receiving mailbox is pre-set in the electronic device. Wherein, the detection result is that the message ID is tampered or the message ID is not tampered. Wherein, if the electronic device determines that the operation result is inconsistent with the preset message ID corresponding to the message receiving mailbox, it may determine that the message ID is tampered; or, if the electronic device determines that the operation result is consistent with the preset message ID corresponding to the message receiving mailbox, it may determine that the message ID is not tampered.
[0040] Step S130: If the detection result indicates that the message ID is tampered, rewrite the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0041] In some embodiments, after the electronic device performs tampering detection on the message ID corresponding to the message receiving mailbox according to the preset detection mask and obtains a detection result, if it is determined that the detection result indicates that the message ID is tampered, it may rewrite the message ID corresponding to the message receiving mailbox based on the preset message ID to ensure the reliability of the message ID corresponding to the message receiving mailbox, and avoid the problem that due to reasons such as occasional running failures of the controller software or poor production batches of the microcontroller hardware, the message ID corresponding to the message receiving mailbox in the controller is abnormally tampered during operation, the expected message cannot be normally received by the message receiving mailbox or the software cannot receive the expected message, resulting in abnormal or ineffective functions of the software.
[0042] Among them, if the electronic device determines that the detection result indicates that the message ID of the message receiving mailbox has not been tampered with, it can return to execute step S110 and subsequent steps based on a preset time interval. When the controller is running, it polls and detects the message ID corresponding to the message receiving mailbox of the controller, and performs tampering detection and error correction on the message ID corresponding to the message receiving mailbox of the controller, preventing the message ID corresponding to the message receiving mailbox from being abnormally tampered with during the operation of the controller due to reasons such as occasional software operation failures of the controller or poor production batches of microcontroller hardware, resulting in the upper-layer application software being unable to read the expected received message, thereby causing functional abnormalities or failures. This improves the reliability of the message ID corresponding to the message receiving mailbox and also improves the reliability of the messages in the message receiving mailbox.
[0043] The message error correction method provided by an embodiment of the present application obtains the message ID corresponding to the message receiving mailbox of the controller, performs tampering detection on the message ID according to a preset detection mask to obtain a detection result, and if the detection result indicates that the message ID has been tampered with, rewrites the message ID corresponding to the message receiving mailbox of the controller based on a preset message ID, thereby adding a mechanism for detecting and correcting errors to the message ID corresponding to the message receiving mailbox of the controller, effectively avoiding the abnormal tampering of the message ID corresponding to the message receiving mailbox during the operation of the controller due to reasons such as occasional software operation failures of the controller or poor production batches of microcontroller hardware, and further avoiding the problem that the expected message cannot be normally received, improving the reliability of the message ID corresponding to the message receiving mailbox.
[0044] Please refer to Figure 2 , Figure 2 which shows a schematic flowchart of the message error correction method provided by an embodiment of the present application. This method is applied to the above-mentioned electronic device. The following will elaborate in detail on the Figure 2 shown process. The message error correction method may specifically include the following steps:
[0045] Step S210: Poll and detect the message ID corresponding to the message receiving mailbox according to a preset period, where the preset period is less than or equal to the target period, and the target period is the smallest message period among the messages received by the controller.
[0046] In some embodiments, a preset period can be pre-set in the electronic device, such as 100 ms, 50 ms, etc.; among them, the electronic device can, when the controller is running, poll and detect the message IDs corresponding to the respective message receiving mailboxes of the controller according to this preset period.
[0047] Among them, the preset period can be less than or equal to the target period, and the target period can be the minimum message period in the messages received by the controller. Among them, the preset period being less than or equal to the minimum message period in the messages received by the controller can ensure that the controller performs tampering detection and error correction on the message ID corresponding to the message receiving mailbox before receiving the message, preventing the problem that the message ID corresponding to the message receiving mailbox is abnormally tampered during the operation of the controller due to reasons such as occasional software operation failures of the controller or poor production batches of the microcontroller hardware, resulting in the upper-layer application software being unable to read the expected received message, thereby causing functional abnormalities or failures. This improves the reliability of the message ID corresponding to the message receiving mailbox and also improves the reliability of the messages in the message receiving mailbox.
[0048] Step S220: Perform a logical AND operation on the message ID and the preset detection mask to obtain a to-be-verified ID.
[0049] Among them, preset detection masks corresponding to each message receiving mailbox of the controller can be preset in the electronic device. Among them, after the electronic device obtains the message IDs corresponding to each message receiving mailbox of the controller, it can perform a logical AND operation on the message IDs corresponding to each message receiving mailbox and the preset detection masks corresponding to each message receiving mailbox to obtain the to-be-verified IDs corresponding to each message receiving mailbox. Exemplarily, the preset detection mask corresponding to the message receiving mailbox is 0x7FF. Correspondingly, after the electronic device obtains the message ID corresponding to this message receiving mailbox, it can perform a logical AND operation on this message ID and the preset detection mask 0x7FF to obtain the to-be-verified ID.
[0050] Step S230: If the to-be-verified ID is the same as the preset message ID, it is determined that the message ID has not been tampered with.
[0051] In some embodiments, preset message IDs corresponding to each message receiving mailbox of the controller can be preset in the electronic device. Among them, after the electronic device obtains the to-be-verified ID corresponding to the message receiving mailbox, it can compare this to-be-verified ID with the preset message ID corresponding to this message receiving mailbox, and can determine whether the message ID corresponding to this message receiving mailbox has been tampered with according to the comparison result.
[0052] Exemplarily, if the electronic device determines according to the comparison result that the to-be-verified ID corresponding to the message receiving mailbox is the same as the preset message ID corresponding to this message receiving mailbox, it can be determined that the message ID corresponding to this message receiving mailbox has not been tampered with.
[0053] Step S240: If the to-be-verified ID is different from the preset message ID, it is determined that the message ID has been tampered with.
[0054] In some embodiments, if the electronic device determines that the ID to be verified corresponding to the message receiving mailbox is different from the preset message ID corresponding to the message receiving mailbox, it can be determined that the message ID corresponding to the message receiving mailbox has been tampered with. Among them, the difference between the ID to be verified corresponding to the message receiving mailbox and the preset message ID corresponding to the message receiving mailbox can indicate that there is an abnormal problem of tampering with the message ID corresponding to the message receiving mailbox during the operation of the controller. Correspondingly, the electronic device can rewrite the message ID corresponding to the message receiving mailbox based on the preset message ID to ensure the reliability of the message ID corresponding to the message receiving mailbox, improve the reliability of the messages in the message receiving mailbox, and effectively prevent the problem of vehicle function abnormality or even endangerment to driving safety.
[0055] Step S250: If the detection result indicates that the message ID has been tampered with, rewrite the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0056] For the specific description of step S250, please refer to the description of step S130 above and will not be elaborated here in detail.
[0057] Step S260: If the rewrite of the message ID corresponding to the message receiving mailbox fails, return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0058] In some embodiments, during the process of the electronic device rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID, if it is determined that the rewrite of the message ID corresponding to the message receiving mailbox fails, it can return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID to attempt to rewrite the message ID corresponding to the message receiving mailbox again.
[0059] Among them, if the electronic device successfully rewrites the message ID corresponding to the message receiving mailbox, it can end the detection of the tampering of the message ID corresponding to the message receiving mailbox this time.
[0060] Step S270: If the rewrite of the message ID corresponding to the message receiving mailbox fails, obtain the cumulative number of times of failure in rewriting the message ID corresponding to the message receiving mailbox.
[0061] In some embodiments, during the process of the electronic device rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID, if it is determined that the rewrite of the message ID corresponding to the message receiving mailbox fails, it can obtain the cumulative number of times of failure in rewriting the message ID corresponding to the message receiving mailbox.
[0062] Step S280: If the cumulative number of times is less than the preset number of times, return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0063] Among them, after the electronic device obtains the cumulative number of times of failure to rewrite the message ID corresponding to the message receiving mailbox, if it is determined that the cumulative number of times is less than the preset number of times, it can return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0064] Among them, a preset number of times can be preset in the electronic device. The preset number of times can be set independently by the user or obtained through third-party experimental data. Exemplarily, the preset number of times is independently set by the user to 5 times, 6 times, etc., which is not limited herein. Among them, the preset number of times can be understood as the maximum number of times to rewrite the message ID corresponding to the message receiving mailbox.
[0065] Step S290: If the cumulative number of times reaches the preset number of times, reset the controller, and after the controller completes the reset, set the message ID corresponding to the message receiving mailbox to the preset message ID.
[0066] In some embodiments, if the electronic device determines that the cumulative number of times of failure to rewrite the message ID corresponding to the message receiving mailbox reaches the preset number of times, it can reset the controller, and after the controller completes the reset, set the message ID corresponding to the message receiving mailbox to the preset message ID. In the case where it is still unsuccessful to rewrite the message ID corresponding to the message receiving mailbox to the preset message ID after attempting the preset number of times, perform a reset operation on the controller software to force the message ID corresponding to the message receiving mailbox to be restored to the default value, that is, the preset message ID.
[0067] Among them, during the process of resetting the controller, the controller can be reset based on software reset or based on hardware reset, which is not limited herein.
[0068] Among them, when the electronic device determines that the cumulative number of times of failure to rewrite the message ID corresponding to the message receiving mailbox reaches the preset number of times, it can record the fault code corresponding to the controller before resetting the controller, so as to analyze the reason for the abnormal tampering of the message ID corresponding to the message receiving mailbox and the reason for the failure to rewrite the message ID corresponding to the message receiving mailbox according to the fault code. Optionally, during the process of the electronic device recording the fault code corresponding to the controller, it can record the fault code for the failure to write the message ID corresponding to the message receiving mailbox for this detection of the tampering of the message ID corresponding to the message receiving mailbox, thereby saving the resource consumption of abnormal records.
[0069] In some embodiments, when the electronic device determines that the cumulative number of failures to rewrite the message ID corresponding to the message receiving mailbox reaches a preset number, it can also output a prompt message, where the prompt message can be used to prompt that the message ID corresponding to the message receiving mailbox is abnormal. Among them, the electronic device can output the prompt message based on methods such as indicator light prompting, voice prompting, and interface text prompting. Exemplarily, the electronic device may include an instrument panel or a central control screen. Among them, the electronic device can output the prompt message through the instrument panel or the central control screen to prompt the user that the message ID corresponding to the message receiving mailbox is abnormal.
[0070] Exemplarily, please refer to Figure 3 and Figure 4 . Among them, Figure 3 shows a schematic diagram of an application scenario provided by an embodiment of the present application, Figure 4 a schematic flowchart of a message error correction method provided by an embodiment of the present application. Among them, the number of message receiving mailboxes of the controller is multiple. For example, the message receiving mailbox corresponding to the message ID of 0x101, the message receiving mailboxes corresponding to the message IDs of 0x102 and 0x102,......, the message receiving mailbox corresponding to the message ID of 0xXXX. Among them, the message receiving mailbox corresponding to the message ID of 0x101 can store the message content of 0x101, the message receiving mailboxes corresponding to the message IDs of 0x102 and 0x102 can store the message content of 0x102 and 0x102, and the message receiving mailbox corresponding to the message ID of 0xXXX can store the message content of 0xXXX. Among them, the message ID corresponding to each message receiving mailbox is associated with the message filter corresponding to each message receiving mailbox, and can be used to filter the message content stored in the message receiving mailbox.
[0071] Among them, the software architecture corresponding to the controller is composed of BSW, RTE, Swc1, Swc2,......, Swcn. Among them, the upper-layer application software (Swc1, Swc2,......, Swcn) corresponding to the controller can read the required signals from relevant message receiving mailboxes according to the functional implementation requirements. For example, Swc1 can read the message content stored in the message receiving mailbox corresponding to the message ID of 0x101, Swc2 can read the message content stored in the message receiving mailbox corresponding to the message ID of 0x101 and the message receiving mailboxes corresponding to the message IDs of 0x102 and 0x102, and Swcn can read the message content stored in the message receiving mailboxes corresponding to the message IDs of 0x102 and 0x102 and the message receiving mailbox corresponding to the message ID of 0xXXX.
[0072] Among them, the electronic device can start a periodic detection timer and poll the message ID corresponding to the message receiving mailbox of the controller according to a preset period. Among them, after the electronic device obtains the message ID corresponding to the message receiving mailbox of the controller, it can perform a logical AND operation on the message ID corresponding to the message receiving mailbox and the preset detection mask corresponding to the message receiving mailbox to obtain an operation result. Among them, the electronic device can determine whether the operation result is consistent with the preset message ID corresponding to the message receiving mailbox. If they are consistent, it can be determined that the message ID corresponding to the message receiving mailbox has not been tampered with, and this tampering detection of the message ID corresponding to the message receiving mailbox can be ended. Among them, if it is determined that the operation result is inconsistent with the preset message ID corresponding to the message receiving mailbox, the message ID corresponding to the message receiving mailbox can be rewritten based on the preset message ID corresponding to the message receiving mailbox, and it can be determined whether the message ID corresponding to the message receiving mailbox is successfully written. If it is successful, this tampering detection of the message ID corresponding to the message receiving mailbox can be ended; if it is not successful, the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID can be returned, and the cumulative number of times of failed rewriting of the message ID corresponding to the message receiving mailbox can be obtained.
[0073] Among them, the electronic device can determine whether the cumulative number of times reaches a preset number of times. If it does not reach the preset number of times, the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID can be returned; if it reaches, the fault code of the failed writing of the message ID corresponding to the message receiving mailbox can be recorded, and after the recording of the fault code is completed, the controller can be software reset. After the controller completes the software reset, the message ID corresponding to the message receiving mailbox can be forcibly set to the preset message ID, so as to timely discover the problem of accidental abnormal tampering of the message ID corresponding to the message receiving mailbox during the operation of the controller through the periodic polling detection method and perform rewriting correction, preventing problems such as abnormal vehicle functions and even endangering driving safety, and improving the reliability of the messages in the message receiving mailbox.
[0074] The message error correction method provided by an embodiment of the present application, compared with Figure 1 the message error correction method shown, this embodiment can also poll and detect the message ID corresponding to the message receiving mailbox according to a preset period, where the preset period is less than or equal to the target period, and the target period is the smallest message period among the messages received by the controller, so as to timely discover the problem of accidental abnormal tampering of the message ID corresponding to the message receiving mailbox during the operation of the controller through the periodic polling detection method, and improve the accuracy and reliability of the tampering detection of the message ID corresponding to the message receiving mailbox.
[0075] Meanwhile, this embodiment can also perform a logical AND operation on the message ID and a preset detection mask to obtain a to-be-verified ID. If the to-be-verified ID is the same as the preset message ID, it is determined that the message ID has not been tampered with; or, if the to-be-verified ID is different from the preset message ID, it is determined that the message ID has been tampered with. Thus, by determining whether the message ID has been tampered with based on the logical AND operation of the message ID and the detection mask, the detection rate of message ID tampering corresponding to the message receiving mailbox is improved.
[0076] In addition, after the message ID corresponding to the message receiving mailbox is rewritten based on the preset message ID in this embodiment, if the rewrite of the message ID corresponding to the message receiving mailbox fails, the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID is returned. Thus, in the case where the message ID corresponding to the message receiving mailbox is tampered with, the message ID corresponding to the message receiving mailbox is continuously rewritten until successful, realizing the correction of the message ID corresponding to the message receiving mailbox and ensuring the reliability of the message ID corresponding to the message receiving mailbox.
[0077] Moreover, in this embodiment, if the rewrite of the message ID corresponding to the message receiving mailbox fails, the cumulative number of failures of rewriting the message ID corresponding to the message receiving mailbox can be obtained. If the cumulative number is less than the preset number, the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID is returned; or, if the cumulative number reaches the preset number, the controller is reset, and after the controller completes the reset, the message ID corresponding to the message receiving mailbox is set to the preset message ID. Thus, in the case where the message ID corresponding to the message receiving mailbox is tampered with, the message ID corresponding to the message receiving mailbox is continuously rewritten, and when the number of attempts to rewrite reaches the preset number, the controller is reset, and after the reset, the message ID corresponding to the message receiving mailbox is forcibly set to the preset message ID, ensuring the reliability of the message ID corresponding to the message receiving mailbox and preventing the problem that the message ID corresponding to the message receiving mailbox is abnormally tampered with during the operation of the controller, resulting in abnormal or invalid functions of the upper-layer application software of the controller due to reasons such as occasional software operation failures of the controller or poor production batches of microcontroller hardware, and the expected message cannot be received normally.
[0078] Please refer to Figure 5 , Figure 5 which shows a block diagram of a message error correction device provided by an embodiment of the present application. The message error correction device 200 is applied to the above-mentioned electronic device. The following will elaborate in detail on the Figure 5 shown process. The message error correction device 200 includes: a message ID acquisition module 210, a tampering detection module 220, and a message ID rewrite module 230, where:
[0079] Message ID acquisition module 210 is configured to acquire the message ID corresponding to the message receiving mailbox of the controller.
[0080] Tamper detection module 220 is configured to perform tamper detection on the message ID according to a preset detection mask to obtain a detection result.
[0081] Message ID rewrite module 230 is configured to, if the detection result indicates that the message ID is tampered, rewrite the message ID corresponding to the message receiving mailbox based on a preset message ID.
[0082] Further, the tamper detection module 220 may include: a logical AND operation unit, a first tamper detection unit, and a second tamper detection unit, where:
[0083] The logical AND operation unit is configured to perform a logical AND operation on the message ID and the preset detection mask to obtain a to-be-verified ID.
[0084] The first tamper detection unit is configured to determine that the message ID is not tampered if the to-be-verified ID is the same as the preset message ID.
[0085] The second tamper detection unit is configured to determine that the message ID is tampered if the to-be-verified ID is different from the preset message ID.
[0086] Further, after rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID, the message error correction device 200 may further include: a first message ID rewrite unit, where:
[0087] The first message ID rewrite unit is configured to, if the rewrite of the message ID corresponding to the message receiving mailbox fails, return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0088] Further, the message error correction device 200 may further include: a message ID rewrite times accumulation unit, a second message ID rewrite unit, and a controller reset unit, where:
[0089] The message ID rewrite times accumulation unit is configured to, if the rewrite of the message ID corresponding to the message receiving mailbox fails, obtain the accumulated number of times of the failure of rewriting the message ID corresponding to the message receiving mailbox.
[0090] The second message ID rewrite unit is configured to, if the accumulated number of times is less than a preset number of times, return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
[0091] A controller reset unit, which is configured to reset the controller if the cumulative number of times reaches the preset number of times, and after the controller completes the reset, set the message ID corresponding to the message receiving mailbox to the preset message ID.
[0092] Further, the message error correction device 200 may further include: a prompt information output unit, where:
[0093] The prompt information output unit is configured to output prompt information if the cumulative number of times reaches the preset number of times, where the prompt information is used to prompt that the message ID corresponding to the message receiving mailbox is abnormal.
[0094] Further, before resetting the controller, the message error correction device 200 may further include: a fault code recording unit, where:
[0095] The fault code recording unit is configured to record the fault code corresponding to the controller.
[0096] Further, the message ID acquisition module 210 may include: a message ID acquisition subunit, where:
[0097] The message ID acquisition subunit is configured to poll and detect the message ID corresponding to the message receiving mailbox according to a preset period, where the preset period is less than or equal to the target period, and the target period is the smallest message period among the messages received by the controller.
[0098] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0099] In several embodiments provided by the present application, the coupling between modules may be electrical, mechanical, or other forms of coupling.
[0100] In addition, in each embodiment of the present application, the various functional modules may be integrated in one processing module, or each module may exist physically alone, or two or more modules may be integrated in one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0101] Please refer to Figure 6, which shows a structural block diagram of an electronic device 100 provided by an embodiment of the present application. The electronic device 100 may be an electronic device with processing capabilities such as an electric vehicle, a gasoline vehicle, a robot, a computer, a vehicle-mounted terminal, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more application programs, where one or more application programs may be stored in the memory 120 and configured to be executed by one or more processors 110, and one or more programs are configured to execute the methods described in the foregoing method embodiments.
[0102] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts within the entire electronic device 100, and by running or executing instructions, programs, code sets, or instruction sets stored in the memory 120, and by calling data stored in the memory 120, it executes various functions of the electronic device 100 and processes data. Optionally, the processor 110 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 110 may integrate one or several combinations of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 110 and may be implemented separately through a communication chip.
[0103] The memory 120 may include random access memory (RAM), and may also include read-only memory. The memory 120 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created during the use of the electronic device 100 (such as phone book, audio and video data, chat record data, etc.).
[0104] Please refer toFigure 7 , which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable medium 300, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0105] The computer-readable storage medium 300 can be an electronic memory such as a flash memory, EEPROM (electrically erasable programmable read-only memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 300 has a storage space for the program code 310 that executes any method step in the above method. These program codes can be read out from or written into one or more computer program products. The program code 310 can be compressed in an appropriate form, for example.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A message error correction method, characterized in that: The method comprises: Get the message ID corresponding to the controller's message receiving mailbox; According to a preset detection mask, the message ID is tampered with to obtain a detection result; If the detection result indicates that the message ID has been tampered with, the message ID corresponding to the message receiving mailbox is rewritten based on the preset message ID.
2. The method according to claim 1, characterized in that The tampering detection is performed on the message ID according to the preset detection mask to obtain the detection result, including: Perform a logical AND operation on the message ID and the preset detection mask to obtain an ID to be verified; If the ID to be verified is the same as the preset message ID, it is determined that the message ID has not been tampered with; or If the ID to be verified is different from the preset message ID, it is determined that the message ID has been tampered with.
3. The method according to claim 1, characterized in that After rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID, the method further includes: If rewriting the message ID corresponding to the message receiving mailbox fails, return to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID.
4. The method according to claim 3, characterized in that The method further comprises: If the rewriting of the message ID corresponding to the message receiving mailbox fails, obtaining the cumulative number of failures in rewriting the message ID corresponding to the message receiving mailbox; If the accumulated number of times is less than the preset number of times, returning to the step of rewriting the message ID corresponding to the message receiving mailbox based on the preset message ID; or If the accumulated number of times reaches the preset number of times, the controller is reset, and after the controller is reset, the message ID corresponding to the message receiving mailbox is set to the preset message ID.
5. The method according to claim 4, characterized in that The method further comprises: If the accumulated number of times reaches the preset number of times, a prompt message is output, wherein the prompt message is used to prompt that the message ID corresponding to the message receiving mailbox is abnormal.
6. The method according to claim 4, characterized in that Before resetting the controller, the method further includes: The fault code corresponding to the controller is recorded.
7. The method according to any one of claims 1 to 6, characterized in that: The obtaining of the message ID corresponding to the message receiving mailbox of the controller includes: The message ID corresponding to the message receiving mailbox is detected by polling according to a preset period, wherein the preset period is less than or equal to a target period, and the target period is the minimum message period among the messages received by the controller.
8. A message error correction device, characterized in that: The device comprises: A message ID acquisition module is used to obtain the message ID corresponding to the message receiving mailbox of the controller; A tamper detection module, used to perform tamper detection on the message ID according to a preset detection mask to obtain a detection result; The message ID rewriting module is used to rewrite the message ID corresponding to the message receiving mailbox based on a preset message ID if the detection result indicates that the message ID has been tampered with.
9. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 7.