CN109324920B - Method for checking and correcting byte array and intelligent equipment - Google Patents

Method for checking and correcting byte array and intelligent equipment Download PDF

Info

Publication number
CN109324920B
CN109324920B CN201811174926.7A CN201811174926A CN109324920B CN 109324920 B CN109324920 B CN 109324920B CN 201811174926 A CN201811174926 A CN 201811174926A CN 109324920 B CN109324920 B CN 109324920B
Authority
CN
China
Prior art keywords
byte
copy
data
array
length
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
Application number
CN201811174926.7A
Other languages
Chinese (zh)
Other versions
CN109324920A (en
Inventor
杨波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou rabbit small two Technology Industry Co., Ltd
Original Assignee
Hangzhou Rabbit Small Two Technology Industry Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hangzhou Rabbit Small Two Technology Industry Co ltd filed Critical Hangzhou Rabbit Small Two Technology Industry Co ltd
Priority to CN201811174926.7A priority Critical patent/CN109324920B/en
Publication of CN109324920A publication Critical patent/CN109324920A/en
Application granted granted Critical
Publication of CN109324920B publication Critical patent/CN109324920B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1012Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using codes or arrangements adapted for a specific type of error
    • G06F11/102Error in check bits

Abstract

The method and the intelligent device for checking and correcting the byte array comprise the following steps: obtaining a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array; determining the length of the positive copy byte array according to the length of the positive copy corresponding to the positive copy byte array, the length of the copy corresponding to the copy byte array and the length of the error correcting code corresponding to the error correcting code byte array; according to the length of the byte array of the positive copy, the random numerical value of the tail end of the byte array of the positive copy and/or the byte array of the copy is filled, so that the length of the positive copy is equal to the length of the copy; performing check operation according to the head byte of the original data, the middle byte of the original data, the head byte of the copy data, the middle byte of the copy data and the corresponding error correction code byte of the copy byte array to obtain a check result; and correcting according to the check result to obtain a correct original byte array. The method is simple and efficient to realize, checks and corrects the byte array, and calculates and restores the correct original byte array.

Description

Method for checking and correcting byte array and intelligent equipment
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an intelligent device for performing check correction on byte arrays.
Background
With the development of network technology and the aggravation of market competition, people have higher and higher requirements on data accuracy, but interference factors in the actual environment are many and influence on the data accuracy is inevitable.
In order to monitor the accuracy of data in the data transmission and data storage processes, the first method is to directly compare the original data with the data to be compared to see whether the original data and the data to be compared are completely the same, however, the data verification method has extremely low efficiency, and only the transmitted data can be stored again and cannot be corrected and modified. The second way is to add one extra bit in the byte during data storage and transmission to transmit odd/even check bits to check errors, however, this check method can not correct and modify errors after data errors are found.
How to simply, efficiently and quickly correct data and correct error data so as to calculate and restore correct original data even if the data has errors is an urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a method and intelligent equipment for checking and correcting byte arrays, which are concise and efficient to check the byte arrays and quickly correct error byte data, so that correct original byte arrays can be calculated and restored even if the byte data are in error.
The technical scheme provided by the invention is as follows:
the invention provides a method for checking and correcting a byte array, which comprises the following steps:
obtaining a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
determining the length of the positive copy byte array and the length of the error correcting code byte array according to the positive length corresponding to the positive byte array, the copy length corresponding to the copy byte array and the error correcting code length corresponding to the error correcting code byte array;
according to the length of the byte array of the positive copy, the random value of the tail end of the byte array of the positive copy and/or the byte array of the copy is filled, so that the length of the positive copy is equal to the length of the copy; the random number value is a constant;
performing check operation according to the head byte and the middle byte of the original data of the original byte array, the head byte and the middle byte of the copy data of the copy byte array and the corresponding error correction code byte to obtain a check result;
and correcting according to the check result to obtain a correct original byte array.
Further, the obtaining the target byte array specifically includes:
processing the byte array to be processed to obtain a positive byte array and a copy byte array;
obtaining an error correcting code byte array according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
and assembling the positive byte array, the copy byte array and the error correcting code byte number into a target byte array so as to carry out data transmission or data storage.
Further, before the operation of obtaining the error correction code byte array according to the positive byte array or the copy byte array, the method includes the steps of:
carrying out byte quantity statistics on the positive byte array or the copy byte array to obtain a byte quantity result;
when the result of the byte number is an odd number, performing end-filling on the original byte array or the copy byte array to obtain a preset value, so that the byte number of the original byte array or the copy byte array is an even number; the preset value is zero.
Further, the obtaining of the error correction code byte array by the operation according to the positive byte array or the replica byte array specifically includes the steps of:
symmetrically dividing the original data head byte array or the copy byte array to obtain the original data head byte array, the original data middle byte array, the copy data head byte array and the copy data middle byte array;
according to the head byte of the original data and the middle byte of the original data, carrying out XOR operation on the head byte of the copy data and the middle byte of the copy data to obtain the error correcting code byte;
and arranging the error correction code bytes obtained by operation corresponding to the arrangement sequence of the original byte array or the copy byte array to obtain the error correction code byte array.
Further, the obtaining the error correction code byte by performing an exclusive or operation on the original data header byte and the original data middle byte according to the original data header byte and the original data middle byte specifically includes:
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the original data to obtain a first byte of an error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the copy data to obtain a second undetermined error correction code byte;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the original data to obtain a third byte of the error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the copy data to obtain a fourth byte of the error correcting code to be determined;
and counting the occurrence times corresponding to each undetermined error correction code byte, and determining the undetermined error correction code byte with the largest occurrence times as the final error correction code byte.
Further, the step of performing a check operation according to the original data head byte and the original data middle byte of the original byte array, the copy data head byte, the copy data middle byte of the copy byte array, and the corresponding error correction code byte to obtain a check result specifically includes:
when the exclusive-or operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte, and the exclusive-or operation result of the head byte of the original data and the middle byte of the copy data is equal to the exclusive-or operation result of the head byte of the copy data and the middle byte of the original data, determining that the head byte of the original data, the middle byte of the original data, the head byte of the copy data and the middle byte of the copy data are normal;
when the exclusive-or operation result of the head byte of the original data and the middle byte of the original data is not equal to the error correction code byte, and the exclusive-or operation result of the head byte of the copy data and the middle byte of the copy data is equal to the error correction code byte, determining that the head byte of the original data and the middle byte of the original data are in error, and the head byte of the copy data and the middle byte of the copy data are normal;
when the XOR operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte and the XOR operation result of the head byte of the duplicate data and the middle byte of the duplicate data is not equal to an error correction code byte, determining that the head byte of the duplicate data and the middle byte of the duplicate data are in error and the head byte of the original data and the middle byte of the original data are normal;
when the XOR operation result of the head byte of the original data and the middle byte of the copy data is not equal to the error correction code byte and the XOR operation result of the head byte of the copy data and the middle byte of the original data is equal to the error correction code byte, determining that the head byte of the original data and the middle byte of the copy data are in error and the head byte of the copy data and the middle byte of the original data are normal;
when the XOR operation result of the head byte of the duplicate data and the middle byte of the original data is not equal to the error correction code byte, and the XOR operation result of the head byte of the original data and the middle byte of the duplicate data is equal to the error correction code byte, determining that the head byte of the duplicate data and the middle byte of the original data are in error, and the head byte of the original data and the middle byte of the duplicate data are normal;
and when the XOR operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte, and the XOR operation result of the head byte of the original data and the middle byte of the copy data is equal to the XOR operation result of the head byte of the copy data and the middle byte of the original data, determining that the head byte of the original data, the middle byte of the original data, the head byte of the copy data and the middle byte of the copy data are normal, and determining that the error correction code byte is in error.
Further, the step of correcting to obtain a correct original byte array according to the check result specifically includes the steps of:
when the head byte of the original data and the middle byte of the original data are in error and the head byte of the duplicate data and the middle byte of the duplicate data are normal, replacing the head byte of the original data with the head byte of the duplicate data and replacing the middle byte of the original data with the middle byte of the duplicate data;
when the head byte of the duplicate data and the middle byte of the duplicate data are in error and the head byte of the original data and the middle byte of the original data are normal, replacing the head byte of the duplicate data with the head byte of the original data and replacing the middle byte of the duplicate data with the middle byte of the original data;
when the head byte of the original data and the middle byte of the duplicate data are in error and the head byte of the duplicate data and the middle byte of the original data are normal, replacing the head byte of the original data with the head byte of the duplicate data and replacing the middle byte of the original data with the middle byte of the duplicate data;
when the head byte of the duplicate data and the middle byte of the original data are in error and the head byte of the original data and the middle byte of the duplicate data are normal, replacing the head byte of the duplicate data with the head byte of the original data and replacing the middle byte of the duplicate data with the middle byte of the original data;
and when the byte of the head of the original data, the byte of the middle part of the original data, the byte of the head of the copy data and the byte of the middle part of the copy data are normal and the error correction code byte has an error, re-operating to determine a new error correction code byte.
Further, the determining the length of the positive copy byte array according to the length of the positive copy corresponding to the positive copy byte array, the length of the copy corresponding to the copy byte array, and the length of the error correction code byte array specifically includes:
comparing the original length, the copy length and the error correction code length to obtain a corresponding comparison result; the length of the error correcting code is the actual length of the byte array of the error correcting code;
when the original length is equal to the copy length, determining that the length of an original copy byte array is the original length or the copy length, and the length of the error correcting code byte array is (original length +1)/2 or (copy length + 1)/2;
when the positive copy length is not equal to the copy length and the (positive copy length +1)/2 is equal to the error correction code length, determining the positive copy byte array length as the positive copy length; the length of the error correcting code byte array is (original length + 1)/2;
when the positive copy length is not equal to the copy length and the (copy length +1)/2 is equal to the error correction code length, determining that the positive copy byte array length is the copy length and the error correction code byte array length is (copy length + 1)/2;
when the original length is larger than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the original length, and the length of the byte array of the error correction code is (original length + 1)/2;
when the original length is smaller than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the copy length, and the length of the byte array of the error correction code is (copy length + 1)/2;
wherein the length of the error correction code byte array takes the value of an integer bit.
The invention also provides an intelligent device for checking and correcting the byte array, which comprises:
the acquisition module is used for acquiring a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
the length determining module is connected with the acquiring module and used for determining the length of the positive copy byte array and the length of the error correcting code byte array according to the original length corresponding to the original byte array, the copy length corresponding to the copy byte array and the error correcting code length corresponding to the error correcting code byte array;
the data complementing module is connected with the length determining module and used for carrying out tail end complementing random numerical values on the positive copy byte array and/or the copy byte array according to the length of the positive copy byte array so as to enable the positive copy length to be equal to the copy length; the random number value is a constant;
the operation module is connected with the data completion module and is used for carrying out check operation according to the head byte and the middle byte of the original data of the original byte array, the head byte and the middle byte of the copy data of the copy byte array and the corresponding error correction code byte to obtain a check result;
and the processing module is connected with the operation module and used for correcting to obtain a correct original byte array according to the check result.
Further, the obtaining module includes:
the processing unit is used for processing the byte array to be processed to obtain a positive byte array and a copy byte array;
the operation unit is connected with the processing unit and used for obtaining an error correcting code byte array according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
and the acquisition unit is connected with the operation unit and is used for assembling the original byte array, the copy byte array and the error correction code byte array into a target byte array so as to carry out data transmission or data storage.
The method and the intelligent equipment for checking and correcting the byte array provided by the invention have the advantages that the byte array is checked and corrected simply and efficiently, error byte data are corrected quickly, and therefore, even if the byte data are in error, the correct original byte array can be calculated and restored.
Drawings
The above features, technical features, advantages and implementations of a method and a smart device for parity correction of byte arrays are further described in the following detailed description of preferred embodiments in a clearly understandable manner with reference to the accompanying drawings.
FIG. 1 is a flow chart of one embodiment of a method of parity correction of a byte array of the present invention;
FIG. 2 is a flow chart of another embodiment of a method for parity correction of byte arrays in accordance with the present invention.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
An embodiment of the present invention provides a method for performing check correction on a byte array, as shown in fig. 1, including:
s100, obtaining a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
s200, determining the length of the byte array of the positive copy and the length of the byte array of the error correcting code according to the length of the positive copy corresponding to the byte array of the positive copy, the length of the copy corresponding to the byte array of the copy and the length of the byte array of the error correcting code;
specifically, after the byte array to be processed is processed to obtain the original byte array, the copy byte array and the error correction code byte array, the original byte array, the copy byte array and the error correction code byte array are assembled into a target byte array, and therefore data transmission or data storage is carried out on the target byte array. For example, a byte array to be processed in a mobile phone is stored in a computer, data to be processed in the mobile phone needs to be processed to obtain a target byte array, then the target byte array imported by the mobile phone is read by the computer, and then the lengths of the positive byte array and the replica byte array and the length of the error correction code byte array are determined according to the positive length corresponding to the positive byte array, the replica length corresponding to the replica byte array and the error correction code length corresponding to the error correction code byte array.
S300, according to the length of the byte array of the positive copy, conducting tail end completion random numerical values on the byte array of the positive copy and/or the byte array of the copy, and enabling the length of the positive copy to be equal to the length of the copy; the random number value is a constant;
s400, carrying out check operation according to the original data head byte Ai and the original data middle byte Bi of the original byte array, the copy data head byte Ai 'and the copy data middle byte Bi' of the copy byte array and the corresponding error correction code byte Ci to obtain a check result;
and S500, correcting according to the check result to obtain a correct original byte array.
Specifically, in this embodiment, when the lengths of the positive byte array and the negative byte array are even numbers, no processing is performed. When the lengths of the positive byte array and the copy byte array are odd numbers, the random numerical value is supplemented to the tail ends of the positive byte array or the copy byte array, or the positive byte array and the copy byte array, so that the positive length is equal to the copy length. The first half positive byte of the positive byte array is directly defined as a positive data head byte Ai, and the second half positive byte of the positive byte array is defined as a positive data middle byte Bi. Similarly, the first half copy byte of the copy byte array may be defined as the copy data header byte Ai ', and the second half copy byte of the copy byte array may be defined as the copy data middle byte Bi'. In this way, the xor operation of the header byte and the middle byte of the positive data is performed on the header byte Ai, the middle byte Bi of the positive data, the header byte Ai 'of the duplicate data and the middle byte Bi' of the duplicate data to obtain the corresponding error correction code byte Ci, so as to determine the error correction code byte Ci. And then, according to the determined error correction code byte Ci, the head byte Ai of the original data, the middle byte Bi of the original data, the head byte Ai 'of the copy data and the middle byte Bi' of the copy data, the results obtained by performing XOR operation on the head byte and the middle byte are sequentially compared, so that a corresponding verification result is obtained, and according to the verification result, the error correction code byte Ci corresponding to the error correction code byte Ci, the head byte Ai of the original data, the middle byte Bi of the original data, the head byte Ai 'of the copy data and the middle byte Bi' of the copy data are corrected.
After the technical scheme is applied to practical application, the data accuracy in data transmission or data storage is greatly improved, so that the times of data retransmission or data storage are reduced, and the times of data retransmission are reduced, so that the network resources occupied by data transmission communication can be reduced, and the communication quality and the network transmission quality are indirectly improved. Because the number of times of data re-storage is reduced, the efficiency of data backup and copying is improved. And the byte array is simply and efficiently checked and error byte data is quickly corrected, so that the correct original byte array can be calculated and restored even if the byte data is in error, the problems that the original byte array is maliciously modified and damaged are solved, and the purpose that the original byte array can be quickly restored to obtain the original byte array without retransmitting the original byte array or storing the original byte array again is achieved. In addition, a special principle that the exclusive-or operation is reversible is adopted, so that almost no performance bottleneck exists, and the functionality is greatly improved compared with the traditional integrity check.
Based on the foregoing embodiment, as shown in fig. 2, the present embodiment includes:
s110, processing the byte array to be processed to obtain a positive byte array and a copy byte array;
whether digital communication, or data streams transmitted by network protocols, or data stores in the form of files, are defined as: an array of bytes. First, a "positive byte array" is defined as src data, which is src len in length. Second, a "copy byte array" is defined as cpydata, which is cpyLen in length. Then, an "error correction code byte array" is defined as corrdata, which is corrLen in length. After the byte data to be processed is obtained, the byte data to be processed is respectively stored in two storage addresses to obtain a positive byte array and a copy byte array.
S120, an error correcting code byte array is obtained according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
specifically, the positive byte array includes a plurality of positive bytes, and the duplicate byte array includes a plurality of duplicate bytes. And after carrying out XOR calculation according to the arrangement sequence of the positive bytes in the positive byte array in turn according to the digits to obtain the corresponding error correction code bytes, arranging the error correction code bytes in turn according to the digits corresponding to the positive bytes in the positive byte array to obtain the error correction code byte array. And similarly, after the corresponding error correction code bytes are obtained by sequentially carrying out XOR calculation according to the arrangement sequence of the copy bytes in the copy byte array and the bits, the error correction code bytes are sequentially arranged according to the bits corresponding to the copy bytes in the copy byte array to obtain the error correction code byte array.
S130, assembling the positive byte array, the copy byte array and the error correcting code byte array into a target byte array so as to carry out data transmission or data storage;
s200, determining the length of the byte array of the positive copy and the length of the byte array of the error correcting code according to the length of the positive copy corresponding to the byte array of the positive copy, the length of the copy corresponding to the byte array of the copy and the length of the byte array of the error correcting code;
s300, according to the length of the byte array of the positive copy, conducting tail end completion random numerical values on the byte array of the positive copy and/or the byte array of the copy, and enabling the length of the positive copy to be equal to the length of the copy; the random number value is a constant;
s400, carrying out check operation according to the original data head byte Ai and the original data middle byte Bi of the original byte array, the copy data head byte Ai 'and the copy data middle byte Bi' of the copy byte array and the corresponding error correction code byte Ci to obtain a check result;
and S500, correcting according to the check result to obtain a correct original byte array.
Based on the foregoing embodiments, the present embodiment includes:
s110, processing the byte array to be processed to obtain a positive byte array and a copy byte array;
s111, carrying out byte quantity statistics on the positive byte array or the copy byte array to obtain a byte quantity result;
s112, when the result of the byte number is an odd number, performing end-padding on the original byte array or the duplicate byte array to obtain a preset value, so that the byte number of the original byte array or the duplicate byte array is an even number; the preset value is zero;
specifically, when the byte number result obtained by counting the byte number of the positive byte array or the copy byte array is an even number, the positive byte of the first half of the positive byte array is directly defined as the head byte Ai of the positive data, and the positive byte of the second half of the positive byte array is defined as the middle byte Bi of the positive data. Similarly, the first half copy byte of the copy byte array may be defined as the copy data header byte Ai ', and the second half copy byte of the copy byte array may be defined as the copy data middle byte Bi'.
When the byte quantity result obtained by counting the byte quantity of the positive byte array or the copy byte array is an odd number, if the byte quantity result of the positive byte array is an odd number, the tail end of the positive byte array is filled with zero, so that the byte quantity of the positive byte array is an even number. Similarly, if the result of the byte number of the copy byte array is odd, the tail end of the copy byte array is filled with zero, so that the byte number of the copy byte array is even.
For example, if the result of the byte number of the positive byte array is 9 and the result of the byte number of the duplicate byte array is 8, it indicates that the number of the head byte bits of the positive byte array is not equal to the number of the middle byte bits, which results in that the error correction code bytes corresponding to the head byte and the middle byte of the positive byte array cannot be obtained through accurate operation.
S121 symmetrically dividing the original byte array or the copy byte array to obtain an original data head byte array { A1, … …, Ai }, an original data middle byte array { B1, … …, Bi }, a copy data head byte array { A1 ', … …, Ai' } and a copy data middle byte array { B1 ', … …, Bi' }; i is more than or equal to 1 and is an even number;
s122, carrying out XOR operation according to the header byte Ai of the original data, the middle byte Bi of the original data, the header byte Ai 'of the copy data and the middle byte Bi' of the copy data to obtain the error correcting code byte Ci;
s123, arranging the error correction code bytes Ci obtained by operation corresponding to the arrangement sequence of the original byte array or the copy byte array to obtain the error correction code byte array;
further, the step S122 of performing an exclusive or operation according to the original data header byte Ai, the original data middle byte Bi, the copy data header byte Ai 'and the copy data middle byte Bi' to obtain the error correction code byte Ci specifically includes:
s1221, carrying out XOR operation on the byte Ai at the head of the original data and the byte Bi in the middle of the original data to obtain a first byte Ci1 of an error correcting code to be determined;
s1222 performing XOR operation on the header byte Ai of the original data and the middle byte Bi' of the copy data to obtain a second undetermined error correction code byte Ci 2;
s1223, carrying out XOR operation on the byte Ai' at the head of the copy data and the byte Bi in the middle of the original data to obtain a byte Ci3 of a third error correcting code to be determined;
s1224 carries out XOR operation on the byte Ai 'at the head of the copy data and the byte Bi' in the middle of the copy data to obtain a byte Ci4 of a fourth error correcting code to be determined;
s1225, counting the occurrence frequency corresponding to each undetermined error correction code byte, and determining the undetermined error correction code byte with the largest occurrence frequency as the final error correction code byte.
Specifically, assume a positive data header byte array { a1, … …, a4}, a positive data middle byte array { B1, … …, B4}, a duplicate data header byte array { a1 ', … …, a 4' } and a duplicate data middle byte array { B1 ', … …, B4' }; then the xor operation is performed on the head byte and the middle byte to obtain a first pending error correction code byte C11 ═ a1^ B1, a second pending error correction code byte C12 ^ a1^ B1 ', a third pending error correction code byte C13 ^ a 1' ^ B1, and a fourth pending error correction code byte C14 ^ a1 '^ B1'. If a1 is 1, a1 is 1, B1 is 5, and B1 is 5, then C11 is C12, C13 is C14, and thus error correction code byte C1 is 1. And x represents an exclusive or operation. Here, the first-bit-number error correction code byte is only exemplified in the case where both the first-bit-number head byte and the first-bit-number middle byte are maliciously tampered or destroyed. And the other method is to count the number of times of occurrence of numerical values corresponding to the first undetermined error correction code byte Ci1, the second undetermined error correction code byte Ci2, the third undetermined error correction code byte Ci3 and the fourth undetermined error correction code byte Ci4, and determine the undetermined error correction code byte with the largest number of times of occurrence as the final error correction code byte. For example, assuming that the first pending error correction code byte C31 ═ a, the second pending error correction code byte C32 ═ a, the third pending error correction code byte C33 ═ a, and the fourth pending error correction code byte C34 ═ B obtained by performing an exclusive-or operation on the third-digit head byte (A3 and A3 ') and the third-digit middle byte (B3 and B3'), the final third-digit error correction code byte C3 ═ a is determined.
According to the technical scheme, the number of times of occurrence of the numerical value of the corresponding undetermined error correction code byte is obtained through the XOR operation of the head byte and the middle byte according to statistical comparison, so that the undetermined error correction code byte with the largest number of times of occurrence is determined to be the final error correction code byte, the reliability of the error correction code byte can be improved, the reliability of the error correction code byte array is improved, the probability of the error correction code byte array needing to be changed is reduced when the mutual integrity and accuracy check operation is carried out according to the positive byte array, the copy byte array and the error correction code byte array, the operation amount is reduced, and the integrity and accuracy operation check efficiency is improved.
Further, the step of performing a check operation according to the original data header byte Ai and the original data middle byte Bi of the original byte array, the copy data header byte Ai ', the copy data middle byte Bi' of the copy byte array, and the corresponding error correction code byte Ci to obtain a check result specifically includes:
when the exclusive or operation result of the original data head byte Ai and the original data middle byte Bi is equal to an error correction code byte Ci, and the exclusive or operation result of the original data head byte Ai and the copy data middle byte Bi 'is equal to the exclusive or operation result of the copy data head byte Ai' and the original data middle byte Bi, determining that the original data head byte Ai, the original data middle byte Bi, the copy data head byte Ai 'and the copy data middle byte Bi' are normal;
when the XOR operation result of the head byte Ai of the original data and the middle byte Bi 'of the original data is not equal to the error correction code byte Ci, and the XOR operation result of the head byte Ai' of the copy data and the middle byte Bi 'of the copy data is equal to the error correction code byte Ci, it is determined that the head byte Ai of the original data and the middle byte Bi' of the original data are in error, and the head byte Ai 'of the copy data and the middle byte Bi' of the copy data are normal;
when the exclusive-or operation result of the head byte Ai of the original data and the middle byte Bi ' of the original data is equal to the error correction code byte Ci, and the exclusive-or operation result of the head byte Ai ' of the copy data and the middle byte Bi ' of the copy data is not equal to the error correction code byte Ci, determining that the head byte Ai ' of the copy data and the middle byte Bi ' of the copy data are in error, and the head byte Ai of the original data and the middle byte Bi of the original data are normal;
when the exclusive-or operation result of the head byte Ai of the original data and the middle byte Bi ' of the copy data is not equal to the error correction code byte Ci, and the exclusive-or operation result of the head byte Ai ' of the copy data and the middle byte Bi ' of the original data is equal to the error correction code byte Ci, determining that the head byte Ai of the original data and the middle byte Bi ' of the copy data are in error, and the head byte Ai ' of the copy data and the middle byte Bi of the original data are normal;
when the XOR operation result of the head byte Ai 'of the copy data and the middle byte Bi' of the copy data is not equal to the error correction code byte Ci, and the XOR operation result of the head byte Ai 'of the copy data and the middle byte Bi' of the copy data is equal to the error correction code byte Ci, determining that the head byte Ai 'of the copy data, the middle byte Bi' of the copy data is in error, and the head byte Ai 'of the copy data and the middle byte Bi' of the copy data are normal;
when the exclusive or operation result of the original data head byte Ai and the original data middle byte Bi is equal to an error correction code byte Ci, and the exclusive or operation result of the original data head byte Ai and the copy data middle byte Bi 'is equal to the exclusive or operation result of the copy data head byte Ai' and the original data middle byte Bi, it is determined that the original data head byte Ai, the original data middle byte Bi, the copy data head byte Ai 'and the copy data middle byte Bi' are normal, and the error correction code byte Ci is in error.
Further, the step of correcting to obtain a correct original byte array according to the check result specifically includes the steps of:
when the original data head byte Ai and the original data middle byte Bi are in error, and the copy data head byte Ai 'and the copy data middle byte Bi' are normal, replacing the original data head byte Ai with the copy data head byte Ai ', and replacing the copy data middle byte Bi with the copy data middle byte Bi';
when the head byte Ai 'of the duplicate data and the middle byte Bi' of the duplicate data are in error and the head byte Ai of the original data and the middle byte Bi of the original data are normal, replacing the head byte Ai 'of the duplicate data with the head byte Ai of the original data and replacing the middle byte Bi' of the duplicate data with the middle byte Bi of the original data;
when the head byte Ai of the original data and the middle byte Bi 'of the copy data are in error, and the head byte Ai' of the copy data and the middle byte Bi 'of the original data are normal, replacing the head byte Ai of the original data with the head byte Ai' of the copy data, and replacing the middle byte Bi 'of the original data with the middle byte Bi' of the copy data;
when the duplicate data head byte Ai ' and the original data middle byte Bi ' are in error and the original data head byte Ai and the original data middle byte Bi ' are normal, replacing the duplicate data head byte Ai ' with the original data head byte Ai and replacing the duplicate data middle byte Bi with the original data middle byte Bi ';
when the byte Ai of the head of the original data, the byte Bi in the middle of the original data, the byte Ai 'of the head of the copy data and the byte Bi' in the middle of the copy data are normal and the byte Ci of the middle of the copy data is wrong, a new error correcting byte Ci is determined by recalculation.
Further, the determining the length of the positive copy byte array according to the length of the positive copy corresponding to the positive copy byte array, the length of the copy corresponding to the copy byte array, and the length of the error correction code byte array specifically includes:
comparing the original length, the copy length and the error correction code length to obtain a corresponding comparison result; the length of the error correcting code is the actual length of the byte array of the error correcting code;
when the original length is equal to the copy length, determining that the length of an original copy byte array is the original length or the copy length, and the length of the error correcting code byte array is (original length +1)/2 or (copy length + 1)/2;
when the positive copy length is not equal to the copy length and the (positive copy length +1)/2 is equal to the error correction code length, determining the positive copy byte array length as the positive copy length; the length of the error correcting code byte array is (original length + 1)/2;
when the positive copy length is not equal to the copy length and the (copy length +1)/2 is equal to the error correction code length, determining that the positive copy byte array length is the copy length and the error correction code byte array length is (copy length + 1)/2;
when the original length is larger than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the original length, and the length of the byte array of the error correction code is (original length + 1)/2;
when the original length is smaller than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the copy length, and the length of the byte array of the error correction code is (copy length + 1)/2;
wherein the length of the error correction code byte array takes the value of an integer bit.
First, the implementation defines src data as a positive byte array, and src len is the length of the positive byte array. cpydata is the copy byte array and cpyLen is the copy data length. corrdata is an error correction code byte array, and corrLen is the error correction code length. The byte of the head of the Ai positive byte array, the byte of the middle of the Bi positive byte array, the byte of the head of the Ai 'copy byte array, the byte of the middle of the Bi' copy byte array, and the byte of the Ci error correction code.
iF1 is 0; v number of bytes that normally did not require correction after comparison statistics/512. The byte number of the positive byte array or the copy byte array is maximum 512 bytes.
iF2 is 0; v. correcting the number of bytes in the positive byte array using the bytes in the duplicate byte array +
iF3 is 0; v. correcting the number of bytes in the replica byte array using the bytes in the positive byte array +
iF4 is 0; v. correcting the middle byte in the duplicate byte array using the middle byte in the positive byte array and correcting the byte count of the head byte in the duplicate byte array using the head byte in the duplicate byte array +
iF5 is 0; v. correcting the head byte in the duplicate byte array using the head byte in the positive byte array, and correcting the byte count of the middle byte in the duplicate byte array using the middle byte in the duplicate byte array +
iF6 is 0; v. number of bytes of reconstructed error correction code byte +
iF7 is 0; i/other Condition false alarm, not corrected
The steps of the above embodiment are implemented according to the following code:
Figure BDA0001823479390000171
/corrLen takes the real length of the array of error correction code bytes, but is at most (defaultMaxLen +1)/2 ×/greater-
The value of the length of the byte array of the positive copy is very important, otherwise the memory overflow-
Comparing the positive length and the duplicate length, if the positive length is the duplicate length, taking the positive duplicate byte array length as the positive length or the duplicate length as the backup length
1, comparing the original length with the copy length, and if the original length is not equal to the copy length and (the original length +1)/2 is equal to the error correcting code length, taking the byte array length of the positive copy as the original length;
comparing the positive copy length with the copy length, and if the positive copy length is not equal to the copy length and (copy length +1)/2 is equal to the error correction code length, taking the positive copy byte array length as the copy length;
and 3, comparing the original length with the copy length, and if 0, 1 and 2 are not true, taking the length of the byte array of the positive copy as MAX { the original length and the copy length }, namely the larger length after comparing the original length with the copy length. */
/. 4, the error correction code byte array length corrLen is the true length of the error correction code byte array, but is at most (defaultMaxLen +1)/2 × ^ greater than
Specifically, if the defaultMaxLen is an odd number, that is, the length of the positive copy byte array is an odd number, the byte length of the error correction code is less than or equal to (defaultMaxLen + 1)/2. If the defaultMaxLen is even, the byte length of the error correcting code is less than or equal to (defaultMaxLen)/2.
The original length, the copy length and the error correcting code length are obtained, and comparison can be carried out between the original length, the copy length and the error correcting code length to judge whether errors occur due to the influence of external factors. For example, when the length of the positive copy byte array is 20, the length of the copy is 28, and the length of the error correction code is 100, the maximum value of the length of the error correction code can be known to be 28 according to the maximum value of the length of the error correction code being the length of the positive copy byte array, so that it is indicated that the error correction code byte array has an error, and a new error correction code byte array needs to be obtained by recalculation according to the positive copy byte array.
Figure BDA0001823479390000181
Figure BDA0001823479390000191
Figure BDA0001823479390000201
Figure BDA0001823479390000211
Specifically, when the original byte array is obtained, the original byte array is simultaneously stored in different storage paths to obtain a corresponding original byte array and a corresponding copy byte array. And (4) performing even number compensation on the positive byte array, and then folding the positive byte array back and forth. And (4) performing even number padding on the copy byte array, and then folding the copy byte array back and forth. Defining A as the head byte of the array and B as the middle byte of the array, namely:
for(i=0;i<(srcLen+1)/2;i++){A=srcdata[i];B=srcdata[(srcLen+1)/2+i];}
defining C as an error correction code byte, and calculating to obtain the error correction code byte C ═ A ^ B;
thus, a positive data head byte array { A1, … …, Ai }, a positive data middle byte array { B1, … …, Bi }, a copy data head byte array { A1 ', … …, Ai' } and a copy data middle byte array { B1 ', … …, Bi' }; i is more than or equal to 1 and is an even number; and calculating Ci1, Ci2, Ci Ai Bi ', Ci1, Ci1, Ci Ai ' Bi ', so as to obtain final Ci, sequentially obtaining C1, C2, … … and Ci, and then sequentially arranging the C1, the C2, the C … … and the Ci to obtain an error correction code byte array. And assembling according to the positive byte array, the copy byte array and the error correction code byte array to obtain a target byte array Data (positive byte array) (copy byte array) (error correction code byte array), and performing Data transmission or Data storage. After a target byte array Data (a positive byte array) (a copy byte array) (an error correction code byte array) is obtained through transmission or the target byte array Data (the positive byte array) (the copy byte array) (the error correction code byte array) is obtained through reading, verification operation is carried out according to a positive Data head byte Ai of the positive byte array, a positive Data middle byte Bi, a copy Data head byte Ai 'of the copy byte array, a copy Data middle byte Bi' and a corresponding error correction code byte Ci to obtain a verification result, so that a correct original byte array is obtained through correction according to the verification result, and the integrity, the consistency and the accuracy of the original byte array are further guaranteed.
The embodiment of the invention provides intelligent equipment for checking and correcting a byte array, which comprises:
the acquisition module is used for acquiring a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
the length determining module is connected with the acquiring module and used for determining the length of the positive copy byte array and the length of the error correcting code byte array according to the original length corresponding to the original byte array, the copy length corresponding to the copy byte array and the error correcting code length corresponding to the error correcting code byte array;
the data complementing module is connected with the length determining module and used for carrying out tail end complementing random numerical values on the positive copy byte array and/or the copy byte array according to the length of the positive copy byte array so as to enable the positive copy length to be equal to the copy length; the random number value is a constant;
the operation module is connected with the data completion module and is used for carrying out check operation according to the head byte and the middle byte of the original data of the original byte array, the head byte and the middle byte of the copy data of the copy byte array and the corresponding error correction code byte to obtain a check result;
and the processing module is connected with the operation module and used for correcting to obtain a correct original byte array according to the check result.
Specifically, the smart device includes a mobile phone, a computer, a smart phone watch, and the like having a data transmission function or a data storage function. In addition, this embodiment is a device embodiment corresponding to the above method embodiment, and specific effects refer to the above method embodiment, which is not described in detail herein.
Preferably, the obtaining module includes:
the processing unit is used for processing the byte array to be processed to obtain a positive byte array and a copy byte array;
the operation unit is connected with the processing unit and used for obtaining an error correcting code byte array according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
and the acquisition unit is connected with the operation unit and is used for assembling the original byte array, the copy byte array and the error correction code byte array into a target byte array so as to carry out data transmission or data storage.
The present embodiment is a device embodiment corresponding to the above method embodiment, and specific effects refer to the above method embodiment, which is not described herein again.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (5)

1. A method for performing a parity check correction on a byte array, comprising the steps of:
obtaining a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
the obtaining the target byte array specifically includes:
processing the byte array to be processed to obtain a positive byte array and a copy byte array; respectively storing byte data to be processed into two storage addresses to obtain a positive byte array and a copy byte array;
carrying out byte quantity statistics on the positive byte array or the copy byte array to obtain a byte quantity result;
when the result of the byte number is an odd number, performing end-filling on the original byte array or the copy byte array to obtain a preset value, so that the byte number of the original byte array or the copy byte array is an even number; the preset value is zero;
obtaining an error correcting code byte array according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
the operation of obtaining the error correction code byte array according to the positive byte array or the copy byte array specifically comprises the following steps:
symmetrically dividing the original data head byte array or the copy byte array to obtain the original data head byte array, the original data middle byte array, the copy data head byte array and the copy data middle byte array;
according to the head byte of the original data and the middle byte of the original data, carrying out XOR operation on the head byte of the copy data and the middle byte of the copy data to obtain the error correcting code byte;
the obtaining the error correction code byte by performing xor operation on the copy data header byte and the copy data middle byte according to the copy data header byte and the copy data middle byte specifically includes:
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the original data to obtain a first byte of an error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the copy data to obtain a second undetermined error correction code byte;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the original data to obtain a third byte of the error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the copy data to obtain a fourth byte of the error correcting code to be determined;
counting the occurrence times corresponding to each undetermined error correction code byte, and determining the undetermined error correction code byte with the largest occurrence times as a final error correction code byte;
arranging the error correcting code bytes obtained by operation corresponding to the arrangement sequence of the original byte array or the copy byte array to obtain the error correcting code byte array;
assembling the positive byte array, the copy byte array and the error correcting code byte number into a target byte array so as to carry out data transmission or data storage;
determining the length of the positive copy byte array and the length of the error correcting code byte array according to the positive length corresponding to the positive byte array, the copy length corresponding to the copy byte array and the error correcting code length corresponding to the error correcting code byte array;
according to the length of the byte array of the positive copy, the random value of the tail end of the byte array of the positive copy and/or the byte array of the copy is filled, so that the length of the positive copy is equal to the length of the copy; the random number value is a constant;
performing check operation according to the head byte and the middle byte of the original data of the original byte array, the head byte and the middle byte of the copy data of the copy byte array and the corresponding error correction code byte to obtain a check result;
and correcting according to the check result to obtain a correct original byte array.
2. The method according to claim 1, wherein the performing the check operation according to the header byte of the original data, the middle byte of the original data, the header byte of the copy data, the middle byte of the copy data, and the corresponding error correction code byte of the copy byte array to obtain the check result specifically includes:
when the exclusive-or operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte, and the exclusive-or operation result of the head byte of the original data and the middle byte of the copy data is equal to the exclusive-or operation result of the head byte of the copy data and the middle byte of the original data, determining that the head byte of the original data, the middle byte of the original data, the head byte of the copy data and the middle byte of the copy data are normal;
when the exclusive-or operation result of the head byte of the original data and the middle byte of the original data is not equal to the error correction code byte, and the exclusive-or operation result of the head byte of the copy data and the middle byte of the copy data is equal to the error correction code byte, determining that the head byte of the original data and the middle byte of the original data are in error, and the head byte of the copy data and the middle byte of the copy data are normal;
when the XOR operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte and the XOR operation result of the head byte of the duplicate data and the middle byte of the duplicate data is not equal to an error correction code byte, determining that the head byte of the duplicate data and the middle byte of the duplicate data are in error and the head byte of the original data and the middle byte of the original data are normal;
when the XOR operation result of the head byte of the original data and the middle byte of the copy data is not equal to the error correction code byte and the XOR operation result of the head byte of the copy data and the middle byte of the original data is equal to the error correction code byte, determining that the head byte of the original data and the middle byte of the copy data are in error and the head byte of the copy data and the middle byte of the original data are normal;
when the XOR operation result of the head byte of the duplicate data and the middle byte of the original data is not equal to the error correction code byte, and the XOR operation result of the head byte of the original data and the middle byte of the duplicate data is equal to the error correction code byte, determining that the head byte of the duplicate data and the middle byte of the original data are in error, and the head byte of the original data and the middle byte of the duplicate data are normal;
and when the XOR operation result of the head byte of the original data and the middle byte of the original data is equal to an error correction code byte, and the XOR operation result of the head byte of the original data and the middle byte of the copy data is equal to the XOR operation result of the head byte of the copy data and the middle byte of the original data, determining that the head byte of the original data, the middle byte of the original data, the head byte of the copy data and the middle byte of the copy data are normal, and determining that the error correction code byte is in error.
3. The method for performing check correction on a byte array according to claim 2, wherein the step of obtaining a correct original byte array by correction according to the check result specifically comprises the steps of:
when the head byte of the original data and the middle byte of the original data are in error and the head byte of the duplicate data and the middle byte of the duplicate data are normal, replacing the head byte of the original data with the head byte of the duplicate data and replacing the middle byte of the original data with the middle byte of the duplicate data;
when the head byte of the duplicate data and the middle byte of the duplicate data are in error and the head byte of the original data and the middle byte of the original data are normal, replacing the head byte of the duplicate data with the head byte of the original data and replacing the middle byte of the duplicate data with the middle byte of the original data;
when the head byte of the original data and the middle byte of the duplicate data are in error and the head byte of the duplicate data and the middle byte of the original data are normal, replacing the head byte of the original data with the head byte of the duplicate data and replacing the middle byte of the original data with the middle byte of the duplicate data;
when the head byte of the duplicate data and the middle byte of the original data are in error and the head byte of the original data and the middle byte of the duplicate data are normal, replacing the head byte of the duplicate data with the head byte of the original data and replacing the middle byte of the duplicate data with the middle byte of the original data;
and when the byte of the head of the original data, the byte of the middle part of the original data, the byte of the head of the copy data and the byte of the middle part of the copy data are normal and the error correction code byte has an error, re-operating to determine a new error correction code byte.
4. The method according to any of claims 1 to 3, wherein the determining the length of the positive-copy byte array according to the length of the positive-copy byte array, the length of the copy byte array, and the length of the error-correcting code byte array includes:
comparing the original length, the copy length and the error correction code length to obtain a corresponding comparison result; the length of the error correcting code is the actual length of the byte array of the error correcting code;
when the original length is equal to the copy length, determining that the length of an original copy byte array is the original length or the copy length, and the length of the error correcting code byte array is (original length +1)/2 or (copy length + 1)/2;
when the positive copy length is not equal to the copy length and the (positive copy length +1)/2 is equal to the error correction code length, determining the positive copy byte array length as the positive copy length; the length of the error correcting code byte array is (original length + 1)/2;
when the positive copy length is not equal to the copy length and the (copy length +1)/2 is equal to the error correction code length, determining that the positive copy byte array length is the copy length and the error correction code byte array length is (copy length + 1)/2;
when the original length is larger than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the original length, and the length of the byte array of the error correction code is (original length + 1)/2;
when the original length is smaller than the copy length, the (original length +1)/2 is not equal to the error correction code length, and the (copy length +1)/2 is not equal to the error correction code length, determining that the length of the byte array of the original copy is the copy length, and the length of the byte array of the error correction code is (copy length + 1)/2;
wherein the length of the error correction code byte array takes the value of an integer bit.
5. An intelligent device for verifying and correcting byte arrays, comprising:
the acquisition module is used for acquiring a target byte array; the target byte array comprises a positive byte array, a copy byte array and an error correcting code byte array;
the acquisition module includes:
the processing unit is used for processing the byte array to be processed to obtain a positive byte array and a copy byte array; carrying out byte quantity statistics on the positive byte array or the copy byte array to obtain a byte quantity result; when the result of the byte number is an odd number, performing end-filling on the original byte array or the copy byte array to obtain a preset value, so that the byte number of the original byte array or the copy byte array is an even number; the preset value is zero; respectively storing byte data to be processed into two storage addresses to obtain a positive byte array and a copy byte array;
the operation unit is connected with the processing unit and used for obtaining an error correcting code byte array according to the operation of the positive byte array or the copy byte array; the error correction code byte array comprises a plurality of error correction code bytes which are arranged in sequence;
the operation of obtaining the error correction code byte array according to the positive byte array or the copy byte array specifically comprises the following steps:
symmetrically dividing the original data head byte array or the copy byte array to obtain the original data head byte array, the original data middle byte array, the copy data head byte array and the copy data middle byte array;
according to the head byte of the original data and the middle byte of the original data, carrying out XOR operation on the head byte of the copy data and the middle byte of the copy data to obtain the error correcting code byte;
the obtaining the error correction code byte by performing xor operation on the copy data header byte and the copy data middle byte according to the copy data header byte and the copy data middle byte specifically includes:
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the original data to obtain a first byte of an error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the original data and the byte at the middle of the copy data to obtain a second undetermined error correction code byte;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the original data to obtain a third byte of the error correcting code to be determined;
performing exclusive-or operation on the byte at the head of the copy data and the byte at the middle of the copy data to obtain a fourth byte of the error correcting code to be determined;
counting the occurrence times corresponding to each undetermined error correction code byte, and determining the undetermined error correction code byte with the largest occurrence times as a final error correction code byte;
arranging the error correcting code bytes obtained by operation corresponding to the arrangement sequence of the original byte array or the copy byte array to obtain the error correcting code byte array;
the acquisition unit is connected with the operation unit and is used for assembling the original byte array, the copy byte array and the error correction code byte array into a target byte array so as to carry out data transmission or data storage;
the length determining module is connected with the acquiring module and used for determining the length of the positive copy byte array and the length of the error correcting code byte array according to the original length corresponding to the original byte array, the copy length corresponding to the copy byte array and the error correcting code length corresponding to the error correcting code byte array;
the data complementing module is connected with the length determining module and used for carrying out tail end complementing random numerical values on the positive copy byte array and/or the copy byte array according to the length of the positive copy byte array so as to enable the positive copy length to be equal to the copy length; the random number value is a constant;
the operation module is connected with the data completion module and is used for carrying out check operation according to the head byte and the middle byte of the original data of the original byte array, the head byte and the middle byte of the copy data of the copy byte array and the corresponding error correction code byte to obtain a check result;
and the processing module is connected with the operation module and used for correcting to obtain a correct original byte array according to the check result.
CN201811174926.7A 2018-10-09 2018-10-09 Method for checking and correcting byte array and intelligent equipment Active CN109324920B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811174926.7A CN109324920B (en) 2018-10-09 2018-10-09 Method for checking and correcting byte array and intelligent equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811174926.7A CN109324920B (en) 2018-10-09 2018-10-09 Method for checking and correcting byte array and intelligent equipment

Publications (2)

Publication Number Publication Date
CN109324920A CN109324920A (en) 2019-02-12
CN109324920B true CN109324920B (en) 2022-03-04

Family

ID=65261152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811174926.7A Active CN109324920B (en) 2018-10-09 2018-10-09 Method for checking and correcting byte array and intelligent equipment

Country Status (1)

Country Link
CN (1) CN109324920B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02309821A (en) * 1989-05-25 1990-12-25 Fujitsu Ltd Fano type successive decoder
CN102356384A (en) * 2011-08-23 2012-02-15 华为技术有限公司 Method and device for data reliability detection
CN103744750A (en) * 2014-01-13 2014-04-23 杭州华为数字技术有限公司 Method and device for recovering data
CN104052576A (en) * 2014-06-07 2014-09-17 华中科技大学 Data recovery method based on error correcting codes in cloud storage
CN106844098A (en) * 2016-12-29 2017-06-13 中国科学院计算技术研究所 A kind of fast data recovery method and system based on right-angled intersection erasure code

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02309821A (en) * 1989-05-25 1990-12-25 Fujitsu Ltd Fano type successive decoder
CN102356384A (en) * 2011-08-23 2012-02-15 华为技术有限公司 Method and device for data reliability detection
CN103744750A (en) * 2014-01-13 2014-04-23 杭州华为数字技术有限公司 Method and device for recovering data
CN104052576A (en) * 2014-06-07 2014-09-17 华中科技大学 Data recovery method based on error correcting codes in cloud storage
CN106844098A (en) * 2016-12-29 2017-06-13 中国科学院计算技术研究所 A kind of fast data recovery method and system based on right-angled intersection erasure code

Also Published As

Publication number Publication date
CN109324920A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
US5517508A (en) Method and apparatus for detection and error correction of packetized digital data
US8127212B2 (en) System and method for determining the fault-tolerance of an erasure code
US20040117722A1 (en) Performance of communication systems using forward error correction
US20050132259A1 (en) Error correction method and system
EP2533450A1 (en) Method and device for data check processing
CN112380046B (en) Calculation result verification method, system, device, equipment and storage medium
US20120245793A1 (en) Multi-cell voltage secure data encoding in hybrid vehicles
CN105528183B (en) A kind of method and storage equipment of storing data
EP1762006A1 (en) Data processing
CN109324920B (en) Method for checking and correcting byte array and intelligent equipment
CN105007286B (en) Coding/decoding method and device and cloud storage method and system
CN111464267A (en) Communication data checking method and device, computer equipment and storage medium
CN1750411A (en) Detecting data module for detecting cyclic redundency code calculation
CN112189315A (en) Progressive length error control code
CN115129509A (en) Data transmission method, device and medium
US7424667B2 (en) Digital data transmission error checking method and system
CN114866445A (en) Communication system, communication method and electronic terminal
CN109753369B (en) Data coding and checking method for sequence array in register and memory
CN114564336A (en) Data consistency checking method, device, equipment and storage medium
JP3059305B2 (en) Transmission error detection method and transmission system using the same
CN100418312C (en) Digital data transmission error-detecting method and system
JP6813637B1 (en) Transmission device and transmission method
CN114595486B (en) Zero data identification method and device, readable storage medium and electronic equipment
CN110504976B (en) Polar code decoding method and device
CN116108022B (en) Electric energy meter data storage method, device, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200108

Address after: 310051 room 906, North block, building 9, No. 88, Jiangling Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Hangzhou rabbit small two Technology Industry Co., Ltd

Address before: Room 418, 123 Building No. 1 Fengcheng Road, Yangpu District, Shanghai

Applicant before: Shanghai Rabbit Little Two Technology Co., Ltd.

GR01 Patent grant
GR01 Patent grant