CN112822226B - Data transmission method and device, electronic equipment and machine-readable storage medium - Google Patents

Data transmission method and device, electronic equipment and machine-readable storage medium Download PDF

Info

Publication number
CN112822226B
CN112822226B CN201911121393.0A CN201911121393A CN112822226B CN 112822226 B CN112822226 B CN 112822226B CN 201911121393 A CN201911121393 A CN 201911121393A CN 112822226 B CN112822226 B CN 112822226B
Authority
CN
China
Prior art keywords
bit
data
data bit
transmission signal
duration
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
CN201911121393.0A
Other languages
Chinese (zh)
Other versions
CN112822226A (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 Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology 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 Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201911121393.0A priority Critical patent/CN112822226B/en
Publication of CN112822226A publication Critical patent/CN112822226A/en
Application granted granted Critical
Publication of CN112822226B publication Critical patent/CN112822226B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Dc Digital Transmission (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The embodiment of the invention provides a data transmission method, a data transmission device, electronic equipment and a machine-readable storage medium.A receiving end receives a transmission signal sent by a sending end, detects a start bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, counts the data bit duration of each data bit, identifies the corresponding numerical value of each data bit based on the preset corresponding relation between the data bit duration and the numerical value, and determines to receive data consisting of the corresponding numerical values of each data bit based on the corresponding numerical value of each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal is detected based on the level states, the value of each data bit is identified based on the corresponding relation between the preset data bit duration and the preset value, the accurate detection of each data bit of the transmission signal can be ensured, the specific value of each data bit can be accurately identified, and the accurate data received by a receiving end is ensured.

Description

Data transmission method and device, electronic equipment and machine-readable storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data transmission method and apparatus, an electronic device, and a machine-readable storage medium.
Background
In the current communication system, data communication between devices and between modules is generally implemented by using a point-to-point communication protocol such as UART (Universal Asynchronous Receiver/Transmitter), 1WIRE (single bus), and the like.
When data communication is performed by using the communication protocol, the sending end sends a transmission signal to the receiving end, where the transmission signal includes a start bit, a data bit, and a stop bit, and the high and low of the level state of the data bit indicates a specific value of the data bit, for example, if a data bit is high, it indicates that the value of the data bit is 1, and if a data bit is low, it indicates that the value of the data bit is 0. After receiving the transmission signal, the receiving end samples the transmission signal, identifies the start bit, the data bit and the stop bit of the transmission signal, and identifies the specific numerical value of each data bit according to the level state of each data bit obtained by sampling, thereby obtaining the data transmitted by the transmitting end.
However, in an actual situation, the sampling frequency of the receiving end for sampling the transmission signal is often irregular, and the condition of 1 or 0 continuously occurs in the data transmitted by the transmitting end, and the irregularity of the sampling frequency easily identifies two continuous same values as a value of one data bit, which results in inaccurate data received by the receiving end.
Disclosure of Invention
Embodiments of the present invention provide a data transmission method, an apparatus, an electronic device, and a machine-readable storage medium, so as to ensure that a receiving end receives accurate data. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a data transmission method, which is applied to a receiving end, where the method includes:
receiving a transmission signal sent by a sending end;
detecting a start bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, wherein the level states of every two adjacent bits of the transmission signal are different;
counting the data bit duration of each data bit, and identifying a numerical value corresponding to each data bit based on a preset corresponding relation between the data bit duration and the numerical value;
and determining to receive data consisting of the numerical values corresponding to the data bits based on the numerical values corresponding to the data bits between the start bit and the stop bit.
Optionally, the detecting a start bit, each data bit, and a stop bit of the transmission signal according to a level state of each bit of the transmission signal includes:
when the transmission signal is in a default level state, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a start bit is detected;
after the start bit is detected, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a data bit is detected;
and after the data bit with the preset bit number is detected, if the interrupt signal is detected and the level state of the transmission signal is overturned, determining that the stop bit is detected.
Optionally, the detecting a start bit, each data bit, and a stop bit of the transmission signal according to a level state of each bit of the transmission signal includes:
acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in a default level state, and determining that a start bit is detected if the acquired level state of the transmission signal is turned over;
after the start bit is detected, if the level state of the transmission signal is acquired to be overturned according to the preset frequency, determining that a data bit is detected;
and after the data bits with preset bits are detected, if the level state of the transmission signal is acquired to be turned according to the preset frequency, determining that the stop bit is detected.
Optionally, after detecting the start bit, each data bit, and the stop bit of the transmission signal according to the level state of each bit of the transmission signal, the method further includes:
counting the starting bit duration of the starting bit;
calculating a reference time according to the starting bit duration, wherein the starting bit duration is a first preset multiple of the reference time;
the identifying the corresponding numerical value of each data bit based on the corresponding relation between the preset data bit duration and the numerical value comprises the following steps:
aiming at each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time;
if the data bit duration of the data bit is a second preset multiple of the reference time, determining that the value of the data bit is 0;
and if the data bit duration of the data bit is a third preset multiple of the reference time, determining that the value of the data bit is 1.
Optionally, the determining, based on the numerical value corresponding to each data bit between the start bit and the stop bit, that data is received and composed of the numerical value corresponding to each data bit includes:
after the data bit with the preset digit is detected, counting the stop duration if the stop bit is detected;
judging whether the stop duration exceeds the first preset multiple of the reference time or not;
and if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
In a second aspect, an embodiment of the present invention provides a data transmission method, which is applied to a sending end, where the method includes:
acquiring data to be transmitted;
identifying the numerical value of each data bit in the data to be sent;
setting the data bit duration of each data bit in a transmission signal based on the corresponding relation between the preset data bit duration and the value according to the value of each data bit in the data to be transmitted, wherein the transmission signal comprises a start bit, each data bit and a stop bit, and the level states of every two adjacent bits of the transmission signal are different;
and sending the transmission signal to a receiving end.
Optionally, before the transmitting the transmission signal to the receiving end, the method further includes:
setting the starting bit time length and the stopping bit time length of the starting bit and the stopping bit of the stopping bit in the transmission signal based on preset reference time, wherein the starting bit time length and the stopping bit time length are first preset multiples of the reference time.
Optionally, the setting, according to the value of each data bit in the data to be transmitted, the data bit duration of each data bit in the transmission signal based on a preset correspondence between the data bit duration and the value includes:
if the value of any data bit in the data to be transmitted is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a second preset multiple of the reference time; and if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a third preset multiple of the reference time.
In a third aspect, an embodiment of the present invention provides a data transmission apparatus, which is applied to a receiving end, where the apparatus includes:
the receiving module is used for receiving a transmission signal sent by a sending end;
the detection module is used for detecting a start bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, wherein the level states of every two adjacent bits of the transmission signal are different;
the identification module is used for counting the data bit duration of each data bit and identifying the corresponding numerical value of each data bit based on the preset corresponding relation between the data bit duration and the numerical value;
and the determining module is used for determining to receive data consisting of the numerical values corresponding to the data bits based on the numerical values corresponding to the data bits between the start bit and the stop bit.
Optionally, the detection module is specifically configured to:
when the transmission signal is in a default level state, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a start bit is detected;
after the start bit is detected, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a data bit is detected;
and after the data bit with the preset bit number is detected, if the interrupt signal is detected and the level state of the transmission signal is overturned, determining that the stop bit is detected.
Optionally, the detection module is specifically configured to:
acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in a default level state, and determining that a start bit is detected if the acquired level state of the transmission signal is turned over;
after the start bit is detected, if the level state of the transmission signal is acquired to be overturned according to the preset frequency, determining that a data bit is detected;
and after the data bits with preset bits are detected, if the level state of the transmission signal is acquired to be turned according to the preset frequency, determining that the stop bit is detected.
Optionally, the apparatus further comprises:
the counting module is used for counting the starting bit duration of the starting bit;
the calculation module is used for calculating reference time according to the starting bit duration, and the starting bit duration is a first preset multiple of the reference time;
the identification module is specifically configured to:
aiming at each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time;
if the data bit duration of the data bit is a second preset multiple of the reference time, determining that the value of the data bit is 0;
and if the data bit duration of the data bit is a third preset multiple of the reference time, determining that the value of the data bit is 1.
Optionally, the determining module is specifically configured to:
after the data bit with the preset digit is detected, counting the stop duration if the stop bit is detected;
judging whether the stop duration exceeds the first preset multiple of the reference time or not;
and if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
In a fourth aspect, an embodiment of the present invention provides a data transmission apparatus, which is applied to a sending end, where the apparatus includes:
the acquisition module is used for acquiring data to be transmitted;
the identification module is used for identifying the numerical value of each data bit in the data to be sent;
a setting module, configured to set a data bit duration of each data bit in a transmission signal based on a preset correspondence between a data bit duration and a value according to the value of each data bit in the to-be-transmitted data, where the transmission signal includes a start bit, each data bit, and a stop bit, and level states of every two adjacent bits of the transmission signal are different;
and the sending module is used for sending the transmission signal to a receiving end.
Optionally, the setting module is further configured to:
setting the starting bit time length and the stopping bit time length of the starting bit and the stopping bit of the stopping bit in the transmission signal based on preset reference time, wherein the starting bit time length and the stopping bit time length are first preset multiples of the reference time.
Optionally, the setting module is specifically configured to:
for any data bit in the data to be transmitted, if the value of the data bit is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a second preset multiple of the reference time; and if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a third preset multiple of the reference time.
In a fifth aspect, an embodiment of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores machine executable instructions that can be executed by the processor, and the machine executable instructions are loaded and executed by the processor to implement the method provided in the first aspect or the second aspect of the embodiment of the present invention.
In a sixth aspect, an embodiment of the present invention provides a machine-readable storage medium, where a machine-executable instruction is stored, and when the machine-executable instruction is loaded and executed by a processor, the machine-executable instruction implements the method provided by the first aspect or the second aspect of the embodiment of the present invention.
In the data transmission method, the apparatus, the electronic device, and the machine-readable storage medium provided in the embodiments of the present invention, the receiving end receives a transmission signal sent by the sending end, detects a start bit, each data bit, and a stop bit of the transmission signal according to a level state of each bit of the transmission signal, counts a data bit duration of each data bit, identifies a value corresponding to each data bit based on a preset correspondence between the data bit duration and the value, and determines to receive data composed of the values corresponding to each data bit based on the values corresponding to each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a timing diagram illustrating a UART protocol according to the prior art;
FIG. 2 is a schematic diagram of reset and acknowledge pulses during initialization of a prior art 1-WIRE protocol;
FIG. 3 is a timing diagram of write slots of a prior art 1-WIRE protocol;
FIG. 4 is a read slot timing diagram of a prior art 1WIRE protocol;
FIG. 5 is a prior art sample timing diagram at 16 baud rate;
fig. 6 is a flowchart illustrating a data transmission method applied to a receiving end according to an embodiment of the present invention;
FIG. 7 is a timing diagram of transmission signals according to an embodiment of the present invention;
fig. 8 is a flowchart illustrating a data transmission method applied to a receiving end according to another embodiment of the present invention;
FIG. 9 is a timing diagram of transmission signals according to another embodiment of the present invention;
FIG. 10 is a flowchart illustrating a method for detecting each bit of a transmission signal according to an embodiment of the present invention;
FIG. 11 is a flowchart illustrating a method for detecting each bit of a transmission signal according to another embodiment of the present invention;
fig. 12 is a flowchart illustrating a data transmission method applied to a sending end according to an embodiment of the present invention;
fig. 13 is a schematic structural diagram of a data transmission apparatus applied to a receiving end according to an embodiment of the present invention;
fig. 14 is a schematic structural diagram of a data transmission apparatus applied to a transmitting end according to an embodiment of the present invention;
fig. 15 is a schematic structural diagram of an electronic device according to an embodiment of the invention;
fig. 16 is a schematic structural diagram of an electronic device according to another embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In a communication system, two devices or two modules can transmit data through a bus port, wherein the main bus port comprises I 2 C (Inter-Integrated Circuit, two-wire serial bus port), GPIO (General-purpose Input/Output)And the GPIO is taken as an example for description. The GPIO function is similar to P0-P3 of 8051, the PIN can be freely used by the user under program control, and the PIN can be used as General Purpose Input (GPI) or General Purpose Output (GPO) or General Purpose Input and Output (GPIO) depending on practical considerations.
The conventional point-to-point communication protocol includes UART and 1WIRE protocols, and these protocols have a common characteristic that main signals only include data signals and do not include signals such as clock, read/write, and the like.
As shown in the UART protocol transceiving timing sequence of fig. 1, both the transmitting end and the receiving end that use the UART protocol to perform communication transmit and receive a signal, which has no corresponding clock signal and signals such as read/write, chip select, etc., and the signal has a start bit and a stop bit, a default level (level during sleep, generally high level), and a 16-fold or 64-fold sampling clock, that is, the receiving end needs to sample the received signal at a speed 16-fold or 64-fold of the baud rate of the received signal, and after identifying the sampled signal level state, can confirm whether the received signal is 0 or 1.
If the UART scheme is used, similar signals can be generated over 1 GPIO signal. However, the receiving end also needs to detect the received signal continuously by a sampling frequency far exceeding the baud rate, and the load on a Central Processing Unit (CPU) is very large.
The 1WIRE protocol is divided into initialization and read-write time slot processes. Under the 1WIRE protocol, a receiving end is divided into a master and a slave, before data transmission is carried out, the master needs to drive the slave to carry out initialization, such as reset and response pulses in the 1WIRE initialization process shown in fig. 2, the initialization process is equal to the reset pulse plus the slave response pulse, the master generates the reset pulse by pulling down 480-960 us of a single bus, then releases the bus and enters a receiving mode. When the master machine releases the bus, a rising edge that the low level jumps to the high level is generated, after the slave machine detects the rising edge, the time is delayed by 15-60 us, and the bus is pulled down by 60-240 us to generate a response pulse. The host receives the response pulse of the slave to indicate that the slave is ready, and the initialization process is completed.
After the initialization process is completed, two kinds of write time slots are performed, including a time slot for writing 0 and a time slot for writing 1. As shown in FIG. 3, after the data line is pulled low, the data line is sampled within a time window of 15-60 us. If the data line is low, a 0 is written, and if the data line is high, a 1 is written. To generate a write 1 slot, the host must pull the data line low, allowing the data line to pull high for 15us after the start of the write slot. To generate a slot to write a 0, the host must pull the data line low and hold it for 60 us.
The timing of the read slot, corresponding to the write slot, as shown in fig. 4, must be read within 15us when the host pulls the bus low and releases the bus after holding at least 1 us.
As shown in the 3 timing diagrams of fig. 2 to 4, since there are no auxiliary signals such as the clock signal and the read/write signal, the receiving end must sample the received signal in a manner much higher than the data transmission rate, and if this state is maintained all the time, the load of the CPU is very high.
According to the above analysis, in the absence of the reference clock and the read/write signal, the received data can only be read at a sampling frequency much higher than the data transmission in order to resolve the received signal.
Assuming that the sampling clock of the UART protocol is 16 baud rate, for example, the actual sampling is not necessarily 16 times, but may be 15 times or 14 times, because of the phase difference between the data edge and the sampling clock. With the 16 baud rate sampling scheme timing shown in fig. 5, each sample point reads the correct data if sampled on the rising edge, but data sampling errors may occur if sampled on the falling edge. In addition, the regular time sequence cannot occur in actual sampling, and the sampling clock is changed continuously.
After the start bit is detected, each data bit is sampled, which causes sampling inaccuracy due to the above-mentioned reason, and in addition, if continuous same values, such as continuous 0 or 1, appear, it is difficult to judge how two or more data bits are.
In order to solve the above problem, embodiments of the present invention provide a data transmission method and apparatus, an electronic device, and a machine-readable storage medium. Next, a data transmission method provided in an embodiment of the present invention is first described.
As shown in fig. 6, an embodiment of the present invention provides a data transmission method, where the method is applied to a receiving end, where the receiving end may be an electronic device in a communication system, or may also be a module such as a CPU in one device, and the method may include the following steps.
S601, receiving a transmission signal sent by a sending end.
When a sending end sends data, a transmission signal is generated according to the data to be sent, and the transmission signal is a timing signal and comprises a start bit, a data bit and a stop bit.
S602, according to the level state of each bit of the transmission signal, detecting the start bit, each data bit and the stop bit of the transmission signal, wherein the level states of each two adjacent bits of the transmission signal are different.
For example, if the first bit is high, the second bit is low, the third bit is high, the fourth bit is low, and so on, so that the receiving end can recognize a bit of data bits according to the transmission signal when the level is inverted. The default level state of the receiving end is generally high level, so that the initial bit level state can be set as low level, and the stop bit level state can be set as high level (as shown in fig. 7). Of course, the default level state may be set to low level, and thus, the initial bit level state may be set to high level and the stop bit level state may be set to low level.
S603, counting the data bit duration of each data bit, and identifying the corresponding numerical value of each data bit based on the corresponding relation between the preset data bit duration and the numerical value.
In the transmission signal as shown in fig. 7, a problem that whether the value of the data bit is 0 or 1 cannot be determined occurs, even if a certain bit is 0, the level state of the bit in the transmission signal is a high level due to the level inversion of the data bit, and in order to solve the problem, in the embodiment of the present invention, the size of the value is determined according to the data bit duration, a corresponding relationship between the data bit duration and the value is preset, for example, a data bit duration of 1ms corresponds to a value 0, a data bit duration of 2ms corresponds to a value 1, and based on the corresponding relationship, a value corresponding to each data bit can be identified.
S604, determining to receive data composed of the numerical values corresponding to the data bits based on the numerical values corresponding to the data bits between the start bit and the stop bit.
The stop bit represents the end of data reception, so that after detecting the start bit, the stop bit, and the values corresponding to the data bits between the start bit and the stop bit, it can be determined that data consisting of the values corresponding to the data bits is received.
By applying the embodiment of the invention, the receiving end receives the transmission signal sent by the sending end, detects the start bit, each data bit and the stop bit of the transmission signal according to the level state of each bit of the transmission signal, counts the data bit duration of each data bit, identifies the numerical value corresponding to each data bit based on the preset corresponding relation between the data bit duration and the numerical value, and determines to receive the data consisting of the numerical values corresponding to each data bit based on the numerical value corresponding to each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
Based on the embodiment shown in fig. 6, an embodiment of the present invention further provides a data transmission method, as shown in fig. 8, which includes the following steps.
S801, receiving a transmission signal sent by a sending end.
S802, according to the level state of each bit of the transmission signal, detecting a start bit, each data bit and a stop bit of the transmission signal, wherein the level states of each two adjacent bits of the transmission signal are different.
S803, counting the start bit duration of the start bit.
S804, calculating the reference time according to the starting bit time length, wherein the starting bit time length is a first preset multiple of the reference time.
In the embodiment of the invention, a reference time can be defined, and the duration occupied by the start bit and the data bit of the transmission signal can be multiples of the reference time. Therefore, after the receiving end receives the transmission signal, the receiving end detects the start bit and counts the start bit duration of the start bit, and the start bit duration is a first preset multiple of the reference time, so that the reference time can be calculated at the receiving end according to the start bit duration. For example, if the start bit duration is set to be 3 times of the reference time, and the counted start bit duration is 3ms, the reference time can be determined to be 1 ms.
S805, counting the data bit duration of each data bit, and for each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time, if the data bit duration of the data bit is the second preset multiple of the reference time, determining that the value of the data bit is 0, and if the data bit duration of the data bit is the third preset multiple of the reference time, determining that the value of the data bit is 1.
After the reference time is determined, because the preset data bit duration of each data bit has a multiple relation with the reference time, the data bit duration of each data bit can be counted, then the multiple relation between the data bit duration of each data bit and the reference time is calculated, the preset data bit duration of the value 0 is a second preset multiple of the reference time, and the preset data bit duration of the value 1 is a third preset multiple of the reference time, so that after the multiple relation between the data bit duration of each data bit and the reference time is calculated, the data bit duration of one data bit is identified to be the second preset multiple or the third preset multiple of the reference time, and the value of the data bit can be determined to be 0 or 1. For example, it is preset that the data bit duration of 0 is 1 time of the reference time, the data bit duration of 1 is 2 times of the reference time, and the above step calculates that the reference time is 1ms, then if the data bit duration of a data bit is 1ms, the data bit is 0, and if the data bit duration of a data bit is 2ms, the data bit is 1.
S806, determining that data composed of the numerical values corresponding to the data bits are received based on the numerical values corresponding to the data bits between the start bit and the stop bit.
If the time sequence of the transmission signal received by the receiving end is as shown in fig. 9, the default level is a high level, the start bit of the data bit which is turned over by 3 times the reference time is detected, the value of the data bit which is 1 time the reference time is set to be 0, and the value of the data bit which is 2 times the reference time is set to be 1, after each bit of the transmission signal is detected, the 1-bit start bit, the 8-bit data bit and the 1-bit stop bit are detected, and the received data can be determined to be 01000111 according to the data bit time length of each data bit.
By applying the embodiment of the invention, the reference time can be calculated by counting the duration of the start bit based on the preset duration of the start bit being the first preset multiple of the reference time, the multiple relation between the duration of the data bit of each data bit and the reference time can be calculated by counting the duration of the data bit of each data bit and the calculated reference time, the receiving end is preset with the corresponding relation between the second preset multiple and the value 0 and the corresponding relation between the third preset multiple and the value 1, and the specific value of each data bit can be quickly determined based on the corresponding relations.
Optionally, S806 may be specifically implemented by the following steps:
step one, after detecting the data bit of the preset digit, if the stop bit is detected, counting the stop duration.
And secondly, judging whether the stop duration exceeds a first preset multiple of the reference time.
And thirdly, if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
Based on the embodiment shown in fig. 8, the detection of the stop bit may also be based on the reference time, and if a data bit with a preset number of bits is detected (for example, 8 bits are detected), it is identified whether the stop bit is detected, that is, whether the level is flipped, if the stop bit is detected, statistics of the stop duration is started, the stop duration is often set to be greater than or equal to the start bit duration, therefore, it needs to be determined whether the stop duration exceeds a first preset multiple of the reference time, if the stop duration exceeds the first preset multiple, it is determined that the stop bit is an accurate stop bit, it is determined that the data is completely received, if the stop duration does not exceed the first preset multiple, it is determined that the data is a data transmission error, and it is not an accurate stop bit, and it is necessary to prompt the sending end to resend the data.
Since some devices or modules can support the upper and lower edge interrupt detection of GPIO, and some devices or modules cannot support the upper and lower edge interrupt detection, the following describes the detection process of each bit in the transmission signal for these two cases.
For the case of supporting the upper and lower edge interrupt detection of GPIO, as shown in fig. 10, the steps of detecting the start bit, each data bit, and the stop bit of the transmission signal according to the level state of each bit of the transmission signal are mainly implemented as follows.
S1001, when the transmission signal is in the default level state, if the interrupt signal is detected and the level state of the transmission signal is inverted, it is determined that the start bit is detected.
S1002, after detecting the start bit, if the interrupt signal is detected and the level state of the transmission signal is inverted, determining that the data bit is detected.
And S1003, after the data bit with the preset digit is detected, if the interrupt signal is detected and the level state of the transmission signal is turned over, determining that the stop bit is detected.
In the embodiment of the invention, the GPIO terminal is set to have interruption on the upper edge and the lower edge, the interruption means that when some other conditions need to be interfered by a host computer in the running process of a computer, the machine can automatically stop a running program and transfer the program into a program for processing a new condition, and the original suspended program is returned to continue to be processed after the processing is finished. If the receiving end detects the interrupt signal and detects that the level state of the transmission signal is turned over, the receiving end indicates that the GPIO upper and lower edges are interrupted at the moment, and correspondingly can detect a start bit, a data bit or a stop bit.
And when the GPIO default level is a high level, detecting whether the level state of the transmission signal is a low level or not, if so, determining that the level state is a start bit, if the interrupt is generated again, detecting whether the level state of the transmission signal is the high level or not, determining that the level state is a first data bit, generating the interrupt again, detecting whether the level state of the transmission signal is the low level or not, determining that the level state is a second data bit, and so on, and determining that one data bit is detected every time the interrupt is generated and the level is inverted once. In this embodiment, the way of counting the duration of the data bit may be to calculate the interval time between two adjacent interrupts, and then, whether the data bit is 0 or 1 may be determined according to the interval time.
For the situation that the GPIO upper and lower edge interrupt detection is not supported, as shown in fig. 11, the step of detecting the start bit, each data bit, and the stop bit of the transmission signal according to the level state of each bit of the transmission signal is mainly implemented by the following steps.
And S1101, acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in the default level state, and determining that the start bit is detected if the acquired level state of the transmission signal is turned over.
And S1102, after the start bit is detected, if the level state of the transmission signal is acquired to be inverted according to the preset frequency, determining that the data bit is detected.
And S1103, after the data bits with preset bits are detected, if the level state of the transmission signal is acquired according to the preset frequency and is turned over, determining that the stop bit is detected.
Different from the situation of supporting the upper and lower edge interrupt detection of the GPIO, in the situation of not supporting the upper and lower edge interrupt detection of the GPIO, the start bit, the data bit, and the stop bit need to be confirmed by sampling at a high frequency, and since it is set that each bit in the transmission signal is subjected to level inversion once, the set predetermined frequency can be set to a small point, for example, 10 baud rates. The operation and interruption when receiving the transmission signal are basically consistent, and when the timing detection is carried out, the start bit is detected firstly, and the time length of the detected start bit may not be accurate, but the error of 10% can be allowed. The level inversion of the transmission signal is detected in a sampling manner, and a data bit and a stop bit are detected.
As shown in fig. 12, an embodiment of the present invention provides a data transmission method, where the method is applied to a sending end, where the sending end may be an electronic device in a communication system, or may also be a module such as a CPU in one device, and the method may include the following steps.
And S1201, acquiring data to be transmitted.
S1202, identifying the numerical value of each data bit in the data to be sent.
S1203, setting a data bit duration of each data bit in a transmission signal based on a preset corresponding relationship between a data bit duration and a value according to the value of each data bit in the data to be transmitted, where the transmission signal includes a start bit, each data bit, and a stop bit, and level states of each two adjacent bits of the transmission signal are different.
Corresponding to the above-mentioned method embodiment applied to the receiving end, the sending end needs to identify the data to be sent before sending the data, and sets the transmission signal based on the identified value of each data bit of the data to be sent, specifically, when setting the transmission signal, the level states of every two adjacent bits of the transmission signal are different, that is, each bit will be level-reversed, and the data bit duration of each data bit can be set according to the value of the data bit.
S1204, sending the transmission signal to a receiving end.
The sending end sends the transmission signal, and the sending end can adopt timing interruption to send.
By applying the embodiment of the invention, the sending end needs to identify the data to be sent before sending the data, and sets the transmission signal based on the identified numerical value of each data bit of the data to be sent, specifically, in the setting of the transmission signal, the level states of each two adjacent bits of the transmission signal are different, that is, each bit is level-reversed, and the data bit duration of each data bit can be set according to the value of the data bit, so that after the receiving end receives the transmission signal, according to the level state of each bit of the transmission signal, detecting the start bit, each data bit and the stop bit of the transmission signal, counting the data bit duration of each data bit, and identifying the corresponding numerical value of each data bit based on the corresponding relation between the preset data bit duration and the numerical value, and determining to receive data consisting of the corresponding numerical values of each data bit based on the corresponding numerical value of each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
Optionally, before executing S1204, the method may further include the steps of:
and setting the start bit duration and the stop bit duration of the start bit and the stop bit in the transmission signal based on preset reference time, wherein the start bit duration and the stop bit duration are first preset multiples of the reference time.
When the transmission signal is set, the start bit duration and the stop bit duration of the transmission signal may also be set, and are generally set based on the reference time, and in general, the start bit duration and the stop bit duration may be set as a first preset multiple of the reference time, for example, the start bit duration and the stop bit duration may be set as 3 times of the reference time. The step of setting the start bit and the stop bit may be performed before or after the step of setting the data bit, and is not particularly limited herein.
Optionally, S1203 may specifically be:
for any data bit in the data to be transmitted, if the value of the data bit is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal as a second preset multiple of the reference time; if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal as a third preset multiple of the reference time.
The data bit duration of each data bit may also be set based on the reference time, if the value of one data bit is 0, the data bit duration of the data bit may be set to a second preset multiple (e.g., 1 time) of the reference time, and if the value of one data bit is 1, the data bit duration of the data bit may be set to a second preset multiple (e.g., 2 times) of the reference time.
Corresponding to the method embodiment shown in fig. 6, an embodiment of the present invention provides a data transmission apparatus, which is applied to a receiving end, and as shown in fig. 13, the apparatus may include:
a receiving module 1310, configured to receive a transmission signal sent by a sending end;
a detecting module 1320, configured to detect a start bit, each data bit, and a stop bit of the transmission signal according to a level state of each bit of the transmission signal, where level states of every two adjacent bits of the transmission signal are different;
an identifying module 1330, configured to count a data bit duration of each data bit, and identify a corresponding value of each data bit based on a preset corresponding relationship between the data bit duration and the corresponding value;
the determining module 1340 is configured to determine that data composed of values corresponding to the data bits is received based on the values corresponding to the data bits between the start bit and the stop bit.
By applying the embodiment of the invention, the receiving end receives the transmission signal sent by the sending end, detects the start bit, each data bit and the stop bit of the transmission signal according to the level state of each bit of the transmission signal, counts the data bit duration of each data bit, identifies the numerical value corresponding to each data bit based on the preset corresponding relation between the data bit duration and the numerical value, and determines to receive the data consisting of the numerical values corresponding to each data bit based on the numerical value corresponding to each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
Optionally, the detection module 1320 may be specifically configured to:
when the transmission signal is in a default level state, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a start bit is detected;
after the start bit is detected, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a data bit is detected;
and after the data bit with the preset bit number is detected, if the interrupt signal is detected and the level state of the transmission signal is overturned, determining that the stop bit is detected.
Optionally, the detection module 1320 may be specifically configured to:
acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in a default level state, and determining that a start bit is detected if the acquired level state of the transmission signal is turned over;
after the start bit is detected, if the level state of the transmission signal is acquired to be overturned according to the preset frequency, determining that a data bit is detected;
and after the data bits with preset bits are detected, if the level state of the transmission signal is acquired to be turned according to the preset frequency, determining that the stop bit is detected.
Optionally, the apparatus may further include:
the counting module is used for counting the start bit duration of the start bit;
the calculation module is used for calculating reference time according to the starting bit duration, and the starting bit duration is a first preset multiple of the reference time;
the identification module 1330 may be specifically configured to:
aiming at each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time;
if the data bit duration of the data bit is a second preset multiple of the reference time, determining that the value of the data bit is 0;
and if the data bit duration of the data bit is a third preset multiple of the reference time, determining that the value of the data bit is 1.
Optionally, the determining module 1340 may specifically be configured to:
after the data bit with the preset digit is detected, counting the stop duration if the stop bit is detected;
judging whether the stop duration exceeds the first preset multiple of the reference time or not;
and if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
Corresponding to the method embodiment shown in fig. 12, an embodiment of the present invention provides a data transmission apparatus, which is applied to a sending end, and as shown in fig. 14, the apparatus may include:
an obtaining module 1410, configured to obtain data to be sent;
an identifying module 1420, configured to identify a value of each data bit in the data to be sent;
a setting module 1430, configured to set a data bit duration of each data bit in a transmission signal based on a preset correspondence between a data bit duration and a value according to the value of each data bit in the to-be-transmitted data, where the transmission signal includes a start bit, each data bit, and a stop bit, and level states of every two adjacent bits of the transmission signal are different;
a sending module 1440, configured to send the transmission signal to a receiving end.
By applying the embodiment of the invention, the sending terminal needs to identify the data to be sent before sending the data, and sets the transmission signal based on the identified numerical value of each data bit of the data to be sent, when the transmission signal is set, the level states of each two adjacent bits of the transmission signal are different, that is, each bit is level-reversed, and the data bit duration of each data bit can be set according to the value of the data bit, so that after the receiving end receives the transmission signal, according to the level state of each bit of the transmission signal, detecting the start bit, each data bit and the stop bit of the transmission signal, counting the data bit duration of each data bit, and identifying the corresponding numerical value of each data bit based on the corresponding relation between the preset data bit duration and the numerical value, and determining to receive data consisting of the corresponding numerical values of each data bit based on the corresponding numerical value of each data bit between the start bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
Optionally, the setting module 1430 may further be configured to:
setting the start bit duration and the stop bit duration of a start bit and the stop bit in the transmission signal based on preset reference time, wherein the start bit duration and the stop bit duration are first preset multiples of the reference time.
Optionally, the setting module 1430 may be specifically configured to:
for any data bit in the data to be transmitted, if the value of the data bit is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a second preset multiple of the reference time; and if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a third preset multiple of the reference time.
An electronic device is provided in an embodiment of the present invention, as shown in fig. 15, and includes a processor 1501 and a memory 1502, where the memory 1502 stores machine executable instructions that can be executed by the processor 1501, and the machine executable instructions are loaded and executed by the processor 1501 to implement the data transmission method applied to a receiving end provided in an embodiment of the present invention.
An embodiment of the present invention further provides an electronic device, as shown in fig. 16, which includes a processor 1601 and a memory 1602, where the memory 1602 stores machine executable instructions that can be executed by the processor 1601, and the machine executable instructions are loaded and executed by the processor 1601 to implement the data transmission method applied to the transmitting end according to the embodiment of the present invention.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor including a CPU, an NP (Network Processor), and the like; but also DSPs (Digital Signal processors), ASICs (Application Specific Integrated circuits), FPGAs (Field-Programmable Gate arrays) or other Programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
Data transmission between the memory 1502 and the processor 1501 and between the memory 1602 and the processor 1601 can be performed by means of wired connection or wireless connection, and communication between the electronic device and other devices can be performed by means of wired communication interface or wireless communication interface. Fig. 15 and 16 are only examples of data transmission via a bus, and are not limited to specific connection methods.
In the embodiment of the present invention, the processor can realize that: the receiving end receives a transmission signal sent by the sending end, detects an initial bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, counts the data bit duration of each data bit, identifies the numerical value corresponding to each data bit based on the preset corresponding relation between the data bit duration and the numerical value, and determines to receive data consisting of the numerical values corresponding to each data bit based on the numerical value corresponding to each data bit between the initial bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
In addition, an embodiment of the present invention provides a machine-readable storage medium, where machine-executable instructions are stored in the machine-readable storage medium, and when the machine-executable instructions are loaded and executed by a processor, the data transmission method applied to a receiving end provided by the embodiment of the present invention is implemented.
The embodiment of the invention provides a machine-readable storage medium, wherein machine-executable instructions are stored in the machine-readable storage medium, and when the machine-executable instructions are loaded and executed by a processor, the data transmission method applied to a sending end provided by the embodiment of the invention is realized.
In the embodiment of the present invention, the machine-readable storage medium stores machine-executable instructions for executing the data transmission method provided in the embodiment of the present invention when executed, so that the following can be implemented: the receiving end receives a transmission signal sent by the sending end, detects an initial bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, counts the data bit duration of each data bit, identifies the numerical value corresponding to each data bit based on the preset corresponding relation between the data bit duration and the numerical value, and determines to receive data consisting of the numerical values corresponding to each data bit based on the numerical value corresponding to each data bit between the initial bit and the stop bit. The level states of every two adjacent bits of the transmission signal are different, each data bit of the transmission signal can be detected based on the change of the level states, the corresponding relation between the data bit duration and the data value is preset, and the actual numerical value of the data bit with different data bit durations can be identified based on the corresponding relation, so that each data bit of the transmission signal can be accurately detected, the specific numerical value of each data bit can be accurately identified, missing identification of the numerical value is avoided, and accurate data received by a receiving end is ensured.
For the embodiments of the electronic device and the machine-readable storage medium, since the contents of the related methods are substantially similar to those of the foregoing embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the embodiments of the methods.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, and the machine-readable storage medium embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some portions of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (14)

1. A data transmission method, applied to a receiving end, the method comprising:
receiving a transmission signal sent by a sending end;
detecting a start bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, wherein the level states of every two adjacent bits of the transmission signal are different;
counting the data bit duration of each data bit, and identifying a numerical value corresponding to each data bit based on a preset corresponding relation between the data bit duration and the numerical value;
determining to receive data composed of values corresponding to the data bits based on the values corresponding to the data bits between the start bit and the stop bit;
after the detecting the start bit, the data bits, and the stop bit of the transmission signal according to the level state of each bit of the transmission signal, the method further includes:
counting the starting bit duration of the starting bit;
calculating a reference time according to the starting bit duration, wherein the starting bit duration is a first preset multiple of the reference time;
the identifying the corresponding numerical value of each data bit based on the corresponding relationship between the preset data bit duration and the numerical value comprises the following steps:
aiming at each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time;
if the data bit duration of the data bit is a second preset multiple of the reference time, determining that the value of the data bit is 0;
and if the data bit duration of the data bit is a third preset multiple of the reference time, determining that the value of the data bit is 1.
2. The method of claim 1, wherein the detecting a start bit, data bits and a stop bit of the transmission signal according to a level state of each bit of the transmission signal comprises:
when the transmission signal is in a default level state, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a start bit is detected;
after the start bit is detected, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a data bit is detected;
and after the data bit with the preset bit number is detected, if the interrupt signal is detected and the level state of the transmission signal is overturned, determining that the stop bit is detected.
3. The method of claim 1, wherein the detecting the start bit, the data bits and the stop bit of the transmission signal according to the level status of each bit of the transmission signal comprises:
acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in a default level state, and determining that a start bit is detected if the acquired level state of the transmission signal is turned over;
after the start bit is detected, if the level state of the transmission signal is acquired to be overturned according to the preset frequency, determining that a data bit is detected;
and after the data bits with preset bits are detected, if the level state of the transmission signal is acquired to be turned according to the preset frequency, determining that the stop bit is detected.
4. The method of claim 1, wherein determining that data consisting of the value corresponding to each data bit is received based on the value corresponding to each data bit between the start bit and the stop bit comprises:
after the data bit with the preset digit is detected, counting the stop duration if the stop bit is detected;
judging whether the stop duration exceeds the first preset multiple of the reference time or not;
and if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
5. A data transmission method, applied to a transmitting end, the method comprising:
acquiring data to be transmitted;
identifying the numerical value of each data bit in the data to be sent;
setting the data bit duration of each data bit in a transmission signal based on a preset corresponding relation between the data bit duration and the value according to the value of each data bit in the data to be transmitted, wherein the transmission signal comprises a start bit, each data bit and a stop bit, the level states of every two adjacent bits of the transmission signal are different, and the start bit duration of the start bit is a first preset multiple of the reference time;
sending the transmission signal to a receiving end;
the setting of the data bit duration of each data bit in the transmission signal based on the preset corresponding relationship between the data bit duration and the value according to the value of each data bit in the data to be transmitted includes:
for any data bit in the data to be transmitted, if the value of the data bit is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a second preset multiple of the reference time; and if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a third preset multiple of the reference time.
6. The method of claim 5, wherein before the transmitting the transmission signal to a receiving end, the method further comprises:
setting the starting bit time length and the stopping bit time length of the starting bit and the stopping bit of the stopping bit in the transmission signal based on preset reference time, wherein the starting bit time length and the stopping bit time length are first preset multiples of the reference time.
7. A data transmission apparatus, applied to a receiving end, the apparatus comprising:
the receiving module is used for receiving a transmission signal sent by a sending end;
the detection module is used for detecting a start bit, each data bit and a stop bit of the transmission signal according to the level state of each bit of the transmission signal, wherein the level states of every two adjacent bits of the transmission signal are different;
the identification module is used for counting the data bit duration of each data bit and identifying the corresponding numerical value of each data bit based on the preset corresponding relation between the data bit duration and the numerical value;
a determining module, configured to determine to receive data composed of values corresponding to the data bits based on the values corresponding to the data bits between the start bit and the stop bit;
the counting module is used for counting the starting bit duration of the starting bit;
the calculation module is used for calculating reference time according to the starting bit duration, and the starting bit duration is a first preset multiple of the reference time;
the identification module is specifically configured to:
aiming at each data bit, calculating the multiple relation between the data bit duration of the data bit and the reference time according to the data bit duration of the data bit and the reference time;
if the data bit duration of the data bit is a second preset multiple of the reference time, determining that the value of the data bit is 0;
and if the data bit duration of the data bit is a third preset multiple of the reference time, determining that the value of the data bit is 1.
8. The apparatus according to claim 7, wherein the detection module is specifically configured to:
when the transmission signal is in a default level state, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a start bit is detected;
after the start bit is detected, if an interrupt signal is detected and the level state of the transmission signal is inverted, determining that a data bit is detected;
and after the data bit with the preset bit number is detected, if the interrupt signal is detected and the level state of the transmission signal is overturned, determining that the stop bit is detected.
9. The apparatus according to claim 7, wherein the detection module is specifically configured to:
acquiring the level state of the transmission signal according to a preset frequency when the transmission signal is in a default level state, and determining that a start bit is detected if the acquired level state of the transmission signal is turned over;
after the start bit is detected, if the level state of the transmission signal is acquired to be overturned according to the preset frequency, determining that a data bit is detected;
and after the data bits with preset bits are detected, if the level state of the transmission signal is acquired to be turned according to the preset frequency, determining that the stop bit is detected.
10. The apparatus of claim 7, wherein the determining module is specifically configured to:
after the data bit with the preset digit is detected, counting the stop duration if the stop bit is detected;
judging whether the stop duration exceeds the first preset multiple of the reference time or not;
and if so, determining that the data with the preset number of bits formed by the numerical values corresponding to the data bits is received.
11. A data transmission apparatus, applied to a transmitting end, the apparatus comprising:
the acquisition module is used for acquiring data to be transmitted;
the identification module is used for identifying the numerical value of each data bit in the data to be sent;
the setting module is used for setting the data bit duration of each data bit in a transmission signal based on the preset corresponding relation between the data bit duration and the numerical value according to the numerical value of each data bit in the data to be transmitted, wherein the transmission signal comprises a start bit, each data bit and a stop bit, the level states of every two adjacent bits of the transmission signal are different, and the start bit duration of the start bit is a first preset multiple of the reference time;
the sending module is used for sending the transmission signal to a receiving end;
the setting module is specifically configured to:
for any data bit in the data to be transmitted, if the value of the data bit is 0, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a second preset multiple of the reference time; and if the value of the data bit is 1, setting the data bit duration of the data bit corresponding to the data bit in the transmission signal to be a third preset multiple of the reference time.
12. The apparatus of claim 11, wherein the setup module is further configured to:
setting the starting bit time length and the stopping bit time length of the starting bit and the stopping bit of the stopping bit in the transmission signal based on preset reference time, wherein the starting bit time length and the stopping bit time length are first preset multiples of the reference time.
13. An electronic device comprising a processor and a memory, wherein the memory stores machine executable instructions executable by the processor, the machine executable instructions being loaded and executed by the processor to implement the method of any one of claims 1-4 or 5-6.
14. A machine-readable storage medium having stored therein machine-executable instructions which, when loaded and executed by a processor, implement the method of any of claims 1-4 or 5-6.
CN201911121393.0A 2019-11-15 2019-11-15 Data transmission method and device, electronic equipment and machine-readable storage medium Active CN112822226B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911121393.0A CN112822226B (en) 2019-11-15 2019-11-15 Data transmission method and device, electronic equipment and machine-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911121393.0A CN112822226B (en) 2019-11-15 2019-11-15 Data transmission method and device, electronic equipment and machine-readable storage medium

Publications (2)

Publication Number Publication Date
CN112822226A CN112822226A (en) 2021-05-18
CN112822226B true CN112822226B (en) 2022-09-02

Family

ID=75851757

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911121393.0A Active CN112822226B (en) 2019-11-15 2019-11-15 Data transmission method and device, electronic equipment and machine-readable storage medium

Country Status (1)

Country Link
CN (1) CN112822226B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116980294B (en) * 2023-06-28 2024-04-30 深圳精控集成半导体有限公司 Communication data receiving method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1458772A (en) * 2002-05-13 2003-11-26 义隆电子股份有限公司 Radio communication coding and decoding method using variable length signal to express digital data
CN102789436A (en) * 2011-05-18 2012-11-21 国基电子(上海)有限公司 Master and slave chips in single-line two-way communication and method thereof
CN102970300A (en) * 2012-11-29 2013-03-13 苏州瀚瑞微电子有限公司 Asynchronous communication protocol
CN103378923A (en) * 2012-04-18 2013-10-30 北京鼎合远传技术有限公司 FM (frequency modulation)-based baseband transmission encoding method and apparatus thereof
CN105071912A (en) * 2015-07-03 2015-11-18 华中科技大学 Binary digital baseband code element communication method based on dual level
WO2016034036A1 (en) * 2014-09-05 2016-03-10 深圳光启智能光子技术有限公司 Signal encoding and decoding methods, device and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1458772A (en) * 2002-05-13 2003-11-26 义隆电子股份有限公司 Radio communication coding and decoding method using variable length signal to express digital data
CN102789436A (en) * 2011-05-18 2012-11-21 国基电子(上海)有限公司 Master and slave chips in single-line two-way communication and method thereof
CN103378923A (en) * 2012-04-18 2013-10-30 北京鼎合远传技术有限公司 FM (frequency modulation)-based baseband transmission encoding method and apparatus thereof
CN102970300A (en) * 2012-11-29 2013-03-13 苏州瀚瑞微电子有限公司 Asynchronous communication protocol
WO2016034036A1 (en) * 2014-09-05 2016-03-10 深圳光启智能光子技术有限公司 Signal encoding and decoding methods, device and system
CN105071912A (en) * 2015-07-03 2015-11-18 华中科技大学 Binary digital baseband code element communication method based on dual level

Also Published As

Publication number Publication date
CN112822226A (en) 2021-05-18

Similar Documents

Publication Publication Date Title
US9946677B2 (en) Managing single-wire communications
JP2018517987A (en) Test for 50 nanosecond spike filter
KR101086426B1 (en) Apparatus and method for controlling the timing of data transition of serial data line in I2C controller
US11221977B2 (en) Daisy chain mode entry sequence
CN104461972B (en) A kind of method and apparatus of data signal samples
WO2017065923A1 (en) Methods to avoid i2c void message in i3c
TWI408931B (en) Data communication device, communication control method, and program
CN112579509A (en) Single-wire communication method, device, electronic equipment and readable storage medium
CN110647486B (en) PCIe link training method, end equipment and communication system
CN112822226B (en) Data transmission method and device, electronic equipment and machine-readable storage medium
CN108011692A (en) A kind of data communications method for microcontroller
CN108306967B (en) Data processing method and terminal
CN108369565B (en) Communication device, communication method, storage medium, and communication system
JP3566630B2 (en) Card system, IC card and card reader / writer used for it
CN114006842B (en) Method, device, equipment and medium for detecting baud rate
KR100609781B1 (en) Asynchronous serial data interface
CN111984582B (en) PCIE link training method, equipment and medium
CN114443537A (en) Method, device, equipment and medium for configuring parameters of PCIE signal sending terminal
CN112445744B (en) I2C communication
CN114095300A (en) Adaptive rate data read-write method and device
US8953662B1 (en) Method and apparatus for baud rate tracking
CN109167736B (en) High-uniformity data packet sending method and device
CN113868178B (en) Communication method, system and storage medium based on I2C bus
JP3461614B2 (en) Communication device and communication method for digital control device
TWI786890B (en) Rs-485 circuit and communication system

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
GR01 Patent grant
GR01 Patent grant