Embodiment
For making the object of the invention, technical scheme and advantage clearer, will combine accompanying drawing that embodiment of the present invention is done further below and describe in detail.
Embodiment 1
The embodiment of the invention provides the method for the USB port that a kind of positioning equipment connected; Particularly; Be that example describes with HID equipment in the present embodiment; HID equipment is connected on the host computer through USB HUB, and the USB HUB that wherein is connected between host computer and the HID equipment can be one or more.
Referring to Fig. 1, the method for the USB port that a kind of HID of location equipment is connected, concrete performing step is following:
Step 101: host computer reads the HID path that is connected oneself HID equipment on one's body;
Wherein, the HID equipment that links to each other with host computer can be one or more, and when a plurality of HID equipment, then host computer reads the HID path of all HID equipment, particularly, is that example describes with a HID equipment in the present embodiment;
Further, the HID path can be read from the parameter that WM_DEVICECHANGE message is imported into, also can enumerate the HID equipment that has connected through calling SetupDiGetDeviceInterfaceDetail, obtains its HID path;
Particularly, read the HID path that obtains and be? Hid#vid_096e&pid_0304#7&2c7bc087&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}.
Step 102: host computer is inquired about master controller, obtains the title of the root USB HUB that connects on the master controller;
In the present embodiment, host computer specifically through master controller being sent the IOCTL_USB_GET_ROOT_HUB_NAME request, obtains the title of the root USBHUB that is connected on the master controller.
Step 103: host computer is opened current USB HUB, and this current USB HUB is inquired about, and obtains the port number of current USB HUB;
In the present embodiment, when being the equipment that connects on for the first time to this master controller when inquiring about, the root USB HUB that then connects on this master controller promptly is current USB HUB;
The method of particularly, current USB HUB being inquired about is:
Host computer sends the IOCTL_USB_GET_NODE_INFORMATION request to current USB HUB, obtains the port number of current USB HUB.
Step 104: host computer is inquired about when front port current USB HUB's, obtains the equipment link information on front port;
In the present embodiment, when being when for the first time this current USB HUB being inquired about, then first port of this current USBHUB is then for working as front port;
Wherein, the method for inquiring about when front port to current USB HUB is:
Host computer is asked when front port sends IOCTL_USB_GET_NODE_CONNECTION_INFORMATION to current USB HUB's; Obtain the equipment link information on this port, wherein specifically comprise information such as connection status zone bit, HUB zone bit, producer's identifier information and device identifier information in the equipment link information;
Particularly, one of them equipment link information of acquisition is:
USB_NODE_CONNECTION_INFORMATION connectionInfo
connectionInfo.connectionIndex=0x00000003
connectionInfo.DeviceDescriptor.blength=0x12
connectionInfo.DeviceDescriptor.bDescriptorType=0x01
connectionInfo.DeviceDescriptor.bcdUSB=0x0110
connectionInfo.DeviceDescriptor.bDeviceClass=0x00
connectionInfo.DeviceDescriptor.bDeviceSubClass=0x00
connectionInfo.DeviceDescriptor.bDeviceProtocol=0x00
connectionInfo.DeviceDescriptor.bMaxPacketSize0=0x10
connectionInfo.DeviceDescriptor.idVendor=0x096e
connectionInfo.DeviceDescriptor.idProduct=0x0304
connectionInfo.DeviceDescriptor.bcdDevice=0x0104
connectionInfo.DeviceDescriptor.iManufacturer=0x01
connectionInfo.DeviceDescriptor.iProduct=0x02
connectionInfo.DeviceDescriptor.iSerialNumber=0x00
connectionInfo.DeviceDescriptor.bNumConfigurations=0x01
connectionInfo.CurrentConfigurationValue=0x01
connectionInfo.LowSpeed=0x00
connectionInfo.DeviceIsHub=0x00
connectionInfo.DeviceAddress=0x0002
connectionInfo.NumberOfOpenPipes=0x00000002
connectionInfo.ConnectionStatus=0x00000001
connectionInfo.PipeList=0x00150f33。
Step 105: judge working as front port according to the equipment link information that obtains; Obtain on front port, not having connection device if judge; Then execution in step 106, if judge that obtain on front port, connecting is USBHUB, then execution in step 111; If what judgement obtained on front port, connecting is generic USB equipment, then execution in step 112;
In the present embodiment, specific as follows according to the equipment link information that obtains to the method for judging when front port:
Earlier the connection status zone bit connectionInfo.ConnectionStatus in the equipment link information is judged; When judgement obtains connection status zone bit connectionInfo.ConnectionStatus and is 0x00000001; Then expression is deserved to have connected equipment on the front port; When judgement obtained connection status zone bit connectionInfo.ConnectionStatus and is 0x00000000, then expression deserved do not have connection device on the front port;
Further; When judgement obtains connection status zone bit connectionInfo.ConnectionStatus and is 0x00000001; Also need the HUB zone bit connectionInfo.DeviceIsHub in the judgment device link information to be for 0x00 or to be 0x01; When judgement obtains HUB zone bit connectionInfo.DeviceIsHub is 0x01; That then expression is deserved to connect on the front port is USB HUB, is 0x00 when judgement obtains HUB zone bit connectionInfo.DeviceIsHub, and what then expression was deserved to connect on the front port is generic USB equipment.
Step 106: host computer judges whether to have inquired about all of the port of current USB HUB, if then execution in step 107, if not, then execution in step 110;
In the present embodiment, host computer specifically judges whether to have inquired about all of the port of current USB HUB according to the port number of the current USB HUB that is obtained in the step 103.
Step 107: judge whether current USB HUB exists upper level USB HUB, if then execution in step 108, if not, then execution in step 109;
Step 108: the upper level USB HUB of current USB HUB as current USB HUB, is turned back to step 106 then;
Step 109: host computer judges whether to have inquired about all master controllers, if then end operation, and prompting can't position the HID equipment in the step 101, if not, then turns back to step 102 pair next master controller and inquires about;
In the present embodiment, judge whether that the method for having inquired about all master controllers is specially:
Host computer can be known the number of master controller in advance through traversal managing hardware device device;, then then inquires about host computer next master controller after having inquired about a master controller; When the number of the master controller that obtains up to number and the above-mentioned traversal of the master controller of inquiry equates; Then all master controllers have been inquired about in expression; When the number of knowing master controller in advance is 1, then inquired about behind the master controller then directly end operation, and prompting can't position to the HID equipment in the step 101;
Perhaps,
Host computer is opened device name beginning successively and be the equipment of HDC, as HDC1, HDC2, HDC3 ..., if open success, then also there is the master controller of not inquiring about in explanation, if open failure, then explains and has inquired about all master controllers;
Be that example describes specifically to comprise a plurality of master controllers on the host computer; When having inquired about a master controller; And behind all devices that this master controller connected; Host computer continues the next master controller of inquiry, and all devices that this master controller connected, and all inquires about up to all master controllers to finish;
Perhaps, in the present embodiment, when host computer comprises a plurality of master controller; The method of inquiry can also be: host computer master controller of inquiry earlier; The title of the root USB HUB that obtains connecting on this master controller does not then continue this root of inquiry USB HUB then, but begins to inquire about next master controller; All inquire about up to all master controllers and to finish, each root USB HUB that begins to inquire about on the master controller again and connected;
Further; In actual application, also might only contain a master controller on the host computer, then do not need execution in step 109 in the present embodiment this moment again; The root USBHUB that directly connects on this master controller of inquiry, and the equipment that connects on the root USB HUB gets final product.
Step 110: with current USB HUB when the next port of front port as working as front port, and turn back to step 104;
Step 111: the USB HUB that connects as current USB HUB, is turned back to step 103 then;
Step 112: host computer obtains the path DriverKeyName of this generic USB equipment below driver;
Particularly; Because in actual application; The equipment that possibly connect a plurality of same types on the host computer; Like a plurality of HID equipment, therefore only can not correctly navigate to the port that this HID equipment is connected with device identifier information PID, so also need utilize DriverKeyName in the present embodiment with the identifier information VID of producer in the equipment link information of step 104 acquisition;
In the present embodiment, the concrete grammar that obtains DriverKeyName is:
Host computer sends the IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME request to this generic USB equipment; Receive the relevant information that this generic USB equipment returns; The information of wherein returning comprises parameter DriverKeyName, and the structure of the information of returning specifically is defined as USB_NODE_CONNECTION_DRIVERKEY_NAME;
Wherein, it is following to obtain the realization code of DriverKeyName:
Particularly, the DriverKeyName that acquires in the present embodiment is: 0120
Step 113:, under the registration table path of this generic USB equipment, search the subitem of the data and the driverKeyName coupling of Driver key assignments according to VID and the PID in the equipment link information of step 104 acquisition;
In the present embodiment, VID and the PID in the equipment link information of step 104 acquisition is respectively 0x096e and 0x0304;
Searching the data of Driver key assignments and the method for the subitem that driverKeyName matees is specially:
Search this generic USB equipment the registration table path SYSTEM _ all subitems below the 096e&Pid_0304; Find the subitem of data and the driverKeyName coupling of Driver key assignments, the data that promptly find the Driver key assignments for 0120 subitem;
Particularly, the subitem that finds in the present embodiment is 6&c195ce&0&3.
Step 114: the data that read the ParentIdPrefix key assignments under the subitem that finds;
Particularly, in the present embodiment, the data that read the ParentIdPrefix key assignments that obtains are 7&2c7bc087&0.
Step 115: determining step 101 reads and whether comprises step 114 in the HID path that obtains and read the data that obtain the ParentIdPrefix key assignments; If not, then turn back to step 106, if; Represent then that target HID equipment promptly is connected and deserve on the front port execution in step 116;
In the present embodiment; Be specially judge the HID path? Hid#vid_096e&pid_0304#7&2c7bc087&0&0000#{4d1e55b2-f16f-whether comprise the data 7&2c7bc087&0 of ParentIdPrefix key assignments among the 11cf-88cb-001111000030}; Hence one can see that; Therefore the data that comprise the ParentIdPrefix key assignments in the step 101HID path represent that target HID equipment promptly is connected on this USB port execution in step 116.
Step 116: host computer carries out relatedly with above-mentioned when front port the HID path of the HID equipment in the step 101, locatees the front port of working as that this HID equipment connected.
Further, in the present embodiment, step 105 to step 111 can also realize through following steps:
Step 105 ': judge working as front port according to the equipment link information of obtaining; Obtain on front port, not having connection device if judge; Execution in step 106 ' then, if judge that obtain on front port, connecting is USBHUB, execution in step 111 ' then; If what judgement obtained on front port, connecting is generic USB equipment, then execution in step step 112;
Step 106 ': host computer judges whether to have inquired about all of the port of current USB HUB, if not, execution in step 107 ' then, if, execution in step 108 ' then;
Step 107 ': with current USB HUB when the next port of front port as working as front port, and turn back to step 104;
Step 108 ': judge whether to exist the USB HUB that has numbered and do not inquired about, if, execution in step 109 ' then, if not, execution in step 110 ' then;
Step 109 ': will number top USB HUB as current USB HUB, and turn back to step 103;
Step 110 ': host computer judges whether to have inquired about all master controllers, if then end operation, and prompting can't position the HID equipment in the step 101, if not, then returns step 102 pair next master controller and inquires about;
Step 111 ': host computer judges whether to exist the USB HUB that has numbered, and if not, then the USB HUB with this connection is numbered a USB HUB; Turn back to step 106 '; If, then follow already present numbering and continue the USB HUB of this connection is numbered, turn back to step 106 '.
Present embodiment provides the method for the USB port that a kind of HID of location equipment connected, and just can locate the USB port that HID equipment is connected through the method that present embodiment provides.
Embodiment 2
The embodiment of the invention provides the method for the USB port that a kind of positioning equipment connected; Particularly; Be that example describes with CCID equipment in the present embodiment; CCID equipment is connected on the host computer through USB HUB, and the USB HUB that wherein is connected between host computer and the CCID equipment can be one or more.
Referring to Fig. 2, the method for the USB port that a kind of CCID of location equipment is connected, concrete performing step is following:
Step 201: host computer reads the USB path that is connected oneself CCID equipment on one's body;
Wherein, the CCID equipment that links to each other with host computer can be one or more, and when a plurality of CCID equipment, then host computer reads the USB path of all CCID equipment, particularly, is that example describes with a CCID equipment in the present embodiment;
Further, the USB path of CCID equipment can be read from the parameter that WM_DEVICECHANGE message is imported into, also can enumerate the CCID equipment that has connected through calling SetupDiGetDeviceInterfaceDetail, obtains its USB path;
Particularly, in the present embodiment, the USB path of reading the CCID equipment that obtains be? Usb#vid_096e&pid_070f#6&c195ce&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Step 202: host computer is inquired about master controller, obtains the title of the root USB HUB that connects on the master controller;
In the present embodiment, host computer specifically through master controller being sent the IOCTL_USB_GET_ROOT_HUB_NAME request, obtains the title of the root USBHUB that is connected on the master controller.
Step 203: host computer is opened current USB HUB, and this current USB HUB is inquired about, and obtains the port number of this current USB HUB;
In the present embodiment, when being the equipment that connects on for the first time to this master controller when inquiring about, the root USB HUB that then connects on the master controller promptly is current USB HUB;
And the method that current USB HUB is inquired about is specially:
Host computer sends the IOCTL_USB_GET_NODE_INFORMATION request to current USB HUB, obtains the port number of this current USB HUB.
Step 204: host computer is inquired about when front port current USB HUB's, obtains the equipment link information on front port;
In the present embodiment, when being when for the first time this current USB HUB being inquired about, then first port of this current USBHUB is and works as front port;
Wherein, the method for inquiring about when front port to current USB HUB is:
Host computer is asked when front port sends IOCTL_USB_GET_NODE_CONNECTION_INFORMATION to current USB HUB's; Obtain the equipment link information of deserving on the front port, wherein specifically comprise information such as connection status zone bit, HUB zone bit, producer's identifier information and device identifier information in the equipment link information;
Particularly, one of them the equipment link information that obtains in the present embodiment is:
USB_NODE_CONNECTION_INFORMATION connectionInfo;
connectionInfo.ConnectionIndex=0x00000002;
connectionInfo.DeviceDescriptor.bLength=0x12;
connectionInfo.DeviceDescriptor.bDescriptorType=0x01;
connectionInfo.DeviceDescriptor.bcdUSB=0x0110
connectionInfo.DeviceDescriptor.bDeviceClass=0x00
connectionInfo.DeviceDescriptor.bDeviceSubClass=0x00
connectionInfo.DeviceDescriptor.bDeviceProtocol=0x00
connectionInfo.DeviceDescriptor.bMaxPacketSize0=0x08
connectionInfo.DeviceDescriptor.idVendor=0x096e
connectionInfo.DeviceDescriptor.idProduct=0x070f
connectionInfo.DeviceDescriptor.bcdDevice=0x2100
connectionInfo.DeviceDescriptor.iManufacturer=0x01
connectionInfo.DeviceDescriptor.iProduct=0x02
connectionInfo.DeviceDescriptor.iSerialNumber=0x00
connectionInfo.DeviceDescriptor.bNumConfigurations=0x01
connectionInfo.CurrentConfigurationValue=0x01
connectionInfo.LowSpeed=0x00
connectionInfo.DeviceIsHub=0x00
connectionInfo.DeviceAddress=0x0002
connectionInfo.NumberOfOpenPipes=0x00000002
connectionInfo.ConnectionStatus=0x00000001
connectionInfo.PipeList=0x00170093
Step 205: judge working as front port according to the equipment link information that obtains; Obtain on front port, not having connection device if judge; Then execution in step 206, if judge that obtain on front port, connecting is USBHUB, then execution in step 210; If what judgement obtained on front port, connecting is generic USB equipment, then execution in step 211;
In the present embodiment, specific as follows according to the equipment link information that obtains to the method for judging when front port:
Earlier the connection status zone bit connectionInfo.ConnectionStatus in the equipment link information is judged; When judgement obtains connection status zone bit connectionInfo.ConnectionStatus and is 0x00000001; Then expression is deserved to have connected equipment on the front port; When judgement obtained connection status zone bit connectionInfo.ConnectionStatus and is 0x00000000, then expression deserved do not have connection device on the front port;
Further; When judgement obtains connection status zone bit connectionInfo.ConnectionStatus and is 0x00000001; Also need the HUB zone bit connectionInfo.DeviceIsHub in the judgment device link information to be for 0x00 or to be 0x01; When judgement obtains HUB zone bit connectionInfo.DeviceIsHub is 0x01; That then expression is deserved to connect on the front port is USB HUB, is 0x00 when judgement obtains HUB zone bit connectionInfo.DeviceIsHub, and what then expression was deserved to connect on the front port is generic USB equipment.
Step 206: host computer judges whether to have inquired about all of the port of current USB HUB, if then execution in step 207, if not, then execution in step 209;
In the present embodiment, host computer specifically judges whether to have inquired about all of the port of current USB HUB according to the port number of the current USB HUB that is obtained in the step 203.
Step 207: judge whether current USB HUB exists upper level USB HUB, if then execution in step 208, if not, end operation then, and prompting can't position the CCID equipment in the step 201;
Step 208: the upper level USB HUB of current USB HUB as current USB HUB, is turned back to step 206 then;
Step 209: with current USB HUB when the next port of front port as working as front port, and turn back to step 204;
Step 210: the USB HUB that connects as current USB HUB, is turned back to step 203 then;
Step 211: host computer obtains the path DriverKeyName of this generic USB equipment below driver;
Particularly; Because in actual application; The equipment that possibly connect a plurality of same types on the host computer; Like a plurality of CCID equipment, therefore only can not correctly navigate to the port that said CCID equipment is connected in the step 201 with device identifier information PID, so also need utilize DriverKeyName in the present embodiment with the identifier information VID of producer in the equipment link information of step 204 acquisition;
In the present embodiment; The method of obtaining DriverKeyName is specially: host computer sends the IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME request to this generic USB equipment; Receive the relevant information that above-mentioned generic USB equipment returns; The information of wherein returning comprises parameter DriverKeyName, and the structure of the information of returning specifically is defined as USB_NODE_CONNECTION_DRIVERKEY_NAME);
Particularly, the DriverKeyName that acquires in the present embodiment is: 0005.
Step 212:, under the registration table path of above-mentioned generic USB equipment, search the subitem of the data and the driverKeyName coupling of Driver key assignments according to VID and the PID in the equipment link information of step 204 acquisition;
In the present embodiment, VID and the PID in the equipment link information of step 204 acquisition is respectively 0x096e and 0x070f;
The method of subitem of searching data and the driverKeyName coupling of Driver key assignments is: SYSTEM _ data of searching the Driver key assignments below the 096e&Pid_070f path for 0005 subitem; Particularly, the subitem that finds in the present embodiment is 6&c195ce&0&2.
Step 213: determining step 201 reads in the CCID path that obtains whether comprise the title that step 212 is searched the subitem that obtains; If not, then turn back to step 206, if; Represent then in the step 201 that said CCID equipment promptly is connected and deserve on the front port execution in step 214;
In the present embodiment; Be specially judge the CCID path? Usb#vid_096e&pid_070f#6&c195ce&0&2#{a5dcbf10-6530-11d2-whether comprise the title 6&c195ce&0&2 of subitem among the 901f-00c04fb951ed}; Hence one can see that; Therefore the title that comprises subitem in the CCID path, representing that said CCID equipment promptly is connected in the step 201 deserves on the front port execution in step 214.
Step 214: host computer with said CCID device path in the step 201 with carry out relatedly when front port, locate the USB port that this CCID equipment is connected.
In the present embodiment; Specifically only comprising a master controller with host computer is that example describes; Therefore in the present embodiment when there is not upper level USB HUB in the current USB HUB of step 207 judgement; Then direct end operation, and point out and can't the CCID equipment in the step 301 be positioned, do not need to go again to inquire about next master controller;
Perhaps, can also be the same in the present embodiment with embodiment 1, host computer comprises a plurality of master controllers; Then host computer need be inquired about these a plurality of master controllers, and querying method is identical with querying method described in the embodiment 1, is specially: when present embodiment step 207 judges that there is not upper level USBHUB in current USB HUB; Then host computer continues to judge whether to have inquired about all master controllers, if, end operation then; And prompting can't position the CCID equipment in the step 201; If not, then turn back to step 202 and continue next master controller is inquired about, all inquire about up to all master controllers and finish;
The method of inquiry can also be: host computer master controller of inquiry earlier; The title of the root USB HUB that obtains connecting on this master controller; Then do not continue this root of inquiry USB HUB then; But begin to inquire about next master controller, all inquire about up to all master controllers and finish, each root USB HUB that begins to inquire about on the master controller again and connected.
Present embodiment provides the method for the USB port that a kind of CCID of location equipment connected, and just can locate the USB port that CCID equipment is connected through the method that present embodiment provides.
Further; Present embodiment provides the method for the USB port that a kind of CCID of location equipment connected, and present embodiment only describes with a kind of method, and in actual application, has multiple localization method; Specifically in the present invention; The method of the USB port that the another kind location HID equipment that embodiment 1 provides is connected also is applicable to the USB port that the said location of present embodiment CCID equipment is connected, and performing step is similar with it, therefore no longer repeats at this.
Embodiment 3
The embodiment of the invention provides the method for the USB port that a kind of positioning equipment connected; Particularly; Be that example describes in the present embodiment with the scsi device; Scsi device is connected on the host computer through USB HUB, and the USB HUB that wherein is connected between host computer and the scsi device can be one or more.
Referring to Fig. 3, a kind of method of locating the USB port that scsi device connects, concrete performing step is following:
Step 301: host computer reads the SCSI path that is connected oneself scsi device on one's body;
Wherein, the scsi device that links to each other with host computer can be one or more, and when a plurality of scsi device, then host computer reads the SCSI path of all scsi devices, particularly, is that example describes with a scsi device in the present embodiment;
Further, read the SCSI path of scsi device and can from the parameter that WM_DEVICECHANGE message is imported into, read, also can enumerate the scsi device that has connected, obtain its SCSI path through calling SetupDiGetDeviceInterfaceDetail;
Particularly, in the present embodiment, read the SCSI path that obtains and be? Usbstor#cdrom&ven_usb&prod_token_2000auto&rev_1.00#7&b4 952b9&0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b}
Step 302: host computer is inquired about master controller, obtains the title of the root USB HUB that connects on the master controller;
In the present embodiment, host computer specifically through master controller being sent the IOCTL_USB_GET_ROOT_HUB_NAME request, obtains the title of the root USBHUB that is connected on the master controller.
Step 303: host computer is opened current USB HUB, and this current USB HUB is inquired about, and obtains the port number of this current USB HUB;
In the present embodiment, when being the equipment that connects on for the first time to this master controller when inquiring about, the root USB HUB that then connects on the master controller promptly is current USB HUB;
And the method that current USB HUB is inquired about is specially:
Host computer sends the IOCTL_USB_GET_NODE_INFORMATION request to current USB HUB, obtains the port number of this current USB HUB.
Step 304: host computer is inquired about when front port current USB HUB's, obtains the equipment link information on front port;
In the present embodiment, when being when for the first time this current USB HUB being inquired about, then first port of this current USBHUB is and works as front port;
Wherein, the method for inquiring about when front port to current USB HUB is:
Host computer is asked when front port sends IOCTL_USB_GET_NODE_CONNECTION_INFORMATION to current USB HUB's; Obtain the equipment link information of deserving on the front port, wherein specifically comprise information such as connection status zone bit, HUB zone bit, producer's identifier information and device identifier information in the equipment link information;
The equipment link information of certain port that obtains in the present embodiment particularly, is:
USB_NODE_CONNECTION_INFORMATION connectionInfo;
connectionInfo.ConnectionIndex=0x00000004;
connectionInfo.DeviceDescriptor.bLength=0x12;
connectionInfo.DeviceDescriptor.bDescriptorType=0x01;
connectionInfo.DeviceDescriptor.bcdUSB=0x0110
connectionInfo.DeviceDescriptor.bDeviceClass=0x00
connectionInfo.DeviceDescriptor.bDeviceSubClass=0x00
connectionInfo.DeviceDescriptor.bDeviceProtocol=0x00
connectionInfo.DeviceDescriptor.bMaxPacketSize0=0x08
connectionInfo.DeviceDescriptor.idVendor=0x096e
connectionInfo.DeviceDescriptor.idProduct=0x0305
connectionInfo.DeviceDescriptor.bcdDevice=0x2007
connectionInfo.DeviceDescriptor.iManufacturer=0x01
connectionInfo.DeviceDescriptor.iProduct=0x02
connectionInfo.DeviceDescriptor.iSerialNumber=0x00
connectionInfo.DeviceDescriptor.bNumConfigurations=0x01
connectionInfo.CurrentConfigurationValue=0x01
connectionInfo.LowSpeed=0x00
connectionInfo.DeviceIsHub=0x00
connectionInfo.DeviceAddress=0x0002
connectionInfo.NumberOfOpenPipes=0x00000002
connectionInfo.ConnectionStatus=0x00000001
connectionInfo.PipeList=0x001704b3
Step 305: host computer is judged working as front port according to the equipment link information; Obtain on front port, not having connection device if judge; Then execution in step 306, if judge obtain on front port, connecting be USBHUB, execution in step 310; If what judgement obtained on front port, connecting is generic USB equipment, then execution in step 311;
In the present embodiment, according to the equipment link information method of judging when front port is specially:
Connection status zone bit connectionInfo.ConnectionStatus in the equipment link information judges; When connection status zone bit connectionInfo.ConnectionStatus is 0x00000001; Then expression has connected equipment on front port; When connection status zone bit connectionInfo.ConnectionStatus was 0x00000000, then expression did not have connection device on front port;
Further; When connection status zone bit connectionInfo.ConnectionStatus is 0x00000001; Also need the HUB zone bit connectionInfo.DeviceIsHub in the judgment device link information further to be for 0x00 or to be 0x01; If connectionInfo.DeviceIsHub is 0x01; That then expression is deserved to connect on the front port is USB HUB, if connectionInfo.DeviceIsHub is 0x00, what then expression was deserved to connect on the front port is generic USB equipment.
Step 306: host computer judges whether to have inquired about all of the port of current USB HUB, and if not, then execution in step 307, if then execution in step 308;
In the present embodiment, host computer specifically judges whether to have inquired about all of the port of current USB HUB according to the port number of the current USB HUB that is obtained in the step 303.
Step 307: with current USB HUB when the next port of front port as working as front port, and turn back to step 304;
Step 308: judge whether to exist the USB HUB that has numbered and do not inquired about, if not, then end operation, and prompting can't position the scsi device in the step 301, if then execution in step 309;
Step 309: will number top USB HUB as current USB HUB, and turn back to step 303;
Step 310: host computer judges whether to exist the USB HUB that has numbered, and if not, then the USB HUB with this connection is numbered a USB HUB; Turn back to step 306 then; If, then follow already present numbering and continue the USB HUB of this connection is numbered, turn back to step 306 then;
Step 311: host computer obtains the path DriverKeyName of this generic USB equipment below driver;
Particularly; Because in actual application; The equipment that possibly connect a plurality of same types on the host computer; Like a plurality of scsi devices, therefore only can not correctly navigate to the port that this scsi device belongs to, so also need utilize DriverKeyName in the present embodiment with identifier information VID of producer in the equipment link information of step 304 acquisition and device identifier information PID;
In the present embodiment; The method of obtaining DriverKeyName is specially host computer and sends the IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME request to this generic USB equipment; Receive the relevant information that this generic USB equipment returns; The information of wherein returning comprises parameter DriverKeyName, and the structure of the information of returning specifically is defined as USB_NODE_CONNECTION_DRIVERKEY_NAME);
Particularly, the DriverKeyName that acquires in the present embodiment is: 0120.
Step 312:, under the registration table path of above-mentioned generic USB equipment, search the subitem of the data and the driverKeyName coupling of Driver key assignments according to VID and the PID in the equipment link information of step 304 acquisition;
In the present embodiment, VID and the PID in the equipment link information of step 304 acquisition is respectively 0x096e and 0x0305;
The method of subitem of searching data and the driverKeyName coupling of Driver key assignments is: SYSTEM _ data of searching the Driver key assignments below the 096e&Pid_0305 for 0120 subitem, the subitem that specifically finds is 6&c195ce&0&4.
Step 313: the data that read the ParentIdPrefix key assignments under the subitem that finds;
In the present embodiment, the data that read the ParentIdPrefix key assignments that obtains are 7&b4952b9&0
Step 314: determining step 301 reads and whether comprises step 313 in the SCSI path that obtains and read the data that obtain the ParentIdPrefix key assignments; If not, then turn back to step 306, if; Represent then in the step 301 that said scsi device promptly is connected and deserve on the front port execution in step 315;
In the present embodiment; Be specially judge the SCSI path? Usb#vid_096e&pid_070f#6&c195ce&0&2#{a5dcbf10-6530-11d2-whether comprise the title 6&c195ce&0&2 of subitem among the 901f-00c04fb951ed}; Hence one can see that; Therefore the title that comprises subitem in the SCSI path, representing that said scsi device promptly is connected in the step 301 deserves on the front port execution in step 315.
Step 315: host computer carries out relatedly with above-mentioned when front port said scsi device path in the step 301, locatees the USB port that this scsi device connects.
In the present embodiment; Specifically only comprising a master controller with host computer is that example describes; Therefore in the present embodiment when there is not the USB HUB that has numbered and do not inquired about in step 308 judgement; Then direct end operation, and point out and can't the scsi device in the step 401 be positioned, do not need to go again to inquire about next master controller;
Perhaps, can also be the same in the present embodiment with embodiment 1, host computer comprises a plurality of master controllers; Then host computer need be inquired about these a plurality of master controllers, and querying method is identical with querying method described in the embodiment 1, is specially: when present embodiment step 308 is judged when not had the USB HUB that has numbered and do not inquired about; Then host computer continues to judge whether to have inquired about all master controllers, if, end operation then; And prompting can't position the scsi device in the step 301; If not, then turn back to step 302 and continue next master controller is inquired about, all inquire about up to all master controllers and finish;
The method of inquiry can also be: host computer master controller of inquiry earlier; The title of the root USB HUB that obtains connecting on this master controller; Then do not continue this root of inquiry USB HUB then; But begin to inquire about next master controller, all inquire about up to all master controllers and finish, each root USB HUB that begins to inquire about on the master controller again and connected.
Present embodiment provides a kind of method of locating the USB port that scsi device connects, and just can locate the USB port that scsi device connects through the method that present embodiment provides.
Further; Present embodiment provides a kind of method of locating the USB port that scsi device connects, and present embodiment only describes with a kind of method, and in actual application, has multiple localization method; Specifically in the present invention; The method of the USB port that the another kind location HID equipment that embodiment 1 provides is connected also is applicable to the USB port that the said location of present embodiment scsi device is connected, and performing step is similar with it, therefore no longer repeats at this.
The above; Be merely embodiment of the present invention, but protection scope of the present invention is not limited thereto, any technician who is familiar with the present technique field is in the technical scope that the present invention discloses; Can expect easily changing or replacement, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion by said protection domain with claim.