Search

CN-121455423-B - Method and device for offline storage of real-time sensing data based on Flash ROM inside singlechip

CN121455423BCN 121455423 BCN121455423 BCN 121455423BCN-121455423-B

Abstract

The invention discloses a method and equipment for storing real-time sensing data offline based on Flash ROM in a singlechip, which are applied to the technical field of data processing, and the method is characterized in that the method is used for carrying out standardized processing, storage, indexing, time alignment and transmission expansion on multi-parameter sensor data, firstly receiving carbon dioxide concentration, temperature and humidity and air pressure data, generating a standard data packet according to the specification of 4-32 bytes, and combining a real-time timestamp and data interval information; based on the Flash ROM characteristic, writing the data packet and the auxiliary information in a unit sequence of 64-512 bytes, only erasing the new sector before writing, extracting 12-24 bytes of core index information, circularly storing and fully writing the special sector for unified erasure, positioning a data address through indexes, realizing time recovery after interruption by relying on nonvolatile storage of a time stamp, accurately aligning the data and the time, uploading the data to a mobile phone APP through Bluetooth, and receiving an APP time synchronization RTC module to complete the whole-flow data management and interaction.

Inventors

  • QIU ZHIJIE

Assignees

  • 厦门赫德曼电子科技有限公司

Dates

Publication Date
20260505
Application Date
20251231

Claims (8)

  1. 1. A method for offline storing real-time sensing data based on Flash ROM in a singlechip is characterized by comprising the following steps: receiving the data of carbon dioxide concentration, temperature, relative humidity and air pressure acquired by a sensor, carrying out standardized processing according to the specification of 4-32 bytes of each packet, generating a sensor data packet with a uniform format, acquiring real-time information, and generating time stamp and data generation interval information; Integrating a standardized sensor data packet with a time stamp, a read-write mark and data generation interval information according to the unit of 64 to 512 bytes based on Flash ROM storage characteristics, storing sensor data and auxiliary information in each unit, writing the sensor data and the auxiliary information into a designated storage area according to a sector sequence, and executing erasing operation only when writing a new sector to generate sensor data storage result information, wherein the auxiliary information comprises a 4-byte time stamp, a 1-byte data written mark, a 1-byte data read-out mark, 1-byte data generation interval information and a 1-byte reserved field, wherein the time stamp is the time stamp of the latest packet of data; Extracting auxiliary index core information, integrating according to 12-24 byte specifications, dividing a plurality of exclusive sectors as storage areas, updating an index value and circularly writing in each packet of sensor data, and uniformly erasing and circularly storing after the storage is completed to generate auxiliary index data storage result information, wherein the auxiliary index core information comprises a first address of auxiliary index data, a first address of latest packet of sensor data, a timestamp of latest packet of data, a first address of oldest packet of sensor data, a mark whether the current power-on is synchronized with real-time through Bluetooth or not, and a mark whether the sensor data exists or not; Combining a sensor data storage result and auxiliary index data, locating the latest/oldest data address through indexes, carrying out nonvolatile storage on a time stamp to realize data time information recovery when continuous detection is forced to be interrupted, calculating the real-time of each packet of data according to the time stamp and data generation interval information, realizing accurate alignment of the data and time, and generating data and time alignment result information; Based on the Bluetooth module interface, the aligned sensor data are uploaded to the mobile phone APP according to a stipulated protocol, real-time fed back by the APP is received to synchronously update the RTC module, and data transmission and time synchronization result information is generated.
  2. 2. The method for offline storing real-time sensing data based on Flash ROM in a single chip microcomputer according to claim 1, wherein the method for receiving the data of carbon dioxide concentration, temperature, relative humidity and air pressure collected by the sensor, carrying out standardized processing according to the specification of 4 to 32 bytes of each packet, generating a sensor data packet with a uniform format, acquiring real-time information, generating a time stamp and data generation interval information comprises the following steps: Processing sensor output data based on sensor data acquisition requirements and offline storage targets, extracting carbon dioxide concentration, temperature, relative humidity and barometric core parameters by adopting a data standardization mechanism, packaging according to 4-32 byte specifications of each package by a format regulation module, extracting and processing parameter types, data precision and storage formats according to classification rules, and generating a sensor data package, data specification verification information, parameter coding mapping information and data integrity assessment information in a unified format; Performing multidimensional verification on various generated information according to the data integrity evaluation information, starting a data complement mechanism aiming at parameter deficiency, performing secondary standardization on data correction service called by format abnormal equipment, triggering a sensor calibration flow on data with precision not reaching standards, and generating an optimized data processing scheme comprising an abnormal processing strategy and a complement time window; and integrating and executing the optimized processing scheme, responding to the data acquisition instruction, and simultaneously acquiring real-time through the Bluetooth module or assisting timing by depending on the RTC module to generate time stamp and data generation interval information.
  3. 3. The method for offline storing real-time sensing data based on Flash ROM inside a single chip microcomputer according to claim 1, wherein based on Flash ROM storage characteristics, standardized sensor data packets are integrated with time stamps, read-write flags, data generation interval information in units of 64 to 512 bytes, sensor data and auxiliary information are stored per unit, the sensor data and the auxiliary information are written into a designated storage area in a sector sequence, an erasing operation is performed only when a new sector is written, and sensor data storage result information is generated, comprising: Classifying and integrating the standardized sensor data packet with the timestamp, the read-write mark and the auxiliary information of the data generation interval according to the storage characteristics of 512Bytes and 20000 times of erasability of the Flash ROM sector to generate storage unit information with 128 Bytes as a unit; The method comprises the steps of designing the content arrangement of 128-byte storage units based on storage efficiency requirements, and determining the storage ratio of 15 packets of sensor data and 8-byte auxiliary information to generate storage unit content design information, wherein each packet of data occupies 8 bytes in a storage space of a sensing data area, and each group of data occupies 15 packets of data, and the total number of the data is 120 bytes; setting operation rules of writing according to the sequence of the sectors and executing erasing only when writing new sectors by combining the erasing characteristic of the only sectors and the life prolonging requirement of the Flash ROM, and ensuring that each sector is erased once every day under the fastest acquisition frequency; and processing the storage unit integration result, the content design information and the erasing and writing rule to generate sensor data storage result information containing unit constitution, storage arrangement and operation specifications.
  4. 4. The method for offline storing real-time sensing data based on the Flash ROM in the single chip microcomputer according to claim 1, wherein the method is characterized in that the auxiliary index core information is extracted and integrated according to the specification of 12-24 bytes, a plurality of exclusive sectors are divided as storage areas, each packet of sensor data is stored, namely, an index value is updated and written circularly, and after the sensor data is written fully, the storage result information of the auxiliary index data is generated by uniformly erasing and storing the data in a recycling mode, and the method comprises the following steps: Acquiring auxiliary index core information based on auxiliary index function requirements, and extracting a head address, a time stamp, a synchronous mark and a data existence mark, wherein the head address comprises a head address of auxiliary index data, a head address of the latest packet of sensor data and a head address of the oldest packet of sensor data; Performing specification verification on the extracted auxiliary index core information, confirming the integrity and data format standardization of each information item, and generating information verification parameters; Integrating and packaging auxiliary index core information passing verification based on a 12-byte standard to generate a standardized index data packet, wherein the 12-byte standard comprises a head address of 2-byte auxiliary index data, a head address of 2-byte latest packet of sensor data, a time stamp of 4-byte latest packet of data, a head address of 2-byte oldest packet of sensor data, a 1-byte CRC-8 check code combined by a mark of whether the current power-on is synchronized with real-time through Bluetooth and a mark of whether the sensor data is stored; planning a storage area in combination with the service life requirement of the product, dividing 6 exclusive sectors, defining area boundaries and use rules, and generating storage area configuration information; Setting a writing rule based on the Flash ROM erasing characteristic, updating an index value when each packet of sensor data is stored, and continuously and circularly writing the index value into a storage area according to the sequence to generate a circular writing operation scheme; setting a sector erasure triggering mechanism, executing unified erasure after 6 exclusive sectors are fully written, and circularly storing the sectors from the head to generate an erasure scheduling rule; And integrating the standardized index data packet, the storage area configuration information, the cyclic write operation scheme and the erasure scheduling rule to generate auxiliary index data storage result information comprising data constitution, storage positions and operation specifications.
  5. 5. The method for offline storing real-time sensing data based on Flash ROM in a single chip microcomputer according to claim 4, wherein the method is characterized in that the latest/oldest data address is located by index in combination with the sensor data storage result and auxiliary index data, the recovery of data time information when the continuous detection is forced to be interrupted is realized by nonvolatile storage of a time stamp, the real-time of each packet of data is calculated according to the time stamp and data generation interval information, the accurate alignment of the data and time is realized, and the data and time alignment result information is generated, and the method comprises the following steps: The method comprises the steps of carrying out multidimensional feature extraction on a sensor data storage result and auxiliary index data, analyzing storage address, data packet format and quantity information of the sensor data, identifying head address, timestamp and data generation interval information in the auxiliary index, and generating a feature set to be processed comprising data storage features and index positioning features, wherein the head address comprises a head address of the auxiliary index data, a head address of the latest packet of sensor data and a head address of the oldest packet of sensor data; Performing cooperative processing on the feature set based on a preset time alignment rule, realizing accurate positioning of the latest/oldest sensor data address through an index matching algorithm, calculating real-time of each packet of data by adopting a time calculation model and combining a time stamp and data generation interval information, confirming calculation logic consistency by utilizing a data relevance checking tool, and generating a time alignment processing result and evaluation information covering address matching degree and time calculation accuracy; Performing targeted optimization according to the evaluation information, adjusting the address positioning deviation by adopting an index correction mechanism, correcting the time calculation error by adopting an interval calibration algorithm, and re-checking the corresponding relation between the index and the sensor data aiming at the data relevance abnormality to generate optimized alignment content; and integrating and optimizing the alignment content, and finally checking by combining the accuracy requirement of the time tracing of the sensing data to generate data comprising an address positioning step, a time reckoning method and an exception handling scheme and time alignment result information.
  6. 6. A device for offline storing real-time sensing data based on Flash ROM inside a single-chip microcomputer, for implementing the method of claim 1, the device comprising: The acquisition module is used for receiving the carbon dioxide concentration, temperature, relative humidity and air pressure data acquired by the sensor, carrying out standardized processing according to the specification of 4-32 bytes of each packet, generating a sensor data packet with a uniform format, acquiring real-time information, and generating time stamp and data generation interval information; The processing module is used for integrating standardized sensor data packets with time stamps, read-write marks and data generation interval information according to units of 64-512 bytes based on Flash ROM storage characteristics, storing sensor data and auxiliary information according to units, writing the sensor data and the auxiliary information into a designated storage area according to sector sequences, executing erasing operation only when writing new sectors, generating sensor data storage result information, extracting auxiliary index core information, integrating the auxiliary index core information according to 12-24 byte specifications, dividing a plurality of exclusive sectors as storage areas, updating an index value when each packet of sensor data is stored and circularly writing, uniformly erasing and storing after the storage is completed, generating auxiliary index data storage result information, combining the sensor data storage result and the auxiliary index data, positioning the latest/oldest data address through indexes, calculating the real-time of each packet of data according to the time stamps and the data generation interval information, generating the accurate alignment result information of the data and the time, transmitting the aligned sensor data to the APP according to the contract of the Bluetooth module interface, and transmitting the data to the APP (application) after the mobile phone is aligned, and synchronizing the data with the real-time and the APP (application) and the real-time synchronization result.
  7. 7. An electronic device, comprising: and a memory for storing executable instructions of the first processor; The method for storing real-time sensing data offline based on the Flash ROM inside the single chip microcomputer according to any one of claims 1 to 5 is configured by the first processor through executing the executable instructions.
  8. 8. A computing device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to perform the method of storing real-time sensory data offline based on a Flash ROM within a single-chip microcomputer of any one of claims 1-5.

Description

Method and device for offline storage of real-time sensing data based on Flash ROM inside singlechip Technical Field The invention relates to the technical field of data processing, in particular to a method and equipment for offline storage of real-time sensing data based on Flash ROM in a single chip microcomputer. Background In the prior art, various data such as carbon dioxide concentration, temperature, relative humidity, air pressure and the like collected by a sensor often have different storage formats, byte lengths and coding modes of different parameters due to no standardized packaging rule. Therefore, when the data is read, analyzed and transmitted across devices in the follow-up process, various format conversion logics are required to be adapted, so that the complexity of data processing is increased, analysis errors are easy to occur, the data utilization efficiency is reduced, and the requirements for data uniformity and compatibility in an offline storage scene cannot be met. Flash ROM has the inherent characteristics of "sector level erase, byte level write" and limited erase life (e.g., about 20000 times conventional single sector erasability). The existing storage method does not optimize the storage strategy aiming at the characteristics, and has two major problems that firstly, the data integration mode is unreasonable, the sector space is not fully utilized, the storage redundancy is caused, the storage efficiency is low, secondly, the erasing operation is frequent, and the mode of 'erasing before writing' or 'random erasing' is mostly adopted, so that the service life of the Flash ROM is greatly shortened, and the Flash ROM cannot be adapted to the application scene of long-term offline storage. The time relevance of real-time sensing data directly affects the data application value, but the prior art lacks an efficient time synchronization and calculation mechanism. On one hand, the method only depends on a single timing module (such as RTC) in an offline state, thus being easy to cause inaccurate data time stamp due to accumulation of timing errors, and on the other hand, an accurate index association mechanism is not established, so that data addresses cannot be rapidly positioned through indexes and real-time of each packet of data cannot be accurately aligned, the actual generation time of the subsequent data is difficult to confirm during tracing, and the effectiveness of the data is affected. In the prior art, the time synchronization of the sensor data uploaded to the terminal (such as a mobile phone APP) and the RTC module is mostly independent, and the collaborative design is lacking. In the offline storage period, the timing error of the RTC module is continuously accumulated, the real-time fed back by the terminal is not timely utilized to update the RTC reference after the data is uploaded, so that the continuous deviation of the time stamp of the subsequent acquired data is caused, and meanwhile, the data uploading protocol lacks of standardized design, so that the problems of transmission interruption, data loss and the like are easy to occur, and the smooth connection of offline storage data to online application is influenced. Disclosure of Invention In order to solve the technical problems, the invention provides the following technical scheme: A method for storing real-time sensing data offline based on Flash ROM in a singlechip comprises the steps of receiving carbon dioxide concentration, temperature, relative humidity and air pressure data collected by a sensor, carrying out standardized processing according to the specification of 4-32 bytes of each packet, generating a sensor data packet with uniform format, obtaining real-time information, generating time stamp and data generation interval information, integrating the standardized sensor data packet with the time stamp, a read-write mark and the generation interval information according to the unit of 64-512 bytes based on Flash ROM storage characteristics, storing sensor data and auxiliary information per unit, writing the sensor data and auxiliary information into a designated storage area according to sector sequence, executing erasing operation only when writing a new sector, generating sensor data storage result information, extracting auxiliary index core information, integrating according to the specification of 12-24 bytes, dividing a plurality of exclusive sectors, namely updating an index value, cyclically writing each packet of sensor data, uniformly erasing and storing after writing, generating auxiliary index data storage result information, combining the sensor data storage result with auxiliary index data, carrying out index positioning latest/latest data, carrying out non-storage by non-time detection on the time, continuously storing the data, carrying out erasing operation on the data storage result information, updating the data with the data storage result information, carrying out continu