Data access method and electronic device
By detecting the operating status of the black box device and determining the storage mode and time interval based on the status, the problem of the easy overwriting or missing of key data in the prior art is solved, and efficient storage and accurate reading of key data are achieved.
Patent Information
- Application Number
- CN202210391746.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-04-14
AI Technical Summary
The existing black box device data access methods cannot effectively meet the access needs of key data, resulting in the easy overwriting or missing of key data, and it is easy to read a large amount of useless data during reading.
By detecting the operating status of the target device, the target storage data, storage method and storage time interval are determined, and the data is stored in the target storage area in the memory according to these parameters, ensuring that the storage frequency of key data in different operating status increases and does not cover other data.
It realizes the storage frequency of key data in black box devices, avoids missing or overwriting of key data, and improves the accuracy of data access and analysis results.
Smart Images

Figure CN114860159B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular relates to a data access method and electronic device. Background Art
[0002] Black box devices are electronic devices installed in cars, airplanes and other equipment. They can record the working information of cars, airplanes and other equipment to assist in reconstructing the process of the accident.
[0003] Currently, the data storage logic of black box devices can only overwrite the entire storage area. This often reduces the critical data needed for data analysis due to loss or overwriting. Correspondingly, the data reading logic of black box devices can only read the entire data within the area, which can easily lead to the reading of a large amount of useless data. Therefore, existing data access methods cannot meet the black box device's access needs for critical information. Summary of the Invention
[0004] The embodiments of the present application provide a data access method and electronic device, which can solve the problem that existing data access methods cannot meet the access requirements of black box devices for key data.
[0005] A first aspect of an embodiment of the present application provides a data access method, including:
[0006] Detect whether a data read instruction sent from the instruction sending end is received; when the data read instruction is not received, obtain the operating status of the target device; determine the target storage data of the target device, the target storage method of the target storage data and the storage time interval of the target storage data according to the operating status of the target device; according to the storage time interval, store the target storage data in the target storage area in the memory according to the target storage method.
[0007] A second aspect of an embodiment of the present application provides a data access device, including:
[0008] A detection unit is used to detect whether a data read instruction sent from an instruction sending end is received; an operation status acquisition unit is used to obtain the operation status of the target device when the data read instruction is not received; a storage information acquisition unit is used to determine the target storage data of the target device, the target storage method of the target storage data, and the storage time interval of the target storage data according to the operation status of the target device; a data storage unit is used to store the target storage data in the target storage area in the memory according to the target storage method according to the storage time interval.
[0009] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data access method when executing the computer program.
[0010] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned data access method are implemented.
[0011] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the steps of implementing the above-mentioned data access method.
[0012] In an embodiment of the present application, when receiving a data read instruction sent from an instruction sending end, the operating status of the target device is obtained, and according to the operating status of the target device, the target storage data of the target device, the target storage method of the target storage data and the storage time interval of the target storage data are determined, and then according to the storage time interval, the target storage data is stored in the target storage area in the memory in accordance with the target storage method. Different storage time intervals can be assigned to different operating states, thereby increasing the storage frequency of key data in a specific operating state. At the same time, data will not be overwritten in all storage areas in the memory during data storage, thereby avoiding the problem of key data being reduced due to missing or overwritten. Therefore, compared with the existing technology, the data access method provided by the present application can meet the access requirements of the black box device for key data. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0014] Figure 1 This is a schematic diagram of an implementation flow of a data access method provided in an embodiment of the present application;
[0015] Figure 2 This is a schematic diagram of a specific implementation flow of configuring a memory provided in an embodiment of the present application;
[0016] Figure 3 This is a schematic diagram of a specific implementation process of initializing header data provided by an embodiment of the present application;
[0017] Figure 4This is a schematic diagram of a specific implementation process for obtaining the operating status of a target device provided in an embodiment of the present application;
[0018] Figure 5 This is a schematic diagram of a specific implementation process for storing fault data provided by an embodiment of the present application;
[0019] Figure 6 This is a schematic diagram of a specific implementation process for storing basic data provided by an embodiment of the present application;
[0020] Figure 7 This is a schematic diagram of a specific implementation process of reading data provided by an embodiment of the present application;
[0021] Figure 8 This is a schematic diagram of the data access process provided by the embodiment of the present application;
[0022] Figure 9 This is a schematic structural diagram of a data access device provided in an embodiment of the present application;
[0023] Figure 10 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of this application more clear, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without making any creative work are protected by this application.
[0025] In order to illustrate the technical solution of the present application, specific embodiments are provided below.
[0026] Figure 1 The following is a schematic diagram illustrating a data access method according to an embodiment of the present application. This method can be applied to electronic devices, particularly those requiring access to critical data from a black box device. The electronic device may refer to a black box device or other devices with data access capabilities, such as a smartphone or computer.
[0027] Specifically, the data access method may include the following steps S101 to S104.
[0028] Step S101 , detecting whether a data read instruction sent from an instruction sending end is received.
[0029] The instruction sending end is a device that instructs the electronic device to read data and instructs the electronic device to feedback the read data. Specifically, the instruction sending end can be a host computer of the electronic device, or a smart device such as a mobile phone or tablet computer that is remotely connected to the electronic device.
[0030] In an embodiment of the present application, different instructions may carry a data field for identifying the type of the instruction. Each time the electronic device receives an instruction, it may analyze whether the data field carried in the instruction is a data field corresponding to a data read instruction, thereby determining whether the received instruction is a data read instruction.
[0031] If the electronic device receives a data read instruction from the instruction sending end, it indicates that the electronic device currently needs to perform a data read operation. Otherwise, it indicates that the electronic device currently does not need to perform a data read operation and can perform other operations besides data reading. It should be noted that in some embodiments of the present application, data storage and data reading are not performed simultaneously.
[0032] In the embodiments of the present application, there is no restriction on the triggering method of the data read instruction. For example, the instruction sending end may send the data read instruction to the electronic device upon receiving an input operation performed by the user on the application, or upon receiving an operation of pressing a physical button by the user.
[0033] Step S102: When no data read instruction is received, the operating status of the target device is obtained.
[0034] The target device is the source of data stored by the electronic device, and can specifically include vehicles, aircraft, power generation equipment, etc. The electronic device can be used to passively receive and store data sent by the target device. The operating status refers to the operating state of the target device, which can include fault status, standby status, and normal operating status.
[0035] It should be understood that when the target device is in different operating states, the data sent by the target device to the electronic device (i.e., the data stored by the electronic device) may have different data types and at least partially different data contents. To meet the electronic device's storage needs for different data from the target device, the electronic device may obtain the operating state of the target device and then adopt different data storage strategies based on the operating state of the target device.
[0036] In some embodiments of the present application, the operating status of the target device can be sent by the target device to the electronic device at a preset frequency, wherein the preset frequency can be set by the staff according to actual needs.
[0037] Specifically, the target device may be configured with a self-test module and a communication module. The self-test module can be used to detect parameters such as voltage, current, response data, and response time of the target device to determine the operating status of the target device. The communication module can be used to transmit the operating status information to the electronic device after determining the operating status of the target device. The communication module can implement data transmission via wired or wireless means.
[0038] In other embodiments of the present application, the electronic device may also determine the data type of the data after acquiring the data to be stored by the target device, and further determine the operating status of the target device.
[0039] Step S103 : determining the target storage data of the target device, the target storage mode of the target storage data, and the storage time interval of the target storage data according to the operating state of the target device.
[0040] The target storage data refers to the data that currently needs to be stored.
[0041] In some implementations of the present application, the electronic device may obtain target storage data of a target device in an operating state.
[0042] Specifically, if the operating state of the target device is a fault state, the target storage data may be fault data, which may include one or more of the target device's battery state, battery operating state, charge and discharge state, battery State of Charge (SOC) state, and fault type.
[0043] If the target device is in a standby state or a normal operating state, the target storage data may be basic data, which may include one or more of the target device's battery state, battery operating state, charge and discharge state, and SOC state.
[0044] The target storage method refers to the storage method used to store the target data. Examples include cyclic accumulation and overwrite. The cyclic accumulation method involves cyclic storage within the storage area, while the overwrite method overwrites the entire storage area with the target data. The storage interval refers to the time interval between two consecutive storage operations when storing the target data multiple times.
[0045] In some embodiments of the present application, the electronic device may determine a target storage mode of the target storage data and a storage time interval of the target storage data according to a data type of the target storage data.
[0046] The stored data of each data type corresponds to a storage method and a storage time interval.
[0047] Considering that when the electronic device is a black box device, the purpose of data storage is to store fault data in a fault state. Therefore, if the target storage data is fault data, its storage interval can be a first duration. If the target storage data is basic data, its storage interval can be a second duration. The first duration is shorter than the second duration, thereby increasing the frequency of storage of fault data in the target device's fault state.
[0048] Furthermore, when storing basic data, if the basic data stored is in a normal operating state, the storage interval may be the third time period, and if the basic data stored is in a standby state, the storage interval may be the fourth time period. The third time period is shorter than the fourth time period, thereby ensuring that the basic data can be stored for a long time while also ensuring that data under abnormal conditions or charging and discharging conditions can be monitored.
[0049] It should be noted that the first duration, the third duration and the fourth duration can be set according to actual conditions. For example, the first duration can be 1 second, the third duration can be 5 seconds, and the fourth duration can be 1 minute.
[0050] Step S104 , storing the target storage data into the target storage area in the memory according to the target storage method based on the storage time interval.
[0051] In an embodiment of the present application, the electronic device may store the acquired target storage data in a target storage area in the memory according to a target storage method when the current time satisfies the storage time interval.
[0052] The target storage data can be obtained from data collected by the active front end (AFE) or rectifier unit or analog to digital converter (AD) of the battery management system (BMS) module through a serial peripheral interface (SPI).
[0053] The target storage area is a storage area in the memory of the electronic device for storing target storage data.
[0054] In some embodiments of the present application, the electronic device may divide the storage area of the memory into multiple storage areas. Each storage area is bound to an identifier of a data type and is used to store data of the data type. For example, in this embodiment, the memory includes a first storage area and several second storage areas, the second storage area is used to store the storage data of the target device, and the first storage area is used to save the storage information of the second storage area; the first storage area is a header data storage area for storing fault data, the second storage area includes a fault data storage area for storing fault data, a basic data storage area for storing basic data, and a firmware data storage area for storing firmware data, and the header data includes the storage information of the fault data storage area, the basic data storage area, and the firmware data storage area.
[0055] In step S104, the target storage data is stored in the corresponding second storage area according to the target storage method; and the storage data in the first storage area is updated according to the storage information in the second storage area.
[0056] For example, the storage area of the memory may include a header data storage area for storing header data, a fault data storage area for storing fault data, a basic data storage area for storing basic data, and a firmware data storage area for storing firmware data.
[0057] The header data includes storage information of the fault data storage area, the basic data storage area, and the firmware data storage area. The storage information may specifically refer to the data storage status, which may include the storage status of the basic data storage area, the fault data storage area, and the firmware data storage area. The basic data storage area status and the fault data storage area storage status include one or more of the address and size of the memory area, the size of a single piece of data, the number of memory-stored data, and the sequence number of the last data stored; the firmware data storage status includes one or more of the current firmware version, the version of the previous firmware, the size of the current firmware, the number of firmware upgrades, and the time of the current firmware update.
[0058] Accordingly, after obtaining the target storage data, the electronic device can store the target storage data in the target storage area bound to its data type according to the target storage method, so as to store data of different data types separately and avoid the storage of non-critical data and the storage of critical data affecting each other.
[0059] In an embodiment of the present application, when receiving a data read instruction sent from an instruction sending end, the operating status of the target device is obtained, and according to the operating status of the target device, the target storage data of the target device, the target storage method of the target storage data and the storage time interval of the target storage data are determined, and then according to the storage time interval, the target storage data is stored in the target storage area in the memory in accordance with the target storage method. Different storage time intervals can be assigned to different operating states, thereby increasing the storage frequency of key data in a specific operating state. At the same time, data will not be overwritten in all storage areas in the memory during data storage, thereby avoiding the problem of key data being reduced due to missing or overwritten. Therefore, compared with the existing technology, the data access method provided by the present application can meet the access requirements of the black box device for key data.
[0060] In some embodiments of the present application, the above-mentioned memory may refer to a cache, a flash memory (Flash EEPROM) or other memory, or a combination of these memories.
[0061] Specifically, the above-mentioned electronic devices are generally equipped with a microcontroller unit (MCU). The MCU itself may include a cache, and the cache space is relatively small. Therefore, in actual use, an external flash memory may be configured for the above-mentioned electronic devices, and the external flash memory may be connected to the MCU.
[0062] After the MCU of the electronic device is connected to the target device, it can receive the data transmitted by the target device and store the data in the MCU's cache first. In some implementations, the MCU's cache can also be divided into a first-level cache and a second-level cache. After receiving the data from the target device, the MCU can first store the data in the first-level cache. After the amount of data stored in the first-level cache reaches a certain threshold, the data is stored in the second-level cache. After the amount of data stored in the second-level cache reaches a certain threshold, the data is stored in an external flash memory, thereby avoiding the problem of shortening the flash memory service life due to frequent reading and writing of the flash memory.
[0063] Since an external flash memory is required, in some embodiments of the present application, the electronic device may configure the memory before data access.
[0064] Specifically, such as Figure 2 As shown, the process of configuring the memory may include the following steps S201 to S203.
[0065] Step S201 : configuring the memory according to preset reference configuration data.
[0066] The configuration data can be used to configure the communication parameters between the flash memory and the MCU. The reference configuration data is the configuration data used by the electronic device when configuring the memory, and can generally be provided by the staff.
[0067] Specifically, after the electronic device is powered on, the registers of the external flash memory can be configured through the SPI interface according to preset reference configuration data. Specifically, the state of the external flash memory (HOLD / RESET mode, security register mode and area), communication mode, communication baud rate, etc. can be configured to ensure that the external flash memory enters the normal working state.
[0068] Step S202: Acquire current configuration data of the memory.
[0069] Step S203: If the current configuration data is consistent with the reference configuration data, it is confirmed that the memory configuration is successful, and a step of detecting whether a data read instruction sent from the instruction sending end is received is executed.
[0070] The current configuration data is the actual configuration data in the memory.
[0071] That is, the electronic device can read back the actual configuration data of the registers in the memory and determine whether the read-back data is consistent with the data used during configuration.
[0072] If the current configuration data is consistent with the reference configuration data, it can be confirmed that the memory configuration is successful, and the step of detecting whether a data read instruction sent from the instruction sending end is received is executed to start data access.
[0073] If the current configuration data is inconsistent with the reference configuration data, the memory configuration is confirmed to be unsuccessful. Accordingly, if the configuration is unsuccessful, the external flash memory can notify the MCU for exception handling or return an exception when the MCU reads the data. Data reading and configuration tasks can be implemented in specific functions or tasks. When calling these functions or tasks, the external flash memory can return a status of OK or FALSE, with OK indicating success and FALSE indicating an error.
[0074] Since configuration failure may be caused by a timing error, SPI communication anomaly, or a busy external flash memory bus, the terminal device can re-execute the configuration steps from step S201 to step S203 when configuration fails until configuration is successful. Alternatively, when the number of configuration attempts reaches a preset threshold, indicating that the failure may be caused by an SPI communication anomaly or an external flash memory anomaly, the terminal device notifies the MCU to perform exception processing and waits for the MCU processing result before executing subsequent steps. The threshold number of times can be set according to actual conditions, for example, set to 3 times.
[0075] It should be noted that the above configuration process does not affect the data access function of the electronic device. Configuring the memory is beneficial for adding reserved functions to the electronic device in practical applications.
[0076] After the memory configuration is successful, such as Figure 3 As shown, the electronic device may further perform the following steps S301 to S303.
[0077] Step S301: read header data from a header data storage area of a memory.
[0078] Among them, the description of the header data can refer to the specific description of the aforementioned step S104, and this application will not elaborate on it.
[0079] Step S302: verify the header data.
[0080] The verification method may be implemented by using a checksum, a cyclic redundancy check (CRC) 8, CRC16, CRC32, a negation check, or the like.
[0081] In the embodiments of the present application, the data composition format of each storage area may be different, and the verification method adopted may also be different. The data composition format may include a data header byte, a data frame, a data check byte, and a data tail byte. The electronic device can calculate the verification data of the read data using the verification method bound to the data type, and compare the calculated verification data with the data check byte contained in the read data. If the two are consistent, it can be confirmed that the verification is successful; otherwise, it can be confirmed that the verification has failed.
[0082] Step S303: If the verification fails, it is determined that the memory is used for the first time, and the header data is initialized.
[0083] If the verification fails, the electronic device can confirm that the external flash memory is being used for the first time and then perform an initialization operation on the header data. The initialization operation can be to divide the memory into the aforementioned header data storage area, fault data storage area, basic data storage area, and firmware data storage area, and confirm the initial storage location of each storage area.
[0084] For example, if the total storage space of the external flash memory is 16MB, the storage space from 0 to 1MB can be divided as the header data storage area, the storage space from 1 to 12MB as the basic data storage area, the storage space from 12 to 14MB as the fault data storage area, and the storage space from 14 to 16MB as the firmware data storage area. The above is only an example. In actual applications, the total storage space size and the corresponding allocation of each storage area can be set based on actual needs.
[0085] If the verification is successful, the electronic device can confirm that the external flash memory is not used for the first time. At this time, the electronic device can also initialize the header data. The initialization operation can be to divide the storage area in the area where no data is stored in the external flash memory.
[0086] For example, assuming that the external flash memory is not used for the first time, the total storage space is 1G, and the storage space of the external flash memory that originally stored data is 512M, the electronic device can use the remaining 512M storage area of the external flash memory as the area for subsequent data storage.
[0087] It should be understood that after the above configuration and verification process, the external flash memory is in normal working condition and the various storage areas are clearly divided. At this time, the electronic device can use the external flash memory to execute the above steps S101 to S104 to store the target storage data in the target storage area in the external flash memory.
[0088] In the process of storing the target storage data, in order to obtain the operating status of the target device, such as Figure 4 As shown, the electronic device may adopt the following steps S401 to S405.
[0089] Step S401: Obtain a fault flag.
[0090] The fault flag can be an internal flag of the MCU that can be used to indicate whether fault data needs to be stored. Each time the MCU receives fault data, it can update the fault flag so that the fault flag is at a first threshold. After storage is complete, the MCU can update the fault flag so that the fault flag is updated from the first threshold to a second threshold. Both the first threshold and the second threshold can be set based on actual conditions. For example, the first threshold can be set to 1, and the second threshold can be set to 0.
[0091] Step S402: When the fault flag is at the first threshold, it is determined that the operating state of the target device is a fault state.
[0092] Step S403: When the fault flag is at the second threshold, it is determined whether the storage data received from the target device is fault data.
[0093] In some embodiments of the present application, if the fault flag is at the first threshold, it indicates that the fault data is still being stored, and therefore the target device's operating state can be determined to be a faulty state. If the fault flag is at the second threshold, it indicates that the current operating state is unknown, and it is necessary to determine whether the stored data from the target device is faulty data based on the stored data.
[0094] The method for determining whether the storage data received from the target device is fault data can be selected according to actual conditions, for example, by determining the data type identifier of the storage data or the data composition format of the data type of the storage data.
[0095] Step S404: If it is fault data, determine that the operating state of the target device is a fault state, and update the fault flag to a first threshold.
[0096] Step S405: If the data is not fault data, determine whether the operating state of the target device is a standby state or a normal working state according to the stored data received from the target device.
[0097] If the storage data received from the target device is fault data, the operating state of the target device may be confirmed to be a fault state, the fault flag may be updated to a first threshold, and the fault data may be stored.
[0098] Specifically, such as Figure 5 As shown, the above process of storing fault data may specifically include the following steps S501 to S505.
[0099] Step S501: determining the total number of times the fault data is stored according to the fault type of the target device.
[0100] Among them, the fault type can be divided according to the cause of the fault, for example, divided into software-triggered faults and hardware-triggered faults; it can also be divided according to the source of the fault, for example, divided into faults of the upper computer of the target device, faults of the lower computer of the target device, and faults of the target device itself.
[0101] The total number of storage times refers to the total number of times the fault data is continuously stored. It should be understood that the total number of storage times required for fault data of different fault types can be the same or different, and the specific correspondence between the two can be set according to actual needs.
[0102] For example, if the fault is triggered by software, the total number of fault data storage times can be 10 times; if the fault is triggered by hardware, the total number of fault data storage times can be 5 times. If the fault is in the target device's host computer, the total number of fault data storage times can be 5 times; if the fault is in the target device's slave computer, the total number of fault data storage times can be 10 times. If the fault is in the target device itself, since this part of the data is critical data stored by the black box device, the total number of fault data storage times can be the number of times required to store all fault data.
[0103] Step S502: When the storage time interval is met, the fault data is stored in the fault data storage area.
[0104] Step S503: Acquire the stored fault data and perform data verification on the stored fault data.
[0105] Step S504: If the verification is successful and the actual storage times of the fault data does not reach the total storage times, then when the storage time interval is met again, the fault data storage and data verification will continue until the actual storage times of the fault data reaches the total storage times, and then the fault data storage will stop.
[0106] That is to say, when the current time meets the storage time interval for the first time, the electronic device can store the fault data in the fault data storage area, then read back the stored fault data, and perform data verification on the stored fault data to determine whether the read-back data is consistent with the original data.
[0107] Among them, the verification method of fault data can refer to the verification method of header data, which will not be described in detail in this application.
[0108] If the verification fails, the electronic device needs to re-execute the steps of obtaining the stored fault data and performing data verification on the stored fault data to determine whether the stored data is consistent with the data read back. When the number of verification failures reaches the threshold, the data verification stops and an exception notification message is generated to notify the MCU to perform exception processing. The electronic device waits for the MCU processing result before proceeding to the next step. The number of times threshold can be set according to actual conditions, for example, it can be set to 3 times.
[0109] If the verification is successful, it means that the storage is valid. When the storage time interval is met next time, the data is stored for the second time and the data stored for the second time is verified. This process is repeated until the actual storage times of the fault data reach the total storage times, at which point the data storage of the fault data is stopped.
[0110] Step S505 : updating the header data according to the storage information in the fault data storage area, and updating the fault flag from the first threshold to the second threshold.
[0111] After completing the storage of the total number of fault data, the electronic device can update the header data based on the stored information in the fault data storage area to ensure the accuracy of the header data. At the same time, the electronic device needs to update the fault flag from the first threshold to the second threshold to avoid erroneously confirming that the target device's operating status is in a fault state the next time the target device's operating status is acquired.
[0112] In the embodiment of this application, based on Figure 4 and Figure 5With the data storage method shown, the electronic device can store fault data multiple times in a row, so that when analyzing the fault of the target device, sufficient fault data can be referenced, thereby improving the accuracy of the fault analysis.
[0113] In some implementations of the present application, when storing fault data, the electronic device may adopt a write offset address algorithm.
[0114] Among them, the write offset address algorithm can be expressed as:
[0115]
[0116] offset1=(index-1)*data_size1.
[0117] Among them, index is the current location number of data storage in the fault data storage area; max_num is the maximum location number that data storage can reach in the fault data storage area; data_size1 is the data size of the fault data, and offset1 is the location where the fault data is stored in the fault data storage area.
[0118] That is, when index>max_num, index=1 is set so that the data is saved from the very beginning address, otherwise index is incremented downward.
[0119] In other embodiments of the present application, if the storage data received from the target device is not fault data, the electronic device may determine that the operating state of the target device is a standby state or a normal operating state, and store the basic data.
[0120] Specifically, such as Figure 6 As shown, the above process of storing basic data may specifically include the following steps S601 to S604.
[0121] Step S601: When the storage time interval is met, the basic data is stored in the basic data storage area.
[0122] Step S602: Acquire the stored basic data and perform data verification on the stored basic data.
[0123] Step S603: If the verification fails, the steps of obtaining the stored basic data and performing data verification on the stored basic data are executed again until the number of verification failures reaches a threshold, at which time the data verification is stopped and an abnormality notification message is generated.
[0124] Step S604: If the verification is successful, the header data is updated according to the storage information of the basic data.
[0125] Similarly, the electronic device can store basic data in the basic data storage area when the current time meets the storage time interval, then read back the stored basic data, and perform data verification on the stored basic data to determine whether the read-back data is consistent with the original data.
[0126] Among them, the verification method of basic data can also refer to the verification method of header data, which will not be elaborated in this application.
[0127] If the verification fails, the electronic device needs to re-execute the steps of obtaining the stored fault data and performing data verification on the stored basic data to determine whether the stored data is consistent with the data read back. When the number of verification failures reaches the threshold, the data verification stops and an exception notification message is generated to notify the MCU to handle the exception. The electronic device waits for the MCU's processing results before proceeding to the next step. The number of times threshold can be set according to actual conditions, for example, it can be set to 3 times.
[0128] If the verification is successful, it means that the storage is valid. At this time, the header data can be updated according to the storage information of the basic data to ensure the accuracy of the header data.
[0129] It should be noted that when storing basic data, electronic devices can also use a write offset address algorithm, which is not described in detail in this application.
[0130] In the embodiments of the present application, the above-described data storage process enables, on the one hand, separate storage of data provided by the target device under different operating states, and storage strategies can also be differentiated according to data type, thereby increasing the storage frequency of critical data (such as fault data) and avoiding overwriting critical data when storing non-critical data. Furthermore, each time data is stored, the stored data is verified to ensure that the stored data is accurate, thereby improving the accuracy of the analysis results obtained from subsequent data analysis of the stored data.
[0131] In some other embodiments of the present application, if it is detected that a data read instruction sent from the instruction sending end is received, the electronic device needs to read data from the memory according to the data read instruction.
[0132] Specifically, such as Figure 7 As shown, the above process of reading data may include the following steps S701 to S704.
[0133] Step S701 : upon receiving a data read instruction, obtaining the data type of the target read data in the data read instruction.
[0134] The target read data refers to the data that the electronic device currently needs to read, that is, the data required by the instruction sending end.
[0135] Specifically, the data read instruction may carry an identifier of the data type of the target read data. Based on the identifier, the electronic device may determine the data type of the target read data required by the instruction sending end.
[0136] Step S702 , obtaining a storage mode and a target storage location of the data type, and determining a reading mode of the target read data according to the storage mode.
[0137] Step S703 : Read target data from a target storage location in the memory according to the reading mode.
[0138] The target storage location is the storage location of the target read data in the storage area where the target read data is located. The electronic device can obtain the target storage location from the storage information recorded in the aforementioned header data.
[0139] In some embodiments of the present application, since the electronic device uses different storage methods to store data in different operating states of the target device (that is, data of different data types) in the target storage location area corresponding to the data type, when reading data, the electronic device needs to determine the reading method of the target data based on the storage method.
[0140] Specifically, the electronic device may obtain the storage method bound to the data type according to the identifier of the data type of the target read data, and then determine the reading method corresponding to the storage method.
[0141] In some embodiments of the present application, if the storage method is a cyclic accumulation method, the electronic device may determine the target read data reading method as follows: from the target storage location, read at least one piece of data closest to the request time of the data read instruction as the target read data. The amount of data read may be adjusted based on actual conditions. In other words, the target read data may be read until the actual number of reads meets the total number of reads required by the data read instruction.
[0142] In other embodiments of the present application, if the storage method is an overwrite type, the electronic device may determine that the target read data is read in a manner of: reading all data in the storage area where the target storage location is located from the target storage location as the target read data.
[0143] Step S704: Send the target read data to the instruction sending end.
[0144] After reading the target read data, the electronic device can send the target read data to the instruction sending end to complete the data reading task.
[0145] In the process of reading target data, the electronic device may adopt a read offset address algorithm.
[0146] Among them, the read offset address algorithm is expressed as:
[0147]
[0148]
[0149] offset2=(max_num+index-read_num-1)×data_size2.
[0150] Among them, data_size2 refers to the data size of the target read data; read_num is the total number of reads of the target read data; index is the current location number for data storage in the storage area where the target read data is located; max_num is the maximum location number that can be reached for data storage in the fault data storage area; offset2 indicates the target storage location.
[0151] That is to say, when max_num is 0, it means that the target read data has not reached the maximum number of times that can be saved in the storage area. At this time, if read_num>index, it means that the number of data saved in the storage area fails to meet the required number, then change read_num=index-1 to ensure that the data read is the latest data in the data storage memory. If max_num is not 0, if read_num>max_num, then change the number of reads read_num to max_num. If the number of reads read_num≤index, it means that the data that has been read is not covered data. At this time, the target read data is the range where the new data covers the old data. Clear max_num, that is, max_num=0, and the data read is the covered data. When max_num≤index, it means that the current data has filled the entire memory, and the saved sequence number is assigned to the starting address position of the memory, that is, index=1. At this time, the data read can read the data at the end position of the memory.
[0152] In addition, after each data read, the electronic device needs to determine whether the read is successful.
[0153] Similarly, the electronic device can verify the read data based on the verification method bound to the data type of the target read data. If the verification is successful, the read is confirmed to be successful, and the target read data is sent to the instruction sending end through the link loop. If the verification fails, the data reading and data verification can be repeated until the reading is successful. Alternatively, when the number of verification failures reaches a threshold, the data verification is stopped and an exception notification message is generated to notify the MCU to perform exception processing and wait for the MCU processing result before proceeding to the next step. The number threshold can be set according to the actual situation, for example, it can be set to 3 times.
[0154] In an embodiment of the present application, through the above-mentioned data reading process, the electronic device can read part or all of the data in the storage area, and can read data nearby according to the time of data storage, avoiding reading non-critical data, thereby improving the accuracy of the analysis results obtained by performing data analysis on the read data.
[0155] See also Figure 8 , Figure 8 A complete flow chart of data access by the electronic device provided in this application is shown.
[0156] After powering on, the electronic device can configure the external flash memory and verify the header data. If the verification fails, it will retry. If it fails after three retries, it will notify the MCU to handle the exception. If the verification succeeds, it can detect whether the data read command from the command sender has been received.
[0157] If a data read command is received from the instruction sender, the data type is determined based on the storage method and target storage location. The data is then read based on the storage method. The data is read until the total number of reads is met, and the read data is sent to the instruction sender. If the read fails, the MCU is notified to handle the exception if the read fails after three retries.
[0158] If the data read instruction sent from the instruction sending end is not received, the electronic device can judge the operating status of the target device based on the fault flag and the storage data from the target device, and determine the target storage data of the target device, the target storage method of the target storage data and the storage time interval of the target storage data according to the operating status of the target device. Among them, the storage time interval of the fault data in the fault state can be 1 second, the storage time interval of the basic data in the normal working state can be 5 seconds, and the storage time interval of the basic data in the standby state can be 1 minute. Then, when the current time meets the storage time interval, the target storage data can be stored in the target storage area in the memory according to the target storage method. Similarly, each time data is stored, a check is required. If the check fails, retry. If it still fails after 3 retries, the MCU can be notified to perform exception processing.
[0159] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations. However, those skilled in the art should be aware that this application is not limited to the described order of actions, because according to this application, certain steps can be performed in other orders.
[0160] like Figure 9 FIG2 is a schematic structural diagram of a data access device 900 provided in an embodiment of the present application. The data access device 900 is configured on an electronic device.
[0161] Specifically, the data access device 900 may include:
[0162] The detection unit 901 is used to detect whether a data read instruction sent from the instruction sending end is received; the operation status acquisition unit 902 is used to obtain the operation status of the target device when the data read instruction is not received; the storage information acquisition unit 903 is used to determine the target storage data of the target device, the target storage method of the target storage data and the storage time interval of the target storage data according to the operation status of the target device; the data storage unit 904 is used to store the target storage data to the target storage area in the memory according to the target storage method according to the storage time interval.
[0163] In some embodiments of the present application, the above-mentioned data access device 900 may further include a data reading unit, which is specifically used to: when receiving the data read instruction, obtain the data type of the target read data in the data read instruction; obtain the storage method and target storage location of the data type, and determine the reading method of the target read data according to the storage method; read the target read data from the target storage location in the memory according to the reading method; and send the target read data to the instruction sending end.
[0164] In some embodiments of the present application, the above-mentioned memory includes a first storage area and several second storage areas, the second storage area is used to store the storage data of the target device, and the first storage area is used to save the storage information of the second storage area; the above-mentioned data storage unit 904 can be specifically used to: store the target storage data to the corresponding second storage area according to the target storage method; and update the storage data of the first storage area according to the storage information of the second storage area.
[0165] In some embodiments of the present application, the above-mentioned data access device 900 may further include a configuration unit, which is used to: configure the memory according to preset reference configuration data; obtain current configuration data of the memory; if the current configuration data is consistent with the reference configuration data, confirm that the memory configuration is successful, and execute the step of detecting whether the data read instruction sent from the instruction sending end is received.
[0166] In some embodiments of the present application, the first storage area is a header data storage area for storing fault data, the second storage area includes a fault data storage area for storing fault data, a basic data storage area for storing basic data, and a firmware data storage area for storing firmware data, and the header data includes storage information of the fault data storage area, the basic data storage area, and the firmware data storage area; the above-mentioned data access device 900 may also include an initialization unit, which is used to: after the memory is successfully configured, read header data from the header data storage area of the memory; verify the header data; if the verification fails, confirm that the memory is used for the first time, and perform an initialization operation on the header data.
[0167] In some embodiments of the present application, the above-mentioned operating status acquisition unit 902 can be specifically used to: obtain a fault flag; when the fault flag is a first threshold, determine that the operating status of the target device is a fault state; when the fault flag is a second threshold, determine whether the stored data received from the target device is fault data; if it is fault data, determine that the operating status of the target device is a fault state, and update the fault flag to the first threshold; if it is not fault data, determine that the operating status of the target device is a standby state or a normal working state based on the stored data received from the target device.
[0168] In some embodiments of the present application, the above-mentioned storage information acquisition unit 903 can be specifically used to: obtain the target storage data of the target device in the operating state, wherein when the operating state is the fault state, the target storage data is fault data, and when the operating state is the standby state or the normal working state, the target storage data is basic data; according to the data type of the target storage data, determine the target storage method of the target storage data and the storage time interval of the target storage data, wherein the storage data of each data type corresponds to a storage method and a storage time interval respectively.
[0169] In some embodiments of the present application, when the target storage data is fault data, the above-mentioned data storage unit 904 can be specifically used to: determine the total storage times of the fault data according to the fault type of the target device; store the fault data in the fault data storage area when the storage time interval is met; obtain the stored fault data, and perform data verification on the stored fault data; if the verification is successful and the actual storage times of the fault data does not reach the total storage times, then when the storage time interval is met again, continue to store and verify the fault data until the actual storage times of the fault data reaches the total storage times, and then stop storing the fault data; update the header data according to the storage information of the fault data storage area, and update the fault flag from the first threshold to the second threshold.
[0170] In some embodiments of the present application, when the target storage data is basic data, the above-mentioned data storage unit 904 can be specifically used to: store the basic data in the basic data storage area when the storage time interval is met; obtain the stored basic data, and perform data verification on the stored basic data; if the verification fails, re-execute the steps of obtaining the stored basic data and performing data verification on the stored basic data until the number of verification failures reaches a threshold number, stop data verification, and generate an exception notification message; if the verification is successful, update the header data according to the storage information of the basic data.
[0171] In some embodiments of the present application, the above-mentioned data reading unit can be specifically used to: if the storage method is a cyclic accumulation type, then determine that the reading method of the target read data is to read at least one piece of data closest to the request time of the data read instruction from the target storage location as the target read data; if the storage method is an overlay type, then determine that the reading method of the target read data is to read all data in the storage area where the target storage location is located from the target storage location as the target read data.
[0172] It should be noted that for the convenience and simplicity of description, the specific working process of the data access device 900 can be referred to Figures 1 to 8 The corresponding process of the method will not be described in detail here.
[0173] like Figure 10 FIG. 1 is a schematic diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 may include: a processor 1000, a memory 1001, and a computer program 1002 stored in the memory 1001 and executable on the processor 1000, such as a data access program. When the processor 1000 executes the computer program 1002, the steps in the above-mentioned data access method embodiments are implemented, such as Figure 1 Alternatively, when the processor 1000 executes the computer program 1002, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 9 The detection unit 901, the operation status acquisition unit 902, the storage information acquisition unit 903 and the data storage unit 904 are shown.
[0174] The computer program may be divided into one or more modules / units, which are stored in the memory 1001 and executed by the processor 1000 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0175] For example, the computer program can be divided into: a detection unit, an operation status acquisition unit, a storage information acquisition unit, and a data storage unit. The specific functions of each unit are as follows: the detection unit is used to detect whether a data read instruction sent from the instruction sending end is received; the operation status acquisition unit is used to obtain the operation status of the target device when the data read instruction is not received; the storage information acquisition unit is used to determine the target storage data of the target device, the target storage method of the target storage data, and the storage time interval of the target storage data based on the operation status of the target device; the data storage unit is used to store the target storage data in the target storage area of the memory according to the target storage method and the storage time interval.
[0176] The electronic device may include, but is not limited to, a processor 1000 and a memory 1001. Those skilled in the art will understand that Figure 10These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0177] The processor 1000 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0178] The memory 1001 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 1001 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the memory 1001 may also include both an internal storage unit of the electronic device and an external storage device. The memory 1001 is used to store the computer program and other programs and data required by the electronic device. The memory 1001 may also be used to temporarily store data that has been output or is to be output.
[0179] It should be noted that, for the convenience and brevity of description, the structure of the above electronic device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0180] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0181] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0182] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0183] In the embodiments provided in this application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. On the other hand, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0184] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0185] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0186] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. 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. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A data access method, characterized in that: include: Detect whether a data read instruction sent from the instruction sending end is received; When the data read instruction is not received, obtaining the operating status of the target device; determining target storage data of the target device, a target storage mode of the target storage data, and a storage time interval of the target storage data according to the operating state of the target device; when the operating state is a fault state, the target storage data is fault data, and the storage time interval is a first duration; when the operating state is a standby state or a normal operating state, the target storage data is basic data, and the storage time interval may be a second duration; wherein the first duration is less than the second duration; According to the storage time interval, the target storage data is stored in the target storage area in the memory according to the target storage method, wherein, when storing the fault data, the storage is stopped until the actual storage times of the fault data reaches the total storage times.
2. The data access method according to claim 1, wherein: After detecting whether a data read instruction sent from the instruction sending end is received, the data access method further includes: Upon receiving the data read instruction, obtaining the data type of the target read data in the data read instruction; Acquire a storage mode and a target storage location of the data type, and determine a reading mode of the target read data according to the storage mode; Reading the target read data from the target storage location in the memory according to the reading mode; The target read data is sent to the instruction sending end.
3. The data access method according to claim 1, wherein: The memory includes a first storage area and a plurality of second storage areas, the second storage areas are used to store storage data of the target device, and the first storage area is used to save storage information of the second storage areas; The storing the target storage data in the target storage area of the memory according to the target storage method includes: storing the target storage data in the corresponding second storage area according to the target storage method; The storage data in the first storage area is updated according to the storage information in the second storage area.
4. The data access method according to claim 3, wherein: The data access method further includes: Configuring the memory according to preset reference configuration data; Obtaining current configuration data of the memory; If the current configuration data is consistent with the reference configuration data, it is confirmed that the memory configuration is successful, and the step of detecting whether a data read instruction sent from the instruction sending end is received is performed.
5. The data access method according to claim 4, wherein: The first storage area is a header data storage area for storing fault data, and the second storage area includes a fault data storage area for storing fault data, a basic data storage area for storing basic data, and a firmware data storage area for storing firmware data, wherein the header data includes storage information of the fault data storage area, the basic data storage area, and the firmware data storage area; After the memory configuration is successful, the data access method further includes: Reading header data from a header data storage area of the memory; Verifying the header data; If the verification fails, it is determined that the memory is used for the first time, and the header data is initialized.
6. The data access method according to claim 5, wherein: The obtaining of the operating status of the target device includes: Get the fault flag; When the fault flag is at a first threshold, determining that the operating state of the target device is a fault state; When the fault flag is at a second threshold, determining whether the storage data received from the target device is fault data; If it is fault data, determining that the operating state of the target device is a fault state, and updating the fault flag to a first threshold; If it is not fault data, it is determined that the operating state of the target device is a standby state or a normal working state according to the storage data received from the target device.
7. The data access method according to claim 6, wherein: The determining, according to the operating state of the target device, target storage data of the target device, a target storage mode of the target storage data, and a storage time interval of the target storage data includes: Acquire target storage data of the target device in the running state; According to the data type of the target stored data, a target storage mode of the target stored data and a storage time interval of the target stored data are determined, wherein each data type of stored data corresponds to a storage mode and a storage time interval.
8. The data access method according to claim 7, wherein: When the target storage data is the fault data, storing the target storage data in a target storage area in a memory according to the target storage method based on the storage time interval includes: Determining a total number of times the fault data is stored according to a fault type of the target device; When the storage time interval is met, storing the fault data in a fault data storage area; Acquiring the stored fault data and performing data verification on the stored fault data; If the verification is successful and the actual number of times the fault data is stored does not reach the total number of times it is stored, then when the storage time interval is met again, the data storage and data verification of the fault data will continue until the actual number of times the fault data is stored reaches the total number of times it is stored, at which point the data storage of the fault data will be stopped; According to the storage information of the fault data storage area, the header data is updated, and the fault flag is updated from the first threshold to the second threshold; or, When the target storage data is the basic data, storing the target storage data in a target storage area in a memory according to the target storage method based on the storage time interval includes: When the storage time interval is met, storing the basic data in a basic data storage area; Acquiring the stored basic data and performing data verification on the stored basic data; If the verification fails, re-execute the steps of obtaining the stored basic data and performing data verification on the stored basic data until the number of verification failures reaches a threshold, then stop the data verification and generate an abnormality notification message; If the verification is successful, the header data is updated according to the storage information of the basic data.
9. The data access method according to claim 2, wherein: The determining of a reading method of the target read data according to the storage method includes: If the storage mode is a cyclic accumulation mode, determining the target read data to be read in a manner of reading at least one piece of data closest to the request time of the data read instruction from the target storage location as the target read data; If the storage mode is an overwriting mode, the target read data is determined to be read in a mode of reading all data from the target storage location as the target read data.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the data access method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Log recording method and device and electronic equipment
CN114168401A