Data storage method and device and electronic equipment

The proposed data storage method addresses the challenge of writing diagnostic data to flash storage by temporarily buffering data when the NVM is idle and writing it once available, improving writing speed and stability in vehicle systems.

CN119718184APending Publication Date: 2025-03-28GUANGZHOU AUTOMOBILE GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411551229.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing technologies face challenges in ensuring the stable and efficient writing of diagnostic data to flash storage in vehicles, particularly due to the slow write speed of flash storage and the inability to handle bulk data writing effectively, leading to potential data loss and instability in systems like T-Box and central gateways with dual-core architectures.

Method used

A data storage method that temporarily saves diagnostic data in a buffer when the non-volatile memory (NVM) is not idle and writes it to flash once the NVM becomes available, optimizing the writing process by managing NVM states and utilizing buffer storage to balance flash load and improve writing speed.

Benefits of technology

This approach enhances the speed and stability of writing diagnostic data to flash storage, ensuring efficient data handling and reducing the risk of data loss by managing NVM states and utilizing buffer storage to handle bulk data efficiently.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718184A_ABST
    Figure CN119718184A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method and device and electronic equipment, and the method comprises the steps: obtaining diagnosis data of a vehicle, and obtaining a data identifier (DID) corresponding to the diagnosis data; if it is determined that the storage position of the diagnosis data is a flash memory according to the DID, obtaining the state of a non-volatile memory manager (NVM); if the state of the NVM is an idle state, the diagnosis data is written into the flash through the NVM; or, if the state of the NVM is a non-idle state, writing the diagnostic data into the first buffer area, and when it is detected that the state of the NVM is switched from the non-idle state to the idle state, writing the diagnostic data into the flash from the first buffer area through the NVM, so that when the NVM state is not idle, writing the diagnostic data into the buffer area added before the flash, and when it is detected that the NVM state is idle, writing the diagnostic data into the buffer area added before the flash. And the diagnosis data is stored in the flash, so that the load of the flash is balanced, and the stability of writing the data into the flash is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automotive electronic technology, and more specifically, to a data storage method, device and electronic device. Background Art

[0002] With the development of science and technology, cars are becoming more and more intelligent. The diagnostic function of cars is a technology that is crucial to vehicle performance, fault identification and maintenance guidance. In related technologies, the self-diagnosis function of cars has evolved from simple fault code reading to the ability to perform in-depth data analysis, and some important diagnostic data can be written to flash for power-off preservation. Based on this, in related technologies, there is a challenge to improve the stability of writing diagnostic data to flash. Summary of the invention

[0003] In view of this, the embodiments of the present application propose a data storage method, device and electronic device to improve the above problems.

[0004] In a first aspect, an embodiment of the present application provides a data storage method, the method comprising: obtaining diagnostic data of a vehicle, and obtaining a data identifier DID corresponding to the diagnostic data; if it is determined according to the DID that the storage location of the diagnostic data is a flash memory flash, obtaining the state of a non-volatile memory manager NVM; if the state of the NVM is an idle state, writing the diagnostic data to the flash through the NVM; or if the state of the NVM is a non-idle state, writing the diagnostic data to a first buffer, until it is detected that the state of the NVM switches from a non-idle state to an idle state, and then writing the diagnostic data from the first buffer to the flash through the NVM.

[0005] In a second aspect, an embodiment of the present application provides a data storage device, the device comprising: a diagnostic data acquisition module, an NVM state acquisition module, a first storage module and a second storage module. The diagnostic data acquisition module is used to acquire the diagnostic data of the vehicle and acquire the data identifier DID corresponding to the diagnostic data; the NVM state acquisition module is used to acquire the state of the non-volatile memory manager NVM if the storage location of the diagnostic data is determined to be a flash memory flash according to the DID; the first storage module is used to write the diagnostic data to the flash through the NVM if the state of the NVM is an idle state; the second storage module is used to write the diagnostic data to the first buffer if the state of the NVM is a non-idle state, until it is detected that the state of the NVM switches from a non-idle state to an idle state, and then write the diagnostic data from the first buffer to the flash through the NVM.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores 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 a program code is stored, and the program code can be called by a processor to execute the above method.

[0008] In the scheme of the present application, the electronic device obtains the diagnostic data of the vehicle and obtains the data identifier DID corresponding to the diagnostic data. If the storage location of the diagnostic data is determined to be a flash memory flash according to the DID, the state of the non-volatile memory manager NVM is obtained. If the state of the NVM is an idle state, the diagnostic data is written to the flash through the NVM; or, if the state of the NVM is a non-idle state, the diagnostic data is written to the first buffer until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer to the flash through the NVM, thereby temporarily saving the diagnostic data when the NVM state is not idle, and then saving the diagnostic data to the flash when it is detected that the NVM state is idle, thereby improving the speed of writing the diagnostic data in batches to the flash, balancing the load of the flash, and improving the stability of writing data to the flash. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0010] Figure 1 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0011] Figure 2 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0012] Figure 3 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0013] Figure 4 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0014] Figure 5 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0015] Figure 6 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0016] Figure 7 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present application is shown;

[0017] Figure 8 A module block diagram of a data storage device provided by an embodiment of the present application is shown;

[0018] Fig. 9 A block diagram of an electronic device for executing a data storage method according to an embodiment of the present application is shown;

[0019] Fig.10 A storage unit for storing or carrying a program code for implementing a data storage method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0020] 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.

[0021] The diagnostic function of the car is a technology that is crucial to vehicle performance, fault identification and maintenance guidance; it involves the use of professional testing equipment and methods to conduct special tests on various subsystems of the car, such as the engine management system, electrical system, etc. By reading the diagnostic real-time data stream of the on-board controller, diagnosing fault codes, and combining physical inspections, engineers can accurately determine the existing problems of various subsystems of the vehicle, such as electronic component failures, mechanical wear, and system performance degradation. For example, the on-board T-Box self-diagnosis function has evolved from simple fault code reading to the ability to perform in-depth data analysis; the on-board T-Box self-diagnosis function can monitor the working status of various vehicle systems (such as engine, brake system, battery status, etc.) in real time. Once an abnormality is found, the potential problem is immediately sent to the owner or maintenance service provider, and sometimes even a preliminary fault solution can be provided. Therefore, car diagnosis not only helps to solve known problems, but also predicts potential faults to ensure safe and efficient operation of the vehicle.

[0022] With the development of technology, modern automobile diagnosis increasingly relies on advanced diagnostic software and remote communication technology, which can provide deeper vehicle status monitoring and fault diagnosis capabilities. In addition, regular automobile diagnosis is very important for maintaining stable vehicle performance, optimizing fuel efficiency and improving driving experience. Therefore, automobile diagnosis is of great significance to the complex technology and daily maintenance of modern automobiles, and can ensure that the vehicle is always in the best condition. In the Unified Diagnostic Service (UDS) protocol, some important diagnostic data that can be accessed through the data identifier DID is expected to be saved after power failure. In the Autosar specification, the application software sends a request through the RTE (Runtime Environment). After the RTE detects the request identifier, it calls the service provided by the NVM (Non-Volatile Memory Manager) and writes the data to the flash memory through the relevant driver. However, the read and write speed of the flash is very slow compared to the instruction speed. For example, in the scenario where a large amount of writing is required, it will cause a long write time. In addition, for components with dual-core heterogeneous architecture (such as T-box, central gateway, etc.), when synchronizing DID data during inter-core communication, if the MCU receives too much synchronization data, the flash cannot be written in time and the data is in a waiting state, affecting the subsequent DID data writing. Therefore, in the related art, there is a problem of low stability of diagnostic data writing to the flash.

[0023] In view of the above problems, the inventors have found through long-term research that they have proposed a data storage method, device, and electronic device provided in the embodiments of the present application. By temporarily saving diagnostic data when the NVM state is not idle, and then saving the diagnostic data to the flash when the NVM state is detected to be idle, the speed of writing diagnostic data to the flash in batches is increased, the load of the flash is balanced, and the stability of writing data to the flash is improved. Among them, the specific data storage method is described in detail in the subsequent embodiments.

[0024] In order to better understand the solutions of the embodiments of the present application, the technical terms used in the embodiments of the present application are explained below.

[0025] RTE, RunTime Environment, refers to the state of a software program when it is executed.

[0026] OBD, On-Board Diagnostics, is an on-board automatic diagnostic system used to monitor the vehicle's emission control system.

[0027] UDS protocol, unified diagnostic service, provides a set of standardized services for vehicle fault diagnosis, parameter configuration, software update and other functions.

[0028] flash, non-volatile memory.

[0029] NVM, Non-Volatile Memory Manager, non-volatile memory manager.

[0030] Flow control frames are a way for the sender (diagnostic instrument) to ask the receiver whether it is ready to receive more data.

[0031] SOC, System on a Chip, is a system-level chip that has a processor that handles business and algorithms.

[0032] MCU, Microcontroller Unit, microcontroller, is a processor mainly used to quickly respond to the requirements of external devices and low power consumption.

[0033] ECU, electronic control unit, electronic controller.

[0034] DID, short for Data Identifier, is a unique identifier used to represent a specific data item or group of data items within a vehicle's electronic control unit (ECU); these data items can include sensor readings, actuator positions, and diagnostic trouble codes (DTCs), etc.

[0035] Service identifiers, in vehicle diagnostics, can be used to specify or access specific diagnostic services, such as reading fault codes, control module information, etc.

[0036] AUTOSAR, AUTomotive Open System Architecture, automotive open system architecture.

[0037] BSW, part of the AutoSAR standard, provides basic software components for automotive electronic systems. BSW includes a series of modules and interfaces to support the development of various automotive applications.

[0038] The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0039] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of a data storage method provided by an embodiment of the present application. In a specific embodiment, the data storage method can be applied to Figure 8 The data storage device 200 and the electronic device 100 ( Fig. 9). The following will take electronic equipment as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic equipment used in this embodiment may include desktop computers, laptops, vehicle terminals, vehicle large screens and other devices, which are not limited here. Figure 1 The process shown is described in detail, and the data storage method may specifically include the following steps:

[0040] Step S110: Acquire the diagnostic data of the vehicle, and acquire the data identifier DID corresponding to the diagnostic data.

[0041] In some embodiments, the electronic device may obtain the vehicle's diagnostic data from an associated cloud or electronic device through wireless communication technology (e.g., Bluetooth, WiFi, zigbee, and other wireless technologies). Alternatively, the electronic device may also obtain the vehicle's diagnostic data from an associated electronic device through serial communication technology (e.g., serial peripheral interface, serial bus, etc.). Exemplarily, the electronic device may be a vehicle, which may include an onboard automatic diagnostic system OBD. Accordingly, the vehicle may obtain the vehicle's diagnostic data through an OBD interface or using a diagnostic tool that supports the UDS protocol.

[0042] The vehicle's diagnostic data may include fault codes, real-time data streams, freeze frame data, historical data, etc. The electronic device may also be connected to the vehicle's diagnostic instrument for communication, and accordingly, the electronic device may obtain the vehicle's diagnostic data through the diagnostic instrument; accordingly, the diagnostic instrument may write the vehicle's diagnostic data to the electronic device in batches.

[0043] In some embodiments, after the electronic device obtains the diagnostic data of the vehicle, it can parse the diagnostic data to obtain the data identifier DID corresponding to the diagnostic data. The electronic device can parse the diagnostic data based on the diagnostic protocol specification (such as UDS protocol, ISO protocol, etc.) to obtain the data identifier DID corresponding to the diagnostic data. It should be noted that in the unified diagnostic service (UDS) protocol, for diagnostic data carrying a DID number, the electronic device can access the diagnostic data through the DID; based on this, the electronic device expects to save the diagnostic data after power failure.

[0044] Exemplarily, the electronic device can obtain the diagnostic data of the vehicle written by the diagnostic instrument; wherein, the diagnostic instrument can send the diagnostic data to the electronic device in the form of a CAN message. Accordingly, the electronic device can obtain the CAN message, and can parse the CAN message based on the UDS protocol to obtain the DID number corresponding to the CAN message. Among them, the diagnostic data can carry the content to be written and the DID; wherein, if the diagnostic data is a multi-frame message, in order to ensure the smooth transmission of the diagnostic data by the diagnostic instrument, the diagnostic instrument can send a flow control frame to the electronic device to ensure that the electronic device can process the incoming diagnostic data without losing information due to overload of diagnostic data.

[0045] Step S120: If it is determined according to the DID that the storage location of the diagnostic data is a flash memory, then the state of a non-volatile memory manager NVM is obtained.

[0046] In some embodiments, after the electronic device obtains the data identifier DID corresponding to the diagnostic data, it can determine the storage location of the diagnostic data according to the type of the DID. If the electronic device determines that the storage location of the diagnostic data is a flash memory flash according to the type of the DID, the status of the non-volatile memory manager NVM can be obtained.

[0047] Among them, NVM as a non-volatile memory manager can be in an idle state or a non-idle state. Among them, in the idle state, NVM has no ongoing data read and write operations and is in a standby state, ready to respond to new read and write requests; when NVM is in an idle state, it can respond to new read and write requests faster because there is no ongoing operation that needs to be interrupted or completed; in the idle state, NVM can provide a read and write speed close to the maximum performance. Among them, in the non-idle state, NVM is processing data read and write operations, such as saving data to a memory or reading data from a memory; when NVM is in a non-idle state, if a new read and write request arrives, it may need to wait for the current operation to be completed, which will increase the response time. In the non-idle state, the performance of NVM may be limited because multiple operations may need to share memory resources, resulting in performance degradation. Based on this, after determining that the storage location of the diagnostic data is a flash memory flash, the electronic device can obtain the state of NVM, so that when the state of NVM is determined to be an idle state, the diagnostic data is written to flash through NVM, which improves the rate of writing diagnostic data to flash and also improves the response speed of writing diagnostic data to flash through NVM.

[0048] Exemplarily, the electronic device can collect diagnostic messages through a CAN driver, and can parse the diagnostic messages through a protocol stack, save the DID corresponding to the diagnostic messages and the content to be written to a preset buffer, and can pass the DID corresponding to the diagnostic messages parsed into the buffer and the content to be written to the preset application software through a function call, determine the DID type through the functions and parameters in the preset application software, determine the storage location of the diagnostic data, and check whether the current NVM is in an idle state.

[0049] Step S130: If the state of the NVM is an idle state, writing the diagnostic data into the flash through the NVM.

[0050] In some embodiments, after the electronic device obtains the state of the NVM, if it is determined that the state of the NVM is idle, the diagnostic data can be written to the flash through the NVM. The electronic device can send a request through the RTE, and after the RTE detects the request identifier, it can call the service provided by the NVM and write the diagnostic data to the flash memory through the relevant driver.

[0051] Among them, when the electronic device determines that the state of the NVM is idle, it can save the diagnostic data to the buffer corresponding to the runtime environment of the NVM (the buffer of the RTE), and after writing the diagnostic data to the buffer of the RTE, use the relevant services of the NVM to write the diagnostic data to the flash.

[0052] Step S140: if the state of the NVM is a non-idle state, the diagnostic data is written into a first buffer, until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer into the flash through the NVM.

[0053] In some embodiments, after the electronic device obtains the state of the NVM, if it is determined that the state of the NVM is a non-idle state, the diagnostic data can be written into the first buffer until the state of the NVM is detected to switch from the non-idle state to the idle state, and the diagnostic data is written from the first buffer to the flash through the NVM. In the process of writing the diagnostic data into the first buffer, the electronic device can cyclically check the state of the NVM, and when it is detected that the state of the NVM switches from the non-idle state to the idle state, a request is issued through the RTE, and after the RTE detects the request identifier, it calls the service provided by the NVM, and writes the diagnostic data from the first buffer to the flash memory through the relevant driver, thereby using the queue buffer in the diagnostic data writing process, and in the case of a large amount of diagnostic data to be written, the response speed of data writing is improved, and the load of writing to the flash can also be evenly distributed, thereby improving the stability of writing the diagnostic data to the flash.

[0054] In the process of writing diagnostic data to flash through NVM, when the NVM state is not idle, the diagnostic data can be written to the added buffer queue for temporary storage, and then the state of NVM is periodically detected until the NVM state is idle, and the data is saved to flash instead of being written directly to flash. This allows the diagnostic data to be written to flash in batches faster, balancing the flash load and improving the efficiency of writing to flash.

[0055] In some embodiments, a diagnostic time period may be pre-set in the electronic device, and accordingly, the electronic device may receive diagnostic data sent by the diagnostic instrument within the diagnostic time period and write the diagnostic data into the flash. If the electronic device completes flash writing of the diagnostic data sent by the received diagnostic instrument within the diagnostic time period, information indicating that the diagnostic data has been successfully written may be generated and sent to the diagnostic instrument, thereby ensuring the validity of the data writing.

[0056] It can be understood that in this embodiment, the electronic device can ensure the response speed, accuracy and stability of writing the diagnostic data carrying the DID into the flash by adding a redundant design buffer during the process of writing the diagnostic data into the flash through the NVM.

[0057] A data storage method provided in an embodiment of the present application obtains diagnostic data of a vehicle and obtains a data identifier DID corresponding to the diagnostic data. If the storage location of the diagnostic data is determined to be a flash memory flash according to the DID, the state of a non-volatile memory manager NVM is obtained. If the state of the NVM is an idle state, the diagnostic data is written to the flash through the NVM; or, if the state of the NVM is a non-idle state, the diagnostic data is written to the first buffer until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer to the flash through the NVM, thereby temporarily saving the diagnostic data when the NVM state is not idle, and then saving the diagnostic data to the flash when it is detected that the NVM state is idle, thereby improving the speed of writing the diagnostic data in batches to the flash, balancing the load of the flash, and improving the efficiency and stability of writing data to the flash.

[0058] See also Figure 2 , Figure 2 The flowchart of the data storage method provided by an embodiment of the present application is shown. The method is applied to the above electronic device. Figure 2 The process shown is described in detail, and the data storage method may specifically include the following steps:

[0059] Step S210: Acquire diagnostic data of the vehicle.

[0060] In some embodiments, the electronic device may acquire diagnostic data of the vehicle, wherein the diagnostic data of the vehicle may be acquired by a diagnostic instrument in the vehicle. The electronic device may collect the diagnostic data of the vehicle based on a diagnostic protocol specification (eg, UDS protocol, etc.).

[0061] Step S220: If the service identifier corresponding to the diagnostic data is within the preset identifier range corresponding to the electronic controller ECU, the diagnostic data is parsed to obtain the DID corresponding to the diagnostic data.

[0062] In some embodiments, after obtaining the diagnostic data of the vehicle, the electronic device can parse the diagnostic data based on the diagnostic protocol specification (such as UDS protocol, etc.) to obtain the service identifier corresponding to the diagnostic data. The service identifier corresponding to the diagnostic data may include a diagnostic message frame ID, wherein the diagnostic message frame ID can be understood as the ECU node on which the diagnostic message acts.

[0063] In some embodiments, a preset identifier range may be pre-set in the electronic device, wherein the preset identifier range may represent the range of diagnostic message frame IDs that the ECU in the electronic device may receive. After the electronic device obtains the service identifier corresponding to the diagnostic data, it may determine whether the service identifier corresponding to the diagnostic data is within the preset identifier range, that is, whether the ECU may receive the message of the service identifier. If the electronic device determines that the service identifier corresponding to the diagnostic data is within the preset identifier range corresponding to the ECU, it may parse the diagnostic data to obtain the DID corresponding to the diagnostic data.

[0064] It can be understood that in this embodiment, the electronic device can obtain the diagnostic data whose corresponding service identifier is within the preset identifier range corresponding to the electronic controller ECU, that is, the electronic device can obtain the diagnostic message that the corresponding ECU can receive in the diagnostic data of the vehicle. In addition, the diagnostic data obtained by the electronic device carries the DID and the content to be written.

[0065] Step S230: If it is determined according to the DID that the storage location of the diagnostic data is the flash, the byte length corresponding to the diagnostic data is obtained.

[0066] In some embodiments, after the electronic device obtains the DID corresponding to the diagnostic data, it can determine whether the storage location of the diagnostic data is flash according to the type of the DID. If it is determined according to the DID that the storage location of the diagnostic data is flash, a process of writing the diagnostic data to flash can be executed; if it is determined according to the DID that the storage location of the diagnostic data is not flash, other processes of writing the diagnostic data to non-flash can be executed.

[0067] When the electronic device writes diagnostic data into the flash, the byte length corresponding to the diagnostic data can be obtained to determine whether the byte length corresponding to the diagnostic data meets the requirements, thereby improving the accuracy of writing the diagnostic data into the flash.

[0068] Step S240: If the byte length satisfies a preset length, the state of the NVM is obtained.

[0069] In some embodiments, a preset length may be pre-set in the electronic device, and the preset length may be used as a basis for judging whether the byte length corresponding to the diagnostic data meets the requirements. After the electronic device obtains the byte length corresponding to the diagnostic data, the byte length may be compared with the preset length. If it is determined that the byte length meets the preset length, the state of the NVM may be obtained, thereby improving the reliability of DID data writing.

[0070] For example, see Figure 3 , which shows a flow chart of a data storage method provided by an embodiment of the present application. Wherein, the electronic device may be a vehicle, wherein the vehicle may include a T-BOX, a BSW, etc. Wherein, the diagnostic instrument may write the diagnostic data of the vehicle to the vehicle, wherein the T-BOX of the vehicle may receive the CAN message corresponding to the diagnostic data, and may parse the CAN message through the BSW to obtain the DID number corresponding to the diagnostic data. Wherein, a preset application software may be pre-set in the vehicle, and the vehicle may send the DID number corresponding to the diagnostic data to the preset application software by way of a function call. Accordingly, the preset application software can be used to determine whether the storage location of the diagnostic data is flash according to the DID number.

[0071] Among them, if the electronic device calls the preset application software to determine that the storage location of the diagnostic data is not flash according to the DID number corresponding to the diagnostic data, the diagnostic data can be stored based on other writing processes. Among them, if the electronic device calls the preset application software to determine that the storage location of the diagnostic data is flash according to the DID number corresponding to the diagnostic data, the state of the NVM can be obtained, and it can be determined whether the state of the NVM is idle. If so, the diagnostic data is written to the flash through the NVM; or, if the state of the NVM is determined to be non-idle, the diagnostic data carrying the DID number can be written to the first buffer, and the state of the NVM is periodically detected until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer to the flash through the NVM.

[0072] Among them, it can be understood that when the diagnostic instrument writes a large amount of diagnostic data carrying DID numbers, it can be temporarily saved when the NVM state is not idle, and then the diagnostic data is saved to the flash when the NVM state is detected to be idle, which improves the speed of the diagnostic instrument to write diagnostic data to the flash in batches, balances the flash load, and improves the efficiency of writing data to the flash.

[0073] Step S250: If the state of the NVM is an idle state, writing the diagnostic data into the flash through the NVM.

[0074] Step S260: if the state of the NVM is a non-idle state, the diagnostic data is written into a first buffer, until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer into the flash through the NVM.

[0075] For the detailed description of step S250 to step S260, please refer to the above description of step S130 to step S140, which will not be repeated here.

[0076] Compared with the data storage method provided by an embodiment of the present application, Figure 1 The data storage method shown in the embodiment can also obtain the diagnostic data of the vehicle; if the service identifier corresponding to the diagnostic data is within the preset identifier range corresponding to the electronic controller ECU, the diagnostic data is parsed to obtain the DID corresponding to the diagnostic data; if the storage location of the diagnostic data is determined to be flash according to the DID, the byte length corresponding to the diagnostic data is obtained; if the byte length meets the preset length, the state of the NVM is obtained, thereby improving the stability and rate of writing the diagnostic data to the flash and improving the accuracy of the diagnostic data written to the flash.

[0077] See also Figure 4 , Figure 4 The flowchart of the data storage method provided by an embodiment of the present application is shown. The method is applied to the above electronic device. Figure 4 The process shown is described in detail, and the data storage method may specifically include the following steps:

[0078] Step S310: Acquire diagnostic data of the vehicle, and acquire a data identifier DID corresponding to the diagnostic data.

[0079] Step S320: If it is determined according to the DID that the storage location of the diagnostic data is a flash memory, then the state of a non-volatile memory manager NVM is obtained.

[0080] For the detailed description of step S310 to step S320, please refer to the above description of step S110 to step S120, which will not be repeated here.

[0081] Step S330: If the state of the NVM is an idle state, the diagnostic data is saved in a second buffer, and the diagnostic data in the second buffer is written into the flash through the NVM, wherein the second buffer is a buffer corresponding to the runtime environment of the NVM.

[0082] In some embodiments, if the electronic device determines that the state of the NVM is an idle state, the diagnostic data may be saved to the second buffer, and the diagnostic data in the second buffer may be written to the flash through the NVM. The second buffer may be a buffer corresponding to the runtime environment of the NVM.

[0083] In some embodiments, the electronic device may include components of a dual-core heterogeneous architecture (such as T-BOX, battery management system, central gateway, etc.); optionally, after determining that the state of the NVM is idle, the electronic device may save the diagnostic data to a queue to be synchronized, and synchronize the diagnostic data between cores by periodically searching the queue to be synchronized. Exemplarily, the components of the dual-core heterogeneous architecture of the vehicle include T-BOX, wherein the dual cores corresponding to the T-BOX are MCU and SOC; wherein the diagnostic data inter-core communication synchronization can be understood as synchronizing the diagnostic data to the MCU and SOC.

[0084] As an implementable method, when the electronic device is writing diagnostic data to flash through NVM, if it is detected that the diagnostic data carries a synchronization flag, the diagnostic data can be saved to a queue to be synchronized, and the queue to be synchronized can be polled to synchronize the diagnostic data to the microcontroller unit MCU. Optionally, if the electronic device detects that the state of the NVM is idle through the MCU, the diagnostic data can be written to the second buffer, and the diagnostic data in the second buffer can be written to the flash through the NVM. Alternatively, if the state of the NVM is detected as non-idle through the electronic device MCU, the diagnostic data can be written to the first buffer until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer to the flash through the NVM.

[0085] For example, see Figure 5, which shows the process intention of the data storage method provided by an embodiment of the present application. Wherein, the electronic device can be a vehicle, wherein the vehicle can include a T-BOX, a BSW, etc. Wherein, the diagnostic instrument can write the diagnostic data of the vehicle to the vehicle, wherein the T-BOX of the vehicle can receive the CAN message corresponding to the diagnostic data, and can parse the CAN message through the BSW to obtain the DID number corresponding to the diagnostic data. Wherein, a preset application software can be pre-set in the vehicle, and the vehicle can send the DID number corresponding to the diagnostic data to the preset application software by way of function call. Accordingly, the preset application software can be used to determine whether the storage location of the diagnostic data is flash according to the DID number.

[0086] Among them, if the electronic device calls the preset application software to determine that the storage location of the diagnostic data is not flash according to the DID number corresponding to the diagnostic data, the diagnostic data can be stored based on other writing processes. Among them, if the electronic device calls the preset application software to determine that the storage location of the diagnostic data is flash according to the DID number corresponding to the diagnostic data, the state of the NVM can be obtained, and it can be determined whether the state of the NVM is idle. If so, the diagnostic data can be saved to the queue to be synchronized, and the queue to be synchronized can be periodically searched to synchronize the diagnostic data in the queue to be synchronized for inter-core communication synchronization. Alternatively, if it is determined that the state of the NVM is a non-idle state, the diagnostic data carrying the DID number can be written to the first buffer, and the state of the NVM can be periodically detected until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is saved from the first buffer to the queue to be synchronized, and the diagnostic data is synchronized for inter-core communication by periodically searching the queue to be synchronized.

[0087] In some embodiments, the diagnostic data can be synchronized to the MCU and the system on chip SOC at the same time. After the queue to be synchronized is polled and the diagnostic data is synchronized to the microcontroller unit MCU, if the electronic device detects a modification operation on the diagnostic data in the SOC, it can obtain the modified diagnostic data based on the modification operation, and can write the modified diagnostic data to the queue to be synchronized, and poll the queue to be synchronized to synchronize the modified diagnostic data to the MCU.

[0088] In some embodiments, after the electronic device obtains the modified diagnostic data obtained based on the modification operation of the diagnostic data in the SOC, the memory of the SOC and the MCU can be shared through a mutex lock. The modified diagnostic data carries a synchronization flag, and accordingly, the electronic device can write the modified diagnostic data into the queue to be synchronized to unlock it, and perform a periodic round-robin search of the queue to be synchronized to synchronize the modified diagnostic data to the MCU through inter-core communication, thereby adding a mechanism of the queue to be synchronized on the SOC side. When multiple threads write data carrying DID at the same time, resources such as locks can be quickly released, and the use of the queue to be synchronized improves the efficiency of inter-core communication.

[0089] In some embodiments, the electronic device may also obtain the data written to the SOC when detecting that the SOC corresponds to a write operation, and may set a synchronization flag in the data and send it to the queue to be synchronized. Accordingly, the electronic device may poll the queue to be synchronized to synchronize the data carrying the synchronization flag to the MCU through inter-core communication.

[0090] For example, see Figure 6 , which shows a flow chart of a data storage method provided by an embodiment of the present application. Among them, the electronic device can synchronize the diagnostic data to the MCU and the SOC at the same time. Among them, if the electronic device detects a write operation on the diagnostic data in the SOC, it can share the memory of the SOC and the MCU through a mutex lock, and can obtain the modified diagnostic data after the data is written to the SOC, and can write the modified diagnostic data carrying the synchronization flag into the queue to be synchronized and unlock it. Among them, the electronic device can periodically search the queue to be synchronized to synchronize the diagnostic data carrying the synchronization flag to the MCU through inter-core communication.

[0091] Among them, after the electronic device synchronizes the diagnostic data carrying the synchronization flag in the queue to be synchronized to the MCU through inter-core communication, it can determine whether the storage location of the diagnostic data is flash according to the DID number corresponding to the diagnostic data. Among them, if the electronic device determines that the storage location of the diagnostic data is not flash according to the DID number corresponding to the diagnostic data, the diagnostic data can be stored based on other writing processes. Among them, if the electronic device determines that the storage location of the diagnostic data is flash according to the DID number corresponding to the diagnostic data, the state of the NVM can be detected by the MCU to determine whether the state of the NVM is idle.

[0092] If the electronic device detects that the state of the NVM is idle through the MCU, the diagnostic data can be written into the second buffer, and the diagnostic data in the second buffer is written into the flash through the NVM. Alternatively, if the electronic device detects that the state of the NVM is non-idle through the MCU, the diagnostic data can be written into the first buffer, and the diagnostic data is written from the first buffer into the flash through the NVM until the state of the NVM is detected to switch from the non-idle state to the idle state.

[0093] It can be understood that in this example, for dual-core heterogeneous electronic devices, by adding a queue to be synchronized as a buffer in the SOC, the time of thread mutual exclusion can be reduced when there are many threads writing data with DID numbers, avoiding the situation where the lock can be released only after waiting for the response of inter-core communication, thereby improving the efficiency of inter-core communication. In addition, adding a queue to be synchronized as a buffer in the SOC writing process can ensure that the response speed of flash data writing is improved when the amount of data is large, reduce the resource occupation of multi-threaded writing of data carrying DID numbers, and improve the efficiency of inter-core communication.

[0094] In some embodiments, a preset duration may be pre-set in the electronic device, and the preset duration may be used to determine whether the diagnostic data is successfully written. Exemplarily, if the electronic device does not receive a response sent by the MCU during the process of synchronizing the diagnostic data to the MCU by searching the queue to be synchronized, the duration of synchronizing the diagnostic data to the MCU by searching the queue to be synchronized may be obtained, and the duration may be compared with the preset duration. If it is determined that the duration is greater than the preset duration, a prompt message may be output. Among them, the prompt message may be used to indicate that the diagnostic data writing fails.

[0095] For example, see Figure 7 , which shows a flow chart of a data storage method provided by an embodiment of the present application. Among them, in the process of periodically searching for the queue to be synchronized to synchronize the diagnostic data to the MCU through the core-to-core communication, the electronic device can send the diagnostic data to the MCU through the inter-core communication, and can receive the response made by the MCU when the diagnostic data is received. Among them, if the electronic device does not receive the response, it can obtain the duration of sending the diagnostic data to the MCU, and determine whether the sending of the diagnostic data to the MCU has timed out based on the relationship between the duration and the preset duration. If the duration is greater than the preset duration, it can be determined that the timeout has occurred, and a prompt message for prompting the failure of writing the diagnostic data can be output, and the diagnostic data can be resent to the MCU.

[0096] If the electronic device receives a response from the MCU when the diagnostic data is received, the electronic device can continue to poll the queue to be synchronized to synchronize the diagnostic data to the MCU. If the electronic device determines that the duration of sending the diagnostic data to the MCU is not greater than the preset duration, the electronic device can continue to wait for the response from the MCU when the diagnostic data is received.

[0097] Step S340: if the state of the NVM is a non-idle state, the diagnostic data is written into a first buffer, until it is detected that the state of the NVM switches from a non-idle state to an idle state, and the diagnostic data is written from the first buffer into the flash through the NVM.

[0098] For the specific description of step S340, please refer to the above description of step S140, which will not be repeated here.

[0099] Compared with the data storage method provided by an embodiment of the present application, Figure 1 The data storage method shown in the embodiment can also save the diagnostic data to a second buffer, and write the diagnostic data in the second buffer to the flash through the NVM, wherein the second buffer is a buffer corresponding to the runtime environment of the NVM, so that in the process of writing the diagnostic data to the flash through the NVM, the response speed, accuracy and stability of writing the diagnostic data carrying the DID to the flash are guaranteed by means of redundant design of the buffer.

[0100] See also Figure 8 , Figure 8 The module block diagram of the data storage device provided by an embodiment of the present application is shown. The data storage device 200 is applied to the above electronic device. Figure 8 The process shown is described in detail, the data storage device 200 includes: a diagnostic data acquisition module 210, an NVM state acquisition module 220, a first storage module 230 and a second storage module 240, wherein:

[0101] The diagnostic data acquisition module 210 is used to acquire diagnostic data of the vehicle and acquire a data identifier DID corresponding to the diagnostic data.

[0102] The NVM state acquisition module 220 is configured to acquire the state of a non-volatile memory manager NVM if it is determined according to the DID that the storage location of the diagnostic data is a flash memory flash.

[0103] The first storage module 230 is configured to write the diagnostic data into the flash through the NVM if the state of the NVM is an idle state.

[0104] The second storage module 240 is used to write the diagnostic data into the first buffer if the state of the NVM is a non-idle state, and write the diagnostic data from the first buffer into the flash through the NVM until it is detected that the state of the NVM switches from a non-idle state to an idle state.

[0105] Furthermore, the diagnostic data acquisition module 210 may include: a diagnostic data acquisition subunit and a diagnostic data parsing unit, wherein:

[0106] The diagnostic data acquisition subunit is used to acquire the diagnostic data of the vehicle.

[0107] The diagnostic data parsing unit is used to parse the diagnostic data and obtain the DID corresponding to the diagnostic data if the service identifier corresponding to the diagnostic data is within the preset identifier range corresponding to the electronic controller ECU.

[0108] Furthermore, the NVM state acquisition module 220 may include: a byte length acquisition unit and an NVM state acquisition subunit, wherein:

[0109] A byte length obtaining unit is used to obtain a byte length corresponding to the diagnostic data if it is determined according to the DID that the storage location of the diagnostic data is the flash.

[0110] The NVM state acquisition subunit is used to acquire the state of the NVM if the byte length meets the preset length.

[0111] Furthermore, the first storage module 230 may include: a first storage subunit, wherein:

[0112] The first storage subunit is used to save the diagnostic data to a second buffer, and write the diagnostic data in the second buffer into the flash through the NVM, wherein the second buffer is a buffer corresponding to the runtime environment of the NVM.

[0113] Furthermore, the first storage module 230 may include: a queue unit to be synchronized, a diagnostic data synchronization unit to an MCU unit, a third storage unit, and a fourth storage unit, wherein:

[0114] The diagnostic data is stored in a queue to be synchronized unit, and is used to save the diagnostic data into the queue to be synchronized if the diagnostic data carries a synchronization flag.

[0115] The diagnostic data is synchronized to the MCU unit, which is used to poll the queue to be synchronized and synchronize the diagnostic data to the micro control unit MCU.

[0116] The third storage unit is used for writing the diagnostic data into the second buffer if the MCU detects that the state of the NVM is an idle state, and writing the diagnostic data in the second buffer into the flash through the NVM.

[0117] The fourth storage unit is used to write the diagnostic data into the first buffer if the MCU detects that the state of the NVM is a non-idle state, and write the diagnostic data from the first buffer to the flash through the NVM until it is detected that the state of the NVM switches from the non-idle state to the idle state.

[0118] Furthermore, the diagnostic data is synchronized to the MCU and the system on chip SOC at the same time. After the queue to be synchronized is searched in rounds and the diagnostic data is synchronized to the microcontroller unit MCU, the data storage device 200 may further include: a diagnostic data modification unit and a modified diagnostic data synchronization unit to the MCU, wherein:

[0119] The diagnostic data modification unit is configured to, if a modification operation on the diagnostic data in the SOC is detected, obtain modified diagnostic data based on the modification operation.

[0120] The modified diagnostic data is synchronized to the MCU unit, which is used to write the modified diagnostic data into the queue to be synchronized, and poll the queue to be synchronized to synchronize the modified diagnostic data to the MCU.

[0121] Furthermore, the data storage device 200 may also include: a response detection unit and a timeout determination unit, wherein:

[0122] The response detection unit is used to obtain the duration of polling the queue to be synchronized to synchronize the diagnostic data to the MCU if no response sent by the MCU is received during the process of polling the queue to be synchronized to synchronize the diagnostic data to the MCU.

[0123] A timeout judgment unit is used to output a prompt message if the time length is greater than a preset time length, wherein the prompt message is used to prompt that the diagnostic data writing fails.

[0124] 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 aforementioned method embodiments, and will not be repeated here.

[0125] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0126] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0127] See also Fig. 9 , which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device with processing capabilities, such as a vehicle, a tablet computer, a robot, 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 applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0128] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0129] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may 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, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0130] See also Fig.10 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0131] The computer readable storage medium 300 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, 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 data storage method, characterized in that: The method comprises: Acquire diagnostic data of the vehicle, and acquire a data identifier DID corresponding to the diagnostic data; If it is determined according to the DID that the storage location of the diagnostic data is a flash memory, then obtaining a state of a non-volatile memory manager NVM; If the state of the NVM is an idle state, writing the diagnostic data into the flash through the NVM; or If the state of the NVM is a non-idle state, the diagnostic data is written into a first buffer, and when it is detected that the state of the NVM switches from a non-idle state to an idle state, the diagnostic data is written from the first buffer into the flash through the NVM.

2. The method according to claim 1, characterized in that The step of obtaining the diagnostic data of the vehicle and obtaining a data identifier DID corresponding to the diagnostic data includes: obtaining diagnostic data of the vehicle; If the service identifier corresponding to the diagnostic data is within a preset identifier range corresponding to the electronic controller ECU, the diagnostic data is parsed to obtain the DID corresponding to the diagnostic data.

3. The method according to claim 1, characterized in that If it is determined according to the DID that the storage location of the diagnostic data is a flash memory, obtaining the state of a non-volatile memory manager NVM includes: If it is determined according to the DID that the storage location of the diagnostic data is the flash, then obtaining the byte length corresponding to the diagnostic data; If the byte length satisfies a preset length, the state of the NVM is obtained.

4. The method according to claim 1, characterized in that: The step of writing the diagnostic data into the flash through the NVM includes: The diagnostic data is saved in a second buffer, and the diagnostic data in the second buffer is written into the flash through the NVM, wherein the second buffer is a buffer corresponding to the runtime environment of the NVM.

5. The method according to claim 4, characterized in that The step of writing the diagnostic data into the flash through the NVM includes: If the diagnostic data carries a synchronization flag, the diagnostic data is saved in a queue to be synchronized; Round-robin searching of the queue to be synchronized, synchronizing the diagnostic data to the microcontroller unit MCU; If the MCU detects that the state of the NVM is an idle state, the diagnostic data is written into the second buffer, and the diagnostic data in the second buffer is written into the flash through the NVM; or If the MCU detects that the state of the NVM is a non-idle state, the diagnostic data is written into the first buffer. When it is detected that the state of the NVM switches from a non-idle state to an idle state, the diagnostic data is written from the first buffer into the flash through the NVM.

6. The method according to claim 5, characterized in that The diagnostic data is synchronized to the MCU and the system on chip SOC at the same time. After searching the queue to be synchronized in a round-robin manner and synchronizing the diagnostic data to the microcontroller unit MCU, the method further includes: If a modification operation on the diagnostic data in the SOC is detected, acquiring modified diagnostic data obtained based on the modification operation; The modified diagnostic data is written into the queue to be synchronized, and the queue to be synchronized is polled to synchronize the modified diagnostic data to the MCU.

7. The method according to claim 5 or 6, characterized in that: The method further comprises: If no response is received from the MCU during the process of polling the queue to be synchronized to synchronize the diagnostic data to the MCU, then the duration of polling the queue to be synchronized to synchronize the diagnostic data to the MCU is obtained; If the duration is greater than a preset duration, a prompt message is output, wherein the prompt message is used to prompt that the diagnostic data writing fails.

8. A data storage device, characterized in that: The device comprises: A diagnostic data acquisition module, used to acquire diagnostic data of the vehicle and acquire a data identifier DID corresponding to the diagnostic data; An NVM state acquisition module, configured to acquire the state of a non-volatile memory manager NVM if it is determined according to the DID that the storage location of the diagnostic data is a flash memory flash; a first storage module, configured to write the diagnostic data into the flash through the NVM if the NVM is in an idle state; or The second storage module is used to write the diagnostic data into the first buffer if the state of the NVM is a non-idle state, and write the diagnostic data from the first buffer into the flash through the NVM until it is detected that the state of the NVM switches from a non-idle state to an idle state.

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.