Method, device and equipment for improving data consistency and readable storage medium

By detecting and rewriting the data frame during the data writing process, combining ambient temperature and clock frequency adjustment, the problem of data inconsistency is solved, and data consistency is guaranteed and the stability of the storage area is achieved.

CN119127071AInactive Publication Date: 2024-12-13SHANGHAI RUIPU ENERGY CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411165981.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-12-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is prone to inconsistent with the data to be written due to adverse factors during data writing, and the data to be written cannot be effectively guaranteed.

Method used

By obtaining the check value of the data to be written, the data frame is written to the two storage areas, and its consistency is detected. If it is inconsistent, it will be rewrite until it is consistent. Combined with ambient temperature and clock frequency adjustment to reduce the probability of write errors .

Benefits of technology

It effectively ensures data consistency in the writing stage, reduces the risk of data loss due to corruption in the storage area, and improves the accuracy of data reading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127071A_ABST
    Figure CN119127071A_ABST
Patent Text Reader

Abstract

The invention discloses a method, device and equipment for improving data consistency and a readable storage medium. The method comprises the steps of obtaining to-be-written data when a writing condition is met; calculating a first verification value of the to-be-written data; obtaining a to-be-written data frame according to the to-be-written data and the first check value; writing the to-be-written data frame into a first storage area and a second storage area, and detecting whether writing is successful or not; and if the data frame to be written fails to be written into any storage area, re-writing the data frame to be written into the storage area until the data frame to be written is successfully written into the storage area. Through the method and the device, the consistency of the data subsequently read from the storage area and the data to be written into the storage area can be effectively ensured; and the data frames are written into the two storage areas, so that the risk of data frame loss caused by damage of any storage area can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to a method, apparatus, device and computer-readable storage medium for improving data consistency. Background Art

[0002] In data storage scenarios, it is crucial to ensure the consistency of data read from a storage area and data to be written to the storage area. To achieve this, currently, data written to the storage area is mainly protected through specific policies. That is, when the data in the storage area changes, it is restored.

[0003] However, it is easy to overlook that in the process of writing data into the storage area, the existence of unfavorable factors may cause errors in the data written into the storage area. For example, the data to be written is data frame A, but the data actually written is data frame B. According to the characteristic strategy currently used, it can only be restored to B when data frame B is changed to data frame B'. The consistency of the data read from the storage area and the data to be written into the storage area cannot be guaranteed. Summary of the invention

[0004] The present application provides a method, apparatus, device and computer-readable storage medium for improving data consistency, which can solve the technical problem in the prior art that data read from a storage area is inconsistent with data to be written into the storage area.

[0005] In a first aspect, an embodiment of the present application provides a method for improving data consistency, the method for improving data consistency comprising:

[0006] When the writing condition is met, the data to be written is obtained;

[0007] Calculating a first check value of the data to be written;

[0008] Obtaining a data frame to be written according to the data to be written and a first check value;

[0009] Writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written;

[0010] For the i-th storage area, if the written data frame is inconsistent with the data frame to be written, the data frame to be written is rewritten into the i-th storage area until the written data frame is consistent with the data frame to be written. The i-th storage area is any one of the first storage area and the second storage area.

[0011] In combination with the first aspect, in one embodiment, after the step of rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written, the method further includes:

[0012] If the number of inconsistencies between the written data frame written into the i-th storage area and the data frame to be written is greater than a threshold, detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is greater than a preset temperature;

[0013] If it is greater than a preset temperature, the data writing rate of writing the data frame into the memory is reduced.

[0014] In combination with the first aspect, in one embodiment, after the step of detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is located is greater than a preset temperature, the method further includes:

[0015] If the temperature is not greater than the preset temperature, the clock frequency of the communication peripherals between the core of the microcontroller and the memory is reduced.

[0016] In combination with the first aspect, in one embodiment, the step of writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written includes:

[0017] Writing the to-be-written data frame into a first storage area, and reading the first storage area to obtain a first read-back data frame;

[0018] Verify the first read-back data frame;

[0019] If the first read-back data frame is verified to be passed, it is determined that the written data frame written into the first storage area is consistent with the data frame to be written, otherwise it is determined to be inconsistent;

[0020] Writing the to-be-written data frame into a second storage area, and reading the second storage area to obtain a second read-back data frame;

[0021] Verifying the second read-back data frame;

[0022] If the second read-back data frame passes the check, it is determined that the written data frame written into the second storage area is consistent with the data frame to be written, otherwise it is determined that they are inconsistent.

[0023] In combination with the first aspect, in one implementation, after the data frames written in the first storage area and the second storage area are consistent with the data frames to be written, the method further includes:

[0024] When the reading condition is met, the first storage area is read to obtain a first data frame and the second storage area is read to obtain a second data frame;

[0025] Verifying the first data frame and the second data frame respectively;

[0026] If the first data frame passes the check and the second data frame fails the check, the first data frame is copied to the second storage area, and the second storage area is set to be read first;

[0027] If the second data frame passes the check and the first data frame fails the check, the second data frame is copied to the first storage area, and the first storage area is set to be read first.

[0028] In combination with the first aspect, in one implementation, after the step of obtaining the data to be written when the writing condition is met, the method further includes:

[0029] The target process is executed preferentially, and the target process is used to store important data in the data to be written into the third storage area, and the important data is the data required to ensure the normal operation of the core functions of the vehicle.

[0030] In combination with the first aspect, in one implementation, after the step of respectively performing validity verification on the first data frame and the second data frame, the method further includes:

[0031] If the first data frame fails to be verified and the second data frame fails to be verified, the important data stored in the third storage area is copied to the first storage area and the second storage area.

[0032] In a second aspect, an embodiment of the present application provides a device for improving data consistency, the device for improving data consistency comprising:

[0033] An acquisition module, used for acquiring the data to be written when the writing condition is met;

[0034] A calculation module, used for calculating a first check value of the data to be written;

[0035] A framing module, used for obtaining a data frame to be written according to the data to be written and a first check value;

[0036] A write detection module, used for writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written;

[0037] A rewriting module is used for rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written, until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area.

[0038] In a third aspect, an embodiment of the present application provides a device for improving data consistency, wherein the device for improving data consistency comprises a processor, a memory, and a program for improving data consistency stored in the memory and executable by the processor, wherein when the program for improving data consistency is executed by the processor, the steps of the method for improving data consistency as described in the first aspect are implemented.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which is stored a program for improving data consistency. When the program for improving data consistency is executed by a processor, the steps of the method for improving data consistency as described in the first aspect are implemented.

[0040] The beneficial effects brought by the technical solution provided in the embodiments of the present application include:

[0041] In the embodiment of the present application, when the write condition is met, the data to be written is obtained; the first check value of the data to be written is calculated; the data frame to be written is obtained according to the data to be written and the first check value; the data frame to be written is written into the first storage area and the second storage area, and the written data frame written into the first storage area and the second storage area is detected to be consistent with the data frame to be written; for the i-th storage area, if the written data frame is inconsistent with the data frame to be written, the data frame to be written is re-written into the i-th storage area until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area. Through the embodiment of the present application, in the writing stage, if the data frame written into the storage area is inconsistent with the data frame to be written, the writing operation is re-executed until the data frame written into the storage area is consistent with the data frame to be written, thereby avoiding the problem of inconsistency between the data frame written into the storage area and the data frame to be written due to the influence of adverse factors in the writing stage, and can effectively ensure the consistency of the data subsequently read from the storage area and the data to be written into the storage area; and by writing data frames to two storage areas, the risk of data frame loss due to damage to any storage area can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A flowchart of an embodiment of a method for improving data consistency in the present application;

[0043] Figure 2A schematic diagram of functional modules of an embodiment of a device for improving data consistency according to the present application;

[0044] Figure 3 This is a schematic diagram of the hardware structure of a device for improving data consistency involved in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0046] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0047] In a first aspect, an embodiment of the present application provides a method for improving data consistency.

[0048] In one embodiment, referring to Figure 1 , Figure 1 This is a flow chart of an embodiment of a method for improving data consistency in this application. Figure 1 As shown, methods to improve data consistency include:

[0049] Step S10, when the writing condition is met, obtaining the data to be written;

[0050] In this embodiment, different writing conditions are provided for different application scenarios. For example, for the scenario of writing vehicle battery data into non-volatile memory (NVM), the microcontroller unit (MCU) in the BMS generally receives a power-off signal as a writing condition, and the microcontroller is the execution subject of the embodiment of this application.

[0051] In other application scenarios, the reaching of a preset time may also be used as a writing condition. This is only a schematic description of the application scenario and its corresponding writing condition.

[0052] Step S20, calculating a first check value of the data to be written;

[0053] In this embodiment, after obtaining the data to be written, a first check value of the data to be written is calculated by a check algorithm. The check algorithms available here include parity check, checksum, CRC, LRC, BCC and other check algorithms. The specific check algorithm is selected according to actual needs and is not limited here.

[0054] For example, if a CRC checksum algorithm is selected, CRC calculation is performed on the data to be written, and the calculation result obtained is the first checksum value.

[0055] Step S30, obtaining a data frame to be written according to the data to be written and the first check value;

[0056] In this embodiment, the data to be written and its corresponding first check value are framed to obtain a data frame to be written.

[0057] Step S40, writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written;

[0058] In this embodiment, the writing and detection actions for the two storage areas can be performed sequentially or in parallel. The first storage area and the second storage area can be different addresses in the same memory, or can belong to different memories. The type of memory is selected according to the requirements of the application scenario, for example, a non-volatile memory is selected.

[0059] Take writing the data frame to be written into the first storage area and detecting it as an example:

[0060] After the data frame to be written is written into the first storage area, the first storage area is read to obtain a first read-back data frame. Based on the verification algorithm selected when performing step S20, the first read-back data frame is verified according to the corresponding verification method. If the verification passes, it is determined that the written data frame written into the first storage area is consistent with the data frame to be written. If the verification fails, it is determined that the written data frame written into the first storage area is inconsistent with the data frame to be written.

[0061] The process of writing the data frame to be written into the second storage area and detecting the same is the same as above, which will not be described in detail here.

[0062] Step S50, for the i-th storage area, if the written data frame is inconsistent with the data frame to be written, rewrite the data frame to be written into the i-th storage area until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area.

[0063] In this embodiment, if the written data frame written into the first storage area is inconsistent with the data frame to be written, the data frame to be written is rewritten into the first storage area; similarly, if the written data frame written into the second storage area is inconsistent with the data frame to be written, the data frame to be written is rewritten into the second storage area until it is detected that the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written.

[0064] It should be noted that the written data frames can be protected by relevant policies during the storage process in the storage area, so that even if the written data frames are changed during the storage process, they can be restored.

[0065] In the embodiment of the present application, when the write condition is met, the data to be written is obtained; the first check value of the data to be written is calculated; the data frame to be written is obtained according to the data to be written and the first check value; the data frame to be written is written into the first storage area and the second storage area, and the written data frame written into the first storage area and the second storage area is detected to be consistent with the data frame to be written; for the i-th storage area, if the written data frame is inconsistent with the data frame to be written, the data frame to be written is re-written into the i-th storage area until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area. Through the embodiment of the present application, in the writing stage, if the data frame written into the storage area is inconsistent with the data frame to be written, the writing operation is re-executed until the data frame written into the storage area is consistent with the data frame to be written, thereby avoiding the problem of inconsistency between the data frame written into the storage area and the data frame to be written due to the influence of adverse factors in the writing stage, and can effectively ensure the consistency of the data subsequently read from the storage area and the data to be written into the storage area; and by writing data frames to two storage areas, the risk of data frame loss due to damage to any storage area can be reduced.

[0066] Furthermore, in one embodiment, after the step of rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written into the i-th storage area, the step further includes:

[0067] Step S60, if the number of inconsistencies between the written data frame written into the i-th storage area and the data frame to be written is greater than a threshold, detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is located is greater than a preset temperature;

[0068] In this embodiment, for each storage area, each time a situation occurs in which a written data frame is inconsistent with a data frame written to the storage area, the corresponding number of times is increased by one.

[0069] For example, for the first storage area, when the number is greater than a threshold, it indicates that rewriting has failed multiple times, which may be caused by the fact that the ambient temperature of the memory to which it belongs is too high. In this case, it is detected whether the ambient temperature of the environment in which the memory is located is greater than a preset temperature.

[0070] Among them, the threshold value and the preset temperature are set according to the actual situation and are not limited here.

[0071] Step S70: If the temperature is greater than a preset temperature, then the data writing rate of writing the data frame into the memory is reduced.

[0072] In this embodiment, if it is greater than the preset temperature, it means that this factor causes the written data frame and the data frame written into the first storage area to be inconsistent, so the data writing rate of the data frame into the memory is reduced, so as to execute the step of writing the data frame into the first storage area according to the reduced data writing rate, and perform subsequent detection actions.

[0073] The write rate may be reduced to a first preset value or to a second preset value.

[0074] In this embodiment, considering that the memory to which the storage area belongs may be affected by the working environment, when it is detected that its ambient temperature is too high, the data writing rate is reduced, thereby reducing the probability of data writing errors, thereby ensuring that the written data frame written to the storage area is consistent with the data frame.

[0075] Furthermore, in one embodiment, after step S60, the method further includes:

[0076] If the temperature is not greater than the preset temperature, the clock frequency of the communication peripherals between the core of the microcontroller and the memory is reduced.

[0077] In this embodiment, the microcontroller is driven by a clock, and the clock generation circuit is an oscillating circuit, which can be extended to a very high operating frequency (i.e., a very high clock frequency) through a PLL (phase-locked loop circuit). The higher the clock frequency, the shorter the unit time of the storage operation, and the lower the fault tolerance to interference, so it is easily affected by electromagnetic interference signals, resulting in data writing errors. Therefore, when the number of consecutive write errors reaches a certain number, and it is found that the temperature of the memory is normal at this time, the means used is: reconfigure the clock frequency of the communication peripherals between the MCU core and the memory. For example, the clock frequency of the communication between the SPI peripheral and the external flash is usually at the Mhz level. When the memory temperature is normal but the data is written continuously, it is considered to be due to the influence of electromagnetic interference signals, and the storage operation is performed again after reducing the clock frequency.

[0078] The clock frequency may be reduced by a third preset value, or may be reduced to a fourth preset value.

[0079] Furthermore, in one embodiment, step S40 includes:

[0080] Writing the data frame to be written into a first storage area, reading the first storage area, and obtaining a first read-back data frame; verifying the first read-back data frame; if the first read-back data frame passes the verification, determining that the written data frame written into the first storage area is consistent with the data frame to be written, otherwise determining that they are inconsistent;

[0081] The data frame to be written is written into a second storage area, and the second storage area is read to obtain a second read-back data frame; the second read-back data frame is verified; if the second read-back data frame passes the verification, it is determined that the written data frame written into the second storage area is consistent with the data frame to be written, otherwise it is determined that they are inconsistent.

[0082] In this embodiment, based on the verification algorithm selected for calculating the first verification value of the data to be written in step S20, the first read-back data frame and the second read-back data frame are verified in a corresponding verification manner.

[0083] Furthermore, in one embodiment, after step S50, the method further includes:

[0084] Step S80, when the reading condition is met, reading the first storage area to obtain a first data frame and reading the second storage area to obtain a second data frame;

[0085] Step S90, verifying the first data frame and the second data frame respectively;

[0086] In this embodiment, the scheme adopted for verifying the first / second data frame is the same as the scheme adopted for verifying the first / second read-back data frame.

[0087] Step S100, if the first data frame passes the check and the second data frame fails the check, the first data frame is copied to the second storage area, and the second storage area is set to be read first;

[0088] In this embodiment, if the first data frame passes the check and the second data frame fails the check, it means that the data frame stored in the second storage area has changed and is inconsistent with the data frame to be written described in step S30. In this case, the first data frame needs to be copied to the second storage area, and the second storage area is set to priority reading.

[0089] The second storage area is set to be read first, which can be achieved by setting a flag bit. After the second storage area is set to be read first, when the data to be written needs to be read for related processing, it is achieved by reading the second storage area.

[0090] Step S110: if the second data frame passes the check but the first data frame fails the check, the second data frame is copied to the first storage area, and the first storage area is set to be read first.

[0091] In this embodiment, if the second data frame passes the check and the first data frame fails the check, it means that the data frame stored in the first storage area has changed and is inconsistent with the data frame to be written described in step S30. In this case, the second data frame needs to be copied to the first storage area, and the first storage area is set to be read first.

[0092] Among them, setting any storage area as a priority read can be achieved by setting a flag bit. After setting any storage area as a priority read, when it is necessary to read the to-be-written data to participate in related processing later, it is achieved by reading the storage area.

[0093] In this embodiment, if a storage area is read for a long time, its performance will be reduced. Therefore, in order to achieve balance between the two storage areas, the storage area where the latest data is written is set to be read first.

[0094] Furthermore, in one embodiment, after step S10, the method further includes:

[0095] The target process is executed preferentially, and the target process is used to store important data in the data to be written into the third storage area, and the important data is the data required to ensure the normal operation of the core functions of the vehicle.

[0096] In this embodiment, in different application scenarios, the data required to ensure the normal operation of the core functions of the vehicle may be different. For example, in the scenario of writing vehicle battery data into NVM, important data may include the remaining battery power and fault codes.

[0097] Since the amount of important data is much smaller than that of data to be written, the probability of error in the writing process is very low, and the storage time is short and not easily disturbed. Based on this, storing the important data in the third storage area can be used as the basis for subsequent data recovery.

[0098] In addition, considering that when the write conditions are met, there may be more processes that need to be executed. In order to ensure that the target process used to store important data to be written in the third storage area is not preempted, the priority of the target process is increased so that the target process is executed first.

[0099] Furthermore, in one embodiment, after step S90, the method further includes:

[0100] If the first data frame fails to be verified and the second data frame fails to be verified, the important data stored in the third storage area is copied to the first storage area and the second storage area.

[0101] In this embodiment, if the first data frame fails to be checked and the second data frame fails to be checked, it means that the correct data frame to be written cannot be obtained from the first storage area and the second storage area. At this time, the important data stored in the third storage area is copied to the first storage area and the second storage area, so that the important data can be read from the first storage area or the second storage area later, so as to ensure that the core business corresponding to the important data can be carried out normally.

[0102] In a second aspect, an embodiment of the present application also provides a device for improving data consistency.

[0103] In one embodiment, referring to Figure 2 , Figure 2 This is a functional module diagram of an embodiment of a device for improving data consistency in this application. Figure 2 As shown, the device for improving data consistency includes:

[0104] An acquisition module 10, used for acquiring data to be written when a writing condition is met;

[0105] A calculation module 20, used for calculating a first check value of the data to be written;

[0106] A framing module 30, configured to obtain a data frame to be written according to the data to be written and a first check value;

[0107] A write detection module 40, used for writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written;

[0108] The rewriting module 50 is used for rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written, until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area.

[0109] Furthermore, in one embodiment, the apparatus for improving data consistency further includes an adjustment module, which is used to:

[0110] If the number of inconsistencies between the written data frame written into the i-th storage area and the data frame to be written is greater than a threshold, detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is greater than a preset temperature;

[0111] If it is greater than a preset temperature, the data writing rate of writing the data frame into the memory is reduced.

[0112] Furthermore, in one embodiment, the adjustment module is further used to:

[0113] If the temperature is not greater than the preset temperature, the clock frequency of the communication peripherals between the core of the microcontroller and the memory is reduced.

[0114] Furthermore, in one embodiment, the write detection module 40 is used to:

[0115] Writing the to-be-written data frame into a first storage area, and reading the first storage area to obtain a first read-back data frame;

[0116] Verify the first read-back data frame;

[0117] If the first read-back data frame is verified to be passed, it is determined that the written data frame written into the first storage area is consistent with the data frame to be written, otherwise it is determined to be inconsistent;

[0118] Writing the to-be-written data frame into a second storage area, and reading the second storage area to obtain a second read-back data frame;

[0119] Verifying the second read-back data frame;

[0120] If the second read-back data frame passes the check, it is determined that the written data frame written into the second storage area is consistent with the data frame to be written, otherwise it is determined that they are inconsistent.

[0121] Furthermore, in one embodiment, the apparatus for improving data consistency further includes a reading module, which is used to:

[0122] When the reading condition is met, the first storage area is read to obtain a first data frame and the second storage area is read to obtain a second data frame;

[0123] Verifying the first data frame and the second data frame respectively;

[0124] If the first data frame passes the check and the second data frame fails the check, the first data frame is copied to the second storage area, and the second storage area is set to be read first;

[0125] If the second data frame passes the check and the first data frame fails the check, the second data frame is copied to the first storage area, and the first storage area is set to be read first.

[0126] Furthermore, in one embodiment, the write detection module 40 is further configured to:

[0127] The target process is executed preferentially, and the target process is used to store important data in the data to be written into the third storage area, and the important data is the data required to ensure the normal operation of the core functions of the vehicle.

[0128] Furthermore, in one embodiment, the replication module is further used to:

[0129] If the first data frame fails to be verified and the second data frame fails to be verified, the important data stored in the third storage area is copied to the first storage area and the second storage area.

[0130] Among them, the functional implementation of each module in the above-mentioned device for improving data consistency corresponds to each step in the above-mentioned method embodiment for improving data consistency, and its functions and implementation processes are no longer repeated here one by one.

[0131] On the third aspect, an embodiment of the present application provides a device for improving data consistency. The device for improving data consistency may be a device having a data processing function, such as a microcontroller, a microprocessor, or a system-level chip.

[0132] Reference Figure 3 , Figure 3 Schematic diagram of the hardware structure of the device for improving data consistency involved in the embodiment of the present application. In the embodiment of the present application, the device for improving data consistency may include a processor, a memory, a communication interface and a communication bus.

[0133] The communication bus may be of any type and is used to interconnect the processor, the memory, and the communication interface.

[0134] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces, which are used to interconnect devices within a device to improve data consistency, and interfaces used to interconnect a device to improve data consistency with other devices (such as other computing devices or user devices). Physical interfaces can be Ethernet interfaces, optical fiber interfaces, ATM interfaces, etc.; user devices can be display screens (Display), keyboards (Keyboard), etc.

[0135] The memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.

[0136] The processor may be a general-purpose processor, and the general-purpose processor may call a program for improving data consistency stored in a memory, and execute the method for improving data consistency provided in an embodiment of the present application. For example, the general-purpose processor may be a central processing unit (CPU). The method executed when the program for improving data consistency is called may refer to the various embodiments of the method for improving data consistency of the present application, which will not be repeated here.

[0137] Those skilled in the art will understand that Figure 3 The hardware structure shown in the figure does not constitute a limitation on the present application, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0138] In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium.

[0139] The computer-readable storage medium of the present application stores a program for improving data consistency, wherein when the program for improving data consistency is executed by a processor, the steps of the method for improving data consistency as described above are implemented.

[0140] Among them, the method implemented when the program for improving data consistency is executed can refer to the various embodiments of the method for improving data consistency in this application, and will not be repeated here.

[0141] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0142] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.

[0143] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.

[0144] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.

[0145] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.

[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.

[0147] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for improving data consistency, characterized in that: The method for improving data consistency comprises: When the writing condition is met, the data to be written is obtained; Calculating a first check value of the data to be written; Obtaining a data frame to be written according to the data to be written and a first check value; Writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written; For the i-th storage area, if the written data frame is inconsistent with the data frame to be written, the data frame to be written is rewritten into the i-th storage area until the written data frame is consistent with the data frame to be written. The i-th storage area is any one of the first storage area and the second storage area.

2. The method for improving data consistency according to claim 1, characterized in that: After the step of rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written into the i-th storage area, the method further includes: If the number of inconsistencies between the written data frame written into the i-th storage area and the data frame to be written is greater than a threshold, detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is greater than a preset temperature; If it is greater than a preset temperature, the data writing rate of writing the data frame into the memory is reduced.

3. The method for improving data consistency according to claim 2, characterized in that: After the step of detecting whether the ambient temperature of the environment in which the memory to which the i-th storage area belongs is located is greater than a preset temperature, the method further includes: If the temperature is not greater than the preset temperature, the clock frequency of the communication peripherals between the core of the microcontroller and the memory is reduced.

4. The method for improving data consistency according to claim 1, characterized in that: The step of writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written comprises: Writing the to-be-written data frame into a first storage area, and reading the first storage area to obtain a first read-back data frame; Verify the first read-back data frame; If the first read-back data frame is verified to be passed, it is determined that the written data frame written into the first storage area is consistent with the data frame to be written, otherwise it is determined to be inconsistent; Writing the to-be-written data frame into a second storage area, and reading the second storage area to obtain a second read-back data frame; Verifying the second read-back data frame; If the second read-back data frame passes the check, it is determined that the written data frame written into the second storage area is consistent with the data frame to be written, otherwise it is determined that they are inconsistent.

5. The method for improving data consistency according to claim 1, characterized in that: After the data frames written in the first storage area and the second storage area are consistent with the data frames to be written, the method further includes: When the reading condition is met, the first storage area is read to obtain a first data frame and the second storage area is read to obtain a second data frame; Verifying the first data frame and the second data frame respectively; If the first data frame passes the check and the second data frame fails the check, the first data frame is copied to the second storage area, and the second storage area is set to be read first; If the second data frame passes the check and the first data frame fails the check, the second data frame is copied to the first storage area, and the first storage area is set to be read first.

6. The method for improving data consistency according to claim 5, characterized in that: After the step of obtaining the data to be written when the writing condition is met, the method further includes: The target process is executed preferentially, and the target process is used to store important data in the data to be written into the third storage area, and the important data is the data required to ensure the normal operation of the core functions of the vehicle.

7. The method for improving data consistency according to claim 6, characterized in that: After the step of respectively checking the validity of the first data frame and the second data frame, the method further includes: If the first data frame fails to be verified and the second data frame fails to be verified, the important data stored in the third storage area is copied to the first storage area and the second storage area.

8. A device for improving data consistency, characterized in that: The device for improving data consistency comprises: An acquisition module, used for acquiring the data to be written when the writing condition is met; A calculation module, used for calculating a first check value of the data to be written; A framing module, used for obtaining a data frame to be written according to the data to be written and a first check value; A write detection module, used for writing the data frame to be written into the first storage area and the second storage area, and detecting whether the written data frame written into the first storage area and the second storage area is consistent with the data frame to be written; A rewriting module is used for rewriting the data frame to be written into the i-th storage area if the written data frame is inconsistent with the data frame to be written, until the written data frame is consistent with the data frame to be written, and the i-th storage area is any one of the first storage area and the second storage area.

9. A device for improving data consistency, characterized in that: The device for improving data consistency includes a processor, a memory, and a program for improving data consistency stored in the memory and executable by the processor, wherein when the program for improving data consistency is executed by the processor, the steps of the method for improving data consistency as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program for improving data consistency, wherein when the program for improving data consistency is executed by a processor, the steps of the method for improving data consistency as claimed in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method, system, readable storage medium and terminal device for single chip computer parameter processing

    CN108664358A

  • Data reading and writing method and device, storage equipment and readable storage medium

    CN115904250A

  • Storage device management method and system and storage medium

    CN116072202A

  • Data migration method and device, electronic equipment and storage medium

    CN116301654A