CN111274071A - A USB device plugging and unplugging detection method, device and related equipment - Google Patents
A USB device plugging and unplugging detection method, device and related equipment Download PDFInfo
- Publication number
- CN111274071A CN111274071A CN202010058981.0A CN202010058981A CN111274071A CN 111274071 A CN111274071 A CN 111274071A CN 202010058981 A CN202010058981 A CN 202010058981A CN 111274071 A CN111274071 A CN 111274071A
- Authority
- CN
- China
- Prior art keywords
- usb
- information
- detection
- plugging
- target
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/22—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
- G06F11/2205—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
- G06F11/221—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test buses, lines or interfaces, e.g. stuck-at or open line faults
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/22—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
- G06F11/2273—Test methods
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
本申请公开了一种USB设备插拔检测方法,包括根据接收到的检测命令确定目标USB;发送Disable指令至所述目标USB获得移除信息,判断所述移除信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息;发送Enable指令至所述目标USB获得识别信息,判断所述识别信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息;该USB设备插拔检测方法不仅提高了USB设备的插拔检测效率,还有效保证了检测结果的准确性。本申请还公开了一种USB设备插拔检测装置、服务器及计算机可读存储介质,均具有上述有益效果。
The present application discloses a USB device plug-in detection method, including determining a target USB according to a received detection command; sending a Disable command to the target USB to obtain removal information, judging whether the USB information in the removal information is the same as the standard information of the target USB, and if so, outputting detection pass information; sending an Enable command to the target USB to obtain identification information, judging whether the USB information in the identification information is the same as the standard information of the target USB, and if so, outputting detection pass information; the USB device plug-in detection method not only improves the plug-in detection efficiency of the USB device, but also effectively ensures the accuracy of the detection result. The present application also discloses a USB device plug-in detection device, a server, and a computer-readable storage medium, all of which have the above-mentioned beneficial effects.
Description
技术领域technical field
本申请涉及服务器测试领域,特别涉及一种USB设备插拔检测方法,还涉及一种USB设备插拔检测装置、服务器以及计算机可读存储介质。The present application relates to the field of server testing, in particular to a method for detecting plugging and unplugging of USB devices, and also to a device for detecting plugging and unplugging of USB devices, a server, and a computer-readable storage medium.
背景技术Background technique
USB(Universal Serial Bus,通用串行总线)是一个外部总线标准,用于规范电脑与外部设备的连接和通讯,是应用于PC、Server领域的接口技术。在服务器测试中,外设功能一直是客户较为关心的功能,因为在日常使用中,USB口会外接硬盘、鼠标、优盘等设备,使用频率较高,因此,USB外设识别的稳定性格外重要。USB (Universal Serial Bus, Universal Serial Bus) is an external bus standard used to standardize the connection and communication between computers and external devices, and is an interface technology used in the field of PC and Server. In the server test, the peripheral function has always been a function that customers are more concerned about, because in daily use, the USB port will be connected to external hard disks, mice, USB flash drives and other devices, and the frequency of use is high. Therefore, the stability of USB peripheral identification is particularly important. .
USB设备的识别本身会牵涉到硬件设计、BIOS及OS,需要各模块的配合才能完成快速驱动加载和设备识别,以满足客户的无间隔使用,但是,由于目前的国产替换,软硬件都实现了自主研发,各模块之间的兼容性相对较差。目前,关于OS下设备识别的验证已经被合并到USB设备热插拔测试中,通过人工插拔上百次来检查鼠标或键盘本身能否使用,并不检查系统对设备的识别情况,不仅效率低下,且检测结果的准确度很低。The identification of the USB device itself will involve hardware design, BIOS and OS, and requires the cooperation of each module to complete the fast driver loading and device identification to meet the customer's non-interval use. However, due to the current domestic replacement, both software and hardware have been implemented. Independent research and development, the compatibility between modules is relatively poor. At present, the verification of device identification under the OS has been incorporated into the USB device hot-plug test. By manually plugging and unplugging hundreds of times to check whether the mouse or keyboard itself can be used, it does not check the system's recognition of the device, not only the efficiency low, and the accuracy of the detection results is very low.
因此,如何提高USB设备的插拔检测效率,提高检测结果的准确性是本领域技术人员亟待解决的问题。Therefore, how to improve the plug-in detection efficiency of the USB device and improve the accuracy of the detection result is an urgent problem to be solved by those skilled in the art.
发明内容SUMMARY OF THE INVENTION
本申请的目的是提供一种USB设备插拔检测方法,该USB设备插拔检测方法不仅提高了USB设备的插拔检测效率,还有效保证了检测结果的准确性;本申请的另一目的是提供一种USB设备插拔检测装置、服务器以及计算机可读存储介质,也具有上述有益效果。The purpose of this application is to provide a USB device plugging detection method, which not only improves the plugging detection efficiency of the USB device, but also effectively ensures the accuracy of the detection results; another purpose of the application is To provide a USB device plugging and unplugging detection device, a server and a computer-readable storage medium, which also have the above beneficial effects.
为解决上述技术问题,本申请提供了一种USB设备插拔检测方法,所述USB设备插拔检测方法包括:In order to solve the above-mentioned technical problems, the present application provides a method for detecting plugging and unplugging of a USB device. The method for detecting plugging and unplugging of a USB device includes:
根据接收到的检测命令确定目标USB;Determine the target USB according to the received detection command;
发送Disable指令至所述目标USB获得移除信息,判断所述移除信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息;Send the Disable command to the target USB to obtain removal information, and determine whether the USB information in the removal information is the same as the standard information of the target USB, and if so, output the detection pass information;
发送Enable指令至所述目标USB获得识别信息,判断所述识别信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息。Sending an Enable command to the target USB to obtain identification information, and judging whether the USB information in the identification information is the same as the standard information of the target USB, and if so, output detection pass information.
优选的,所述根据接收到的检测命令确定目标USB,包括:Preferably, the determining of the target USB according to the received detection command includes:
对所述检测命令进行命令解析,获得USB端口号;Perform command parsing on the detection command to obtain a USB port number;
根据所述USB端口号确定所述目标USB。The target USB is determined according to the USB port number.
优选的,所述USB设备插拔检测方法还包括:Preferably, the USB device plugging and unplugging detection method further includes:
通过预设信息采集指令进行USB扫描,获得各USB的标准信息。The USB scan is performed through the preset information collection instruction to obtain the standard information of each USB.
优选的,所述USB的标准信息为USB总线号和/或USB设备号。Preferably, the USB standard information is a USB bus number and/or a USB device number.
优选的,通过预设信息采集指令进行USB扫描,获得所述USB总线号,包括:Preferably, the USB scan is performed through a preset information collection instruction to obtain the USB bus number, including:
通过lsusb命令进行USB扫描,获得各所述USB的USB总线号。Perform USB scanning through the lsusb command to obtain the USB bus number of each USB.
优选的,通过预设信息采集指令进行USB扫描,获得所述USB设备号,包括:Preferably, performing USB scanning through a preset information collection instruction to obtain the USB device number, including:
通过dmesg命令进行USB扫描,获得各所述USB的USB设备号。Perform USB scanning through the dmesg command to obtain the USB device numbers of the USBs.
优选的,所述USB设备插拔检测方法还包括:Preferably, the USB device plugging and unplugging detection method further includes:
当插拔检测未通过时,发出告警指令至告警设备。When the plug-in detection fails, an alarm command is sent to the alarm device.
为解决上述技术问题,本申请还提供了一种USB设备插拔检测装置,所述USB设备插拔检测装置包括:In order to solve the above technical problems, the present application also provides a USB device plug-in detection device, the USB device plug-in detection device includes:
端口确定模块,用于根据接收到的检测命令确定目标USB;a port determination module, used for determining the target USB according to the received detection command;
Disable检测模块,用于发送Disable指令至所述目标USB获得移除信息,判断所述移除信息中的USB信息是否与所述目标USB的标准信息相同,若否,则输出检测通过信息;The Disable detection module is used to send the Disable command to the target USB to obtain removal information, and judge whether the USB information in the removal information is the same as the standard information of the target USB, and if not, output the detection pass information;
Enable检测模块,用于发送Enable指令至所述目标USB获得识别信息,判断所述识别信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息。The Enable detection module is configured to send an Enable command to the target USB to obtain identification information, and determine whether the USB information in the identification information is the same as the standard information of the target USB, and if so, output detection pass information.
为解决上述技术问题,本申请还提供了一种服务器,所述服务器包括:In order to solve the above technical problems, the present application also provides a server, which includes:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现上述任意一种USB设备插拔检测方法的步骤。The processor is configured to implement the steps of any one of the above-mentioned USB device plugging and unplugging detection methods when executing the computer program.
为解决上述技术问题,本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述任意一种USB设备插拔检测方法的步骤。In order to solve the above technical problems, the present application also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, any one of the above-mentioned USB devices can be plugged and unplugged. The steps of the detection method.
本申请所提供的一种USB设备插拔检测方法,包括根据接收到的检测命令确定目标USB;发送Disable指令至所述目标USB获得移除信息,判断所述移除信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息;发送Enable指令至所述目标USB获得识别信息,判断所述识别信息中的USB信息是否与所述目标USB的标准信息相同,若是,则输出检测通过信息。A USB device plugging detection method provided by the present application includes determining a target USB according to a received detection command; sending a Disable command to the target USB to obtain removal information, and judging whether the USB information in the removal information matches the The standard information of the target USB is the same, if yes, output the detection pass information; send the Enable command to the target USB to obtain identification information, and determine whether the USB information in the identification information is the same as the standard information of the target USB, if so , the detection pass information is output.
可见,本申请所提供的USB设备插拔检测方法,通过向USB发送Enable指令和Disable指令实现USB设备插拔的模拟,即Disable USB之后,USB设备将不被识别,EnableUSB之后,USB设备将被正确识别,进而将其插拔过程中的USB信息与标准信息进行比较,并通过比较结果判定插拔检测是否通过,由此,通过自动化脚本实现了对USB设备的自动插拔检测,相较于人工操作方式,该种实现方式极大的提高了插拔检测效率,并有效保证了检测结果的准确性。It can be seen that the USB device plugging and unplugging detection method provided by this application realizes the simulation of USB device plugging and unplugging by sending the Enable command and the Disable command to the USB, that is, after Disable USB, the USB device will not be recognized, and after EnableUSB, the USB device will be Correct identification, and then compare the USB information during the plugging and unplugging process with the standard information, and determine whether the plugging and unplugging detection passes through the comparison results. The manual operation mode greatly improves the plugging detection efficiency and effectively ensures the accuracy of the detection results.
本申请所提供的一种USB设备插拔检测装置、服务器以及计算机可读存储介质,均具有上述有益效果,在此不再赘述。The device for detecting plugging and unplugging of a USB device, the server and the computer-readable storage medium provided by the present application all have the above beneficial effects, which will not be repeated here.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only It is an embodiment of the present application. For those of ordinary skill in the art, other drawings can also be obtained according to the provided drawings without any creative effort.
图1为本申请所提供的一种USB设备插拔检测方法的流程示意图;1 is a schematic flowchart of a method for detecting a USB device plugging and unplugging provided by the application;
图2为本申请所提供的一种USB设备插拔检测装置的结构示意图;2 is a schematic structural diagram of a USB device plugging and unplugging detection device provided by the application;
图3为本申请所提供的一种服务器的结构示意图。FIG. 3 is a schematic structural diagram of a server provided by this application.
具体实施方式Detailed ways
本申请的核心是提供一种USB设备插拔检测方法,该USB设备插拔检测方法不仅提高了USB设备的插拔检测效率,还有效保证了检测结果的准确性;本申请的另一核心是提供一种USB设备插拔检测装置、服务器以及计算机可读存储介质,也具有上述有益效果。The core of this application is to provide a USB device plugging detection method, which not only improves the plugging detection efficiency of USB devices, but also effectively ensures the accuracy of the detection results; another core of the application is To provide a USB device plugging and unplugging detection device, a server and a computer-readable storage medium, which also have the above beneficial effects.
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments It is a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
在现有技术中,通过人工方式实现对USB接口的插拔检测,并不检查系统对设备的识别情况,不仅效率低下,且检测结果的准确度很低。因此,为解决该技术问题,本申请提供了一种USB设备插拔检测方法,该USB设备插拔检测方法通过自动化脚本实现了对USB设备的插拔检测,不仅提高了USB设备的插拔检测效率,还有效保证了检测结果的准确性。In the prior art, the plugging and unplugging detection of the USB interface is implemented manually without checking the recognition status of the device by the system, which is not only inefficient, but also has low accuracy of the detection result. Therefore, in order to solve the technical problem, the present application provides a USB device plugging detection method. The USB device plugging detection method realizes the plugging detection of the USB device through an automated script, which not only improves the plugging detection of the USB device efficiency, and effectively ensure the accuracy of the test results.
请参考图1,图1为本申请所提供的一种USB设备插拔检测方法的流程示意图,该USB设备插拔检测方法可以包括:Please refer to FIG. 1. FIG. 1 is a schematic flowchart of a method for detecting plugging and unplugging of a USB device provided by the present application. The method for detecting plugging and unplugging of a USB device may include:
S101:根据接收到的检测命令确定目标USB;S101: Determine the target USB according to the received detection command;
本步骤旨在实现目标USB的确认,该目标USB即为需要进行插拔检测的USB设备。具体的,当需要对服务器进行USB设备插拔检测时,用户可基于相应的客户端发起检测命令,该检测命令中包括目标USB的相关信息,由此,即可根据这些信息确定目标USB,进而实现对目标USB的插拔检测。The purpose of this step is to realize the confirmation of the target USB, and the target USB is the USB device that needs to be plugged and detected. Specifically, when it is necessary to perform USB device plugging and unplugging detection on the server, the user can initiate a detection command based on the corresponding client, and the detection command includes the relevant information of the target USB. Therefore, the target USB can be determined according to the information, and then the target USB can be determined. Realize the plugging and unplugging detection of the target USB.
可以理解的是,上述基于客户端发起检测命令的方式仅为本申请所提供的一种实现方式,并不唯一,也可以是基于预设响应条件自动触发检测命令的实现方式,如定时检测等,本申请对此不做限定。It can be understood that the above-mentioned method of initiating a detection command based on the client is only an implementation method provided by the present application, and is not unique, and it can also be an implementation method of automatically triggering a detection command based on a preset response condition, such as timing detection, etc. , which is not limited in this application.
优选的,上述根据接收到的检测命令确定目标USB,可以包括对检测命令进行命令解析,获得USB端口号;根据USB端口号确定目标USB。Preferably, determining the target USB according to the received detection command may include performing command analysis on the detection command to obtain the USB port number; and determining the target USB according to the USB port number.
本优选实施例提供了一种较为具体的目标USB的确定方法,即基于USB端口号实现。具体的,USB端口号具有唯一性,因此,当发起检测命令时,可将目标USB的端口号添加至该检测命令中,进一步,当服务器的主控器接收到检测命令时,即可利用信息解析技术对其进行解析,获得USB端口号,进而实现目标USB的确定。其中,命令解析技术参照已有技术中即可,本申请在此不再赘述。This preferred embodiment provides a more specific method for determining the target USB, that is, implementation based on the USB port number. Specifically, the USB port number is unique. Therefore, when a detection command is initiated, the port number of the target USB can be added to the detection command. Further, when the host controller of the server receives the detection command, the information can be used. The parsing technology parses it, obtains the USB port number, and then realizes the determination of the target USB. Wherein, the command parsing technology may be referred to in the prior art, and details are not described herein again in this application.
S102:发送Disable指令至目标USB获得移除信息,判断移除信息中的USB信息是否与目标USB的标准信息相同,若是,则输出检测通过信息;S102: Send a Disable command to the target USB to obtain removal information, and determine whether the USB information in the removal information is the same as the standard information of the target USB, and if so, output detection pass information;
本步骤旨在实现对USB设备的拔检测,具体而言,Disable表示禁用,原则上对USBDisable之后,USB的外接设备将不被识别,因此,可通过向目标USB发送Disable指令实现对USB设备拔测试的模拟;进一步,在向目标USB发送Disable指令后,会获得相应的移除信息,该移除信息中包括有被移除的USB的相关信息,即上述USB信息,由此,即可将其与目标USB的标准信息进行对比,若二者一致,则说明目标USB已被移除,实现了拔操作,且被正确检测到,也即说明对目标USB的拔检测通过,此时,输出检测通过信息即可。The purpose of this step is to realize the unplug detection of the USB device. Specifically, Disable means to disable. In principle, after the USB is disabled, the USB external device will not be recognized. Therefore, the USB device can be unplugged by sending the Disable command to the target USB. The simulation of the test; further, after sending the Disable command to the target USB, the corresponding removal information will be obtained, and the removal information includes the relevant information of the removed USB, that is, the above-mentioned USB information. It is compared with the standard information of the target USB. If the two are consistent, it means that the target USB has been removed, the unplug operation has been realized, and it has been correctly detected, which means that the unplug detection of the target USB has passed. At this time, the output The information can be detected by passing.
其中,上述目标USB的标准信息是在插拔检测之前,预先统计的目标USB的相关信息,包括但不限于端口号、总线号、设备号等信息,进一步,将这些信息统一存储成固定的文档,作为每次插拔检测的对照标准,在使用时直接调用即可。Among them, the standard information of the target USB is the pre-statistical information about the target USB before the plug-in detection, including but not limited to information such as port number, bus number, device number, etc., and further, store these information uniformly into a fixed file , as the control standard for each plugging detection, it can be called directly when using.
S103:发送Enable指令至目标USB获得识别信息,判断识别信息中的USB信息是否与目标USB的标准信息相同,若是,则输出检测通过信息。S103 : Send an Enable command to the target USB to obtain identification information, and determine whether the USB information in the identification information is the same as the standard information of the target USB, and if so, output detection pass information.
本步骤旨在实现对USB设备的插检测,具体而言,Enable表示可用,原则上对USBEnable之后,USB的外接设备将被正确识别,因此,可通过向目标USB发送Enable指令实现对USB设备插测试的模拟;进一步,在向目标USB发送Enable指令后,会获得相应的识别信息,该识别信息中包括有被识别的USB的相关信息,即上述USB信息,由此,即可将其与目标USB的标准信息进行对比,若二者一致,则说明目标USB已被识别,实现了插操作,且被正确检测到,也即说明对目标USB的插检测通过,此时,输出检测通过信息即可。The purpose of this step is to realize the plug-in detection of the USB device. Specifically, Enable indicates that it is available. In principle, after the USB is enabled, the external device of the USB will be correctly identified. Therefore, the USB device can be plugged in by sending the Enable command to the target USB. The simulation of the test; further, after sending the Enable command to the target USB, the corresponding identification information will be obtained, and the identification information includes the relevant information of the identified USB, that is, the above-mentioned USB information, so that it can be associated with the target USB. Compare the standard information of the USB. If the two are consistent, it means that the target USB has been identified, the plug-in operation has been realized, and it has been correctly detected, which means that the plug-in detection of the target USB has passed. At this time, the output detection pass information is Can.
其中,上述目标USB的标准信息即为上述拔检测过程中的目标USB的标准信息,在检测过程中直接调用即可,本申请在此不再赘述。Wherein, the standard information of the target USB is the standard information of the target USB in the above-mentioned unplug detection process, which can be directly called in the detection process, which will not be repeated in this application.
可以理解的是,上述S102与S103的执行顺序并不唯一,可以先执行S103后执行S102,并不影响本技术方案的实施。It can be understood that the execution order of the above S102 and S103 is not unique, and the execution of S103 may be performed first and then the execution of S102 will not affect the implementation of the technical solution.
优选的,该USB设备插拔检测方法还可以包括:通过预设信息采集指令进行USB扫描,获得各USB的标准信息。Preferably, the USB device plugging and unplugging detection method may further include: performing USB scanning through a preset information collection instruction to obtain standard information of each USB.
本优选实施例提供了较为具体的USB标准信息的获取方法,即通过预设信息采集指令实现,在进行插拔检测之前,可利用预设信息采集指令对服务器进行USB扫描,实现信息采集,获得各个USB的标准信息。其中,预设信息采集指令可采用已有技术中的任意一种类型的指令,其具体类型并不影响本技术方案的实施。This preferred embodiment provides a more specific method for obtaining USB standard information, that is, it is realized by a preset information collection instruction, and before the plug-in detection is performed, the server can be scanned for USB by using the preset information collection instruction, so as to realize information collection and obtain Standard information for each USB. Wherein, the preset information collection instruction may adopt any type of instruction in the prior art, and its specific type does not affect the implementation of the technical solution.
优选的,上述USB的标准信息可以为USB总线号和/或USB设备号。Preferably, the above-mentioned USB standard information may be a USB bus number and/or a USB device number.
优选的,通过预设信息采集指令进行USB扫描,获得USB总线号,可以包括:通过lsusb命令进行USB扫描,获得各USB的USB总线号。Preferably, performing USB scanning through a preset information collection instruction to obtain the USB bus number may include: performing USB scanning through the lsusb command to obtain the USB bus number of each USB.
优选的,通过预设信息采集指令进行USB扫描,获得USB设备号,可以包括:通过dmesg命令进行USB扫描,获得各USB的USB设备号。Preferably, performing USB scanning through a preset information collection instruction to obtain the USB device number may include: performing USB scanning through a dmesg command to obtain the USB device number of each USB.
以上优选实施例提供了具体类型的USB的标准信息,即USB总线号和/或USB设备号,并对二者的获取方式进行了具体介绍。其中,对于USB总线号,可通过lsusb命令实现采集,对于USB设备号,可通过dmesg命令实现采集。当然,以上命令类型仅为本申请所提供的一种实现方式,并不唯一,还可以为其他类型的采集命令,本申请对此不做限定。此外,该lsusb命令和lsusb命令还可用于实现上述插拔检测过程中移除信息和识别信息的采集。The above preferred embodiment provides standard information of a specific type of USB, that is, a USB bus number and/or a USB device number, and specifically introduces how to obtain the two. Among them, for the USB bus number, the collection can be realized through the lsusb command, and for the USB device number, the collection can be realized through the dmesg command. Of course, the above command type is only an implementation manner provided by this application, and is not unique, and may also be other types of collection commands, which are not limited in this application. In addition, the lsusb command and the lsusb command can also be used to realize the collection of removal information and identification information in the above-mentioned plugging detection process.
优选的,该USB设备插拔检测方法还可以包括:当插拔检测未通过时,发出告警指令至告警设备。Preferably, the USB device plugging detection method may further include: when the plugging detection fails, sending an alarm instruction to the alarming device.
本优选实施例旨在实现检测失败告警,即当拔检测过程中所获得的移除信息中的USB信息与目标USB的标准信息不同时,说明拔检测失败,或当插检测过程中所获得的识别信息中的USB信息与目标USB的标准信息不同时,说明插检测失败,在以上两种情况中的任意一种情况发生时,则说明目标USB的插拔检测未通过,此时,输出检测失败指令,同时发起告警指令至告警设备实现检测失败告警,以通知技术人员对故障USB设备进行维修或更换。This preferred embodiment aims to realize a detection failure alarm, that is, when the USB information in the removal information obtained during the unplug detection process is different from the standard information of the target USB, it indicates that the unplug detection fails, or when the USB information obtained during the plug detection process is different from the standard information of the target USB When the USB information in the identification information is different from the standard information of the target USB, it means that the plug-in detection fails. When any of the above two situations occurs, it means that the plug-in detection of the target USB fails. At this time, the output detection Failure command, and send an alarm command to the alarm device to realize detection failure alarm, so as to notify the technician to repair or replace the faulty USB device.
本申请实施例所提供的USB设备插拔检测方法,通过向USB发送Enable指令和Disable指令实现USB设备插拔的模拟,即Disable USB之后,USB设备将不被识别,EnableUSB之后,USB设备将被正确识别,进而将其插拔过程中的USB信息与标准信息进行比较,并通过比较结果判定插拔检测是否通过,由此,通过自动化脚本实现了对USB设备的自动插拔检测,相较于人工操作方式,该种实现方式极大的提高了插拔检测效率,并有效保证了检测结果的准确性。The USB device plugging and unplugging detection method provided by the embodiment of the present application realizes the simulation of plugging and unplugging the USB device by sending the Enable command and the Disable command to the USB. That is, after the USB is Disabled, the USB device will not be recognized, and after the EnableUSB Correct identification, and then compare the USB information during the plugging and unplugging process with the standard information, and determine whether the plugging and unplugging detection passes through the comparison results. The manual operation mode greatly improves the plugging detection efficiency and effectively ensures the accuracy of the detection results.
在上述各实施例的基础上,本申请提供了一种更为具体的USB设备插拔检测方法,其具体实现过程如下:On the basis of the above embodiments, the present application provides a more specific USB device plugging and unplugging detection method, and its specific implementation process is as follows:
步骤一、将服务器的USB接口外接鼠标或键盘等,开机进入OS;Step 1. Connect an external mouse or keyboard to the USB port of the server, and boot into the OS;
步骤二、通过dmesg命令采集当前系统USB设备的详细信息;Step 2. Collect detailed information of the current system USB device through the dmesg command;
步骤三、通过lsusb命令采集当前系统已连接外设的USB的详细信息;Step 3. Collect the detailed information of the USB connected to the peripheral device of the current system through the lsusb command;
步骤四、基于步骤二和步骤三分别获得usb bus number(USB总线号)和devicenumber(USB设备号)这两个关键参数(标准信息),并将其存储为固定文档;Step 4: Obtain two key parameters (standard information) of usb bus number (USB bus number) and devicenumber (USB device number) based on step 2 and step 3 respectively, and store them as fixed documents;
步骤五、以USB1设备为例,通过以下命令实现系统下Disable USB1的供电:Step 5. Taking the USB1 device as an example, use the following commands to realize the power supply of Disable USB1 in the system:
#echo suspend>/sys/bus/usb/devices/usb1/power/level;#echo suspend>/sys/bus/usb/devices/usb1/power/level;
步骤六、通过命令#lsusb|grep usb1查看USB1是否被移除,将获得的信息(移除信息)与步骤四种的标准信息进行对比,若二者一致,则check pass,反之fail;Step 6. Use the command #lsusb|grep usb1 to check whether USB1 has been removed, and compare the obtained information (removal information) with the standard information of step 4. If the two are consistent, check pass, otherwise fail;
步骤七、以USB1设备为例,通过以下命令实现系统下Enable USB1的供电:Step 7. Taking the USB1 device as an example, use the following commands to enable the power supply of the Enable USB1 in the system:
#echo on>/sys/bus/usb/devices/usb1/power/level;#echo on>/sys/bus/usb/devices/usb1/power/level;
步骤八、通过命令#lsusb|grep usb1查看USB1是否被正确识别,将获得的信息(识别信息)与步骤四种的标准信息进行对比,若二者一致,则check pass,反之fail。Step 8. Use the command #lsusb|grep usb1 to check whether USB1 is correctly identified, and compare the obtained information (identification information) with the standard information in Step 4. If the two are consistent, check pass, otherwise fail.
至此,实现对服务器中USB设备的插拔检测。So far, the plug-in detection of the USB device in the server is realized.
可见,本申请实施例所提供的USB设备插拔检测方法,通过向USB发送Enable指令和Disable指令实现USB设备插拔的模拟,即Disable USB之后,USB设备将不被识别,EnableUSB之后,USB设备将被正确识别,进而将其插拔过程中的USB信息与标准信息进行比较,并通过比较结果判定插拔检测是否通过,由此,通过自动化脚本实现了对USB设备的自动插拔检测,相较于人工操作方式,该种实现方式极大的提高了插拔检测效率,并有效保证了检测结果的准确性。It can be seen that the USB device plugging and unplugging detection method provided by the embodiment of the present application realizes the simulation of USB equipment plugging and unplugging by sending the Enable command and the Disable command to the USB, that is, after the USB is Disabled, the USB device will not be recognized. It will be correctly identified, and then compare the USB information during the plugging and unplugging process with the standard information, and determine whether the plugging and unplugging detection passes through the comparison results. Compared with the manual operation method, this implementation method greatly improves the plugging detection efficiency, and effectively ensures the accuracy of the detection results.
为解决上述问题,请参考图2,图2为本申请所提供的一种USB设备插拔检测装置的结构示意图,该USB设备插拔检测装置可包括:In order to solve the above problem, please refer to FIG. 2, which is a schematic structural diagram of a USB device plugging and unplugging detection device provided by the present application. The USB device plugging and unplugging detection device may include:
端口确定模块100,用于根据接收到的检测命令确定目标USB;The
Disable检测模块200,用于发送Disable指令至目标USB获得移除信息,判断移除信息中的USB信息是否与目标USB的标准信息相同,若是,则输出检测通过信息;The Disable
Enable检测模块300,用于发送Enable指令至目标USB获得识别信息,判断识别信息中的USB信息是否与目标USB的标准信息相同,若是,则输出检测通过信息。The
可见,本申请实施例所提供的USB设备插拔检测装置,通过向USB发送Enable指令和Disable指令实现USB设备插拔的模拟,即Disable USB之后,USB设备将不被识别,EnableUSB之后,USB设备将被正确识别,进而将其插拔过程中的USB信息与标准信息进行比较,并通过比较结果判定插拔检测是否通过,由此,通过自动化脚本实现了对USB设备的自动插拔检测,相较于人工操作方式,该种实现方式极大的提高了插拔检测效率,并有效保证了检测结果的准确性。It can be seen that the USB device plugging and unplugging detection device provided by the embodiment of the present application realizes the simulation of plugging and unplugging the USB device by sending the Enable command and the Disable command to the USB, that is, after Disable USB, the USB device will not be recognized, and after EnableUSB, the USB device It will be correctly identified, and then compare the USB information during the plugging and unplugging process with the standard information, and determine whether the plugging and unplugging detection passes through the comparison results. Compared with the manual operation method, this implementation method greatly improves the plugging detection efficiency, and effectively ensures the accuracy of the detection results.
作为一种优选实施例,上述端口确定模块100可具体用于对检测命令进行命令解析,获得USB端口号;根据USB端口号确定目标USB。As a preferred embodiment, the above-mentioned
作为一种优选实施例,该USB设备插拔检测装置还可包括标准信息采集模块,用于通过预设信息采集指令进行USB扫描,获得各USB的标准信息。As a preferred embodiment, the device for detecting plugging and unplugging of USB devices may further include a standard information collection module for performing USB scanning through a preset information collection instruction to obtain standard information of each USB.
作为一种优选实施例,上述USB的标准信息为USB总线号和/或USB设备号。As a preferred embodiment, the above-mentioned USB standard information is a USB bus number and/or a USB device number.
作为一种优选实施例,上述标准信息采集模块可具体用于通过lsusb命令进行USB扫描,获得各USB的USB总线号。As a preferred embodiment, the above-mentioned standard information collection module can be specifically configured to perform USB scanning through the lsusb command to obtain the USB bus number of each USB.
作为一种优选实施例,上述标准信息采集模块可具体用于通过dmesg命令进行USB扫描,获得各USB的USB设备号。As a preferred embodiment, the above-mentioned standard information collection module may be specifically configured to perform USB scanning through the dmesg command to obtain the USB device number of each USB.
作为一种优选实施例,该USB设备插拔检测装置还可包括告警模块,用于当插拔检测未通过时,发出告警指令至告警设备。As a preferred embodiment, the device for detecting plugging and unplugging of a USB device may further include an alarm module, configured to send an alarm instruction to the alarming device when the plugging and unplugging detection fails.
对于本申请提供的装置的介绍请参照上述方法实施例,本申请在此不做赘述。For the introduction of the apparatus provided in the present application, please refer to the above method embodiments, which will not be repeated in this application.
为解决上述问题,请参考图3,图3为本申请所提供的一种服务器的结构示意图,该服务器可包括:In order to solve the above problems, please refer to FIG. 3 , which is a schematic structural diagram of a server provided by the application. The server may include:
存储器10,用于存储计算机程序;a
处理器20,用于执行计算机程序时可实现如上述任意一种USB设备插拔检测方法的步骤。When the
对于本申请提供的设备的介绍请参照上述方法实施例,本申请在此不做赘述。For the introduction of the equipment provided in the present application, please refer to the above method embodiments, which are not repeated in this application.
为解决上述问题,本申请还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时可实现如上述任意一种USB设备插拔检测方法的步骤。In order to solve the above problems, the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, any one of the above-mentioned USB device plugging and unplugging detection methods can be implemented. A step of.
该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The computer-readable storage medium may include: a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, etc., which can store program codes. medium.
对于本申请提供的计算机可读存储介质的介绍请参照上述方法实施例,本申请在此不做赘述。For the introduction of the computer-readable storage medium provided in the present application, please refer to the above method embodiments, which will not be repeated in this application.
说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant part can be referred to the description of the method.
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Professionals may further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two, in order to clearly illustrate the possibilities of hardware and software. Interchangeability, the above description has generally described the components and steps of each example in terms of functionality. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of a method or algorithm described in conjunction with the embodiments disclosed herein may be directly implemented in hardware, a software module executed by a processor, or a combination of the two. A software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.
以上对本申请所提供的USB设备插拔检测方法、装置、服务器以及计算机可读存储介质进行了详细介绍。本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围要素。The method, device, server, and computer-readable storage medium for USB device plugging and unplugging detection provided by the present application have been described in detail above. Specific examples are used herein to illustrate the principles and implementations of the present application, and the descriptions of the above embodiments are only used to help understand the methods and core ideas of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principles of the present application, several improvements and modifications can also be made to the present application, and these improvements and modifications also fall into the elements of the protection scope of the claims of the present application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010058981.0A CN111274071A (en) | 2020-01-19 | 2020-01-19 | A USB device plugging and unplugging detection method, device and related equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010058981.0A CN111274071A (en) | 2020-01-19 | 2020-01-19 | A USB device plugging and unplugging detection method, device and related equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111274071A true CN111274071A (en) | 2020-06-12 |
Family
ID=70998733
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010058981.0A Pending CN111274071A (en) | 2020-01-19 | 2020-01-19 | A USB device plugging and unplugging detection method, device and related equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111274071A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104932962A (en) * | 2015-06-05 | 2015-09-23 | 惠州Tcl移动通信有限公司 | USB (Universal Serial Bus) plug testing system and method thereof |
CN105511936A (en) * | 2014-09-22 | 2016-04-20 | 北京奇虎科技有限公司 | Test system, method and device |
CN107402855A (en) * | 2017-06-30 | 2017-11-28 | 郑州云海信息技术有限公司 | A kind of detection method of hard disk, device and server |
CN108228399A (en) * | 2016-12-14 | 2018-06-29 | 浙江舜宇智能光学技术有限公司 | USB device automatic checkout equipment and its method |
CN110489287A (en) * | 2019-07-12 | 2019-11-22 | 苏州浪潮智能科技有限公司 | Method, system and the storage medium of hot plug are tested by Ipmitool |
CN110514925A (en) * | 2019-08-13 | 2019-11-29 | Oppo(重庆)智能科技有限公司 | Test method and system and storage medium |
CN110659168A (en) * | 2019-09-12 | 2020-01-07 | 苏州浪潮智能科技有限公司 | Method for remotely testing hot plug of server peripheral and USB control device |
-
2020
- 2020-01-19 CN CN202010058981.0A patent/CN111274071A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105511936A (en) * | 2014-09-22 | 2016-04-20 | 北京奇虎科技有限公司 | Test system, method and device |
CN104932962A (en) * | 2015-06-05 | 2015-09-23 | 惠州Tcl移动通信有限公司 | USB (Universal Serial Bus) plug testing system and method thereof |
CN108228399A (en) * | 2016-12-14 | 2018-06-29 | 浙江舜宇智能光学技术有限公司 | USB device automatic checkout equipment and its method |
CN107402855A (en) * | 2017-06-30 | 2017-11-28 | 郑州云海信息技术有限公司 | A kind of detection method of hard disk, device and server |
CN110489287A (en) * | 2019-07-12 | 2019-11-22 | 苏州浪潮智能科技有限公司 | Method, system and the storage medium of hot plug are tested by Ipmitool |
CN110514925A (en) * | 2019-08-13 | 2019-11-29 | Oppo(重庆)智能科技有限公司 | Test method and system and storage medium |
CN110659168A (en) * | 2019-09-12 | 2020-01-07 | 苏州浪潮智能科技有限公司 | Method for remotely testing hot plug of server peripheral and USB control device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI386946B (en) | Apparatus and method for memory card testing | |
CN112269697B (en) | Equipment storage performance testing method, system and related device | |
CN112631848B (en) | A mechanical hard disk fault intelligent diagnosis method and system | |
CN112948190B (en) | A server hardware testing method, system and related device | |
EP2798428B1 (en) | Apparatus and method for managing operation of a mobile device | |
CN106201804A (en) | The device of a kind of measuring and calculation mainboard, method and system | |
CN114385496A (en) | Test method, test device, electronic equipment and computer readable storage medium | |
CN109032864A (en) | A kind of method and system of NVMe SSD hot plug test | |
US7624217B2 (en) | Adaptive boot sequence | |
CN114496053A (en) | Data anomaly detection method, device and equipment and computer readable storage medium | |
CN113204456A (en) | Test method, tool, device and equipment for VPP interface of server | |
WO2018227475A1 (en) | Fingerprint chip detection method, device and system | |
CN111274071A (en) | A USB device plugging and unplugging detection method, device and related equipment | |
CN108051728A (en) | One kind is based on MOC boards hardware AC test methods and system | |
CN116820946B (en) | Method and device for automatically testing compatibility of target software | |
CN115757099B (en) | Automatic testing method and device for platform firmware protection and recovery function | |
CN112231159B (en) | A memory installation position testing method, system, terminal and storage medium | |
CN105446767A (en) | Method and system for upgrading terminal software in production test of rear installation of intelligent platform | |
CN109857604A (en) | A kind of method of automatic testing hard disk hot plug stability | |
CN113868048B (en) | Method, device and equipment for determining equipment information | |
CN115687044A (en) | System performance stability testing method, system, device and storage medium | |
CN115016329A (en) | A control method, control device and electronic device | |
CN109032880B (en) | A hardware debugging method and device for cooperative BIOS self-checking | |
CN111338859A (en) | DC stability test method, system and related components | |
TW202141271A (en) | Memory verification system and method with immediate interrupt verification function |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200612 |
|
RJ01 | Rejection of invention patent application after publication |