CN113986785A - USB data transmission based method - Google Patents

USB data transmission based method Download PDF

Info

Publication number
CN113986785A
CN113986785A CN202111291463.4A CN202111291463A CN113986785A CN 113986785 A CN113986785 A CN 113986785A CN 202111291463 A CN202111291463 A CN 202111291463A CN 113986785 A CN113986785 A CN 113986785A
Authority
CN
China
Prior art keywords
data
group
transmission
usb
transmitted
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.)
Pending
Application number
CN202111291463.4A
Other languages
Chinese (zh)
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.)
Shenzhen Xinxinda Electronics Co ltd
Original Assignee
Shenzhen Xinxinda Electronics 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 Shenzhen Xinxinda Electronics Co ltd filed Critical Shenzhen Xinxinda Electronics Co ltd
Priority to CN202111291463.4A priority Critical patent/CN113986785A/en
Publication of CN113986785A publication Critical patent/CN113986785A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention relates to a data transmission method, in particular to a method based on USB data transmission. The method is used for solving the problem of data accuracy in the data transmission process, so that the data transmission is more accurate. The method comprises the following steps: step 1, detecting whether a USB storage device is accessed; step 2, data transmission: after detecting that the USB storage equipment is accessed, dividing data to be transmitted into a plurality of groups according to the byte length of the data, arranging a check bit in each group, forming a new data frame by each group of data and the check bit, respectively transmitting the new data frame to a corresponding cache region, generating grouping information and transmitting the grouping information to the USB host. By grouping the transmission data and adding a check bit behind each group of data, each group of data is transmitted and detected in sequence, data loss or error transmission in the transmission process can be effectively avoided, and the accuracy of the transmission data is protected.

Description

USB data transmission based method
Technical Field
The invention relates to a data transmission method, in particular to a method based on USB data transmission.
Background
USB is a universal serial bus, a new high-speed serial interface supporting plug and play (PnP), which is a Hub (Hub) type bus interface, and up to 127 devices can be connected to one signal line, and therefore, it is also called "daisy chain" type interface. The USB is much faster than the original standard serial port, the original serial port is 115Kb/s, the USB data transmission rate can reach 12Mb/s, and the transmission rate is obviously improved.
The computer system has no unified standard for connecting with the interface of the peripheral equipment, for example, the socket of the keyboard is round, 9-pin or 25-pin parallel interface is needed for connecting the printer, and 9-pin or 25-pin serial interface is needed for the mouse. USB can unify these different interfaces by using only one 4-pin plug as a standard plug through which all peripherals can be connected in daisy chain fashion without losing bandwidth. The current USB interface can support the external devices such as scanners, digital products, printers, keyboards, mice and the like, and has the potential of replacing the original serial and parallel interfaces of a microcomputer.
In the aspect of data transmission, because the USB has the characteristics of hot plug capability, portability, and the like, the data transmission is very convenient, however, the existing scheme based on the USB data transmission at least has the following disadvantages: when the transmitted data is large, the USB data transmission is easily subjected to electromagnetic interference, the phenomenon of data loss or error transmission occurs, and if the data is retransmitted, a large amount of time is wasted; furthermore, voltage instability can also affect USB data transmission, causing data to change out of format, resulting in transmission errors.
Therefore, a new solution is needed to solve the above problems.
Disclosure of Invention
In view of the above, an objective of the present invention is to provide a method for transmitting data based on USB, so as to solve the problem of data accuracy in the data transmission process, and make the data transmission more accurate and stable.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method based on USB data transmission comprises the following steps:
step 1, detecting whether a USB storage device is accessed, wherein the detection is to detect the voltage of D-or D + on a USB interface of the USB storage device;
step 2, data transmission: after detecting that the USB storage equipment is accessed, dividing data to be transmitted into a plurality of groups according to the byte length of the data, arranging a check bit in each group, forming a new data frame by each group of data and the check bit, respectively transmitting the new data frame to a corresponding cache region, generating grouping information and transmitting the grouping information to a USB host;
step 3, detecting each group of transmitted data, and judging whether the transmitted data is accurate or not;
step 4, if the data of the transmission data is accurate, transmitting the data of the cache region to a target region, and if the data of the transmission data is not accurate, repeating the step 2;
and 5, detecting whether the data transmission is finished or not, if the data transmission is finished, finishing the data transmission, informing the USB storage device to be hung by the USB host, and if the data transmission is not finished, repeating the step 2.
Further, the USB storage device in step 1 may be one of a USB disk and a removable hard disk, and the USB host in step 2 is a computer and an operating system installed in the computer.
Further, the grouping information in step 2 includes the join order of each group of data and the length of each group of data.
Furthermore, the length of each group of data is split into a group of data with the length of 10 bytes, and if the length of the last group is less than 10 bytes, the last group is automatically divided into a group.
Further, the generation of the join order of each group of data is to arrange an order number for each group of data in sequence during data splitting as the join order of each group of data.
Further, the check bits in step 2 are obtained by CRC redundancy check, and the check bits are used for checking the transmission data corresponding to the check bits.
Further, the method for judging whether the transmitted data is accurate in the step 3 is to verify the transmitted data by using a check bit, namely, to perform division operation on the received data, and if the division operation is completed, the transmission is correct; if the data is not divided, the transmission is indicated to have errors, and the data with the errors needs to be transmitted again in the step 2.
Further, in the step 5, it is detected whether data transmission is completed, that is, the grouping information generated in the step 2 is utilized to obtain the connection order of the last group of data and the length of the last group of data, each group of data in the target area is detected according to the obtained connection order of the last group of data and the length of the last group of data, if it is detected that the connection order of the last group of data and the length of the last group of data are the same as the connection order and the length of the group of data in the target area, the data transmission is ended, and the USB host notifies the USB storage device of suspension; if not, repeating the step 2.
The invention has the beneficial effects that: 1. the data to be transmitted is grouped, a check bit is added behind each group of data, then each group of data is transmitted and detected, the transmitted data is detected by using the check bit, whether the data is transmitted wrongly or not can be effectively detected, if the data is transmitted wrongly, the data can be transmitted again, and the problem of data loss or wrong transmission in the transmission process is effectively avoided;
2. the invention groups the data to be transmitted, sends the grouping information to the USB host, and can obtain the connection order of the last group of data and the length of the last group of data by utilizing the grouping information, thereby detecting whether the transmission of the last group of data is finished in real time.
Drawings
Fig. 1 is a structure diagram of a USB interface provided by the present invention.
Fig. 2 is a schematic diagram of a USB interface circuit provided in the present invention.
Fig. 3 is a flowchart of a USB data transmission method according to the present invention.
Fig. 4 is a flow chart for detecting accuracy of transmitted data according to the present invention.
Fig. 5 is a flowchart for detecting whether data transmission is completed according to the present invention.
Detailed description of the invention
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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 some, but not all, embodiments of the present invention. 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.
Example 1
Referring to fig. 1 to 5, the present embodiment provides a method for transmitting data based on USB, including the following steps:
step 1, detecting whether a USB storage device is accessed, namely detecting the voltage of D-or D + on a USB interface of the USB storage device;
step 2, data transmission: after detecting that the USB storage equipment is accessed, dividing data to be transmitted into a plurality of groups according to the byte length of the data, arranging a check bit in each group, forming a new data frame by each group of data and the check bit, respectively transmitting the new data frame to a corresponding cache region, generating grouping information and transmitting the grouping information to a USB host;
step 3, detecting each group of transmitted data, and judging whether the transmitted data is accurate or not;
step 4, if the data of the transmission data is accurate, transmitting the data of the cache region to a target region, and if the data of the transmission data is not accurate, repeating the step 2;
and 5, detecting whether the data transmission is finished or not, if the data transmission is finished, finishing the data transmission, informing the USB storage device to be hung by the USB host, and if the data transmission is not finished, repeating the step 2.
Step 1, detecting whether a USB storage device is accessed, specifically:
as a preferred implementation manner of this embodiment, the USB storage device may be one of a USB disk and a removable hard disk;
as shown in FIGS. 1 and 2, the USB interface has four lines, wherein the white and green lines are data lines, denoted by D +, D-; the red and black lines are power lines, denoted Vbus, GND. The ports of the hub at the USB host end are respectively connected with a pull-down resistor of 15K ohms to the ground, and when no USB storage device is connected, the pull-down resistors are all at a low level; and a pull-up resistor of 1.5K ohm is connected to the D + or the D-at the end of the USB storage device. For full-speed and high-speed devices, the pull-up resistor is connected to D +; and the pull-up resistor of the low-speed device is connected to the D-terminal. When the device is plugged into a hub at the USB host end, the voltage of D + or D-of the port of the USB memory device is pulled high due to the voltage division of the pull-up resistor of 1.5K and the pull-down resistor of 15K. When the hub detects this condition, it reports to the USB host's USB host controller, thus detecting the insertion of the device.
If the USB storage equipment is detected to be accessed, a connection path for data transmission between the USB host and the USB storage equipment is established;
if the USB storage device is not detected to be accessed, a notification is sent to the USB main controller of the USB host, and the data transmission is finished.
Step 2, starting data transmission, specifically:
after detecting that the USB storage equipment is accessed, splitting data to be transmitted into a plurality of groups, wherein the data splitting takes 10 bytes as a group of data, if the length of the last group is less than 10 bytes, automatically dividing the data into one group, arranging a check bit in each group, forming a new data frame by each group of data and the check bit, respectively transmitting the new data frame to a corresponding cache region, and transmitting grouping information to the USB host;
the grouping information comprises the connection order of each group of data and the length of each group of data.
The check bits are obtained by CRC (cyclic redundancy check), and specifically comprise:
step 201, splitting data to be transmitted into a plurality of groups, wherein the data splitting takes 10 bytes as a group of data, if the length of the last group is less than 10 bytes, the data are automatically divided into one group, and each group of data is used as a data frame;
step 202, then selecting a suitable divisor;
step 203, looking at the binary digit number of the selected divisor, then adding 0 of-1 bit of the binary digit number of the divisor to the data frame to be transmitted, and then dividing the divisor by a newly generated frame in a mode of modulo-2 division, wherein the obtained remainder is the CRC check bit of the frame;
step 204, the calculated CRC check bits are appended to the original data frame to construct a new data frame, and the new data frame is sent to the corresponding buffer area.
As shown in fig. 4, in step 3, the transmitted data is detected, and whether the transmitted data is accurate is determined, specifically:
the method comprises the steps of detecting transmitted data, verifying the transmitted data by using a check bit, wherein the check bit can be used for verifying the accuracy of the transmitted data, and when the transmitted data and the check bit are received by a cache region, the received data can be verified by using the received check bit, so that whether errors occur in the data transmission process is determined.
Because the check bit adopts CRC, the received data is divided, if the data is divided completely, the transmission is correct; if not, it indicates that the transmission is in error. The method specifically comprises the following steps:
after receiving the new data frame, the receiving end removes the new data frame by the divisor selected in the step 202 in a mode of modulo-2 division, verifies whether the remainder is 0, and if so, indicates that the new data frame has no error.
If the data frame has no error, the next step is carried out;
if the data frame is erroneous, the process returns to step 203 to retransmit the data frame.
Step 4, receiving transmission data, specifically:
and after confirming that the data transmitted by the cache area is correct, starting to receive the transmitted data and storing the data in the target area.
As shown in fig. 5, step 5 detects whether the transmission is completed, specifically:
the grouping information generated in the step 2 is utilized to obtain the connection order of the last group of data and the length of the last group of data, each group of data in the target area is detected according to the obtained connection order of the last group of data and the length of the last group of data, if the connection order of the last group of data and the length of the last group of data are detected to be the same as the connection order and the length of the group of data in the target area, the data transmission is finished, and the USB host informs the USB storage device of being hung; if not, repeating the step 2.
Thus, the flow of the whole method is completed.
By combining with specific implementation, the method has the advantages that the data are grouped, a check bit is added behind each group of data, and each group of data are sequentially transmitted and detected, so that the problem of data loss or error transmission in the transmission process can be effectively avoided, the accuracy of the transmitted data is protected, and particularly when large-capacity data are transmitted, the data transmission method has more obvious effect and can effectively avoid unnecessary property loss.
The invention is not described in detail, but is well known to those skilled in the art.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (8)

1. A method based on USB data transmission is characterized by comprising the following steps:
step 1, detecting whether a USB storage device is accessed, and judging whether the USB storage device is accessed by detecting the voltage of D-or D + on a USB interface of the USB storage device;
step 2, data transmission: after detecting that the USB storage equipment is accessed, dividing data to be transmitted into a plurality of groups according to the byte length of the data, arranging a check bit in each group, forming a new data frame by each group of data and the check bit, respectively transmitting the new data frame to a corresponding cache region, generating grouping information and transmitting the grouping information to a USB host;
step 3, detecting each group of transmitted data, and judging whether the transmitted data is accurate or not;
step 4, if the data of the transmission data is accurate, transmitting the data of the cache region to a target region, and if the data of the transmission data is not accurate, repeating the step 2;
and 5, detecting whether the data transmission is finished or not, if the data transmission is finished, finishing the data transmission, informing the USB storage device to be hung by the USB host, and if the data transmission is not finished, repeating the step 2.
2. The method according to claim 1, wherein the USB storage device in step 1 is one of a USB disk and a removable hard disk, and the USB host in step 2 is a computer and an operating system installed therein.
3. The method according to claim 2, wherein the grouping information in step 2 includes the concatenation order of each group of data and the length of each group of data.
4. The method as claimed in claim 3, wherein the length of each group of data is split into 10 bytes, and the last group is automatically divided into one group if the length of the last group is less than 10 bytes.
5. The method as claimed in claim 4, wherein the generating of the concatenation order of each group of data is to arrange an order number for each group of data in sequence as the concatenation order of each group of data during data splitting.
6. The method according to claim 5, wherein the check bits in step 2 are obtained by CRC redundancy check, and the check bits are used for checking the transmission data corresponding to the check bits.
7. The method according to claim 6, wherein the step 3 of determining whether the transmitted data is accurate is to check the transmitted data by using the check bits, i.e. to divide the received data by division, and if the division is complete, the transmission is correct; if the data is not divided, the transmission is indicated to have errors, and the data with the errors needs to be transmitted again in the step 2.
8. The method as claimed in claim 7, wherein the step 5 detects whether the data transmission is completed, that is, the concatenation order of the last group of data and the length of the last group of data can be obtained by using the grouping information generated in the step 2, each group of data in the target area is detected according to the concatenation order of the last group of data and the length of the last group of data, if the concatenation order of the last group of data and the length of the last group of data are detected to be the same as the concatenation order and the length of the group of data in the target area, the data transmission is ended, and the USB host notifies the USB storage device of suspension; if not, repeating the step 2.
CN202111291463.4A 2021-11-03 2021-11-03 USB data transmission based method Pending CN113986785A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111291463.4A CN113986785A (en) 2021-11-03 2021-11-03 USB data transmission based method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111291463.4A CN113986785A (en) 2021-11-03 2021-11-03 USB data transmission based method

Publications (1)

Publication Number Publication Date
CN113986785A true CN113986785A (en) 2022-01-28

Family

ID=79745949

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111291463.4A Pending CN113986785A (en) 2021-11-03 2021-11-03 USB data transmission based method

Country Status (1)

Country Link
CN (1) CN113986785A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785452A (en) * 2022-03-16 2022-07-22 浙江万胜智能科技股份有限公司 Multi-channel data transmission method fusing terminal USB
CN117493248A (en) * 2023-12-29 2024-02-02 苏州元脑智能科技有限公司 USB data transmission method, device, system, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101272221A (en) * 2008-05-04 2008-09-24 中兴通讯股份有限公司 Transmission, receiving method and device of file data
CN104716991A (en) * 2015-03-26 2015-06-17 北京博望华科科技有限公司 Power line carrier communication system and method for data subpackage continuous transmission
CN106385304A (en) * 2016-08-31 2017-02-08 华为技术有限公司 Data transmission method, device and system
CN109981658A (en) * 2019-03-29 2019-07-05 泰信利美信息科技(常州)有限公司 A kind of novel anti-tampering data protection system
US20200250129A1 (en) * 2019-08-28 2020-08-06 Alibaba Group Holding Limited Rdma data sending and receiving methods, electronic device, and readable storage medium
CN112468407A (en) * 2020-12-15 2021-03-09 东莞中国科学院云计算产业技术创新与育成中心 Data subpackage transmission method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101272221A (en) * 2008-05-04 2008-09-24 中兴通讯股份有限公司 Transmission, receiving method and device of file data
CN104716991A (en) * 2015-03-26 2015-06-17 北京博望华科科技有限公司 Power line carrier communication system and method for data subpackage continuous transmission
CN106385304A (en) * 2016-08-31 2017-02-08 华为技术有限公司 Data transmission method, device and system
CN109981658A (en) * 2019-03-29 2019-07-05 泰信利美信息科技(常州)有限公司 A kind of novel anti-tampering data protection system
US20200250129A1 (en) * 2019-08-28 2020-08-06 Alibaba Group Holding Limited Rdma data sending and receiving methods, electronic device, and readable storage medium
CN112468407A (en) * 2020-12-15 2021-03-09 东莞中国科学院云计算产业技术创新与育成中心 Data subpackage transmission method and device, computer equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785452A (en) * 2022-03-16 2022-07-22 浙江万胜智能科技股份有限公司 Multi-channel data transmission method fusing terminal USB
CN117493248A (en) * 2023-12-29 2024-02-02 苏州元脑智能科技有限公司 USB data transmission method, device, system, electronic equipment and storage medium
CN117493248B (en) * 2023-12-29 2024-04-05 苏州元脑智能科技有限公司 USB data transmission method, device, system, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN113986785A (en) USB data transmission based method
US20050015655A1 (en) Intermediate station
CN112306766A (en) Method, electronic device, storage system and computer program product for error detection
JPH0813027B2 (en) Error detection method and apparatus for fiber distributed interfaced optical fiber links
CN108780430B (en) Sending Universal Serial Bus (USB) data over an alternate mode connection
CN102467431A (en) SATA interface testing device and method
CN102841838B (en) Device, system and method for automatically detecting inter-integrated circuit (I2C) and SGPIO (serious general-purpose input/output)
CN114116337A (en) Hard disk test method, system, terminal and storage medium based on PCIE link configuration
US20070271490A1 (en) Communicating with Error Checking to a Device Capable of Operating According to an Address Prefix Serial Bus Protocol
CN112256464A (en) Hard disk data error correction method and device, electronic equipment and storage medium
CN115542067A (en) Fault detection method and device
WO2021088368A1 (en) Method and device for repairing memory
CN113992239B (en) Device and method for detecting high-speed differential signal
CN115129509A (en) Data transmission method, device and medium
CN115729872A (en) Computing device and detection method for PCIE cable connection
US10635514B2 (en) Storage device, host system, and information processing system
CN116501536A (en) AXI interconnection module checking, checking and protecting method, device and storage medium
WO2023020114A1 (en) Data processing method and apparatus
CN113495849A (en) Data stream cutting device and method for physical layer
CN108780429B (en) Error handling techniques for high speed I/O data transfers
TWI479325B (en) Universal serial bus devices and communication methods and computer products
CN104168082B (en) Method and apparatus for error number estimation
US10461804B2 (en) Elimination of crosstalk effects in non-volatile storage
CN107704403B (en) Device and method for optimizing signal transmission of main back plate
US20060075280A1 (en) Data integrity verification

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