Multi-channel control USB connection on-off automatic test method and test equipment
Through the multi-channel control of USB connection on-off automated testing methods and equipment, the problem of low USB port testing efficiency in the prior art is solved, and the automated pressure testing of USB connection on-off is realized, which improves the testing efficiency and reliability.
Patent Information
- Application Number
- CN202411943956.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-27
AI Technical Summary
In the prior art, USB port testing mainly relies on manual hot swapping, which is inefficient and time-consuming, making it difficult to realize automated testing of USB connection on and off.
The multi-channel control USB connection on-off automatic testing methods and equipment are adopted to realize automatic pressure measurement of USB on-off connection between the host computer under test and USB external device through the USB on-off test box, serial port control module and script M.
It realizes automatic pressure testing of USB connection on and off, improves testing efficiency and reliability, reduces costs, and the test method is simple and easy to operate.
Smart Images

Figure CN119759673A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of automotive electronic software and USB communication on-off testing, and in particular to an automatic testing method and testing equipment for multi-channel controlled USB connection on-off. Background Art
[0002] At present, the test method for testing the USB port of intelligent system equipment is mainly to verify the reliability and compatibility of the USB recognition, USB connection and other functions of the intelligent system equipment by manually hot-plugging various brands of test USB flash drives and USB test peripherals on the market and manually performing stress tests that require USB peripheral plugging and unplugging. Manual stress testing is time-consuming, laborious and inefficient. Summary of the invention
[0003] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a multi-channel controlled USB connection on-off automatic testing method and testing equipment.
[0004] To achieve the above object, the present invention adopts the following technical solution: a multi-channel control USB connection on-off automatic testing method, comprising the following steps: S1: The USB continuity test box is connected to the 5V power input port; The continuity test box realizes the automatic stress test of the USB continuity connection between the tested vehicle host and the USB external device; S2: Insert the test USB peripheral into the USB female interface; The test USB peripherals are U disk and USB serial port; S3: Insert the USB continuity test port 6 into the USB female port of the terminal under test; The terminal under test is the vehicle host under test; S4: Connect the serial port input port to the computer, and input the serial port control command to the serial port control module through the computer; The computer is provided with a designed script M; The script M is used to describe the USB virtual serial port, and the serial port control instruction is sent to the serial port control module through the USB virtual serial port; The serial port control module is used to receive the serial port control instruction and convert the serial port control instruction from the corresponding hexadecimal system to binary system; The specific contents of the script M are as follows: S41: Create USB virtual serial ports COM1, COM2, COM3, and COM4 through the COM0COM tool in the Python library; S42: Setting USB virtual serial port parameters; S43: Processing USB virtual serial port data; Use the read function to read data, use the write function to write data, and use the select function to process asynchronous data.
[0005] In step S43, the following steps are included: S431: Set the parameters related to the select function; Use the FD_ZERO function to initialize the fd_set variable, including FD_ZERO(&read_fds); FD_ZERO(&write_fds); here read_fds and write_fds are used to monitor the readable and writable status respectively; Use the FD_SET function to add the serial port file descriptor to the fd_set to be monitored, wherein the FD_SET function includes the FD_SET(fd,&read_fds) function and the FD_SET(fd,&write_fds) function; Set the timeout timeout of the struct timeval type variable, and set the timeout timeout to 1 second; S432: loop calling the select function and processing the results; Call the select function in an infinite loop; Perform different processing according to the return value ret of the select function; The return value ret = select(fd+1,&read_fds,&write_fds, NULL,&timeout); The fd+1 is the first parameter of the select function, which is the maximum value of all file descriptors to be calculated plus 1; The NULL here represents a file descriptor set of data exception events; If ret == -1, it means that the select function call has an error, and the perror function is used to output the error message and possibly exit the loop; If ret == 0, it means the select function has timed out and you can handle it accordingly (such as resetting the select parameters and calling it again). If ret>0, it means an event occurs: If FD_ISSET(fd,&read_fds) is true, it means that there is data to read from the serial port. At this time, you can use the read function to read the serial port data, and then process the read data; If FD_ISSET(fd,&write_fds) is true, it means the serial port is writable and you can use the write function to send data to the serial port.
[0006] S5: After receiving the command, the serial port control module controls the serial port relay to open and close, realizing the on and off of the VCC power supply line; When the serial port control module sends a closing command, the serial port relay is triggered to close, realizing a closed circuit, and the US peripheral starts to power on, and the USB connection with the terminal under test can be completed; When the serial port control module sends a disconnect command, the serial port relay is triggered to disconnect, thereby disconnecting the circuit. The VCC power supply of the USB peripheral is disconnected and stops working. The USB peripheral can then disconnect the USB connection with the terminal under test.
[0007] Furthermore, a multi-channel controlled USB connection on-off automated test device is provided, wherein the multi-channel controlled USB connection on-off automated test device comprises a USB female interface; a serial port control module; a serial port command input port; a 5V power input port; a serial port relay; and a USB on-off test port.
[0008] USB female port: insert the test USB peripheral.
[0009] Serial port control module: used to receive serial port commands and control serial port relays.
[0010] Serial command input port: connected to the control computer.
[0011] 5V power input port: provides power for the serial port control module.
[0012] Serial port relay: receives commands from the serial port control module and controls the opening and closing of the circuit.
[0013] USB continuity test port: plug into the USB female port of the terminal under test.
[0014] The USB female connector is arranged on the outside of the automated testing equipment, the serial port relay is connected to the USB female connector, and the serial port relay is respectively connected to the serial port control module and the USB on-off test port; the serial port command input port is arranged in the serial port control module, and the 5V power input port is connected to the serial port control module.
[0015] Furthermore, each of the USB female interfaces is connected in series with the serial port relay, and each of the USB female interfaces is provided with a serial port relay for use therewith.
[0016] Furthermore, the serial port relays are connected to the serial port control module in parallel.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention uses multi-channel control of USB connection on-off automated testing equipment and testing methods, and uses computer-designed scripts to perform automated stress testing, which is reliable, low-cost, and the testing method is simple and easy to operate. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a flow chart of the testing method of Example 1 of the present invention; Figure 2 Schematic diagram of the circuit structure of embodiment 1 of the present invention; Label explanation: 1- USB female interface; 2- serial port control module; 3- serial port command input port; 4- 5V power input port; 5- serial port relay; 6- USB on-off test port. DETAILED DESCRIPTION
[0019] In order to provide a further understanding of the purpose, structure, features, and functions of the present invention, the following detailed description is given in conjunction with the embodiments.
[0020] The method for automatically testing the on / off connection of multiple-channel controlled USB connections comprises the following steps: S1: The USB continuity test box is connected to the 5V power input port 4; The continuity test box realizes the automatic stress test of the USB continuity connection between the tested vehicle host and the USB external device; S2: Insert the test USB peripheral into the USB female port 1; The test USB peripherals are U disk and USB serial port; S3: insert the USB continuity test port 6 into the USB female port 6 of the terminal under test; The terminal under test is the vehicle host under test; S4: Connect the serial port input port to the computer, and input the serial port control command to the serial port control module through the computer; The computer is provided with a designed script M; The script M is used to describe the USB virtual serial port, and the serial port control instruction is sent to the serial port control module through the USB virtual serial port; The serial port control module is used to receive the serial port control instruction and convert the serial port control instruction from the corresponding hexadecimal system to binary system; The specific contents of the script M are as follows: S41: Create USB virtual serial ports COM1, COM2, COM3, and COM4 through the COM0COM tool in the Python library; S42: Setting USB virtual serial port parameters; S43: Processing USB virtual serial port data; Use the read function to read data, use the write function to write data, and use the select function to process asynchronous data.
[0021] In step S43, the following steps are included: S431: Set the parameters related to the select function; Use the FD_ZERO function to initialize the fd_set variable, including FD_ZERO(&read_fds); FD_ZERO(&write_fds); here read_fds and write_fds are used to monitor the readable and writable status respectively; Use the FD_SET function to add the serial port file descriptor to the fd_set to be monitored, wherein the FD_SET function includes the FD_SET(fd,&read_fds) function and the FD_SET(fd,&write_fds) function; Set the timeout timeout of the struct timeval type variable, and set the timeout timeout to 1 second; S432: loop calling the select function and processing the results; Call the select function in an infinite loop; Perform different processing according to the return value ret of the select function; The return value ret = select(fd+1,&read_fds,&write_fds, NULL,&timeout); The fd+1 is the first parameter of the select function, which is the maximum value of all file descriptors to be calculated plus 1; The NULL here represents a file descriptor set of data exception events; If ret == -1, it means that the select function call has an error, and the perror function is used to output the error message and possibly exit the loop; If ret == 0, it means the select function has timed out and you can handle it accordingly (such as resetting the select parameters and calling it again). If ret>0, it means an event occurs: If FD_ISSET(fd,&read_fds) is true, it means that there is data to read from the serial port. At this time, you can use the read function to read the serial port data, and then process the read data; If FD_ISSET(fd,&write_fds) is true, it means the serial port is writable and you can use the write function to send data to the serial port.
[0022] By setting up a USB virtual serial port, the compatibility of the system is improved. The USB virtual serial port can work normally in a variety of operating system environments and can run across platforms. It is easy to use and saves work time and cost.
[0023] S5: After receiving the command, the serial port control module controls the serial port relay to open and close, realizing the on and off of the VCC power supply line; When the computer sends a closing command, the serial port relay is triggered to close, realizing a closed circuit, and the USB peripheral starts to power on, and the USB connection with the tested terminal can be completed; When the computer sends a disconnect command, the serial port relay is triggered to disconnect, thereby disconnecting the circuit. The VCC power supply of the USB peripheral is disconnected and stops working. The USB peripheral can then disconnect the USB connection with the terminal under test.
[0024] Therefore, according to this test method and the multi-channel control USB connection on-off test device, the USB connection on-off automatic stress test and the multi-channel USB connection on-off test can be realized, and the automatic compatibility test of replacing USB peripherals can be realized. Further, the multi-channel control USB connection on-off automatic test device, the multi-channel control USB connection on-off automatic test device includes a USB female interface 1; a serial port control module 2; a serial port command input port 3; a 5V power input port 4; a serial port relay 5; and a USB on-off test port 6.
[0025] USB female port 1: Insert the test USB peripheral.
[0026] Serial port control module 2: used to receive serial port commands and control serial port relays.
[0027] Serial command input port 3: connected to the control computer.
[0028] 5V power input port 4: provides power for serial port control module 2.
[0029] Serial port relay 5: receives commands from serial port control module 2 and controls the opening and closing of the circuit.
[0030] USB continuity test port 6: Insert the USB female port of the terminal under test.
[0031] The USB female connector 1 is arranged on the outside of the automated testing equipment, the serial port relay 5 is connected to the USB female connector 1, and the serial port relay 5 is respectively connected to the serial port control module 2 and the USB on-off test port 6; the serial port command input port 3 is arranged in the serial port control module 2, and the 5V power input port 4 is connected to the serial port control module 2.
[0032] Furthermore, each of the USB female interfaces 1 is connected in series with the serial port relay 5, and each of the USB female interfaces 1 is provided with a serial port relay 5 used in conjunction therewith, so as to ensure that each serial port relay 5 can be controlled separately from the USB female interface 1 to avoid mutual interference of electrical signals.
[0033] Furthermore, the serial port relays 5 are connected in parallel with the serial port control module 2. Such a design ensures a one-to-one connection between the serial port control module 2 and the serial port relays 5.
[0034] The present invention has been described by the above-mentioned relevant embodiments, however, the above-mentioned embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, changes and modifications made without departing from the spirit and scope of the present invention are all within the scope of patent protection of the present invention.
Claims
1. A method for automatically testing the on / off connection of multi-channel controlled USB connections, characterized in that: The following steps are involved: S1: The USB continuity test box is connected to the 5V power input port; S2: Insert the test USB peripheral into the USB female interface; The test USB peripherals are U disk and USB serial port; S3: Insert the USB continuity test male interface into the USB female interface of the terminal under test; S4: Connect the serial port input port to the computer, and input the serial port control command to the serial port control module through the computer; The computer is provided with a designed script M; The script M is used to describe the USB virtual serial port, and the serial port control instruction is sent to the serial port control module through the USB virtual serial port; The serial port control module is used to receive serial port control instructions; The specific contents of the script M are as follows: S41: Create USB virtual serial ports COM1, COM2, COM3, and COM4 through the COM0COM tool in the Python library; S42: Setting USB virtual serial port parameters; S43: Processing USB virtual serial port data; Use the read function to read data, use the write function to write data, and use the select function to process asynchronous data; S5: After receiving the command, the serial port control module controls the serial port relay to open and close, thereby turning on and off the VCC power supply line.
2. The method for automatically testing the on / off connection of multiple USB channels as claimed in claim 1, characterized in that: In step S43, the following steps are included: S431: Set the parameters related to the select function; Use the FD_ZERO function to initialize the fd_set variable, including FD_ZERO(&read_fds); FD_ZERO(&write_fds); here read_fds and write_fds are used to monitor the readable and writable status respectively; Use the FD_SET function to add the serial port file descriptor to the fd_set to be monitored, wherein the FD_SET function includes the FD_SET(fd, &read_fds) function and the FD_SET(fd, &write_fds) function; Set the timeout timeout of the struct timeval type variable, and set the timeout timeout to 1 second; S432: loop calling the select function and processing the results; Call the select function in an infinite loop; Perform different processing according to the return value ret of the select function; The return value ret = select(fd+1, &read_fds, &write_fds, NULL, &timeout); The fd+1 is the first parameter of the select function, which is the maximum value of all file descriptors to be calculated plus 1; The NULL here represents a file descriptor set of data exception events; If ret == -1, it means that the select function call has an error, and the perror function is used to output the error message and possibly exit the loop; If ret == 0, it means the select function has timed out and you can handle it accordingly (such as resetting the select parameters and calling it again). If ret>0, it means an event occurs: If FD_ISSET(fd, &read_fds) is true, it means that there is data to read from the serial port. At this time, you can use the read function to read the serial port data, and then process the read data; If FD_ISSET(fd, &write_fds) is true, it means the serial port is writable and you can use the write function to send data to the serial port.
3. The multi-channel control USB connection on-off automatic test equipment as claimed in claim 1, characterized in that: The multi-channel controlled USB connection on-off automated test device comprises a USB female interface (1); a serial port control module (2); a serial port command input port (3); a 5V power input port (4); a serial port relay (5); and a USB on-off test port (6). USB female interface (1): the automated test equipment is provided with a plurality of USB female interfaces (1), which are respectively marked as USB female interface 1, USB female interface 2, USB female interface 3, and USB female interface 4, and each USB female interface (1) can be plugged into a test USB peripheral; Serial port control module (2): used to receive serial port commands and control the serial port relay (5); Serial command input port (3): connected to the control computer; 5V power input port (4): provides power to the serial port control module (2); Serial port relay (5): receives commands from the serial port control module (2) and controls the opening and closing of the circuit; USB continuity test port (6): plug into the USB female port of the terminal under test; The USB female connector (1) is arranged on the outside of the automated testing equipment, the serial port relay (5) is connected to the USB female connector (1), and the serial port relay (5) is respectively connected to the serial port control module (2) and the USB on / off test port (6); the serial port command input port (3) is arranged in the serial port control module (2), and the 5V power input port (4) is connected to the serial port control module (2).
4. The method and device for automatically testing the on / off connection of multiple USB connections as claimed in claim 1, characterized in that: Each of the USB female interfaces (1) is connected in series with the serial port relay (5), and each of the USB female interfaces (1) is provided with a serial port relay (5) for use therewith.
5. The method and device for automatically testing the on / off connection of multiple USB connections as claimed in claim 1, characterized in that: The serial port relays (5) are connected to the serial port control module (2) in a parallel connection manner.
Citation Information
Patent Citations
A device automatically controlling connection and disconnection of USB cables and a testing method
CN106407068A
Java and Python combined automatic script development method and device
CN112597037A
CAN network automatic test box and use method thereof
CN112650196A
Serial port bus quality automatic test system
CN116089180A