CN105224471B - The method of power information acquisition terminal storage data based on built-in Linux - Google Patents
The method of power information acquisition terminal storage data based on built-in Linux Download PDFInfo
- Publication number
- CN105224471B CN105224471B CN201510683330.XA CN201510683330A CN105224471B CN 105224471 B CN105224471 B CN 105224471B CN 201510683330 A CN201510683330 A CN 201510683330A CN 105224471 B CN105224471 B CN 105224471B
- Authority
- CN
- China
- Prior art keywords
- data
- file
- memory mapping
- memory
- acquisition terminal
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Abstract
The present invention discloses a kind of method of power information acquisition terminal based on built-in Linux using Memory Mapping File storage data, the data of required read-write are mapped to by consumer process space by memory mapping function mmap (linux system calling), access storage data, which have, in the form of read/write memory to store data write, power down is not lost, reads and writes the advantage such as convenience, superior performance, cost-effective.
Description
Technical field
The present invention relates to power utilization information collection system field used for intelligent electric network, and in particular to based on built-in Linux telecommunications
Cease the method for acquisition terminal storage data.
Background technology
Power user power consumption information acquisition system (power user electric energy data acquire
System) it is system that the power information of power consumer is acquired, handles and is monitored in real time, realizes the automatic of power information
Collection, metering exception monitoring, electric energy quality monitoring, electrical energy consumption analysis and management, relevant information issue, distributed energy monitoring, intelligence
The functions such as the information exchange of energy electrical equipment.
Power information acquisition terminal (electric energy data acquire terminal) is to each information gathering
The equipment of point power information collection, abbreviation acquisition terminal.It can realize the collection, data management, data double-way of electric energy meter data
Transmission and forwarding or the equipment for performing control command.Power information acquisition terminal by application places be divided into special transformer acquisition terminal,
The types such as centralized automatic meter-reading terminal (including concentrator, collector), distributed energy monitor terminal.
Acquisition terminal is embodied in following because functional requirement in the process of running can frequently read and write partial data progress
Aspect:Acquisition terminal can count collection result, calculated and be stored after every round meter reading, and acquisition terminal can be every point
Clock carries out each collection point data statistics, calculating and stores, acquisition terminal can kind per second read the calculating of itself computation chip data,
Add up and store, acquisition terminal can read pulse table status in real time and add up, store.
Following scheme is currently mainly used to store, read and write such data:
1. depositing file, used data are first buffered in memory and then are stored in file after the completion of reading and writing.Data are stored in
File can avoid the data loss problem that system blackout is brought, but reading and writing of files operation it is relatively complicated, cannot be to operate byte
Form access data are inconvenient for use, and frequently reading and writing of files limited capacity is especially embodied in the repetition of mass file, random write
Write.
2. increasing hardware SRAM (memory is not lost in power down), data can be accessed in the form of operating byte, but need to additionally supply
Electricity, the onboard lithium battery of acquisition terminal were typically designed the service life as 5 years, even the service life does not arrive, there is also self-discharge of battery, batch
Quality problems cause the failure of SRAM supplying cells to cause loss of data, and increase the increase cost of hardware meaning.
3. it is programmed into Flash, it is possible to achieve cure storage and be not required to additionally power, data are not lost after power down, but Flash is compiled
Journey needs special driving and need to first wipe to write again, it is impossible to is read and write in the form of operating byte, also needs to consider the wear leveling of Flash
To ensure its reading-writing life-span.
The content of the invention
In view of the above-mentioned problems, the present invention provides, one kind can store data write, power down is not lost, it is excellent to read and write convenience, performance
The method of the storage data of the power information acquisition terminal based on built-in Linux more.
To solve the above problems, the technical solution that the present invention takes is:Power information collection based on built-in Linux is eventually
The method of end storage data, includes the following steps:
Step 1: the data and data length of storage needed for determining, the memory mapping area defined in the process address space
Base address, and define the opposite offset of the address for being used for storing each data and base address;
For example it is respectively data 1, data 2, data 3..... data 256, Mei Gezhan to need these data of the data of storage 1M
With 4 bytes, if memory mapping area base address is 0xffff0000, the address for storing these data is respectively data 1->
0xffff0000, data 2->0xffff0004, data 3->0xffff0008......, then can be defined as below:
Data 1:(base address+0);
Data 2:(base address+4);
Data 3:(base address+8);.....
It is to read and write each data for convenience to define these offsets;
Step 2: the legitimacy of Memory Mapping File is treated according to the length detection of required storage data in step 1, if literary
Part is legal, enters step three;If do not conform to rule to store data length establishment file needed for and file content is filled with zero
Value enters back into step 3;
Step 3: memory mapping function mmap is called, foundation and the mapping for treating Memory Mapping File in step 2, by
Deposit the base address defined in mapping function mmap return addresses imparting step 1;
Step 4: use the base address of the memory mapping area defined in step 1 and the opposite offset address of other data
Storage data needed for read-write.
Memory Mapping File is using in address space of the virtual memory File Mapping to process, and process is grasped after this
Make file, just as the address in the operation process space, such as the function using internal memory operations such as memcpy.This method energy
Enough apply well is needing the occasion of frequently one file of processing either one big file, and this mode handles IO efficiency ratio
Common IO efficiency will height.Linux provides memory mapping function mmap, and when calling indicates file and file size to be mapped i.e.
Mapping memory first address is can return to, it is mapped to file content on one section of memory.By the reading and modification to this section of memory,
Realize the reading and modification to file.
The length of memory is mapped according to needed for determining required storage data length, while also determines and treats Memory Mapping File
Size.
Detection treats that the condition of Memory Mapping File legitimacy further includes the start byte and file of file in the step 2
End byte.
The present invention discloses a kind of power information acquisition terminal based on built-in Linux and uses Memory Mapping File storage number
According to method, by memory mapping function mmap (linux system calling) by the data of required read-write be mapped to consumer process sky
Between, access storage data, which have, in the form of read/write memory to store data write, power down is not lost, it is excellent to read and write convenience, performance
More, the advantage such as cost-effective.
The present invention possesses following beneficial effect:
1. it is cost-effective to increase hardware, and increases reliability;
2. reading and writing data can be carried out in the form of operating memory;
Cure storage 3. realizing, without battery powered to preserve data after system power failure;
4. it need not consider the abrasion equilibrium of memory device;
5. it need not consider the read-write number of memory device;
6. read-write driver, portable height without specific store device;
7. Memory Mapping File performance advantage:Transmission primaries is in file and kernel to normal system IO read-writes needs twice
Between high-speed buffer, another time between high-speed buffer and user's space buffering area.Use memory mapping function mmap
Just without transmitting for the second time, for input, once corresponding blocks of files is mapped into consumer process after memory by kernel
These data can just be used.For output, consumer process needs only to the content in modification memory, then can be according to
The file of bottom is automatically updated by kernel manager.Except save the once transmission between kernel spacing and user's space it
Afterwards, memory mapping function mmap can also be by the memory that is used needed for reduction come improving performance.
Brief description of the drawings
Fig. 1 is the flow chart of the present invention;
Fig. 2 is the principle of the present invention schematic diagram;
Embodiment
The method of power information acquisition terminal storage data based on built-in Linux, includes the following steps:
Step 1: the data and data length of storage needed for determining, the memory mapping area defined in the process address space
Base address, and define the opposite offset of the address for being used for storing each data and base address;It is true according to required storage data length
The length of mapping memory needed for fixed, while also determine the size for treating Memory Mapping File;
Step 2: according in step 1 it is required storage data length, when Memory Mapping File start byte and to the end of
Byte detects the legitimacy for treating Memory Mapping File, and three are entered step if file is legal;If rule storage needed for is not conformed to
File content is simultaneously filled with null value and enters back into step 3 by data length establishment file;
Step 3: memory mapping function mmap is called, foundation and the mapping for treating Memory Mapping File in step 2, by
Deposit the base address defined in mapping function mmap return addresses imparting step 1;
Step 4: use the base address of the memory mapping area defined in step 1 and the opposite offset address of other data
Storage data needed for read-write.
Claims (3)
1. the method for the power information acquisition terminal storage data based on built-in Linux, it is characterised in that include the following steps:
Step 1: the data and data length of storage needed for determining, the base of the memory mapping area defined in the process address space
Address, and define the opposite offset of the address for being used for storing each data and base address;
Step 2: the legitimacy of Memory Mapping File is treated according to the length detection of required storage data in step 1, if file closes
Rule enters step three;If do not conform to rule to store data length establishment file needed for and file content is filled with null value again
Enter step three;
Step 3: calling memory mapping function mmap, foundation and the mapping for treating Memory Mapping File in step 2, memory is reflected
Penetrate the base address defined in function mmap return addresses imparting step 1;
Step 4: read and write using the base address of the memory mapping area defined in step 1 and the opposite offset address of other data
Required storage data.
2. the method that data are stored according to the power information acquisition terminal based on built-in Linux described in claim 1, its
It is characterized in that:The length of memory is mapped according to needed for determining required storage data length, while also determines and treats memory mapping text
The size of part.
3. the method that data are stored according to the power information acquisition terminal based on built-in Linux described in claim 1, its
It is characterized in that:Detection treats that the condition of Memory Mapping File legitimacy further includes the start byte and file of file in the step 2
End byte.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510683330.XA CN105224471B (en) | 2015-10-20 | 2015-10-20 | The method of power information acquisition terminal storage data based on built-in Linux |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510683330.XA CN105224471B (en) | 2015-10-20 | 2015-10-20 | The method of power information acquisition terminal storage data based on built-in Linux |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105224471A CN105224471A (en) | 2016-01-06 |
CN105224471B true CN105224471B (en) | 2018-04-13 |
Family
ID=54993455
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510683330.XA Active CN105224471B (en) | 2015-10-20 | 2015-10-20 | The method of power information acquisition terminal storage data based on built-in Linux |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105224471B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107329697A (en) * | 2017-06-27 | 2017-11-07 | 湖南威胜信息技术有限公司 | Power information data access method and its electric energy meter for embedded system |
CN108333398B (en) * | 2018-01-18 | 2020-06-09 | 研耀(上海)信息科技有限公司 | High energy-saving ammeter |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8060706B2 (en) * | 2008-03-28 | 2011-11-15 | Inventec Corporation | Method of allocating physical memory in specified address range under Linux system platform |
US8589650B2 (en) * | 2010-05-17 | 2013-11-19 | Texas Instruments Incorporated | Dynamically configurable memory system |
CN103634353A (en) * | 2012-08-27 | 2014-03-12 | 国网电力科学研究院 | Electricity utilization information acquisition terminal and realizing method thereof |
-
2015
- 2015-10-20 CN CN201510683330.XA patent/CN105224471B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN105224471A (en) | 2016-01-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101488796B (en) | Payload management system and method for satellite | |
CN102799392B (en) | Memory device and interrupt control method thereof | |
CN102789439B (en) | The method of the interruption in control data transmission process and memory device | |
CN102799396B (en) | Memory device, interrupt control method and power-on time measuring method | |
CN104317800A (en) | Hybrid storage system and method for mass intelligent power utilization data | |
CN105702300A (en) | NAND Flash fault tolerant system based on FPGA (Field Programmable Gate Array) | |
CN202250053U (en) | Logging device with both storing and remote measuring functions | |
CN105224471B (en) | The method of power information acquisition terminal storage data based on built-in Linux | |
CN103559145B (en) | A kind of digital independent, wiring method and electronic equipment | |
CN105474182A (en) | Storage device supporting periodic writes while in a low power mode for an electronic device | |
CN108664577A (en) | A kind of file management method and system based on the free areas FLASH | |
CN103729143A (en) | Data safety method for electric energy data storage of multi-path electricity meter | |
CN101394347A (en) | Service data management method and system | |
CN108647278A (en) | A kind of file management method and system | |
CN105205015B (en) | A kind of date storage method and storage equipment | |
CN111124313A (en) | Data reading and writing method and device for power acquisition terminal and electronic equipment | |
CN201413345Y (en) | Digital electric energy meter collector based on low-power-consumption short-distance wireless transmission | |
CN104252423A (en) | Consistency processing method and device based on multi-core processor | |
CN108365283A (en) | Device battery and unmanned plane | |
CN201444166U (en) | Hybrid-electric energy meter collector based on low-power-consumption short-distance wireless transmission | |
CN205880852U (en) | Management data client data storage device | |
CN207304164U (en) | Power information acquisition system based on PCIE-SSD environment | |
CN1322319A (en) | Interface circuit and method for transferring data between serial interface and processor | |
CN108664578A (en) | A kind of file cycle storage method and system | |
CN101667195A (en) | Storing system and method of multiuser database |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |