Data transmission method and device, equipment and storage medium
By adding check bits to the data in the I2C protocol and using XOR operation to determine the check bits, the problem of traditional I2C protocol lacking data verification is solved, data correctness verification is achieved, and data transmission security and reliability are improved.
Patent Information
- Application Number
- CN202510120766.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-13
AI Technical Summary
The traditional I2C protocol lacks data verification function, which causes the receiver to be unable to verify whether the received data is correct, which may lead to incorrect use of data.
The data sender adds multiple check bits to the original data, and determines the check bits through XOR operation, and adds them to the data, so that the receiver can use these check bits to verify the data accuracy.
Through the use of the check bit, the receiver can effectively verify whether the received data is correct, avoid incorrect data use, and improve the security and reliability of data transmission.
Smart Images

Figure CN119988294A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data transmission, and in particular to a data transmission method, device, equipment and storage medium. Background Art
[0002] I2C (Inter Integrated Circuit Bus) is a simple half-duplex two-wire universal bus protocol standard and a serial communication bus. The traditional I2C protocol has two receipt mechanisms: ACK (Acknowledge character) and NACK (Negative Acknowledgement character). ACK and NACK are both transmission control characters that the receiver feeds back to the sender after receiving the data sent by the sender. ACK means that the data sent by the sender has been received and requests to start the next data transmission. NACK means that the data sent by the sender has been received, but the next data transmission will not be received, and requests to end the data transmission.
[0003] Whether it is ACK or NACK, it can only tell the sender: "The receiver has received the data sent", but because the receiver lacks the function of verifying the data, that is, the receiver cannot verify whether the received data is correct, if the data is transmitted and the bit jumps from 01 due to interference, the receiver will receive wrong data, and the receiver cannot verify whether the received data is the original data sent by the sender, which may lead to many unexpected situations due to the use of wrong data.
[0004] It can be seen that how to verify the received data at the data receiving party is a problem that those skilled in the art need to solve. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a data transmission method, apparatus, device and storage medium, which can add multiple check bits to the original data at the sender, so that the receiver can use the check bits to check the correctness of the received data, thereby preventing the receiver from using wrong data. The specific scheme is as follows:
[0006] In a first aspect, the present invention provides a data transmission method, applied to a data sender, comprising:
[0007] Using a first preset number of bits to split the original data to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers;
[0008] Performing an XOR operation on each binary number in each group of data to be transmitted, and determining a first XOR operation result as a check bit of the corresponding group of data to be transmitted;
[0009] Adding each check bit to a corresponding set of data to be transmitted to obtain multiple sets of updated data, and encapsulating the multiple sets of updated data to obtain encapsulated data;
[0010] The encapsulated data is transmitted to the data receiver through the data bus, so that the data receiver can use the check bit to check the correctness of the received data, and send the corresponding confirmation character to the data sender based on the correctness check result.
[0011] Optionally, the data bus is an integrated circuit bus; the original data is data using a bus protocol corresponding to the data bus;
[0012] Accordingly, multiple groups of updated data are encapsulated to obtain encapsulated data, including:
[0013] The multiple groups of updated data are encapsulated using a bus protocol corresponding to the data bus to obtain encapsulated data.
[0014] Optionally, when data is transmitted in bytes, the first preset number of bits is the number of bits corresponding to one byte minus one;
[0015] Accordingly, each check bit is added to a corresponding set of data to be transmitted to obtain multiple sets of updated data, including:
[0016] Each check bit is added to a corresponding group of data to be transmitted, so as to restore the number of bits of the binary numbers contained in each group of updated data to the number of bits corresponding to one byte.
[0017] Optionally, the data transmission method of the present invention further includes:
[0018] When the encapsulated data is transmitted to the data receiving party through the data bus, the encapsulated data is stored in a high-speed buffer on the data bus, and a timer is controlled to start timing from zero;
[0019] If the current timing of the timer reaches the preset time length and the data sender does not receive the confirmation character sent by the data receiver, the high-speed buffer is called to perform a fast retransmission operation to retransmit the encapsulated data stored in the buffer to the data receiver, and the process jumps to the step of controlling the timer to start timing from zero;
[0020] If the current timing of the timer does not reach the preset time and the data sender receives a confirmation character sent by the data receiver, a corresponding operation is performed based on the currently received confirmation character;
[0021] Wherein, when the currently received confirmation character is the first confirmation character indicating that the data verification is correct and requesting to start the next data transmission, the next data transmission is started based on the currently received confirmation character;
[0022] When the currently received confirmation character is a second confirmation character indicating that the data verification is correct and requesting to end the data transmission, the data transmission is ended based on the currently received confirmation character;
[0023] When the currently received confirmation character is the third confirmation character indicating a data verification error, the process jumps again to the step of calling the high-speed buffer to perform a fast retransmission operation based on the currently received confirmation character.
[0024] Optionally, the encapsulated data is transmitted to a data receiver through a data bus so that the data receiver uses a check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result, including:
[0025] The encapsulated data is transmitted to the data receiver via the data bus so that the data receiver can use the check bit to check the correctness of the received data, and determine the corresponding confirmation character based on the correctness check result and / or data transmission requirements, and then send the determined confirmation character to the data sender.
[0026] Optionally, the encapsulated data is transmitted to a data receiver through a data bus so that the data receiver uses a check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result, including:
[0027] Transmit the encapsulated data to the data receiver through the data bus, so that the data receiver uses the second preset bit number to split the received data to obtain multiple groups of split data, and performs an XOR operation on the target binary number in each group of split data, so as to determine the correctness check result of the received data based on the consistency of the second XOR operation result and the check bit in the corresponding group of split data, and send a corresponding confirmation character to the data sender based on the correctness check result;
[0028] The second preset number of digits is the sum of the first preset number of digits and the check digit; the target binary number is the other binary numbers except the check digit in each group of split data.
[0029] Optionally, the data transmission method of the present invention further includes:
[0030] Transmitting the encapsulated data to a data receiver through a data bus so that the data receiver can use the check bit to check the correctness of the received data to obtain a correctness check result, and when the correctness check result indicates that the received data is correctly checked, deleting the check bit in each group of split data to obtain multiple groups of deleted data, and recombining the multiple groups of deleted data to obtain recombined data;
[0031] Among them, the reorganized data is the same as the original data.
[0032] In a second aspect, the present invention provides a data transmission device, applied to a data sender, comprising:
[0033] A data splitting module, used to split the original data using a first preset number of bits to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers;
[0034] A check bit determination module, used for performing an XOR operation on each binary number in each group of data to be transmitted, and determining a first XOR operation result as a check bit of the corresponding group of data to be transmitted;
[0035] A check bit adding module, used for adding each check bit to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and encapsulating the multiple groups of updated data to obtain encapsulated data;
[0036] The data transmission module is used to transmit the encapsulated data to the data receiver through the data bus, so that the data receiver can use the check bit to check the correctness of the received data and send the corresponding confirmation character to the data sender based on the correctness check result.
[0037] In a third aspect, the present invention provides an electronic device, comprising:
[0038] Memory for storing computer programs;
[0039] The processor is used to execute the computer program to implement the aforementioned data transmission method.
[0040] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the aforementioned data transmission method when executed by a processor.
[0041] In the present invention, a data sender uses a first preset bit number to split the original data to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers; an XOR operation is performed on each binary number in each group of data to be transmitted, and the first XOR operation result is determined as a check bit of a corresponding group of data to be transmitted; each check bit is added to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and the multiple groups of updated data are encapsulated to obtain encapsulated data; the encapsulated data is transmitted to a data receiver via a data bus, so that the data receiver uses the check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result.
[0042] Beneficial effect: The present invention splits the original data at the data sender, and performs an XOR operation on each binary number in each group of data after the split, so as to use the XOR operation result as the check bit of the corresponding group of data, and add it back to the corresponding group of data, thereby adding a corresponding check bit to each group of data after the split, and then encapsulating each group of data with the added check bit and transmitting it to the data receiver. In this way, after receiving the data, the data receiver can use multiple check bits to jointly check the correctness of the received data to determine whether the received data is correct data, thereby avoiding the data receiver from using wrong data, and improving the accuracy of data correctness verification through multiple check bits, as well as improving the security and reliability of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A flow chart of a data transmission method provided by an embodiment of the present invention;
[0045] Figure 2 A data transmission flow chart provided by an embodiment of the present invention;
[0046] Figure 3 A data processing flow chart of a data sender provided by an embodiment of the present invention;
[0047] Figure 4 A data processing flow chart of a data receiving party provided by an embodiment of the present invention;
[0048] Figure 5 Another data processing flow chart of a data sender provided by an embodiment of the present invention;
[0049] Figure 6 A schematic diagram of the structure of a data transmission device provided by an embodiment of the present invention;
[0050] Figure 7 A structural diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] Since the receiving party lacks the function of verifying the data, that is, the receiving party cannot verify whether the received data is correct, if the data is transmitted and the bit position changes from 0 to 1 due to interference, the receiving party receives the wrong data, and the receiving party cannot verify whether the received data is the original data sent by the sender, which may cause many unexpected situations due to the use of wrong data. To this end, the present invention provides a data transmission method, by adding multiple check bits to the original data at the sending party, so that the receiving party can use the check bits to verify the correctness of the received data, thereby preventing the receiving party from using wrong data.
[0053] See also Figure 1 As shown, an embodiment of the present invention provides a data transmission method, which is applied to a data sender, and includes:
[0054] Step S11, splitting the original data using a first preset bit number to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers.
[0055] In an embodiment of the present invention, a data sender obtains original data sent by an upper-layer application or hardware; wherein the upper-layer application or hardware transmits data using a bus protocol corresponding to a data bus; accordingly, the original data is data using a bus protocol corresponding to the data bus, and the original data is data based on binary numbers.
[0056] It should be noted that the data bus is also used to transmit data between a data sender and a data receiver. In an embodiment of the present invention, the data bus may be an integrated circuit bus I2C. Accordingly, the bus protocol corresponding to the data bus is the bus protocol corresponding to the integrated circuit bus I2C.
[0057] Furthermore, after acquiring the original data sent by the upper layer application or hardware, the data sender splits the original data using the first preset bit number to obtain multiple groups of data to be transmitted.
[0058] When the data bus is an integrated circuit bus I2C, considering that the original data varies in length but all adopt the format of the I2C protocol, that is, the original data is in groups of 8 bits and the data is transmitted in bytes, therefore, when adding check bits to the original data, the embodiment of the present invention needs to split the original data using the first preset number of bits to obtain multiple groups of data to be transmitted. The first preset number of bits is the number of bits corresponding to a byte minus one, that is, the first preset number of bits is 7 bits.
[0059] Step S12: performing an XOR operation on each binary number in each group of data to be transmitted, and determining a first XOR operation result as a check bit of the corresponding group of data to be transmitted.
[0060] In an embodiment of the present invention, after the original data is split into multiple groups of data to be transmitted, it is necessary to add corresponding check bits for each group of data to be transmitted, and the check bits for each group of data to be transmitted are determined by performing an XOR operation on each binary number in each group of data to be transmitted to obtain a first XOR operation result, and the first XOR operation result is determined as the check bit of the corresponding group of data to be transmitted.
[0061] Specifically, each binary number in each group of data to be transmitted is subjected to an XOR operation in sequence bit by bit, and finally a first XOR operation result is obtained; wherein the value of the first XOR operation result is 0 or 1. If the first XOR operation result is 0, it indicates that each binary number in the corresponding group of data to be transmitted contains an even number of 1s; if the first XOR operation result is 1, it indicates that each binary number in the corresponding group of data to be transmitted contains an odd number of 1s.
[0062] Taking the first preset bit number as 7 bits and a group of data to be transmitted as 1000111 as an example, each binary number in the group of data to be transmitted is XORed bit by bit, and the final first XOR operation result is 0, so the check bit of the group of data to be transmitted is 0.
[0063] Step S13: adding each check bit to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and encapsulating the multiple groups of updated data to obtain encapsulated data.
[0064] In the embodiment of the present invention, after obtaining the check bits of each group of data to be transmitted, each check bit is added to the corresponding group of data to be transmitted to obtain multiple groups of updated data; each group of updated data is each group of data to be transmitted after adding the corresponding check bits. Since the data needs to be transmitted from the data sender to the data receiver via the data bus, it is also necessary to use the bus protocol corresponding to the data bus to encapsulate the multiple groups of updated data to obtain encapsulated data, so that the encapsulated data can be transmitted on the data bus.
[0065] It should be noted that, with regard to the location of adding the check bit, the check bit can be added to any position of the corresponding group of data to be transmitted; for example, the check bit can be added to the end of the corresponding group of data to be transmitted, or the check bit can be added to the beginning of the corresponding group of data to be transmitted, and the check bit can also be added to other positions of the corresponding group of data to be transmitted, without specific limitation here.
[0066] Furthermore, when data is transmitted in bytes and the first preset bit number is 7 bits, for the addition of each check bit, each check bit needs to be added to the corresponding group of data to be transmitted, so as to restore the number of bits of the binary numbers contained in each group of updated data to the number of bits corresponding to one byte, that is, each group of updated data includes eight binary bits.
[0067] Step S14: Transmit the encapsulated data to the data receiver via the data bus, so that the data receiver can use the check bit to check the correctness of the received data, and send a corresponding confirmation character to the data sender based on the correctness check result.
[0068] In an embodiment of the present invention, the data sender transmits the encapsulated data to the data receiver via a data bus. After receiving the data sent by the data sender, the data receiver uses each check bit to perform a correctness check on the received data to obtain a correctness check result, and then determines a corresponding confirmation character based on the correctness check result and / or the data transmission requirement of the data receiver, and sends the determined confirmation character to the data sender, so that the data sender knows the current data transmission situation and makes a corresponding response.
[0069] It should be noted that when the correctness check result indicates that the received data is correctly checked, the corresponding confirmation character is determined according to the data transmission requirement of the data receiver; if the data transmission requirement of the data receiver is to request to start the next data transmission, the confirmation character is determined as the first confirmation character; if the data transmission requirement of the data receiver is to request to end the data transmission, the confirmation character is determined as the second confirmation character. When the correctness check result indicates that the received data is incorrectly checked, the confirmation character is directly determined as the third confirmation character.
[0070] Furthermore, when the data sender transmits the encapsulated data to the data receiver via the data bus, it is also necessary to store the encapsulated data backup in the high-speed buffer on the data bus and control the timer to start timing from zero. If the current timing of the timer reaches the preset duration and the data sender does not receive the confirmation character sent by the data receiver, it indicates that the data transmission has timed out, and the data sender needs to call the high-speed buffer to perform a fast retransmission operation to retransmit the encapsulated data stored in the high-speed buffer to the data receiver, and then jump to the above-mentioned step of controlling the timer to start timing from zero. If the current timing of the timer does not reach the preset duration and the data sender receives the confirmation character sent by the data receiver, the data sender needs to perform corresponding operations based on the currently received confirmation character.
[0071] Among them, when the currently received confirmation character is the first confirmation character that indicates that the data verification is correct and requests to start the next data transmission, the data sender needs to start the next data transmission based on the currently received confirmation character; when the currently received confirmation character is the second confirmation character that indicates that the data verification is correct and requests to end the data transmission, the data sender needs to end the data transmission based on the currently received confirmation character; when the currently received confirmation character is the third confirmation character that indicates that the data verification is wrong, the data sender needs to jump to the above-mentioned step of calling the high-speed buffer to perform the fast retransmission operation based on the currently received confirmation character, so as to retransmit the encapsulated data stored in the high-speed buffer to the data receiver. In this way, the embodiment of the present invention sets a timer and a third confirmation character, so as to directly call the high-speed buffer on the data bus to retransmit the encapsulated data stored in itself to the data receiver when the data transmission times out or the data verification is wrong, thereby improving the efficiency of data retransmission.
[0072] In an embodiment of the present invention, a data sender transmits the encapsulated data to a data receiver via a data bus, so that the data receiver uses a second preset number of bits to split the received data to obtain multiple groups of split data, and performs an XOR operation on the target binary number in each group of split data, so as to determine the correctness check result of the received data based on the consistency of the second XOR operation result and the check bit in the corresponding group of split data, and send a corresponding confirmation character to the data sender based on the correctness check result; wherein the second preset number of bits is the sum of the first preset number of bits and the check bit; the target binary number is the other binary numbers in each group of split data except the check bit.
[0073] Specifically, for the determination of the correctness check result, after receiving the data sent by the data sender, the data receiver first splits the received data using the second preset number of bits to obtain multiple groups of split data; wherein the second preset number of bits is equal to the first preset number of bits plus a check bit. Then, other binary numbers except the check bit are determined from each group of split data to obtain the target binary number in each group of split data, and the target binary number in each group of split data is XORed to obtain the second XOR result. After that, the second XOR result is compared with the check bit in the corresponding group of split data for consistency, and the correctness check result of the received data is determined based on the consistency comparison result. Wherein, if the consistency comparison result indicates that each second XOR result is consistent with the check bit in the corresponding group of split data, then the correctness check result is determined to be correct for the received data; if the consistency comparison result indicates that each second XOR result is not consistent with the check bit in the corresponding group of split data, then the correctness check result is determined to be wrong for the received data.
[0074] Furthermore, the data sender transmits the encapsulated data to the data receiver via the data bus. After receiving the data sent by the data sender, the data receiver uses each check bit to check the correctness of the received data to obtain a correctness check result, and when the correctness check result indicates that the received data is correctly checked, the check bit in each group of split data is deleted to obtain multiple groups of deleted data, and the multiple groups of deleted data are reorganized to obtain reorganized data. The reorganized data is the same as the original data; the multiple groups of deleted data are the multiple groups of split data after the check bits are deleted.
[0075] Considering that when the original data is split using the first preset number of bits, the number of bits of the binary numbers in the last group of data to be transmitted obtained by the splitting may be less than the first preset number of bits, at this time, the last group of data to be transmitted can be padded with zeros to fill the number of bits of the binary numbers in the last group of data to be transmitted to the first preset number of bits. It should be noted that the zero-padding operation does not affect the XOR operation result of the binary number. Accordingly, after the number of bits of the binary numbers in the last group of data to be transmitted is padded to the first preset number of bits, an XOR operation is performed on each binary number in each group of data to be transmitted, and the first XOR operation result is determined as the check bit of the corresponding group of data to be transmitted, and then each check bit is added to the corresponding group of data to be transmitted to obtain multiple groups of updated data, and the multiple groups of updated data are encapsulated to transmit the encapsulated data to the data receiver through the data bus. In this way, the embodiment of the present invention can make the number of bits of the binary numbers in each group of data to be transmitted equal to the first preset number of bits through the zero-padding operation, and will not affect the XOR operation result of the binary numbers. At the same time, the number of bits of the binary numbers in each group of data to be transmitted after adding the corresponding check bits can be equal to the second preset number of bits, that is, the number of bits of the binary numbers in each group of updated data can be equal to the second preset number of bits.
[0076] Furthermore, after receiving the data sent by the data sender, the data receiver uses the second preset bit number to split the received data to obtain multiple groups of split data, and performs an XOR operation on the other binary numbers in each group of split data except the check bit to obtain a second XOR operation result, and then the correctness check result of the received data can be determined based on the consistency of the second XOR operation result and the check bit in the corresponding group of split data. If the correctness check result indicates that the received data is correctly checked, the check bit in each group of split data can be deleted, and the zeros added by the zero padding operation in the last group of split data can be deleted to obtain multiple groups of deleted data, and finally the multiple groups of deleted data can be reorganized to obtain the same reorganized data as the original data. In this way, the embodiment of the present invention can ensure that the encapsulated data is transmitted in the required data transmission unit without affecting the correctness of the reorganized data by introducing the zero padding operation.
[0077] Beneficial effect: The present invention splits the original data at the data sender, and performs an XOR operation on each binary number in each group of data after the split, so as to use the XOR operation result as the check bit of the corresponding group of data, and add it back to the corresponding group of data, thereby adding a corresponding check bit to each group of data after the split, and then encapsulating each group of data with the added check bit and transmitting it to the data receiver. In this way, after receiving the data, the data receiver can use multiple check bits to jointly check the correctness of the received data to determine whether the received data is correct data, thereby avoiding the data receiver from using wrong data, and improving the accuracy of data correctness verification through multiple check bits, as well as improving the security and reliability of data transmission.
[0078] When data is transmitted in bytes, the first preset number of bits is the number of bits corresponding to one byte minus one, that is, the first preset number of bits is seven bits. Based on this, taking the data bus as an integrated circuit bus, the first preset number of bits is seven bits, and the second preset number of bits is eight bits as an example, a data transmission method provided in an embodiment of the present invention is specifically described.
[0079] First, Figure 2 As shown, the data sender in the embodiment of the present invention includes a data processing module and a data transmission module, and the data receiver includes a data processing module. The data processing module in the data sender is mainly used to add a check bit to the original data to prepare for subsequent data transmission and verification; the data transmission module in the data sender is mainly used to transmit data and process the situation that needs to be retransmitted; the data processing module in the data receiver is mainly used to receive data from the data bus and perform a correctness check on the data, and then return the corresponding confirmation character according to the correctness check result.
[0080] Specifically, Figure 3 As shown, the data processing module in the data sender includes a long data splitting module, a check bit adding module and a data encapsulation module. The specific steps are: the data sender obtains the original data sent by the upper-layer application or hardware, and splits the original data using the first preset bit number through the long data splitting module in the data processing module to obtain multiple groups of data to be transmitted; then the check bit adding module in the data processing module performs an XOR operation on each binary number in each group of data to be transmitted, and determines the first XOR operation result as the check bit of the corresponding group of data to be transmitted, and then adds each check bit to the corresponding group of data to be transmitted to obtain multiple groups of updated data; further, the data encapsulation module in the data processing module uses the bus protocol corresponding to the data bus to encapsulate the multiple groups of updated data to obtain encapsulated data. Finally, the data sender transmits the encapsulated data to the data receiver through the data bus through the data transmission module.
[0081] Further, such as Figure 4 As shown, after receiving the data sent by the data sender, the data receiver splits the received data using a second preset bit number through the data processing module to obtain multiple groups of split data, and performs an XOR operation on other binary numbers in each group of split data except the check bit to obtain a second XOR operation result, and then determines the correctness check result of the received data based on the consistency of the second XOR operation result with the check bit in the corresponding group of split data, and determines the corresponding confirmation character based on the correctness check result and / or the data transmission requirement of the data receiver, and then sends the determined confirmation character to the data sender so that the data sender knows the current data transmission status and makes a corresponding response.
[0082] It should be noted that, when the correctness check result indicates that the received data is correctly verified and the data transmission requirement of the data recipient is a request to start the next data transmission, the confirmation character sent to the data sender is the first confirmation character; when the correctness check result indicates that the received data is correctly verified and the data transmission requirement of the data recipient is a request to end the data transmission, the confirmation character sent to the data sender is the second confirmation character; when the correctness check result indicates that the received data is incorrectly verified, the confirmation character sent to the data sender is the third confirmation character.
[0083] Furthermore, when the correctness check result indicates that the received data is correctly checked, the data receiver deletes the check bits in each group of split data to obtain multiple groups of deleted data, and reorganizes the multiple groups of deleted data to obtain reorganized data, and then sends the reorganized data to the corresponding hardware or upper-level application.
[0084] Among them, Figure 5As shown, when the data sender transmits the encapsulated data to the data receiver through the data bus, it is also necessary to store the encapsulated data backup in the high-speed buffer on the data bus, and control the timer to start timing from zero. If the current timing of the timer reaches the preset time length and the data sender does not receive the confirmation character sent by the data receiver, it is determined that the data transmission has timed out, and the high-speed buffer is called to perform a fast retransmission operation to retransmit the encapsulated data stored in the high-speed buffer to the data receiver, and then return to the above step of controlling the timer to start timing from zero. If the current timing of the timer does not reach the preset time length and the data sender receives the confirmation character sent by the data receiver, it is determined whether the currently received confirmation character is the third confirmation character (WRONG) representing a data check error; if the currently received confirmation character is the third confirmation character representing a data check error, the high-speed buffer is called based on the currently received confirmation character to perform a fast retransmission operation to retransmit the encapsulated data stored in the high-speed buffer to the data receiver, and the above step of controlling the timer to start timing from zero is returned. If the currently received confirmation character is not the third confirmation character indicating a data check error, then further determine whether the currently received confirmation character is the first confirmation character (ACK) indicating that the data check is correct and requests to start the next data transmission; if the currently received confirmation character is the first confirmation character indicating that the data check is correct and requests to start the next data transmission, then start the next data transmission based on the currently received confirmation character. If the currently received confirmation character is not the first confirmation character indicating that the data check is correct and requests to start the next data transmission, then the currently received confirmation character is the second confirmation character (NACK) indicating that the data check is correct and requests to end the data transmission, and at this time, the data transmission can be ended based on the currently received confirmation character.
[0085] It can be found that the embodiment of the present invention sets a timer and a third confirmation character that represents a data verification error, so that when a data transmission times out or a data verification error occurs, the high-speed buffer on the data bus is directly called to retransmit the encapsulated data stored in itself to the data receiver, thereby improving the efficiency of data retransmission.
[0086] Beneficial effect: The embodiment of the present invention splits the original data at the data sender, and performs an XOR operation on each binary number in each group of data after the split, so as to use the XOR operation result as the check bit of the corresponding group of data, and add it back to the corresponding group of data, thereby adding a corresponding check bit to each group of data after the split, and then encapsulating each group of data with the added check bit and transmitting it to the data receiver. In this way, after receiving the data, the data receiver can use multiple check bits to jointly check the correctness of the received data to determine whether the received data is correct data, thereby avoiding the data receiver from using wrong data, and improving the accuracy of data correctness verification through multiple check bits, as well as improving the security and reliability of data transmission.
[0087] See also Figure 6 As shown, an embodiment of the present invention provides a data transmission device, which is applied to a data sender, including:
[0088] The data splitting module 11 is used to split the original data using a first preset number of bits to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers;
[0089] A check bit determination module 12, configured to perform an XOR operation on each binary number in each group of data to be transmitted, and determine a first XOR operation result as a check bit of the corresponding group of data to be transmitted;
[0090] A check bit adding module 13 is used to add each check bit to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and to encapsulate the multiple groups of updated data to obtain encapsulated data;
[0091] The data transmission module 14 is used to transmit the encapsulated data to the data receiver through the data bus, so that the data receiver can use the check bit to check the correctness of the received data and send a corresponding confirmation character to the data sender based on the correctness check result.
[0092] Since the embodiments of the device part correspond to the above embodiments, please refer to the description of the embodiments of the method part for the embodiments of the device part, and will not be repeated here.
[0093] Beneficial effect: The present invention splits the original data at the data sender, and performs an XOR operation on each binary number in each group of data after the split, so as to use the XOR operation result as the check bit of the corresponding group of data, and add it back to the corresponding group of data, thereby adding a corresponding check bit to each group of data after the split, and then encapsulating each group of data with the added check bit and transmitting it to the data receiver. In this way, after receiving the data, the data receiver can use multiple check bits to jointly check the correctness of the received data to determine whether the received data is correct data, thereby avoiding the data receiver from using wrong data, and improving the accuracy of data correctness verification through multiple check bits, as well as improving the security and reliability of data transmission.
[0094] Furthermore, the present application also discloses an electronic device. Figure 7 This is a structural diagram of an electronic device according to an exemplary embodiment, and the content of the diagram cannot be regarded as any limitation on the scope of use of this application. The electronic device may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the data transmission method disclosed in any of the aforementioned embodiments. In addition, the electronic device in this embodiment may specifically be an electronic computer.
[0095] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0096] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0097] The operating system 221 is used to manage and control various hardware devices on the electronic device and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the data transmission method performed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0098] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed data transmission method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.
[0099] Furthermore, the present application also discloses a computer program product, including a computer program / instruction; wherein the computer program / instruction, when executed by a processor, implements the aforementioned disclosed data transmission method. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0100] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0101] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0102] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0103] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0104] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data transmission method, characterized in that: Applicable to data senders, including: Using a first preset number of bits to split the original data to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers; Performing an XOR operation on each binary number in each group of data to be transmitted, and determining a first XOR operation result as a check bit of the corresponding group of data to be transmitted; Adding each of the check bits to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and encapsulating the multiple groups of updated data to obtain encapsulated data; The encapsulated data is transmitted to a data receiver via a data bus, so that the data receiver uses the check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result.
2. The data transmission method according to claim 1, characterized in that: The data bus is an integrated circuit bus; the original data is data using a bus protocol corresponding to the data bus; Accordingly, encapsulating the multiple groups of updated data to obtain encapsulated data includes: The multiple groups of updated data are encapsulated using a bus protocol corresponding to the data bus to obtain encapsulated data.
3. The data transmission method according to claim 1, characterized in that: When data transmission is performed in bytes, the first preset number of bits is the number of bits corresponding to one byte minus one; Correspondingly, the checking bits are added to a corresponding group of data to be transmitted to obtain multiple groups of updated data, including: Each of the check bits is added to a corresponding group of data to be transmitted, so as to restore the number of bits of the binary numbers contained in each group of updated data to the number of bits corresponding to one byte.
4. The data transmission method according to claim 1, characterized in that: Also includes: When the encapsulated data is transmitted to a data receiver via a data bus, the encapsulated data is stored in a high-speed buffer on the data bus, and a timer is controlled to start timing from zero; If the current timing of the timer reaches the preset time length and the data sender has not received the confirmation character sent by the data receiver, the high-speed buffer is called to perform a fast retransmission operation to retransmit the encapsulated data stored in the buffer to the data receiver, and the process jumps to the step of controlling the timer to start timing from zero; If the current timing of the timer does not reach the preset time length and the data sender receives a confirmation character sent by the data receiver, a corresponding operation is performed based on the currently received confirmation character; Wherein, when the currently received confirmation character is the first confirmation character indicating that the data verification is correct and requesting to start the next data transmission, the next data transmission is started based on the currently received confirmation character; When the currently received confirmation character is a second confirmation character indicating that the data verification is correct and requesting to end the data transmission, ending the data transmission based on the currently received confirmation character; When the currently received confirmation character is the third confirmation character indicating a data check error, the method jumps again to the step of calling the high-speed buffer to perform a fast retransmission operation based on the currently received confirmation character.
5. The data transmission method according to claim 4, characterized in that: The step of transmitting the encapsulated data to a data receiver via a data bus so that the data receiver uses the check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result, comprises: The encapsulated data is transmitted to the data receiver via the data bus, so that the data receiver uses the check bit to check the correctness of the received data, and determines the corresponding confirmation character based on the correctness check result and / or data transmission requirements, and then sends the determined confirmation character to the data sender.
6. The data transmission method according to any one of claims 1 to 5, characterized in that: The step of transmitting the encapsulated data to a data receiver via a data bus so that the data receiver uses the check bit to check the correctness of the received data, and sends a corresponding confirmation character to the data sender based on the correctness check result, comprises: The encapsulated data is transmitted to a data receiver through a data bus, so that the data receiver uses a second preset bit number to split the received data to obtain multiple groups of split data, and performs an XOR operation on the target binary number in each group of split data, so as to determine the correctness check result of the received data based on the consistency of the second XOR operation result and the check bit in the corresponding group of split data, and send a corresponding confirmation character to the data sender based on the correctness check result; The second preset number of bits is the sum of the first preset number of bits and the check bit; and the target binary number is the other binary numbers in each group of split data except the check bit.
7. The data transmission method according to claim 6, characterized in that: Also includes: Transmitting the encapsulated data to a data receiver through a data bus, so that the data receiver uses the check bit to check the correctness of the received data to obtain a correctness check result, and when the correctness check result indicates that the received data is correctly checked, deleting the check bit in each group of split data to obtain multiple groups of deleted data, and recombining the multiple groups of deleted data to obtain recombined data; The reorganized data is the same as the original data.
8. A data transmission device, characterized in that: Applicable to data senders, including: A data splitting module, used to split the original data using a first preset number of bits to obtain multiple groups of data to be transmitted; the original data is data based on binary numbers; A check bit determination module, used for performing an XOR operation on each binary number in each group of data to be transmitted, and determining a first XOR operation result as a check bit of the corresponding group of data to be transmitted; A check bit adding module, used for adding each of the check bits to a corresponding group of data to be transmitted to obtain multiple groups of updated data, and encapsulating the multiple groups of updated data to obtain encapsulated data; The data transmission module is used to transmit the encapsulated data to the data receiver through the data bus, so that the data receiver can use the check bit to check the correctness of the received data and send a corresponding confirmation character to the data sender based on the correctness check result.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the data transmission method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data transmission method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data transmitting method, a data sending method and a data receiving method
CN101645883A
Verification method of data transmission
CN106656424A
Data error correction method and device
CN108242973A
A method of handling link layer data errors
CN108988990A
Method and device for reducing check bit number, computer device and storage medium
CN109669805A