Electricity meter data processing method
By splitting and storing the firmware files of the smart power meter and generating patch packages using the bsdiff algorithm, the security and difficulty of data storage outside the ESAM are solved, and higher data security and update efficiency are achieved.
Patent Information
- Application Number
- CN202411287051.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-13
AI Technical Summary
In the prior art, the key data of the smart power meter is at risk of being tampered with when stored outside the ESAM security module, and the complete firmware file is easily maliciously stolen.
The firmware file of the power meter is divided into multiple sub-files and stored in the internal memory and external memory of the main control chip. The patch package is generated by dividing the node sequence and the bsdiff algorithm to control the storage and update of the files between different time nodes. Improve data security and stealing difficulty.
Effectively improve the security of power meter firmware files, prevent malicious theft, and reduce the size of patch packages during incremental updates, simplifying transmission and management.
Smart Images

Figure CN118797748B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electric energy meters, and in particular to an electric energy meter data processing method. Background Art
[0002] According to the technical specifications for the security authentication of information exchange of smart energy meters, key data such as the remaining amount and number of electricity purchases of smart energy meters should be stored in the ESAM security module. However, the storage medium outside the ESAM security module does not have the encryption function like the ESAM security module, so the data stored in the storage medium outside the ESAM security module of the energy meter is at risk of being tampered with.
[0003] In this regard, patent document 1 discloses a solution, in which the electric energy meter stores the same complete set of data in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip respectively, so that when the electric energy meter is powered on again after power failure, by verifying whether the two copies of data in the internal memory and the external memory are consistent, it is possible to determine whether the data of the electric energy meter has been tampered with after the power failure, thereby ensuring that the data needed to be used has not been tampered with.
[0004] However, the solution in Patent Document 1 still has the following shortcomings:
[0005] Since the data on the electricity meter is completely stored in the external memory of the electricity meter main control chip, a complete set of data can be easily stolen maliciously. For example, the firmware file of the electricity meter is completely stored in the external memory of the electricity meter main control chip. Although it can be discovered after being tampered with, the complete electricity meter firmware file can be easily stolen maliciously.
[0006] Patent document 1, patent name, a data processing method, device, storage medium and electric energy meter for an electric energy meter; publication number, CN112306410A; publication date, 2021-02-02. Summary of the invention
[0007] The purpose of the present invention is to solve at least one of the technical problems existing in the prior art and to provide an electric energy meter data processing method, which can divide a complete firmware into multiple copies and store them respectively in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip, thereby increasing the difficulty of maliciously stealing the complete firmware file of the electric energy meter.
[0008] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions:
[0009] A method for processing electric energy meter data, the method comprising:
[0010] The electric energy meter receives the current version update file sent by the server at the first time node;
[0011] The electric energy meter divides the current version update file into multiple sub-files; wherein the update file includes the firmware of the electric energy meter or the parameters of the electric energy meter;
[0012] The electric energy meter divides the plurality of sub-files into two parts, and stores the two parts in an internal memory of the electric energy meter main control chip and an external memory of the electric energy meter main control chip respectively;
[0013] The electric energy meter receives the patch package corresponding to the new version update file sent by the server at a second time node, and generates a new version update file based on the multiple sub-files and the patch package corresponding to the received new version update file; wherein, the second time node is a preset update time node, and the second time node is later than the first time node.
[0014] As a further improvement, the electric energy meter divides the current version update file into multiple sub-files, specifically including:
[0015] The electric energy meter receives a segmentation node sequence sent by the server; wherein each segmentation node in the segmentation node sequence They each represent a byte offset in the current version update file, and p is the split node The sequence number in the split node sequence, p is a positive integer;
[0016] The energy meter will update the current version in the file from byte offset To the byte offset of The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files ;in, Indicates the byte offset corresponding to the starting position of the nth sub-file in the current version update file. = ; Indicates the byte offset corresponding to the end position of the nth sub-file in the current version update file. = ; n is a positive integer, m is a non-negative integer.
[0017] As a further improvement, the method further comprises:
[0018] The electric energy meter also receives the segmentation node sequence sent by the server at the first time node.
[0019] As a further improvement, the segmentation node sequence is generated by the server through the following steps:
[0020] Get the current version update file and the new version update file;
[0021] Performing a diff process of the bsdiff algorithm on the current version update file and the new version update file to generate the patch package; wherein the patch package includes control information, and the control information records the byte offset of each diff data block generated in the diff process in the current version update file;
[0022] The byte offsets are arranged in the order in which they are recorded to obtain the segmentation node sequence.
[0023] As a further improvement, the electric energy meter divides the multiple sub-files into two parts, and stores the two parts in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip respectively, specifically including:
[0024] The electric energy meter divides the plurality of sub-files into two parts; wherein the two parts include a first part and a second part;
[0025] The electric energy meter calculates the ratio of the data volume of the first part to the data volume of the second part as the actual internal and external ratio;
[0026] The electric energy meter adjusts different combinations of the first part and the second part to obtain different actual internal and external proportions; wherein the different combinations refer to the first part and the second part being composed of different sub-files;
[0027] The electric energy meter obtains the first remaining space capacity of the internal memory of the main control chip and the second remaining space capacity of the external memory;
[0028] The electric energy meter calculates the ratio of the first remaining space capacity to the second remaining space capacity as an internal and external reference ratio;
[0029] When the difference between the actual internal and external ratios and the internal and external reference ratios is the smallest, the electric energy meter stores the first part of the combination in the internal memory of the electric energy meter main control chip, and stores the second part of the combination in the external memory of the electric energy meter main control chip.
[0030] As a further improvement, the first part only includes the nth sub-file of the plurality of sub-files. ;
[0031] and in updating the current version file from byte offset To the byte offset of The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files In the process, through the formula Select the split node sequence and Two split nodes;
[0032] Among them, F is the total number of bytes of the current version update file, W is the internal and external reference ratio, and θ is the preset ratio error threshold.
[0033] As a further improvement, the nth sub-file in the plurality of sub-files The content also includes and ;
[0034] The generating a new version update file based on the patch package corresponding to the plurality of sub-files and the received new version update file specifically includes:
[0035] Execute the patch process of the bsdiff algorithm and read a target sub-file into the running memory; wherein the target sub-file is one of the multiple sub-files;
[0036] During the patch process, data corresponding to the diff data block is directly obtained from the target sub-file read into the running memory.
[0037] As a further improvement, the method further comprises:
[0038] During the patch process, it is detected that the byte offset in the control information corresponding to the diff data block is greater than the nth subfile as the current target subfile. Corresponding When the n+1th sub-file is Read it into the running memory as a new target subfile and release the target subfile The corresponding running memory.
[0039] As a further improvement, the following steps are performed to realize the nth sub-file as the current target sub-file: Get the data corresponding to the diff data block with byte offset K:
[0040] Calculate K- , get the local byte offset; where K is a non-negative integer;
[0041] Using the local byte offset as the starting address, get the nth sub-file The data corresponding to the number of bytes in the diff data block.
[0042] As a further improvement, the method further comprises:
[0043] The first sub-file is stored in a pre-specified file path on the internal storage and the file name of the first sub-file records the file path where the second sub-file is located;
[0044] The second sub-file is stored in the external storage and the file name of the second sub-file records the file path where the third sub-file is located;
[0045] The third sub-file is stored in the internal storage and the file name of the third sub-file records the file path where the fourth sub-file is located;
[0046] By analogy, the adjacent j-th sub-file and j+1-th sub-file are stored in the internal memory and the external memory respectively, and the file name of the j-th sub-file records the file path of the j+1-th sub-file; wherein j is a positive integer greater than 1.
[0047] Beneficial effects: 1. Compared with the prior art, the complete file is stored in the external memory of the main control chip of the electric energy meter, which is easy to be maliciously stolen. In this application, after the current version of the firmware is divided into multiple sub-files, these sub-files are divided into two parts and stored in the internal memory of the main control chip of the electric energy meter and the external memory of the main control chip of the electric energy meter respectively; even if the sub-files in the external memory of the main control chip of the electric energy meter are maliciously stolen, the thief cannot obtain the complete firmware file, which increases the difficulty of maliciously stealing the complete firmware file of the electric energy meter.
[0048] 2. When the electric energy meter is incrementally updated, the current version update file with a large file size is first sent to the electric energy meter at the first time node and divided into multiple copies and stored in the internal and external memory of the electric energy meter respectively, and the patch package for generating the new version update file is received at the second time node when the update can be performed. In this way, since the current version update file is divided into multiple copies and stored in the internal and external memory respectively, it is not easy to be completely stolen by malicious persons. Furthermore, since the patch package is only received at the second time node when the electric energy meter can be updated, the patch package is very small, generally about 10KB, and can be transmitted quickly. In addition, by controlling the electric energy meter to receive the patch only when it can be updated, the time window management of the patch file on the electric energy meter is strictly implemented, and after the new version update file is generated, the patch and each sub-file corresponding to the current version update file are deleted, which further increases the difficulty for malicious thieves to obtain the patch package and the current version update file at the same time.
[0049] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The present invention is further described below in conjunction with the accompanying drawings and embodiments;
[0051] Figure 1 A schematic diagram of a flow chart of a method for processing electric energy meter data in an embodiment;
[0052] Figure 2 A schematic diagram of a flow chart of a method for processing electric energy meter data in an embodiment;
[0053] Figure 3 A schematic diagram of a flow chart of a method for processing electric energy meter data in an embodiment;
[0054] Figure 4 A schematic diagram of a flow chart of a method for processing electric energy meter data in an embodiment;
[0055] Figure 5 This is a schematic diagram of the encoding principle of the bsdiff algorithm;
[0056] Figure 6 This is a schematic diagram of the decoding principle of the bsdiff algorithm. DETAILED DESCRIPTION
[0057] This section will describe in detail the specific embodiments of the present invention. The preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the accompanying drawings is to supplement the description of the text part of the specification with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it cannot be understood as a limitation on the scope of protection of the present invention.
[0058] It should be noted that the bsdiff algorithm used in this embodiment is a mature incremental update algorithm. The electric energy meter data processing method provided in this embodiment involves improvements to the algorithm. Therefore, it is necessary to briefly describe the specific process of the algorithm, which includes 2 sub-processes. The first is the diff process, which calculates the difference between the new version firmware and the old version firmware at the development end, encodes and compresses the difference, and produces a patch package. The second is the patch process, which decompresses the data specified in the patch package at the device end, and applies the patch package and the old version firmware (that is, the current version update file referred to in this application) according to the corresponding decoding rules, thereby constructing a new version firmware (that is, the new version update file referred to in this application).
[0059] Table 1
[0060]
[0061] In the bsdiff algorithm, the format of the patch package is shown in Table 1, where the ctrl area, the diff area, and the extra area are compressed data areas.
[0062] The specific steps of the diff process of the bsdiff algorithm are:
[0063] Step 1: Create an empty patch package (patch file) and apply for two auxiliary spaces a and b.
[0064] Step 2: Search by suffix sorting and binary search algorithm. Figure 5 Similar matching areas and non-matching areas in the old and new files (here the old file is the current version update estimate, and the new file is the new version update file) are shown.
[0065] Step 3: Encode the data of similar matching areas and non-matching areas. First, calculate the character difference between the similar matching areas of the old and new files and generate a Data block, The data blocks are written to the auxiliary space a in an appended manner. Secondly, the unmatched area represents a database unique to the new file, which is encoded as a data block, and The data block is written to the auxiliary space b in an appended manner. Finally, the generated current Data blocks and The data block is used to execute the control information of the patch process, and the control information is stored in a three-element array Among them, express The number of bytes, express The number of bytes, Indicates the byte offset in the old file.
[0066] Step 4: The data in is compressed and written directly into the ctrl area of the patch file.
[0067] Step 5. Repeat steps 1 to 4 until the end of the new file.
[0068] Step 6: Compress the data in auxiliary space a and auxiliary space b respectively, write them into the diff area and extra area of the patch file in sequence, and supplement the file header information to obtain a complete patch file.
[0069] The specific steps of the bsdiff algorithm to execute the corresponding patch process are as follows:
[0070] Step 1, create an empty new file and apply for the required auxiliary space a [new size] and auxiliary space b [oldsize].
[0071] Step 2: Open three parallel decompression processes and use them to decompress the ctrl area, diff area, and extra area of the patch file respectively.
[0072] Step 3, unzip and complete Figure 6 The add operation shown in the figure is obtained by decompressing the ctrl area. Data in , according to the decompressed diff area, the size is Block of bytes ,Will Stored in auxiliary space a, and based on The byte offset in Extract the old file The corresponding data is stored in the auxiliary space b. The target data is obtained by adding the above two data blocks and is temporarily stored in the auxiliary space a in an appended manner.
[0073] Step 4, unzip and complete Figure 6 The copy operation shown in the figure decompresses the extra area to obtain a size of Bytes of data ,Will The data in is copied to the auxiliary space a in an append manner.
[0074] Step 5: Adjust the pointers responsible for managing auxiliary space a and auxiliary space b, and repeat steps 3 and 4 until all the data in the patch file are applied. Data, data in auxiliary space a, data in new file.
[0075] Step 6, write all the data in the auxiliary space a into the new file, release the requested auxiliary space, and close the opened decompression process.
[0076] The above is the specific process of the bsdiff algorithm in the prior art. In this application, the server uses the diff process of the bsdiff algorithm to generate a patch package and send it to the electric energy meter at the first time node. The patch process of the bsdiff algorithm on the electric energy meter is used to build a new version of the firmware for upgrading. However, in the scenario of this application, due to security considerations, the electric energy meter needs to split the old version of the firmware into multiple sub-files and store them in the internal memory and external memory respectively. Based on the limitations of this scenario, it is necessary to make adaptive changes to step 3 in the patch process. The byte offset in Extract the old file The corresponding data is stored in the auxiliary space b. This step is to directly extract the diff data block from the complete old file (i.e. Corresponding data), but in this application, it is necessary to extract diff data blocks from multiple sub-files respectively (i.e. Corresponding data), which is a technical contribution of this application.
[0077] The electric energy meter data processing method provided by the present application will be described in detail below with reference to the accompanying drawings and embodiments.
[0078] Reference Figure 1 In this embodiment, a method for processing electric energy meter data is provided, which is applicable to incremental update of electric energy meter firmware. The method comprises:
[0079] Step S202: the electric energy meter receives the current version update file sent by the server at a first time node.
[0080] Step S204, the electric energy meter divides the current version update file into multiple sub-files, wherein the update file includes the firmware of the electric energy meter or the parameters of the electric energy meter.
[0081] Step S206: the electric energy meter divides the plurality of sub-files into two parts, and stores the two parts in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip respectively.
[0082] Step S208, the electric energy meter receives the patch package corresponding to the new version update file sent by the server at a second time node, and generates a new version update file based on the plurality of sub-files and the patch package corresponding to the received new version update file. The second time node is a preset update time node, and the second time node is later than the first time node.
[0083] Beneficial effects: 1. Compared with the prior art, the complete file is stored in the external memory of the main control chip of the electric energy meter, which is easy to be maliciously stolen. In this application, after the current version of the firmware is divided into multiple sub-files, these sub-files are divided into two parts and stored in the internal memory of the main control chip of the electric energy meter and the external memory of the main control chip of the electric energy meter respectively; even if the sub-files in the external memory of the main control chip of the electric energy meter are maliciously stolen, the thief cannot obtain the complete firmware file, which increases the difficulty of maliciously stealing the complete firmware file of the electric energy meter.
[0084] 2. When the electric energy meter is incrementally updated, the current version update file with a large file size is first sent to the electric energy meter at the first time node and divided into multiple copies and stored in the internal and external memory of the electric energy meter respectively, and the patch package for generating the new version update file is received at the second time node when the update can be performed. In this way, since the current version update file is divided into multiple copies and stored in the internal and external memory respectively, it is not easy to be completely stolen by malicious persons. Furthermore, since the patch package is only received at the second time node when the electric energy meter can be updated, the patch package is very small, generally about tens of KB, and can be transmitted quickly. In addition, by controlling the electric energy meter to receive the patch only when it can be updated, the time window management of the patch file on the electric energy meter is strictly implemented, and after the new version update file is generated, the patch and each sub-file corresponding to the current version update file are deleted, which further increases the difficulty for malicious thieves to obtain the patch package and the current version update file at the same time.
[0085] In one embodiment, the electric energy meter also receives the segmentation node sequence sent by the server at the first time node.
[0086] The electric energy meter divides the current version update file into multiple sub-files, specifically including:
[0087] Step A: The electric energy meter receives a segmentation node sequence sent by the server; wherein each segmentation node in the segmentation node sequence They each represent a byte offset in the current version update file, and p is the split node The sequence number in the split node sequence, p is a positive integer;
[0088] Step B: the electric energy meter updates the current version in the file from the byte offset To the byte offset of The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files ;in, Indicates the byte offset corresponding to the starting position of the nth sub-file in the current version update file. = ; Indicates the byte offset corresponding to the end position of the nth sub-file in the current version update file. = ; n is a positive integer, m is a non-negative integer.
[0089] For example, the number of ternary arrays stored in the ctrl area in Table 1 is 100, so a total of 100 byte offsets are recorded. , so the number of split nodes is also 100, then the offset of these 100 bytes is It constitutes a sequence of segmentation nodes. It can be seen that . Assume that the current version update file is divided into 10 sub-files, which are recorded as ,in, ,if bytes, Bytes, it can be seen that the data volume of the first sub-file is 41 bytes. The data volume of other sub-files is similar, and will not be repeated here.
[0090] According to the process of the bsdiff algorithm, in this embodiment, the starting position of each sub-file corresponds to the offset of the control information in the patch file generated by the bsdiff algorithm, so that in the patch process, after a sub-file is read into the memory space of the electric energy meter, only a single sub-file is used in one patch cycle, and there is no situation where the data in the current version update file corresponding to the diff area that needs to be used in one patch cycle is located in two sub-files respectively. It can be achieved that only the content of one sub-file needs to be read into the memory space at a time, and there is no need to read the data of multiple sub-files into the memory space at the same time, saving memory space.
[0091] like Figure 2 As shown, in one embodiment, the segmentation node sequence is generated by the server through the following steps:
[0092] Step S302, obtaining the current version update file and the new version update file.
[0093] Step S304, performing a diff process of the bsdiff algorithm on the current version update file and the new version update file to generate the patch package, wherein the patch package includes control information, and the control information records the byte offset of each diff data block generated during the diff process in the current version update file.
[0094] Step S306: Arrange the byte offsets in the order in which they are recorded to obtain the segmentation node sequence.
[0095] Specifically, the byte offsets can be referenced in the order in which they are recorded. The records in .
[0096] In this embodiment, when the server executes the diff process of the bsdiff algorithm to generate a patch package, it generates a split node sequence according to the byte offset in the control information, and sends the split node sequence and the current version update file to the electric energy meter at the same time, so that the electric energy meter performs a split operation on the current version update file based on the split node sequence, thereby achieving the purpose of saving the memory space of the electric energy meter during the patch process.
[0097] like Figure 3 As shown, in one embodiment, the electric energy meter divides the multiple sub-files into two parts, and stores the two parts in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip respectively, specifically including:
[0098] Step S402: the electric energy meter divides the plurality of sub-files into two parts; wherein the two parts include a first part and a second part.
[0099] Step S404: The electric energy meter calculates the ratio of the data volume of the first part to the data volume of the second part as the actual internal and external ratio.
[0100] Step S406, the electric energy meter adjusts different combinations of the first part and the second part to obtain different actual internal and external proportions; wherein different combinations refer to different sub-files constituting the first part and the second part.
[0101] Step S408, the electric energy meter obtains the first remaining space capacity of the internal memory of the main control chip and the second remaining space capacity of the external memory.
[0102] Step S410: The electric energy meter calculates a ratio of the first remaining space capacity to the second remaining space capacity as an internal and external reference ratio.
[0103] Step S412, when the difference between the actual internal and external ratios and the internal and external reference ratios is the smallest, the electric energy meter stores the first part of the combination in the internal memory of the electric energy meter main control chip, and stores the second part of the combination in the external memory of the electric energy meter main control chip.
[0104] For example, if the first remaining space of the internal memory is 5MB and the second remaining space of the external memory is 10MB, the internal and external reference ratio is 1 / 2. If the data size of the first to fifth sub-files in the 10 sub-files is 0.1MB, and the data size of the sixth to tenth sub-files is 0.2MB, then the first to fifth sub-files should be divided into the first part, and the sixth to tenth sub-files should be divided into the second part. At this time, the actual internal and external ratio is 1 / 2, so the first part should be stored in the internal memory and the second part should be stored in the external memory according to this combination.
[0105] It should be noted that, in the present embodiment, the proportion of data volume of the current version update file stored in the internal storage device and the external storage device is allocated according to the ratio of the first remaining space capacity to the second remaining space capacity. This can avoid the problem that the remaining space in one of the internal storage device or the external storage device is used up first or the remaining amount is very small, resulting in the subsequent need for other update files to be split and stored in the two memories respectively, and one of the memories has no remaining space or the remaining amount is very small, making it impossible for the two memories to store different parts of the same complete file respectively.
[0106] In one embodiment, the first portion includes only the nth sub-file of the plurality of sub-files. ;
[0107] and in updating the current version file from byte offset To the byte offset of The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files In the process, through the formula Select the split node sequence and Two split nodes;
[0108] Among them, F is the total number of bytes of the current version update file, W is the internal and external reference ratio, and θ is the preset ratio error threshold.
[0109] For example, the total number of bytes of the current version update file is F=1MB, the internal and external reference ratio W is 1 / 4, and the preset ratio error threshold θ is 0.01. For the first sub-file, the formula = =0 bytes, = 230 bytes, = 260 bytes, =270 bytes. Substituting into the formula, we can see that and None of them meet the requirements of the formula, that is, = , at this time, the data volume of the first sub-file is 260 bytes.
[0110] This embodiment controls the data size of a single sub-file so that the difference between the actual internal and external ratios and the internal and external reference ratios can be controlled within a desired range, ultimately ensuring that the internal memory and the external memory can simultaneously retain the same proportion of remaining space, making it convenient for subsequent other files to be split and stored in the two memories, thereby improving the security of the electricity meter data storage.
[0111] In one embodiment, the nth sub-file in the plurality of sub-files The content also includes and Specifically, the energy meter will and These two pieces of information are appended to the nth sub-file At the end, it is easy to get when loaded into memory and These two information.
[0112] The generating a new version update file based on the patch package corresponding to the plurality of sub-files and the received new version update file specifically includes:
[0113] Execute the patch process of the bsdiff algorithm and read a target sub-file into the running memory; wherein the target sub-file is one of the multiple sub-files.
[0114] During the patch process, data corresponding to the diff data block is directly obtained from the target sub-file read into the running memory.
[0115] In this embodiment, there is no need to load the data of the current version update file into the running memory multiple times, which reduces the occupation of bus resources. At the same time, compared with the complete current version update file, the single sub-file is smaller in size and occupies less running memory.
[0116] For details, refer to the specific steps of the bsdiff algorithm to execute the corresponding patch process. In step 3, according to The byte offset in Extract the old file The corresponding data is stored in the auxiliary space b. The above-mentioned prior art solution is only applicable to the case where the old version of the firmware is complete, and is not applicable to the case where the old version of the firmware is divided into multiple sub-files. However, this embodiment is different, and this step will be improved, specifically:
[0117] During the patch process, the diff data block in step 3 (i.e., data block ) is greater than the byte offset in the control information corresponding to the current target subfile, the nth subfile Corresponding When the n+1th sub-file is Read it into the running memory as a new target subfile and release the target subfile The corresponding running memory.
[0118] For example, if the second sub-file corresponds to is 260 bytes, and the current processing progress The byte offset in If the byte offset is 261, we know that the third-party sub-file needs to be read into the running memory, so only the third sub-file has data corresponding to the byte offset of 261.
[0119] In this embodiment, only one sub-file is loaded into the running memory each time and the previous sub-file is immediately released from the running memory after being used, so less running memory is occupied.
[0120] In one embodiment, the following steps are performed to implement the process of selecting the nth sub-file as the current target sub-file: Get the data corresponding to the diff data block with byte offset K:
[0121] First, calculate K- , get the local byte offset; where K is a non-negative integer;
[0122] Secondly, using the local byte offset as the starting address, obtain the nth sub-file The data corresponding to the number of bytes in the diff data block.
[0123] It is understandable that K is the global offset of the current version update file. In fact, K is a ternary array. In However, only a sub-file is read into the running memory, so when obtaining data from the sub-file, the local offset of the sub-file should be used to correctly extract the data. Therefore, in this embodiment, K- , get the local byte offset, and then use the local byte offset as the starting address to get the nth sub-file The data corresponding to the number of bytes in the diff data block.
[0124] like Figure 4 As shown, in one embodiment, the method further includes:
[0125] Step S502, the first sub-file is stored in a pre-specified file path on the internal memory and the file name of the first sub-file records the file path where the second sub-file is located;
[0126] Step S504, the second sub-file is stored in the external storage device and the file name of the second sub-file records the file path where the third sub-file is located;
[0127] Step S506, the third sub-file is stored in the internal memory and the file name of the third sub-file records the file path where the fourth sub-file is located;
[0128] Step S508, and so on, the adjacent j-th sub-file and j+1-th sub-file are stored in the internal memory and the external memory respectively, and the file name of the j-th sub-file records the file path of the j+1-th sub-file; wherein j is a positive integer greater than 1.
[0129] In this embodiment, the adjacent j-th sub-file and the j+1-th sub-file are stored in the internal memory and the external memory, respectively. Even if the data in the external memory is stolen, the adjacent sub-file cannot be obtained according to the file path of the adjacent sub-file recorded on the sub-file, thereby improving data security. In addition, by using the file name of the sub-file to record the file path of other sub-files, computer resources for recording the file path of each sub-file can be saved. It should be noted that the file path of each sub-file in this embodiment is a folder, and there is only one file in the folder, that is, it is only used to store the corresponding sub-file. By extracting the file path of the next sub-file from the file name of the sub-file, each sub-file can be accessed simply and efficiently, without the need to maintain a complex file specifically used to record the file path of each sub-file.
[0130] In one embodiment, an electric energy meter data processing device is also provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of the above-mentioned electric energy meter data processing method when executing the program. The steps of the electric energy meter data processing method here may be the steps in the above-mentioned various embodiments.
[0131] In one embodiment, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores computer-executable instructions, wherein the computer-executable instructions are used to enable a computer to execute the steps of the above-mentioned method for processing electric energy meter data. The steps of the method for processing electric energy meter data here may be the steps of the method for processing electric energy meter data in the above-mentioned embodiments.
[0132] In one embodiment, an electric energy meter is further provided. The electric energy meter includes a controller and an electric energy metering chip. The controller is used to execute the above-mentioned electric energy meter data processing method.
[0133] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRA), memory bus (Rambus) direct RAM (RDRA), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0134] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for processing electric energy meter data, characterized in that: The method comprises: The electric energy meter receives the current version update file sent by the server at the first time node; The electric energy meter divides the current version update file into multiple sub-files; wherein the update file includes the firmware of the electric energy meter or the parameters of the electric energy meter; The electric energy meter divides the plurality of sub-files into two parts, and stores the two parts in an internal memory of the electric energy meter main control chip and an external memory of the electric energy meter main control chip respectively; The electric energy meter receives a patch package corresponding to the new version update file sent by the server at a second time node, and generates a new version update file based on the patch package corresponding to the multiple sub-files and the received new version update file; wherein the second time node is a preset update time node, and the second time node is later than the first time node; The electric energy meter divides the current version update file into multiple sub-files, specifically including: The electric energy meter receives a segmentation node sequence sent by the server; wherein each segmentation node in the segmentation node sequence They each represent a byte offset in the current version update file, and p is the split node The sequence number in the split node sequence, p is a positive integer; The energy meter will update the current version in the file from byte offset To the byte offset The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files ;in, Indicates the byte offset corresponding to the starting position of the nth sub-file in the current version update file. = ; Indicates the byte offset corresponding to the end position of the nth sub-file in the current version update file. = ; n is a positive integer, m is a non-negative integer.
2. The method for processing electric energy meter data according to claim 1, characterized in that: The method further comprises: The electric energy meter also receives the segmentation node sequence sent by the server at the first time node.
3. The method for processing electric energy meter data according to claim 1, characterized in that: The segmentation node sequence is generated by the server through the following steps: Get the current version update file and the new version update file; Performing a diff process of the bsdiff algorithm on the current version update file and the new version update file to generate the patch package; wherein the patch package includes control information, and the control information records the byte offset of each diff data block generated in the diff process in the current version update file; The byte offsets are arranged in the order in which they are recorded to obtain the segmentation node sequence.
4. The method for processing electric energy meter data according to claim 1, characterized in that: The electric energy meter divides the multiple sub-files into two parts, and stores the two parts in the internal memory of the electric energy meter main control chip and the external memory of the electric energy meter main control chip respectively, specifically including: The electric energy meter divides the plurality of sub-files into two parts; wherein the two parts include a first part and a second part; The electric energy meter calculates the ratio of the data volume of the first part to the data volume of the second part as the actual internal and external ratio; The electric energy meter adjusts different combinations of the first part and the second part to obtain different actual internal and external proportions; wherein the different combinations refer to the first part and the second part being composed of different sub-files; The electric energy meter obtains the first remaining space capacity of the internal memory of the main control chip and the second remaining space capacity of the external memory; The electric energy meter calculates the ratio of the first remaining space capacity to the second remaining space capacity as an internal and external reference ratio; When the difference between the actual internal and external ratios and the internal and external reference ratios is the smallest, the electric energy meter stores the first part of the combination in the internal memory of the electric energy meter main control chip, and stores the second part of the combination in the external memory of the electric energy meter main control chip.
5. The method for processing electric energy meter data according to claim 4, characterized in that: The first part includes only the nth sub-file of the plurality of sub-files ; and in updating the current version file from byte offset To the byte offset The corresponding data is split out to obtain the nth sub-file in the plurality of sub-files In the process, through the formula Select the split node sequence and Two split nodes; Among them, F is the total number of bytes of the current version update file, W is the internal and external reference ratio, and θ is the preset ratio error threshold.
6. The method for processing electric energy meter data according to claim 1, characterized in that: The nth sub-file among the plurality of sub-files The content also includes and ; The generating a new version update file based on the patch package corresponding to the plurality of sub-files and the received new version update file specifically includes: Execute the patch process of the bsdiff algorithm and read a target subfile into the running memory; The target subfile is one of the multiple subfiles; During the patch process, data corresponding to the diff data block is directly obtained from the target sub-file read into the running memory.
7. The method for processing electric energy meter data according to claim 6, characterized in that: The method further comprises: During the patch process, it is detected that the byte offset in the control information corresponding to the diff data block is greater than the nth subfile as the current target subfile. Corresponding When the n+1th sub-file is Read it into the running memory as a new target subfile and release the target subfile The corresponding running memory.
8. The method for processing electric energy meter data according to claim 7, characterized in that: The following steps are used to implement the nth sub-file as the current target sub-file Get the data corresponding to the diff data block with byte offset K: Calculate K- , get the local byte offset; where K is a non-negative integer; Using the local byte offset as the starting address, get the nth sub-file The data corresponding to the number of bytes in the diff data block.
9. The method for processing electric energy meter data according to claim 1, characterized in that: The method further comprises: The first sub-file is stored in a pre-specified file path on the internal storage and the file name of the first sub-file records the file path where the second sub-file is located; The second sub-file is stored in the external storage and the file name of the second sub-file records the file path where the third sub-file is located; The third sub-file is stored in the internal storage and the file name of the third sub-file records the file path where the fourth sub-file is located; By analogy, the adjacent j-th sub-file and j+1-th sub-file are stored in the internal memory and the external memory respectively, and the file name of the j-th sub-file records the file path of the j+1-th sub-file; wherein j is a positive integer greater than 1.
Citation Information
Patent Citations
Automatic data storage format maintenance method of intelligent electric energy meter
CN105511918A
Data file incremental updating method, server, client and system
CN106528125A