A USB communication testing method, device, equipment and storage medium

By obtaining the configuration file of the device to be tested in the test host, conducting USB communication tests, and determining and classifying the error packets, the USB communication stability problem is solved, and the accurate evaluation and analysis of USB communication quality is achieved.

CN114625587BActive Publication Date: 2025-05-13GEER TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210278602.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-21
Publication Date
2025-05-13
Estimated Expiration
2042-03-21

AI Technical Summary

Technical Problem

During the equipment production process, the stability of USB communication is affected by a variety of factors, resulting in transmission speed and accuracy issues, affecting production line production.

Method used

The test host obtains configuration files from the device to be tested, sends and receives test packets, determines the error packets in the target packet, and classifies statistics and outputs test reports according to the error type.

Benefits of technology

Ensure the stability of USB communication, help determine the reasons that affect the stability of USB communication by analyzing the type and number of error packets, and improves the accuracy and flexibility of the test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114625587B_ABST
    Figure CN114625587B_ABST
Patent Text Reader

Abstract

The present invention discloses a test method, device, equipment and storage medium for USB communication; in this solution, a test host can perform a communication test on a device to be tested that is connected through a USB interface according to a configuration file of the device to be tested. If a test data packet is disturbed or the communication is abnormal during USB communication, a target data packet will be generated, and the target data packet includes an error data packet, a timeout data packet, etc. After the test is completed and a test report is output, the USB communication test result of the device to be tested can be determined according to the test report. In addition, after the error data packets are classified and counted, the number of error data packets of each error classification can be counted and recorded in the test report, so that the reasons affecting the stability of USB communication can be determined by analyzing different types of target data packets and different types of error data packets in the future.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technology, and more specifically, to a testing method, device, equipment and storage medium for USB communication. Background Art

[0002] During the production process of the device, it is necessary to use the ADB (Android Debug Bridge) interface in the device to perform pre-delivery inspection of the device functions. In Android development, the commonly used ADB interface is the USB (Universal Serial Bus) interface. However, due to the complexity of device testing, there are many factors that affect the stability of USB communication, such as: USB communication line quality, USB HUB (Universal Serial Bus Hub) stability, test instrument interference and other factors, which will affect the transmission speed, transmission accuracy and test yield of USB communication, and thus affect production line production.

[0003] Therefore, how to test the stability of USB communication is a problem that those skilled in the art need to solve. Summary of the invention

[0004] The object of the present invention is to provide a USB communication testing method, device, equipment and storage medium to test the USB communication of the equipment and ensure the stability of the USB communication.

[0005] To achieve the above object, the present invention provides a USB communication testing method, which is executed by a testing host and includes:

[0006] Obtaining a configuration file from a connected device to be tested; wherein the device to be tested is connected to the test host via a USB interface;

[0007] Sending a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host;

[0008] receiving a second test data packet forwarded back by the device to be tested;

[0009] Comparing the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet;

[0010] Classify and count the error data packets according to their error types, and output a test report.

[0011] The step of obtaining a configuration file from the connected device to be tested includes:

[0012] Detect newly connected devices to be tested;

[0013] Searching for a configuration file from a specified directory of the device to be tested;

[0014] If the configuration file does not need to be set, the first test data packet is directly sent to the device to be tested according to the configuration file; otherwise, after the configuration file is set, the first test data packet is sent to the device to be tested according to the set configuration file.

[0015] The step of setting the configuration file includes:

[0016] Determine the hardware properties of the device to be tested according to the configuration file;

[0017] The configuration file is set using the hardware attributes.

[0018] The step of setting the configuration file includes:

[0019] The configuration file is set according to the setting instruction input by the user.

[0020] After comparing the first test data packet and the second test data packet to determine the target data packet, the method further includes:

[0021] If it is detected that the number of the error data packets exceeds a predetermined threshold, the transmission speed of the test data packets is reduced.

[0022] After obtaining the configuration file from the connected device to be tested, the method further includes:

[0023] Setting the test conditions of the device to be tested;

[0024] Correspondingly, sending the first test data packet to the device to be tested according to the configuration file includes: sending the first test data packet to the device to be tested according to the configuration file and the test condition.

[0025] The step of setting the test conditions of the device to be tested includes:

[0026] At least one test condition of the data interval time, data packet size, CPU usage rate and memory usage rate of the device to be tested is set.

[0027] To achieve the above object, the present invention further provides a USB communication test device, the test device is applied to test a host, and the test device comprises:

[0028] An acquisition module, used to acquire a configuration file from a connected device to be tested; wherein the device to be tested is connected to the test host via a USB interface;

[0029] A sending module, configured to send a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host;

[0030] A receiving module, used for receiving a second test data packet forwarded back by the device to be tested;

[0031] A comparison module, used for comparing the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet;

[0032] The output module is used to classify and count the error types of the error data packets and output a test report.

[0033] To achieve the above object, the present invention further provides an electronic device, comprising:

[0034] Memory for storing computer programs;

[0035] A processor is used to implement the steps of the above-mentioned testing method when executing the computer program.

[0036] To achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above test method are implemented.

[0037] It can be seen from the above scheme that a test method for USB communication provided by an embodiment of the present invention is executed by a test host, specifically including: obtaining a configuration file from a connected device to be tested; the device to be tested is connected to the test host through a USB interface; sending a first test data packet to the device to be tested according to the configuration file so that the device to be tested forwards the first test data packet back to the test host; receiving a second test data packet forwarded back by the device to be tested; comparing the first test data packet and the second test data packet to determine the target data packet; wherein the target data packet includes an error data packet; classifying and counting the error types of the error data packets, and outputting a test report. It can be seen that in the scheme, the test host can perform a communication test on the device to be tested connected through the USB interface according to the configuration file of the device to be tested. If the test data packet is interfered or the communication is abnormal in the USB communication, a target data packet will be generated, and the target data packet includes an error data packet, a timeout data packet, etc.; after the test is completed and the test report is output, the USB communication test result of the device to be tested can be determined according to the test report. In addition, after the error data packets are classified and counted, the number of error data packets of each error classification can be counted and recorded in the test report, so that the reasons affecting the stability of USB communication can be determined by analyzing different types of target data packets and different types of error data packets in the future.

[0038] The invention also discloses a USB communication test device, equipment and storage medium, which can also achieve the above technical effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A schematic flow chart of a USB communication testing method disclosed in an embodiment of the present invention;

[0041] Figure 2 A schematic diagram of the structure of a USB communication test system disclosed in an embodiment of the present invention;

[0042] Figure 3 A data flow diagram disclosed in an embodiment of the present invention;

[0043] Figure 4 A schematic diagram of the structure of a USB communication test device disclosed in an embodiment of the present invention;

[0044] Figure 5The present invention is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] The embodiment of the invention discloses a USB communication test method, device, equipment and storage medium, so as to test the USB communication of the equipment and ensure the stability of the USB communication.

[0047] See also Figure 1 , a flow chart of a USB communication test method provided by an embodiment of the present invention, the test method is executed by a test host, and the test method specifically includes the following steps:

[0048] S101, obtaining a configuration file from a connected device to be tested; wherein the device to be tested is connected to a test host via a USB interface;

[0049] In this embodiment, the test host is used to test the USB communication quality of each device to be tested. The device to be tested can be a product to be tested in a production line, specifically a device based on the Android operating system, such as: smart speakers, smart watches, smart headphones, etc., which are not limited here.

[0050] In this solution, it is necessary to create a configuration file containing various configuration items in the specified directory of each device to be tested in advance, such as creating company / factory / test_pattern.json in the root directory. In this embodiment, json (JavaScript Object Notation, JS object notation) can be used to store the configuration file, and some configuration items in the configuration file can be set, as shown in Table 1, which is a schematic table of a configuration file provided in an embodiment of the present invention:

[0051] Table 1

[0052]

[0053] As can be seen from Table 1, in this embodiment, the content of the configuration file specifically includes: VID (vendor ID), PID (product identification code), Speed ​​(communication rate), Charger type (charging mode), USB support (USB supported protocol standard), USB Transport (transmission mode), Test mode (test mode). Among them, VID and PID are the hardware attributes of the device to be tested, and the test host can identify the currently inserted device to be tested by obtaining the hardware attributes; the communication rate can be automatically matched during the test process, so that different communication rates are used to test USB communication in different situations; the charging mode is the charging mode of the device to be tested during the USB communication test process. By configuring the charging mode, it can be obtained whether different charging modes have an impact on USB communication; USB support is used to configure the bus protocol standard supported by the current device to be tested; the test mode in this embodiment includes: responsiveness test mode and large data transmission stress test mode, each test mode has a different transmission mode, wherein: the transmission mode of the responsiveness test mode is: interrupt transmission and control transmission, and the transmission mode of the large data transmission stress test mode is: synchronous transmission and large transmission. In this embodiment, the specific selection of which test mode and transmission mode of the test mode can be customized.

[0054] See also Figure 2 , a schematic diagram of a USB communication test system structure provided by an embodiment of the present invention, through Figure 2 It can be seen that the test system includes a test host and a device to be tested. The test host uses python (computer programming language) to implement the driver. Due to the diversity of USB device classes in the production line, the use of python scripts can shield the differences in USB handshake information. The driver is used to realize the communication between the test host and the device to be tested. The functions realized include: detecting the newly inserted device to be tested, and obtaining the hardware properties from the configuration file of the device to be tested in order to identify the device to be tested. After identifying the device to be tested, the test software can test the USB communication between the test host and the device to be tested through the configuration file.

[0055] In this embodiment, the driver code implemented using Python is as follows:

[0056]

[0057] In this embodiment, Udev (device manager) is used in the device to be tested to realize dynamic loading and control of USB parameters in the configuration file. Specifically, Udev and devfs (device file system) are similar in function and are both used to manage system peripherals (for example, USB ports and serial ports, Udev and devfs are used to manage peripherals). Udev is a driver device management mechanism related to user state, providing a solution for dynamic device node management and naming based on user space. Udev is independent of the hardware platform and belongs to the process of user space. It is a background program. It is separated from the driver layer and is built on the operating system. Udev only needs to modify the configuration file to make it effective without restarting the operating system. In this embodiment, when the underlying device of the device to be tested is plugged in or out, Udev will monitor these events and create, name, and control permissions of the corresponding device nodes in the upper layer.

[0058] That is to say, when the device to be tested is inserted into the test host, the Udev of the device to be tested will receive the system broadcast and automatically match it with the test software on the test host through the written Udev script. The matching process is: determine whether the device to be tested is inserted into the test host. If it is the test host, continue to execute the subsequent test process. If it is not the test host but other devices, end the process.

[0059] Specifically, this application adds the following two scripts to the / etc / udev / rules file:

[0060] 1) Mount the script:

[0061] ACTION! ="add",GOTO="factory_usb_test"

[0062] KERNEL=="sd[az][0-9]",RUN+="mount-t vfat / dev / $1 / mnt / usb&sync%k"

[0063] KERNEL=="sd[az]",RUN+="mount-t vfat / dev / $1 / mnt / usb&sync%k"

[0064] LABEL="factory_usb_test"

[0065] 2) Uninstall script:

[0066] ACTION! ="remove",GOTO="factory_usb_test"

[0067] SUBSYSTEM! ="block",GOTO="factory_usb_test"

[0068] KERNEL=="sd[az][0-9]",RUN+="sync&umount / mnt / usb"

[0069] LABEL="factory_usb_test"

[0070] Among them, the mount script is automatically executed after the device is inserted into the test host. It is used to establish an association between the software and hardware of the device to be tested, so that the test host can obtain the configuration file from the device to be tested and perform subsequent USB communication tests; the uninstall script is automatically executed after the device is unplugged from the test host. It is used to uninstall the device, thereby deleting the relevant data generated by this mount.

[0071] S102, sending a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host;

[0072] S103, receiving a second test data packet forwarded back by the device to be tested;

[0073] In this embodiment, the configuration file records the relevant configurations for executing the test process, such as test mode, transmission mode, etc. Therefore, when the present application performs a USB communication test on the device to be tested, the test can be performed according to the contents recorded in the configuration file.

[0074] It should be noted that in the related art, the USB communication of the device can be tested by professional instruments. However, the professional instruments are very expensive, have high requirements for the test environment, and the product testing process is complicated. In this application, the test host mainly uses pure software to test the USB signal quality, which is low-cost and easy to access. When testing the device, the instrument cost and test complexity can be ignored, so that the USB communication test of the equipment on the production line can be performed more flexibly. For the convenience of explanation, the test software in the test host is called: USB loopback, see Figure 3 , is a data flow diagram provided by an embodiment of the present invention, through Figure 3It can be seen that the data flow between the test host and the device to be tested is: the test host sends a test data packet to the device to be tested, and after receiving the test data packet, the device to be tested completely forwards the received test data packet to the test host. For the convenience of distinction, the test data packet sent by the test host is called the first test data packet in this embodiment, and the test data packet forwarded back by the device to be tested received by the test host is called the second test data packet. In addition, in this embodiment, the number, sending interval, data size, etc. of the first test data packet and the second test data packet are not limited. In actual testing, the settings can be customized according to needs.

[0075] S104, comparing the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet;

[0076] It should be noted that if the USB communication between the test host and the device to be tested is not affected, then under normal circumstances, the test host should promptly receive the second test data packet that is identical to the first test data packet returned by the host to be tested. In this embodiment, the second test data packet that is identical to the first test data packet promptly received by the test host is called a correct data packet, and the total number of correct data packets received is recorded for display in the test report; however, there are many factors in the production line that will lead to the generation of target data packets, such as: high-frequency, high-interference instruments in the production line will interfere with the communication process, thereby generating error data packets, because host communication abnormalities and other situations will generate timeout data packets, etc. In this embodiment, when determining an error data packet, the contents of the first test data packet and the second test data packet may be compared for determination, such as: if the check value of the first test data packet is check value 1, and the check value of the second test data packet is check value 2, since check value 1 is not equal to check value 2, then the second test data packet is an error data packet; when determining a timeout data packet, the sending time of the first test data packet and the receiving time of the second test data packet may be compared for determination, such as: if the time interval between the sending time of the first test data packet and the receiving time of the second test data packet exceeds 10 milliseconds, then the second test data packet is determined to be a timeout data packet.

[0077] S105, classify and count the error data packets according to their error types, and output a test report.

[0078] In this embodiment, the test report includes all relevant information in this test, such as: hardware attributes of the device, test mode, transmission mode, test time, tester, total number of first test data packets, total number of correct test packets, total number of target data packets, number of different types of data packets in the target data packets, etc. In addition, in order to more clearly determine the factors affecting USB communication, different problem data packets in the error data packets can be classified and counted, see Table 2, which is a data packet classification table provided in an embodiment of the present invention:

[0079] Table 2

[0080]

[0081]

[0082] In summary, in this application, the test host can perform a communication test on the device to be tested connected through the USB interface according to the configuration file of the device to be tested. If the test data packet is disturbed or the communication is abnormal during USB communication, a target data packet will be generated, and the target data packet includes an error data packet, a timeout data packet, etc. After the test report is output, the stability test result of the device to be tested communicating through the USB interface can be determined based on the test report. In addition, after the error data packets are classified and counted, the number of error data packets of each error classification can be counted in the present application, and recorded in the test report, so that the reasons affecting the stability of USB communication can be determined by analyzing the number of each target data packet and the number of each error data packet in the future.

[0083] Based on the above embodiment, in this embodiment, when the test host obtains the configuration file from the connected device to be tested, it specifically includes:

[0084] Detect newly connected devices to be tested;

[0085] Search for configuration files in the specified directory of the device to be tested;

[0086] If the configuration file does not need to be set, the first test data packet is directly sent to the device to be tested according to the configuration file; otherwise, after the configuration file is set, the first test data packet is sent to the device to be tested according to the set configuration file.

[0087] In this embodiment, after the device to be tested is inserted into the test host, the driver of the test host will detect it and automatically search for the configuration file from the specified directory of the device to be tested, such as: if the specified directory is: company / factory / test_pattern.json, then the configuration file is searched from this directory. In addition, there are two types of configuration files, one is a file that has been configured and does not need to be configured by the test host, and the other is a file that needs to be configured by the test host. If the configuration file has been configured by triggering the high and low levels of the circuit board after the device to be tested is inserted into the test host, then after the test host obtains the configuration file, it can directly perform subsequent USB communication tests according to the configuration file, that is: execute S102~S10; if the configuration file is not configured after the device to be tested is inserted into the test host, then after the configuration file is configured, subsequent USB communication tests are performed.

[0088] Among them, the test host can set the configuration file by using the hardware attributes to determine the hardware attributes of the device to be tested according to the configuration file. The hardware attributes are the VID and PID obtained from the configuration file. Different VIDs and PIDs correspond to different configurations, so the test host can set the configuration file according to the VID and PID of the device to be tested. In addition, the present application can also set the configuration file according to the setting instructions input by the user. In this way, the configuration of the device to be tested can be customized according to the actual needs of the user.

[0089] Furthermore, in the production line, there are two working modes, one working mode is the test mode, which is used to test the workstation environment. In this mode, a high-speed communication mode is used during the USB communication test; the other working mode is the working mode, and the working mode needs to be negotiated with the device side in the handshake stage. In addition, in the present embodiment, in the working mode, the automatic speed reduction function can be supported, that is: if the number of error data packets detected exceeds a predetermined threshold, the transmission speed of the test data packets is reduced. Moreover, if during the test, a retransmission data packet needs to be sent after an error data packet appears, then the number of error data packets and retransmission data packets will be similar. In the automatic speed reduction, it can also be determined whether the number of retransmission data packets exceeds the predetermined threshold. If it exceeds the predetermined threshold, the transmission speed is automatically reduced until the lowest rate. See Table 3, which is a schematic diagram of the transmission speed provided in an embodiment of the present invention:

[0090] Table 3

[0091] Speed ​​Grade Transfer speed USB1.0 1.5Mbps USB1.1 12Mbps USB2.0 480Mbps USB3.0 -

[0092] From the above, it can be seen that in the present application, the configuration file can be configured through the device to be tested or the test host. After the configuration is completed, the test host can perform different tests according to the configuration file; and, when the present application configures the configuration file through the test host, it can not only automatically configure according to the hardware properties of the device, but also set the configuration file according to the setting instructions triggered by the user, so as to meet different test requirements and improve the flexibility of the test; further, during the test process, the present application can also automatically adjust the transmission speed of the test data packet according to the number of error data packets, so that the test results at different transmission rates can be reflected in the output test report, thereby improving the flexibility of USB communication testing and improving the user experience.

[0093] Based on any of the above embodiments, in this embodiment, after the test host obtains the configuration file from the connected device to be tested, the process further includes:

[0094] Set the test conditions for the device to be tested; correspondingly, when the present application sends the first test data packet to the device to be tested according to the configuration file, specifically, the first test data packet is sent to the device to be tested according to the configuration file and the test conditions.

[0095] It should be noted that due to factors such as the complex factory environment and the complex usage of the test host, the present application sets the test conditions for the device to be tested in order to meet different test scenarios when conducting USB communication quality tests. The test conditions include: data interval time, data packet size, CPU usage rate and memory usage rate, wherein the data interval time is the time interval for sending test data packets, the data packet size is the size of each test data packet, the CPU usage rate and the memory usage rate are the usage rates of the test host when executing the test, and the CPU usage rate and the memory usage rate can be implemented by software simulation, specifically by using a python script. When testing the host to be tested, at least one of the test conditions of the data interval time, data packet size, CPU usage rate and memory usage rate of the device to be tested can be set so as to test the USB communication stability of the host to be tested in different test scenarios. See Table 4, which is a schematic diagram of the test conditions provided for an embodiment of the present invention:

[0096] Table 4

[0097] Interval time 1ms 10ms 100ms 1000ms Packet size 10byte 100byte 1024byte 10000byte CPU usage <10% <20% <50% <100% Memory usage <50% <70% <90% <100%

[0098] It can be seen from Table 4 that the data interval time, data packet size, CPU usage and memory usage in this application can be set to different values. Before executing the test, each test condition can be combined to generate the final test condition, such as: setting the interval time to 1ms, the data packet size to 10bytes, the CPU usage to 5%, and outputting the test report after the test process is automatically run. In this test report, the test conditions of this test will also be recorded. In this way, the staff can understand the test conditions of each test, so as to better analyze the stability of USB communication.

[0099] The following is an introduction to the testing device, equipment and medium provided in the embodiments of the present invention. The testing device, equipment and medium described below can be referenced to the testing method described above.

[0100] See also Figure 4 , a schematic diagram of the structure of a USB communication test device provided by an embodiment of the present invention, the test device is applied to test a host, and the test device includes:

[0101] The acquisition module 11 is used to acquire a configuration file from the connected device to be tested; wherein the device to be tested is connected to the test host through a USB interface;

[0102] A sending module 12, configured to send a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host;

[0103] A receiving module 13, configured to receive a second test data packet forwarded back by the device to be tested;

[0104] A comparison module 14, configured to compare the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet;

[0105] The output module 15 is used to classify and count the error types of the error data packets and output a test report.

[0106] The acquisition module includes:

[0107] A detection unit, used to detect a newly connected device to be tested;

[0108] A search unit, used to search for a configuration file from a specified directory of the device to be tested;

[0109] A configuration unit, used for setting the configuration file when the configuration file needs to be set;

[0110] The sending module is specifically used to send the first test data packet to the device to be tested directly according to the configuration file when the configuration file does not need to be set; when the configuration file needs to be set, send the first test data packet to the device to be tested according to the set configuration file.

[0111] Wherein, the configuration unit includes:

[0112] The first configuration subunit is used to determine the hardware attributes of the device to be tested according to the configuration file, and to set the configuration file using the hardware attributes.

[0113] Wherein, the configuration unit includes:

[0114] The second configuration subunit is used to configure the configuration file according to the configuration instruction input by the user.

[0115] The device further comprises:

[0116] The processing module is used to reduce the transmission speed of the test data packets when it is detected that the number of the error data packets exceeds a predetermined threshold.

[0117] The device further comprises:

[0118] A setting module, used to set the test conditions of the device to be tested;

[0119] Correspondingly, the sending module is specifically used to send a first test data packet to the device to be tested according to the configuration file and the test conditions.

[0120] The setting module is specifically used to set at least one test condition of the data interval time, data packet size, CPU usage rate and memory usage rate of the device to be tested.

[0121] See also Figure 5 , an embodiment of the present invention further provides a schematic diagram of the structure of an electronic device, including:

[0122] A memory 21, used for storing computer programs;

[0123] The processor 22 is used to implement the steps of the testing method described in any of the above method embodiments when executing the computer program.

[0124] In this embodiment, the device may be a PC (Personal Computer), or may be a terminal device such as a smart phone, a tablet computer, a PDA, or a portable computer.

[0125] The device may include a memory 21 , a processor 22 , and a bus 23 .

[0126] Among them, the memory 21 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 21 can be an internal storage unit of the device, such as a hard disk of the device. In other embodiments, the memory 21 can also be an external storage device of the device, such as a plug-in hard disk equipped on the device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 21 can also include both an internal storage unit of the device and an external storage device. The memory 21 can not only be used to store application software and various types of data installed in the device, such as program codes for executing test methods, etc., but also can be used to temporarily store data that has been output or is to be output.

[0127] In some embodiments, the processor 22 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 21, such as program codes for executing test methods.

[0128] The bus 23 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0129] Furthermore, the device may also include a network interface 24, which may optionally include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the device and other electronic devices.

[0130] Optionally, the device may further include a user interface 25, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 25 may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the device and to display a visual user interface.

[0131] Figure 5 Only the device with components 21-25 is shown, and it can be understood by those skilled in the art that Figure 5 The structure shown does not constitute a limitation of the device, and may include fewer or more components than shown, or combine certain components, or arrange the components differently.

[0132] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test method described in any of the above method embodiments are implemented.

[0133] The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0134] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0135] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for testing USB communication, characterized in that: The test method is executed by a test host, and the test method includes: Obtaining a configuration file from a connected device to be tested; wherein the device to be tested is connected to the test host via a USB interface; Sending a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host; receiving a second test data packet forwarded back by the device to be tested; Comparing the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet; Classify and count the error data packets according to their error types, and output a test report.

2. The testing method according to claim 1, characterized in that: The step of obtaining a configuration file from the connected device to be tested includes: Detect newly connected devices to be tested; Searching for a configuration file from a specified directory of the device to be tested; If the configuration file does not need to be set, the first test data packet is directly sent to the device to be tested according to the configuration file; otherwise, after the configuration file is set, the first test data packet is sent to the device to be tested according to the set configuration file.

3. The testing method according to claim 2, characterized in that: The setting of the configuration file includes: Determine the hardware properties of the device to be tested according to the configuration file; The configuration file is set using the hardware attributes.

4. The testing method according to claim 2, characterized in that: The setting of the configuration file includes: The configuration file is set according to the setting instruction input by the user.

5. The testing method according to claim 1, characterized in that: After comparing the first test data packet and the second test data packet to determine the target data packet, the method further includes: If it is detected that the number of the error data packets exceeds a predetermined threshold, the transmission speed of the test data packets is reduced.

6. The testing method according to any one of claims 1 to 5, characterized in that: After obtaining the configuration file from the connected device to be tested, the method further includes: Setting the test conditions of the device to be tested; Correspondingly, sending the first test data packet to the device to be tested according to the configuration file includes: sending the first test data packet to the device to be tested according to the configuration file and the test condition.

7. The testing method according to claim 6, characterized in that: The step of setting the test conditions of the device to be tested includes: At least one test condition of the data interval time, data packet size, CPU usage rate and memory usage rate of the device to be tested is set.

8. A USB communication test device, characterized in that: The testing device is applied to a testing host, and the testing device comprises: An acquisition module, used to acquire a configuration file from a connected device to be tested; wherein the device to be tested is connected to the test host via a USB interface; A sending module, configured to send a first test data packet to the device to be tested according to the configuration file, so that the device to be tested forwards the first test data packet back to the test host; A receiving module, used for receiving a second test data packet forwarded back by the device to be tested; A comparison module, used for comparing the first test data packet and the second test data packet to determine a target data packet; wherein the target data packet includes an error data packet; The output module is used to classify and count the error types of the error data packets and output a test report.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the testing method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the testing method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Product function testing method and device

    CN109800119A

  • Test method, electronic equipment and computer readable storage medium

    CN110659171A