Data Processing Method, Processing Device and Processor Based on Embedded Device
By dividing the storage space of embedded devices into a circular queue and data processing is performed based on the queue head pointer, queue tail pointer and partition status identification, the problem of short storage media life of embedded devices is solved, and the recycling and life of storage space is achieved.
Patent Information
- Application Number
- CN202210270192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-03-18
AI Technical Summary
In the prior art, frequent rewrittening of a certain area of an embedded device leads to a lower life of the storage medium.
By dividing the storage space of the embedded device, multiple continuous and identical partition units are formed, and a circular queue is formed, the queue head pointer and the queue tail pointer are determined, and data storage, reading and deletion operations are performed based on these pointers and partition status identifiers.
The limited storage space of embedded devices is realized, frequent rewrittening is avoided, and the service life of the storage medium is extended.
Smart Images

Figure CN114879902B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular, to a method for processing data based on an embedded device, a processing device, a computer-readable storage medium, and a processor. Background Art
[0002] In the prior art, the data access method based on an embedded device usually performs sequential reading and writing on the storage area of the embedded device. When the storage area is full or the occupancy rate of the storage area reaches 90%, the data with the earliest storage time is deleted in the order of the storage time in the storage area. Although this solution realizes the predetermined processing of the data of the embedded device, due to frequent erasing and writing, the service life of the storage area of the embedded device is reduced, and the storage area is prone to failures.
[0003] The above information disclosed in the background art section is only used to enhance the understanding of the background art of the technology described in this article. Therefore, the background art may contain certain information that is not prior art known to those skilled in the art in this country. Summary of the Invention
[0004] The main object of the present application is to provide a method for processing data based on an embedded device, a processing device, a computer-readable storage medium, and a processor, so as to solve the problem in the prior art that frequent erasing and writing of a certain area of the embedded device results in a low service life of the corresponding storage medium.
[0005] According to one aspect of an embodiment of the present invention, a method for processing data based on an embedded device is provided, including: dividing the storage space of the embedded device to obtain a plurality of consecutive and identically sized partition units, each of the partition units includes a partition status flag and at least one data unit, the partition status flag is used to indicate whether the corresponding partition unit is abnormal, and the data unit is used to store data; a plurality of consecutive partition units form a circular queue, and determine the storage positions pointed to by the queue head pointer and the queue tail pointer of the circular queue; at least according to the target parameter information, perform predetermined processing on the data, the predetermined processing includes at least one of the following: storage, reading, deletion, and the target parameter information includes at least one of the following: the queue head pointer, the queue tail pointer, the partition status flag.
[0006] Optionally, at least according to the target parameter information, perform predetermined processing on the data, including: calculating the remaining storage space of the partition unit pointed to by the queue tail pointer according to the storage position pointed to by the queue tail pointer; in the case where the remaining storage space is less than the target storage space, storing the target data in the next partition unit, where the target data is the data to be stored, the target storage space is the storage space required to store the target data, and the next partition unit and the partition unit where the queue tail pointer is located are two adjacent partition units; in the case where the remaining storage space is greater than or equal to the target storage space, storing the target data in the remaining storage space, and controlling the queue tail pointer to point to the storage position of the target data.
[0007] Optionally, at least according to the target parameter information, perform predetermined processing on the data, including: determining a queue head data unit and a queue head partition unit, where the queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; in the case where the partition status flag of the queue head partition unit indicates normal, reading the data of the queue head data unit.
[0008] Optionally, at least according to the target parameter information, perform predetermined processing on the data, including: determining a queue head data unit and a queue head partition unit, where the queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; in the case where the partition status flag of the queue head partition unit indicates normal, deleting the data of the queue head data unit, and controlling the queue head pointer to move to the target storage position.
[0009] Optionally, the target storage position includes a first target storage position and a second target storage position. The first target storage position is the storage position of the first data unit of the next partition unit adjacent to the queue head partition unit, and the second target storage position is the next data unit adjacent to the queue head data unit. Controlling the queue head pointer to move to the target position includes: determining whether the queue head data unit is the last data unit of the queue head partition unit; in the case where the queue head data unit is the last data unit of the queue head partition unit, controlling the queue head pointer to point to the first target storage position; in the case where the queue head data unit is not the last data unit of the queue head partition unit, controlling the queue head pointer to point to the second target storage position.
[0010] Optionally, when the data is not stored in the storage space, determining the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the circular queue includes: controlling both the queue head pointer and the queue tail pointer to point to the initial position of the storage space, where the initial position is the partition status identifier of the first partition unit in the storage space.
[0011] Optionally, when the data is stored in the storage space, determining the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the circular queue includes: a first determination step of determining whether the target partition unit is abnormal according to the partition status identifier of the target partition unit of the storage space. When the partition status identifier of the target partition unit indicates normal, determining at least the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer according to the data unit corresponding to the target partition unit, where the target partition unit is one of the multiple partition units; when the partition status identifier of the target partition unit indicates abnormal, repeatedly execute the first determination step until the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer are determined, and in any two adjacent first determination steps, the corresponding target partition units are two adjacent partition units.
[0012] Optionally, the data unit further includes data header information, where the data header information includes sequence number information and header check information. The sequence number information is used to represent the order in which the data is stored in the storage space, and the header check information is used to represent whether the data header information is damaged. When the partition status identifier of the target partition unit indicates normal, determining at least the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer according to the data unit corresponding to the target partition unit includes: a second determination step of determining whether the target data unit is damaged according to the header check information of the target data unit in the target partition unit. When the header check information of the target data unit indicates no damage, determining the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer according to the sequence number information corresponding to the target data unit, where the target data unit is one of the data units in the target partition unit; when the header check information of the target data unit indicates damage, repeatedly execute the first determination step until the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer are determined.
[0013] According to another aspect of the embodiments of the present invention, there is also provided a data processing device based on an embedded device, including: a partitioning unit, configured to partition the storage space of the embedded device to obtain a plurality of consecutive and identically sized partition units, each of the partition units including a partition status identifier and at least one data unit, the partition status identifier being used to represent whether the corresponding partition unit is abnormal, and the data unit being used to store data; a determining unit, configured to form a circular queue from a plurality of consecutive partition units, and determine the storage positions pointed to by the queue head pointer and the queue tail pointer of the circular queue; a processing unit, configured to perform a predetermined process on the data at least according to target parameter information, the predetermined process including at least one of the following: storing, reading, and deleting, and the target parameter information including at least one of the following: the queue head pointer, the queue tail pointer, and the partition status identifier.
[0014] According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, the computer-readable storage medium including a stored program, wherein the program executes any one of the above-mentioned processing methods.
[0015] According to yet another aspect of the embodiments of the present invention, there is also provided a processor, the processor being used to run a program, wherein when the program runs, it executes any one of the above-mentioned processing methods.
[0016] In the embodiments of the present invention, in the above-mentioned data processing method based on an embedded device, first, the storage space of the embedded device is partitioned to obtain a plurality of partition units, the plurality of partition units being of the same size and consecutive, and each partition unit including a partition status identifier and at least one data unit; then, the queue head pointer and the queue tail pointer of the circular queue formed by the plurality of consecutive partition units are determined; finally, according to one or more of the queue head pointer, the queue tail pointer, and the partition status identifier, the data not stored in the partition unit is stored in the partition unit, or the data already stored in the partition unit is read, or the data already stored in the partition unit is deleted. In this solution, the queue head pointer and the queue tail pointer of the circular queue formed by the plurality of consecutive partition units are determined, and then according to one or more target parameter information of the queue head pointer, the queue tail pointer, and the partition status identifier, the data in the limited storage space of the embedded device is subjected to a predetermined process, that is, this solution realizes the predetermined process of the data in the embedded device in the form of a circular queue, realizes the circular use of the limited storage space of the embedded device, avoids frequent erasing and writing of a certain area of the storage space of the embedded device, and further ensures that the service life of the corresponding storage medium of the embedded device is relatively long, thus solving the problem in the prior art that the service life of the corresponding storage medium is relatively low due to frequent erasing and writing of a certain area of the embedded device. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings forming a part of this application are used to provide a further understanding of this application. The schematic embodiments and descriptions thereof of this application are used to explain this application and do not constitute an improper limitation to this application. In the drawings:
[0018] Figure 1 A flowchart of a method for processing data based on an embedded device according to an embodiment of this application is shown;
[0019] Figure 2 A schematic diagram of the storage space division of an embedded device according to an embodiment of this application is shown;
[0020] Figure 3 A schematic structural diagram of a device for processing data based on an embedded device according to an embodiment of this application is shown;
[0021] Figure 4 A flowchart of storing data according to a specific embodiment of this application is shown;
[0022] Figure 5 A flowchart of deleting data according to a specific embodiment of this application is shown;
[0023] Figure 6 A flowchart of determining a queue head pointer and a queue tail pointer according to a specific embodiment of this application is shown.
[0024] Among them, the above-mentioned drawings include the following reference numerals:
[0025] 200, partition status identifier; 201, partition unit; 202, data unit; 203, serial number; 204, data length information; 205, data check information; 206, header check information; 207, initial position; 208, end position; 209, data header information; 210, data. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] It should be noted that, without conflict, the embodiments in this application and the features in the embodiments may be combined with each other. The following will describe this application in detail with reference to the drawings and in combination with the embodiments.
[0027] In order to enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
[0028] It should be noted that the terms "first", "second", etc. in the description, claims and the above-mentioned drawings of the present application are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so as to implement the embodiments of the present application described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0029] As described in the background art, the prior art lacks the processing of data of embedded devices in the form of a circular queue. To solve the above problems, in a typical embodiment of the present application, a method for processing data based on an embedded device, a processing device, a computer-readable storage medium and a processor are provided.
[0030] According to an embodiment of the present application, a method for processing data based on an embedded device is provided.
[0031] Figure 1 It is a flowchart of a method for processing data based on an embedded device according to an embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0032] Step S101, divide the storage space of the above-mentioned embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above-mentioned partition units includes a partition status flag and at least one data unit. The above-mentioned partition status flag is used to indicate whether the corresponding above-mentioned partition unit is abnormal, and the above-mentioned data unit is used to store data;
[0033] Step S102, a plurality of consecutive above-mentioned partition units form a circular queue, and determine the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the above-mentioned circular queue;
[0034] Step S103, perform a predetermined process on the above-mentioned data at least according to target parameter information. The above-mentioned predetermined process includes at least one of the following: storage, reading, deletion. The above-mentioned target parameter information includes at least one of the following: the above-mentioned queue head pointer, the above-mentioned queue tail pointer, the above-mentioned partition status flag.
[0035] In the above data processing method based on an embedded device, first, the storage space of the embedded device is partitioned to obtain a plurality of partition units. The plurality of partition units are of the same size and continuous. Each partition unit includes a partition status flag and at least one data unit. Then, the queue head pointer and the queue tail pointer of a circular queue formed by a plurality of continuous partition units are determined. Finally, according to one or more of the queue head pointer, the queue tail pointer, and the partition status flag, data that has not been stored in the partition unit is stored in the partition unit, or data that has been stored in the partition unit is read, or data that has been stored in the partition unit is deleted. In this solution, the queue head pointer and the queue tail pointer of a circular queue formed by a plurality of continuous partition units are determined, and then, according to one or more target parameter information among the queue head pointer, the queue tail pointer, and the partition status flag, predetermined processing is performed on the data in the limited storage space of the embedded device. That is, this solution realizes the predetermined processing of the data in the embedded device through the circular queue, realizes the circular use of the limited storage space of the embedded device, avoids frequent erasing and writing of a certain area of the storage space of the embedded device, and thus ensures a relatively long service life of the storage medium corresponding to the embedded device, thereby solving the problem in the prior art that frequent erasing and writing of a certain area of the embedded device results in a low service life of the corresponding storage medium.
[0036] Specifically, as Figure 2As shown in the figure, the storage space of the embedded device is partitioned to obtain multiple consecutive partition units 201 with the same size. Each partition unit 201 includes a partition status flag 200 and at least one data unit 202. In a partition unit 201, the sizes of the respective data units 202 can be divided according to the size of the data, so the sizes of the respective data units 202 are not fixed. In the case where the data 210 is relatively large, a continuous segment of data 210 may occupy one partition unit 201. For each data unit 202, each data unit 202 includes data header information 209 and data 210. Among them, the data header information 209 includes a serial number 203, data length information 204, data check information 205, and header check information 206. The above serial number 203 is used to represent the order in which the data is inserted into the circular queue. The larger the value of the serial number 203, the later the time of insertion into the circular queue. Similarly, when reading data, the data unit with the smallest serial number value in the circular queue should be returned, thus realizing the first-in-first-out data management; the data length information 204 is used to represent the length of the data and is not a fixed value. Therefore, there is no limit to the size of the stored data, unless it exceeds the length of the entire partition unit; the data check information 205 is calculated for the data through the cyclic redundancy algorithm and is used to determine whether the data is damaged. When reading data, it can be determined whether the data is available through the data check information 205; the header check information 206 is calculated for the data header information 209 through the cyclic redundancy algorithm and is used to determine whether the data header information is damaged. If the data header information indicates damage, the size of the subsequent data cannot be obtained, and the partition status flag of the entire partition unit where the data unit is located is set to abnormal.
[0037] Specifically, the above circular queue further includes control information, and the control information includes: the storage location pointed to by the queue head pointer, the storage location pointed to by the queue tail pointer, and the number of stored data units in the entire circular queue. In the actual application process, in the case where no data is stored in the entire circular queue (i.e., the entire storage space), as Figure 2 shown, both the queue head pointer and the queue tail pointer point to the initial position 207 of the circular queue, and the number of data units is 0; in the case where the entire circular queue is full of data and no data is deleted, the queue head pointer points to the initial position 207 of the circular queue, and the queue tail pointer points to the end position 208 of the circular queue. At this time, the number of data units is the total number of stored data units in the entire circular queue.
[0038] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0039] In an embodiment of the present application, at least according to the target parameter information, the above data is subjected to a predetermined process, including: calculating the remaining storage space of the partition unit pointed to by the above queue tail pointer according to the storage position pointed to by the above queue tail pointer; in the case where the remaining storage space is less than the target storage space, storing the target data into the next above partition unit, the target data being the above data to be stored, the target storage space being the storage space required for storing the target data, and the next above partition unit and the above partition unit where the queue tail pointer is located being two adjacent above partition units; in the case where the remaining storage space is greater than or equal to the above target storage space, storing the above target data into the above remaining storage space, and controlling the queue tail pointer to point to the storage position of the above target data. In this embodiment, in the case where the remaining storage space is greater than or equal to the target storage space, the target data is stored in the remaining storage space, which ensures that the data can be stored in the remaining storage space more completely to avoid errors in the target data during the storage process. In addition, in this embodiment, when inserting data into the circular queue, the data is inserted starting from the position pointed to by the queue tail pointer, which can further avoid repeatedly erasing and writing a certain area, and further extend the service life of the storage medium.
[0040] Specifically, in the above embodiment, after storing the target data into the circular queue, it is also necessary to update the control information of the circular queue, that is, pointing the queue tail pointer to the storage position of the target data and incrementing the number of data units by 1.
[0041] In order to read data more conveniently and quickly, in another embodiment of the present application, at least according to the target parameter information, the above data is subjected to a predetermined process, including: determining the queue head data unit and the queue head partition unit, the queue head data unit being the above data unit pointed to by the above queue head pointer, and the queue head partition unit being the above partition unit where the above queue head pointer is located; in the case where the partition status flag of the above queue head partition unit indicates normal, reading the above data of the above queue head data unit.
[0042] Specifically, in the actual application process, since the partition status flag of the queue head partition unit indicates abnormal, there is at least one damaged data unit in the queue head partition unit. In this case, it is impossible to accurately determine the length of other data. Therefore, in order to ensure the accuracy of reading data, in the case where the partition status flag of the above queue head partition unit indicates abnormal, the above queue head data unit is not read.
[0043] Specifically, during the process of reading data, reading starts from the position pointed to by the queue head pointer. During the process of reading data, the queue head pointer does not move backward due to data reading. Therefore, during the process of reading data, there is no need to update the control information, that is, there is no need to update the queue head pointer, the queue tail pointer, and the number of data units.
[0044] In another embodiment of the present application, at least according to the target parameter information, the above data is subjected to a predetermined process, including: determining a queue head data unit and a queue head partition unit, where the queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; when the partition status flag of the queue head partition unit indicates normal, deleting the data of the queue head data unit, and controlling the queue head pointer to move to the target storage position. In this embodiment, the data pointed to by the queue head pointer is deleted, which ensures that the data stored in the circular queue earlier can be deleted. Subsequently, during the process of storing data in the circular queue, it is possible to further avoid repeatedly and frequently erasing and writing a certain area in the storage space.
[0045] In addition, since the partition status flag of the queue head partition unit indicates abnormal, there is at least one damaged data unit in the queue head partition unit. In this case, it is impossible to accurately determine the length of other data. Therefore, to ensure data integrity and avoid data damage in other data units caused by uncertain data length, when the partition status flag of the queue head partition unit indicates abnormal, the queue head data unit is not deleted.
[0046] In order to simply control the backward movement of the queue head pointer and further ensure the accurate determination of the position pointed to by the queue head pointer, in another embodiment of the present application, the target storage position includes a first target storage position and a second target storage position. The first target storage position is the storage position of the first data unit of the next partition unit adjacent to the queue head partition unit, and the second target storage position is the next data unit adjacent to the queue head data unit. Controlling the queue head pointer to move to the target position includes: determining whether the queue head data unit is the last data unit of the queue head partition unit; when the queue head data unit is the last data unit of the queue head partition unit, controlling the queue head pointer to point to the first target storage position; when the queue head data unit is not the last data unit of the queue head partition unit, controlling the queue head pointer to point to the second target storage position.
[0047] Specifically, while deleting the data, it is also necessary to update the control information, that is, move the queue head pointer backward by one data unit and subtract 1 from the number of data units.
[0048] In the actual application process, the read data can also be deleted. Therefore, during the data reading process, it can be first determined whether the above queue head data unit is the last data unit. When the partition status flag of the queue head partition unit indicates normal, the data of the queue head data unit is read, then the read data is deleted, and the queue head pointer is controlled to move to the target position.
[0049] In order to facilitate subsequent predetermined processing of data according to the queue head pointer and the queue tail pointer, in an embodiment of the present application, when the above data is not stored in the above storage space, determining the storage positions pointed to by the queue head pointer and the queue tail pointer of the above circular queue includes: controlling both the queue head pointer and the queue tail pointer to point to the initial position of the above storage space, and the initial position is the above partition status flag of the first partition unit in the above storage space.
[0050] In another embodiment of the present application, when the above data is already stored in the above storage space, determining the storage positions pointed to by the queue head pointer and the queue tail pointer of the above circular queue includes: a first determination step of determining whether the target partition unit is abnormal according to the above partition status flag of the target partition unit of the above storage space. When the above partition status flag of the target partition unit indicates normal, determining at least the storage positions pointed to by the queue head pointer and the queue tail pointer according to the above data unit corresponding to the target partition unit, and the target partition unit is one of the multiple above partition units; when the above partition status flag of the target partition unit indicates abnormal, repeating the above first determination step until the storage positions pointed to by the queue head pointer and the queue tail pointer are determined, and in any two adjacent above first determination steps, the corresponding above target partition units are two adjacent above partition units. In this embodiment, it is judged whether the partition status flag of the target partition unit is abnormal. When the partition status flag indicates abnormal, there are damaged data units in the target partition unit, so the serial numbers of other data units cannot be determined subsequently, and then move to the next target partition unit. When the partition status flag indicates normal, the storage positions pointed to by the queue head pointer and the queue tail pointer can be determined at least according to each data unit, so as to ensure that the storage positions pointed to by the queue head pointer and the queue tail pointer determined subsequently are relatively accurate.
[0051] Specifically, since the embedded device cannot accurately determine the storage locations of the queue head pointer and the queue tail pointer after being powered on again, after the embedded device is powered on again, it is necessary to scan the entire storage space to determine the storage locations of the queue head pointer and the queue tail pointer. During the specific scanning process, the scanning can be started from the first data unit (i.e., the initial position) in the entire storage space.
[0052] In order to more accurately determine the storage locations pointed to by the queue head pointer and the queue tail pointer, in another embodiment of the present application, the above data unit further includes data header information, and the above data header information includes a serial number and header check information. The above serial number is used to represent the order in which the above data is stored in the above storage space, and the above header check information is used to represent whether the above data header information is damaged. When the partition status identifier of the above target partition unit represents normal, at least based on the above data unit corresponding to the above target partition unit, determining the storage location pointed to by the above queue head pointer and the storage location pointed to by the above queue tail pointer includes: a second determination step of determining whether the above target data unit is damaged according to the above header check information of the target data unit in the above target partition unit. When the above header check information of the above target data unit represents no damage, determining the storage location pointed to by the above queue head pointer and the storage location pointed to by the above queue tail pointer according to the above serial number corresponding to the above target data unit, where the above target data unit is one of the above data units in the above target partition unit; when the above header check information of the above target data unit represents damage, repeatedly execute the above first determination step until the storage location pointed to by the above queue head pointer and the storage location pointed to by the above queue tail pointer are determined.
[0053] Specifically, the specific process of determining the storage positions pointed to by the above queue head pointer and the above queue tail pointer according to the above serial numbers corresponding to the above target data units is as follows: When scanning, it starts from the initial position of the entire storage space. Therefore, both the queue head pointer and the queue tail pointer are pointed to the initial position, that is, the queue head pointer and the queue tail pointer are initialized. When the partition status flag of the first partition unit in the storage space indicates normal, then sequentially read the first target data unit of the first target partition unit, and then both the queue head pointer and the queue tail pointer are pointed to the first target data unit. If the serial number of the second target data unit is greater than the serial number of the first target data unit, it indicates that the data of the second target data unit is stored later than the data of the first target data unit. Therefore, the queue tail pointer is pointed to the data of the second target data unit. Compare the serial numbers of each target data unit in turn to determine the positions pointed to by the queue head pointer and the queue tail pointer. After scanning all the data units of the first target partition unit, the next target partition unit can be scanned continuously until all the target partition units in the entire storage space are scanned or the target partition units with stored data are scanned, and then the storage positions pointed to by the queue head pointer and the queue tail pointer can be determined.
[0054] The embodiment of the present application also provides a data processing device based on an embedded device. It should be noted that the data processing device based on the embedded device in the embodiment of the present application can be used to execute the data processing method based on the embedded device provided in the embodiment of the present application. The following introduces the data processing device based on the embedded device provided in the embodiment of the present application.
[0055] Figure 3 It is a schematic structural diagram of the data processing device based on the embedded device according to the embodiment of the present application. As Figure 3 shown, the device includes:
[0056] A partitioning unit 10, configured to partition the storage space of the above embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above partition units includes a partition status flag and at least one data unit. The above partition status flag is used to indicate whether the corresponding above partition unit is abnormal, and the above data unit is used to store data;
[0057] A determining unit 20, configured to form a circular queue with a plurality of consecutive above partition units, and determine the storage position pointed to by the queue head pointer of the above circular queue and the storage position pointed to by the queue tail pointer;
[0058] A processing unit 30 is configured to perform a predetermined process on the above data at least according to target parameter information. The predetermined process includes at least one of the following: storage, reading, and deletion. The target parameter information includes at least one of the following: the above queue head pointer, the above queue tail pointer, and the above partition status identifier.
[0059] In the above data processing device based on an embedded device, a partitioning unit is configured to partition the storage space of the embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above partition units includes a partition status identifier and at least one data unit. The partition status identifier is used to indicate whether the corresponding partition unit is abnormal, and the data unit is used to store data. A determination unit is configured to form a circular queue from a plurality of consecutive above partition units, and determine the storage positions pointed to by the queue head pointer and the queue tail pointer of the circular queue. A processing unit is configured to perform a predetermined process on the above data at least according to target parameter information. The predetermined process includes at least one of the following: storage, reading, and deletion. The target parameter information includes at least one of the following: the above queue head pointer, the above queue tail pointer, and the above partition status identifier. In this device, the queue head pointer and the queue tail pointer of the circular queue formed by a plurality of consecutive partition units are determined, and then, according to one or more target parameter information among the queue head pointer, the queue tail pointer, and the partition status identifier, a predetermined process is performed on the data in the limited storage space of the embedded device. That is, this solution realizes the predetermined process of the data in the embedded device through the circular queue, realizes the circular use of the limited storage space of the embedded device, avoids frequent erasing and writing of a certain area of the storage space of the embedded device, and thus ensures a relatively long service life of the storage medium corresponding to the embedded device, thereby solving the problem in the prior art that frequent erasing and writing of a certain area of the embedded device results in a relatively low service life of the corresponding storage medium.
[0060] Specifically, such as Figure 2As shown in the figure, the storage space of the embedded device is partitioned to obtain multiple consecutive partition units 201 of the same size. Each partition unit 201 includes a partition status flag 200 and at least one data unit 202. In a partition unit 201, the sizes of the respective data units 202 can be divided according to the size of the data, so the sizes of the respective data units 202 are not fixed. In the case where the data 210 is large, a continuous piece of data 210 may occupy a partition unit 201. For each data unit 202, each data unit 202 includes data header information 209 and data 210. Among them, the data header information 209 includes a sequence number 203, data length information 204, data check information 205, and header check information 206. The above sequence number 203 is used to represent the order in which the data is inserted into the circular queue. The larger the value of the sequence number 203, the later the time of insertion into the circular queue. Similarly, when the data is read, the data unit with the smallest sequence number value in the circular queue should be returned, thus realizing the first-in, first-out data management; the data length information 204 is used to represent the length of the data and is not a fixed value. Therefore, there is no limit to the size of the stored data, unless it exceeds the length of the entire partition unit; the data check information 205 is calculated for the data through a cyclic redundancy algorithm and is used to determine whether the data is damaged. When reading the data, it can be determined whether the data is available through the data check information 205; the header check information 206 is calculated for the data header information 209 through a cyclic redundancy algorithm and is used to determine whether the data header information is damaged. If the data header information indicates damage, the size of the subsequent data cannot be obtained, and the partition status flag of the entire partition unit where the data unit is located is set to abnormal.
[0061] Specifically, the above circular queue further includes control information, and the control information includes: the storage location pointed to by the queue head pointer, the storage location pointed to by the queue tail pointer, and the number of stored data units in the entire circular queue. In the actual application process, in the case where no data is stored in the entire circular queue (i.e., the entire storage space), as Figure 2 shown in the figure, both the queue head pointer and the queue tail pointer point to the initial position 207 of the circular queue, and the number of data units is 0; in the case where the entire circular queue is full of data and no data is deleted, the queue head pointer points to the initial position 207 of the circular queue, and the queue tail pointer points to the end position 208 of the circular queue. At this time, the number of data units is the total number of stored data units in the entire circular queue.
[0062] In an embodiment of the present application, the above-mentioned processing unit includes a calculation module, a storage module, and a first control module. Among them, the above-mentioned calculation module is used to calculate the remaining storage space of the above-mentioned partition unit pointed to by the above-mentioned queue tail pointer according to the storage position pointed to by the above-mentioned queue tail pointer; the above-mentioned storage module is used to store the target data in the next above-mentioned partition unit when the above-mentioned remaining storage space is less than the target storage space, the above-mentioned target data is the above-mentioned data to be stored, the above-mentioned target storage space is the storage space required to store the above-mentioned target data, and the next above-mentioned partition unit and the above-mentioned partition unit where the above-mentioned queue tail pointer is located are two adjacent above-mentioned partition units; the above-mentioned first control module is used to store the above-mentioned target data in the above-mentioned remaining storage space when the above-mentioned remaining storage space is greater than or equal to the above-mentioned target storage space, and control the above-mentioned queue tail pointer to point to the storage position of the above-mentioned target data. In this embodiment, when the remaining storage space is greater than or equal to the target storage space, the target data is stored in the remaining storage space, which ensures that the data can be stored in the remaining storage space more completely to avoid errors in the target data during the storage process. In addition, in this embodiment, when inserting data into the circular queue, the data is inserted starting from the position pointed to by the queue tail pointer, which can further avoid repeatedly erasing and writing a certain area, and further extend the service life of the storage medium.
[0063] Specifically, in the above-mentioned embodiment, after storing the target data in the circular queue, it is also necessary to update the control information of the circular queue, that is, to point the queue tail pointer to the storage position of the target data, and to increment the number of data units by 1.
[0064] In order to read data more conveniently and quickly, in another embodiment of the present application, the above-mentioned processing unit further includes a first determination module and a reading module. Among them, the above-mentioned first determination module is used to determine the queue head data unit and the queue head partition unit. The above-mentioned queue head data unit is the above-mentioned data unit pointed to by the above-mentioned queue head pointer, and the above-mentioned queue head partition unit is the above-mentioned partition unit where the above-mentioned queue head pointer is located; the above-mentioned reading module is used to read the above-mentioned data of the above-mentioned queue head data unit when the above-mentioned partition status flag of the above-mentioned queue head partition unit indicates normal.
[0065] Specifically, in the actual application process, since the partition status flag of the queue head partition unit indicates abnormal, there will be at least one damaged data unit in the queue head partition unit. In this case, it is impossible to accurately determine the length of other data. Therefore, in order to ensure the accuracy of reading data, when the above-mentioned partition status flag of the above-mentioned queue head partition unit indicates abnormal, the above-mentioned queue head data unit is not read.
[0066] Specifically, during the process of reading data, the reading starts from the position pointed to by the queue head pointer. During the data reading process, the queue head pointer does not move backward due to data reading. Therefore, during the data reading process, there is no need to update the control information, that is, there is no need to update the queue head pointer, the queue tail pointer, and the number of data units.
[0067] In another embodiment of the present application, the above processing unit further includes a second determination module and a deletion module. Among them, the second determination module is used to determine the queue head data unit and the queue head partition unit. The queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; the deletion module is used to delete the data of the queue head data unit when the partition status flag of the queue head partition unit indicates normal, and control the queue head pointer to move to the target storage position. In this embodiment, the data pointed to by the queue head pointer is deleted, which ensures that the data stored in the circular queue earlier can be deleted. Subsequently, during the process of storing data in the circular queue, it is possible to further avoid frequent erasing and writing of a certain area in the storage space.
[0068] In addition, since the partition status flag of the queue head partition unit indicates an abnormality, there will be at least one damaged data unit in the queue head partition unit. In this case, it is impossible to accurately determine the length of other data. Therefore, in order to ensure data integrity and avoid data damage in other data units due to uncertain data length, when the partition status flag of the queue head partition unit indicates an abnormality, the queue head data unit is not deleted.
[0069] In order to more simply control the backward movement of the queue head pointer and further ensure a more accurate determination of the position pointed to by the queue head pointer, in another embodiment of the present application, the above-mentioned target storage location includes a first target storage location and a second target storage location. The above-mentioned first target storage location is the storage location of the first data unit of the next partition unit adjacent to the queue head partition unit, and the above-mentioned second target storage location is the next data unit adjacent to the above-mentioned queue head data unit. The deletion module includes a first determination sub-module, a first control sub-module, and a second control sub-module. Among them, the above-mentioned first determination sub-module is used to determine whether the above-mentioned queue head data unit is the last data unit of the above-mentioned queue head partition unit; the above-mentioned first control sub-module is used to control the queue head pointer to point to the above-mentioned first target storage location when the above-mentioned queue head data unit is the last data unit of the above-mentioned queue head partition unit; the above-mentioned second control sub-module is used to control the queue head pointer to point to the above-mentioned second target storage location when the above-mentioned queue head data unit is not the last data unit of the above-mentioned queue head partition unit.
[0070] Specifically, when deleting data, it is also necessary to update the control information, that is, move the queue head pointer backward by one data unit and subtract 1 from the number of data units.
[0071] In the actual application process, a deletion operation can also be performed on the read data. Therefore, during the data reading process, it can be first determined whether the above-mentioned queue head data unit is the last data unit. When the partition status flag of the queue head partition unit indicates normal, the data of the queue head data unit is read, and then the read data is deleted, and the queue head pointer is controlled to move to the target position.
[0072] In order to more conveniently perform predetermined processing on data according to the queue head pointer and the queue tail pointer in the future, in an embodiment of the present application, the above-mentioned determination unit includes a second control module, which is used to control both the queue head pointer and the queue tail pointer to point to the initial position of the above-mentioned storage space when no data is stored in the above-mentioned storage space. The above-mentioned initial position is the partition status flag of the first partition unit in the above-mentioned storage space.
[0073] In another embodiment of the present application, the above-mentioned determination unit further includes a third determination module and an execution module. Among them, the third determination module is configured to, when the above-mentioned data has been stored in the above-mentioned storage space, perform a first determination step of determining whether the target partition unit is abnormal according to the above-mentioned partition status identifier of the target partition unit of the above-mentioned storage space. When the above-mentioned partition status identifier of the target partition unit indicates normal, at least determine the storage position pointed to by the above-mentioned queue head pointer and the storage position pointed to by the above-mentioned queue tail pointer according to the above-mentioned data unit corresponding to the above-mentioned target partition unit. The above-mentioned target partition unit is one of the multiple above-mentioned partition units; the execution module is configured to, when the above-mentioned partition status identifier of the target partition unit indicates abnormal, repeatedly execute the above-mentioned first determination step until the storage position pointed to by the above-mentioned queue head pointer and the storage position pointed to by the above-mentioned queue tail pointer are determined, and in any two adjacent above-mentioned first determination steps, the corresponding above-mentioned target partition units are two adjacent above-mentioned partition units. In this embodiment, it is judged whether the partition status identifier of the target partition unit is abnormal. When the partition status identifier indicates abnormal, there are damaged data units in the target partition unit, so the serial numbers of other data units cannot be determined subsequently, and thus it moves to the next target partition unit. When the partition status identifier indicates normal, the storage position pointed to by the queue head pointer and the storage position pointed to by the queue tail pointer can be determined at least according to each data unit, which ensures that the storage positions pointed to by the queue head pointer and the queue tail pointer determined subsequently are relatively accurate.
[0074] Specifically, since the embedded device cannot accurately determine the storage positions of the queue head pointer and the queue tail pointer after being powered on again, after the embedded device is powered on again, it is necessary to scan the entire storage space to determine the storage positions of the queue head pointer and the queue tail pointer. During the specific scanning process, the scanning can be started from the first data unit (i.e., the initial position) in the entire storage space.
[0075] In order to more accurately determine the storage positions pointed to by the queue head pointer and the queue tail pointer, in another embodiment of the present application, the above data unit further includes data header information, the above data header information includes a serial number and header check information, the above serial number is used to represent the order in which the above data is stored in the above storage space, the above header check information is used to represent whether the above data header information is damaged, the third determination module includes a second determination sub-module and an execution sub-module, wherein, the above second determination sub-module is used for the second determination step, and according to the above header check information of the target data unit in the above target partition unit, determine whether the above target data unit is damaged, in the case that the above header check information of the above target data unit represents no damage, according to the above serial number corresponding to the above target data unit, determine the storage position pointed to by the above queue head pointer and the storage position pointed to by the above queue tail pointer, the above target data unit is one of the above data units in the above target partition unit; the above execution sub-module is used for in the case that the above header check information of the above target data unit represents damage, repeatedly execute the above first determination step until the storage position pointed to by the above queue head pointer and the storage position pointed to by the above queue tail pointer are determined.
[0076] Specifically, the specific process of determining the storage position pointed to by the above queue head pointer and the storage position pointed to by the above queue tail pointer according to the above serial number corresponding to the above target data unit is as follows: when scanning, it starts from the initial position of the entire storage space, so both the queue head pointer and the queue tail pointer point to the initial position, that is, initialize the queue head pointer and the queue tail pointer. In the case that the partition status flag of the first partition unit in the storage space represents normal, then sequentially read the first target data unit of the first target partition unit, and then both the queue head pointer and the queue tail pointer point to the first target data unit. If the serial number of the second target data unit is greater than the serial number of the first target data unit, it indicates that the data of the second target data unit is stored later than the data of the first target data unit. Therefore, the queue tail pointer points to the data of the second target data unit, and sequentially compare the serial numbers of each target data unit to determine the positions pointed to by the queue head pointer and the queue tail pointer. After scanning all the data units in the first target partition unit, the next target partition unit can be scanned continuously until all the target partition units in the entire storage space are scanned or the target partition units with stored data are scanned, then the storage positions pointed to by the queue head pointer and the queue tail pointer can be determined.
[0077] In order to enable those skilled in the art to clearly understand the technical solution of the present application, the following will be specifically described with specific embodiments.
[0078] Embodiment 1
[0079] Such asFigure 4 As shown, in the process of inserting target data into the circular queue, first, according to the position pointed to by the queue tail pointer, determine the remaining storage space in the partition unit pointed to by the queue tail pointer. Then, compare the remaining storage space with the target storage space required to store the target data. When the remaining storage space is greater than or equal to the target storage space (i.e., the remaining storage space can accommodate the target data), calculate the data header information of the target data, and store both the data header information and the target data in the remaining storage space. Also, control the queue tail pointer to point to the storage position of the target data, and increment the number of data units by 1. When the remaining storage space is less than the target storage space (i.e., the remaining storage space cannot accommodate the target data), then determine whether to overwrite the next partition unit (i.e., determine whether the next partition unit already stores data). When there is no need to overwrite a partition unit (i.e., the next partition unit does not store data), store both the data header information and the target data in the next partition unit. When it is necessary to overwrite the next partition unit (i.e., the next partition unit already stores data), delete all the data in this partition unit, update the control information, then store both the data header information and the target data in this partition unit, and update the control information.
[0080] Example 2
[0081] As Figure 5 shown, first, determine the queue head data unit and the queue head partition unit, and determine whether the queue head data unit is the last data unit in the queue head partition unit. When the queue head data unit is not the last data unit, read the partition status flag of the queue head partition unit, and determine whether the partition status flag of the queue head partition unit indicates an abnormality. When the partition status flag indicates an abnormality, do not delete the data in the queue head partition unit, then control the queue head pointer to move to the next partition unit (the partition unit adjacent to the queue head partition unit), and determine the partition status flag of the next partition unit. When the partition status flag indicates normal, then delete the data, and move the queue head pointer to the second target storage position. When the queue head data unit is the last data unit, then delete the queue head data unit, and move the queue head pointer to the first target storage position.
[0082] Example 3
[0083] As Figure 6 As shown in the figure, first, before determining the storage locations of the queue head pointer and the queue tail pointer, the control information is initialized (i.e., both the queue head pointer and the queue tail pointer point to the control information of the storage space, and the number of data units is 0); then, starting from the initial position in the storage space, the first target partition unit is read, and it is determined whether the partition status flag of the first target partition unit is normal. When the partition status flag of the first target partition unit indicates normal, multiple target data units in the first target partition unit are sequentially read. That is, starting from reading the first target data unit, it is judged whether the header check information of the first target data unit is damaged. When it is not damaged, according to the serial number of the first target data unit, the storage locations pointed to by the queue head pointer and the queue tail pointer are determined, and the number of data units is determined. When it is damaged, if it cannot be judged and needs to be judged further, it moves to the next target partition unit. After judging that the first target data unit is not damaged and after judging the first target data unit, the second target data unit is read, and it is judged whether the second target data unit is the last target data unit of the target partition unit. When the second target data unit is not the last target data unit, the control information of the circular queue is updated according to the second target data unit. When it is the last target data unit, it moves to the next target partition unit. When the partition status flag of the first target partition unit indicates abnormal, it moves to the next target partition unit. After moving to the next target partition unit, it is judged whether the next target partition unit is the last partition unit. If it is not, it continues to determine whether the partition unit is abnormal according to the partition status flag. If the partition status flag of the last partition unit indicates abnormal, the scan ends. If the partition status flag of the last partition unit indicates normal, the queue head pointer and the queue tail pointer of the circular queue are further determined according to the multiple target data units. If the partition status flags of all partition units in the entire storage space indicate abnormal, the determined queue head pointer and queue tail pointer both point to the initial position.
[0084] The above data processing device based on an embedded device includes a processor and a memory. The above partitioning unit, determination unit, and partitioning unit, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0085] The processor contains a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set, and by adjusting the kernel parameters, the problem in the prior art that frequent erasing and writing to a certain area of the embedded device leads to a relatively low lifespan of the corresponding storage medium is solved.
[0086] The memory may include non-permanent memory in the form of computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one memory chip.
[0087] An embodiment of the present invention provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the above-mentioned data processing method based on an embedded device is implemented.
[0088] An embodiment of the present invention provides a processor for running a program, wherein when the above-mentioned program runs, the above-mentioned data processing method based on an embedded device is executed.
[0089] An embodiment of the present invention provides a device, which includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, at least the following steps are implemented:
[0090] Step S101: Divide the storage space of the above-mentioned embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above-mentioned partition units includes a partition status flag and at least one data unit. The above-mentioned partition status flag is used to indicate whether the corresponding above-mentioned partition unit is abnormal, and the above-mentioned data unit is used to store data;
[0091] Step S102: A plurality of consecutive above-mentioned partition units form a circular queue, and determine the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the above-mentioned circular queue;
[0092] Step S103: Predetermine the data at least according to the target parameter information. The above-mentioned predetermined processing includes at least one of the following: storage, reading, and deletion. The above-mentioned target parameter information includes at least one of the following: the above-mentioned queue head pointer, the above-mentioned queue tail pointer, and the above-mentioned partition status flag.
[0093] The device in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0094] The present application also provides a computer program product, which is adapted to execute a program initialized with at least the following method steps when executed on a data processing device:
[0095] Step S101: Divide the storage space of the above-mentioned embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above-mentioned partition units includes a partition status flag and at least one data unit. The above-mentioned partition status flag is used to indicate whether the corresponding above-mentioned partition unit is abnormal, and the above-mentioned data unit is used to store data;
[0096] Step S102: A plurality of consecutive partition units form a circular queue, and the storage positions pointed to by the queue head pointer and the queue tail pointer of the circular queue are determined.
[0097] Step S103: At least according to the target parameter information, perform a predetermined process on the data. The predetermined process includes at least one of the following: storage, reading, and deletion. The target parameter information includes at least one of the following: the queue head pointer, the queue tail pointer, and the partition status identifier.
[0098] In the above embodiments of the present invention, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0099] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the above unit division can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.
[0100] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0101] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0102] If the above integrated 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 such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the above methods in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), external hard drives, magnetic disks, or optical discs.
[0103] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0104] 1) In the data processing method based on an embedded device of the present application, first, the storage space of the embedded device is partitioned to obtain multiple partition units. The multiple partition units are of the same size and continuous. Each partition unit includes a partition status flag and at least one data unit. Then, the queue head pointer and queue tail pointer of a circular queue formed by multiple consecutive partition units are determined. Finally, according to one or more of the queue head pointer, queue tail pointer, and partition status flag, the data not stored in the partition unit is stored in the partition unit, or the data already stored in the partition unit is read, or the data already stored in the partition unit is deleted. In this solution, the queue head pointer and queue tail pointer of a circular queue formed by multiple consecutive partition units are determined, and then, according to one or more target parameter information of the queue head pointer, queue tail pointer, and partition status flag, the data in the limited storage space of the embedded device is preprocessed. That is, this solution realizes the preprocessing of the data in the embedded device through the circular queue method, realizes the circular use of the limited storage space of the embedded device, avoids frequent erasing and writing of a certain area of the storage space of the embedded device, and thus ensures that the service life of the storage medium corresponding to the embedded device is relatively long, thereby solving the problem in the prior art that the service life of the corresponding storage medium is relatively low due to frequent erasing and writing of a certain area of the embedded device.
[0105] 2) In the data processing device based on an embedded device of the present application, the partitioning unit is used to partition the storage space of the above-mentioned embedded device to obtain a plurality of consecutive and identically sized partition units. Each of the above-mentioned partition units includes a partition status flag and at least one data unit. The partition status flag is used to indicate whether the corresponding partition unit is abnormal, and the data unit is used to store data; the determination unit is used to form a circular queue from a plurality of consecutive above-mentioned partition units, and determine the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the above-mentioned circular queue; the processing unit is used to perform a predetermined process on the above-mentioned data at least according to target parameter information, and the predetermined process includes at least one of the following: storage, reading, deletion, and the target parameter information includes at least one of the following: the queue head pointer, the queue tail pointer, the partition status flag. In this device, the queue head pointer and the queue tail pointer of the circular queue formed by a plurality of consecutive partition units are determined, and then, according to one or more target parameter information among the queue head pointer, the queue tail pointer, and the partition status flag, the data in the limited storage space of the embedded device is subjected to a predetermined process. That is, this solution realizes the predetermined process of the data in the embedded device through the circular queue method, realizes the circular use of the limited storage space of the embedded device, avoids frequent erasing and writing of a certain area of the storage space of the embedded device, and thus ensures a relatively long service life of the storage medium corresponding to the embedded device, thereby solving the problem in the prior art that the frequent erasing and writing of a certain area of the embedded device results in a relatively low service life of the corresponding storage medium.
[0106] The foregoing are only the preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A method for processing data of an embedded device, characterized in that, Including: Partition the storage space of the embedded device to obtain multiple consecutive partition units of the same size. Each partition unit includes a partition status flag and at least one data unit. The partition status flag is used to indicate whether the corresponding partition unit is abnormal. The data unit is used to store data. The data unit includes data header information, and the data header information includes a sequence number and header check information. The sequence number is used to indicate the order in which the data is stored in the storage space, and the header check information is used to indicate whether the data header information is damaged; The first determination step: When the partition status flag of the target partition unit indicates normal, determine the storage positions pointed to by the queue head pointer and the queue tail pointer at least according to the data units corresponding to the target partition unit, including: Determine whether the target data unit is damaged according to the header check information of the target data unit in the target partition unit. When the header check information of the target data unit indicates no damage, determine the storage positions pointed to by the queue head pointer and the queue tail pointer according to the sequence number corresponding to the target data unit. The target data unit is one of the data units in the target partition unit, and multiple consecutive partition units form a circular queue; Perform a predetermined process on the data at least according to target parameter information. The predetermined process includes at least one of the following: storage, reading, and deletion. The target parameter information includes at least one of the following: the queue head pointer, the queue tail pointer, and the partition status flag.
2. The processing method according to claim 1, wherein Perform a predetermined process on the data at least according to target parameter information, including: Calculate the remaining storage space of the partition unit pointed to by the queue tail pointer according to the storage position pointed to by the queue tail pointer; When the remaining storage space is less than the target storage space, store the target data in the next partition unit. The target data is the data to be stored, the target storage space is the storage space required to store the target data, and the next partition unit and the partition unit where the queue tail pointer is located are two adjacent partition units; When the remaining storage space is greater than or equal to the target storage space, store the target data in the remaining storage space and control the queue tail pointer to point to the storage position of the target data.
3. The processing method according to claim 1, wherein Perform a predetermined process on the data at least according to target parameter information, including: Determine the queue head data unit and the queue head partition unit. The queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; When the partition status flag of the queue head partition unit indicates normal, read the data of the queue head data unit.
4. The processing method according to claim 1, characterized in that, Perform a predetermined process on the data at least according to target parameter information, including: Determine the queue head data unit and the queue head partition unit, where the queue head data unit is the data unit pointed to by the queue head pointer, and the queue head partition unit is the partition unit where the queue head pointer is located; When the partition status flag of the queue head partition unit indicates normal, delete the data of the queue head data unit, and control the queue head pointer to move to the target storage location.
5. The processing method according to claim 4, characterized in that, The target storage location includes a first target storage location and a second target storage location. The first target storage location is the storage location of the first data unit of the next partition unit adjacent to the queue head partition unit, and the second target storage location is the next data unit adjacent to the queue head data unit. Controlling the queue head pointer to move to the target location includes: Determine whether the queue head data unit is the last data unit of the queue head partition unit; When the queue head data unit is the last data unit of the queue head partition unit, control the queue head pointer to point to the first target storage location; When the queue head data unit is not the last data unit of the queue head partition unit, control the queue head pointer to point to the second target storage location.
6. The processing method according to claim 1, wherein When there is no data stored in the storage space, determining the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the circular queue includes: Control both the queue head pointer and the queue tail pointer to point to the initial position of the storage space, and the initial position is the partition status flag of the first partition unit in the storage space.
7. The processing method according to claim 1, wherein When there is data stored in the storage space, determining the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer of the circular queue includes: Determine whether the target partition unit is abnormal according to the partition status flag of the target partition unit of the storage space; When the partition status flag of the target partition unit indicates abnormal, repeatedly execute the first determination step until the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer are determined, and in any two adjacent first determination steps, the corresponding target partition units are two adjacent partition units.
8. The processing method according to claim 7, characterized in that, After determining whether the target data unit is damaged according to the header check information of the target data unit in the target partition unit, the method further includes: When the header check information of the target data unit indicates damage, repeatedly execute the first determination step until the storage location pointed to by the queue head pointer and the storage location pointed to by the queue tail pointer are determined.
9. A data processing device based on an embedded device, characterized in that, Includes: Partitioning unit, configured to partition the storage space of the embedded device to obtain a plurality of consecutive and identically-sized partition units. Each of the partition units includes a partition status flag and at least one data unit. The partition status flag is used to indicate whether the corresponding partition unit is abnormal. The data unit is used to store data. The data unit includes data header information, and the data header information includes a sequence number and header check information. The sequence number is used to indicate the order in which the data is stored in the storage space, and the header check information is used to indicate whether the data header information is damaged; Determination unit, configured to perform a first determination step: when the partition status flag of the target partition unit indicates normal, determine the storage positions pointed to by the queue head pointer and the queue tail pointer based at least on the data units corresponding to the target partition unit, including: determining whether the target data unit is damaged according to the header check information of the target data unit in the target partition unit; when the header check information of the target data unit indicates no damage, determine the storage positions pointed to by the queue head pointer and the queue tail pointer according to the sequence number corresponding to the target data unit. The target data unit is one of the data units in the target partition unit, and a plurality of consecutive partition units form a circular queue; Processing unit, configured to perform a predetermined process on the data based at least on target parameter information. The predetermined process includes at least one of the following: storage, reading, and deletion. The target parameter information includes at least one of the following: the queue head pointer, the queue tail pointer, and the partition status flag.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program executes the processing method according to any one of claims 1 to 8.
11. A processor, characterized in that, The processor is configured to run a program, wherein when the program runs, it executes the processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for prolonging service life of NORFLASH in intelligent electric energy meter
CN108279852A