CN103559162A - Method and host for positioning USB (universal serial bus) devices on HUB set - Google Patents

Method and host for positioning USB (universal serial bus) devices on HUB set Download PDF

Info

Publication number
CN103559162A
CN103559162A CN201310514597.7A CN201310514597A CN103559162A CN 103559162 A CN103559162 A CN 103559162A CN 201310514597 A CN201310514597 A CN 201310514597A CN 103559162 A CN103559162 A CN 103559162A
Authority
CN
China
Prior art keywords
hub
usb device
port
main frame
current
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.)
Granted
Application number
CN201310514597.7A
Other languages
Chinese (zh)
Other versions
CN103559162B (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201310514597.7A priority Critical patent/CN103559162B/en
Publication of CN103559162A publication Critical patent/CN103559162A/en
Application granted granted Critical
Publication of CN103559162B publication Critical patent/CN103559162B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Transfer Systems (AREA)

Abstract

The invention discloses a method and a host for positioning USB (universal serial bus) devices on a HUB set. The method is applied to a system comprising the host, the HUB set and the USB device, the HUB set comprises a plurality of HUBs at least including primary HUBs and secondary HUBs, and the primary HUBs are directly connected with the host through cascade interfaces of the primary HUBs and directly connected with cascade interfaces of one or a plurality of primary HUBs through common ports of the primary HUBs. The host acquires HUB port numbers and HUB ID (identification) of the USB devices according to monitored kernel events or polled device path information of the USB devices, the USB devices on the HUB set are positioned and operated according to the HUB port numbers and the HUB ID, and a plurality of USB devices can be parallelly processed.

Description

A kind of method and main frame of locating the USB device in HUB group
Technical field
The present invention relates to communication technical field, particularly relate to method and the main frame of the USB device in a kind of HUB of location group.
Background technology
HUB(hub) be the transponder of a multiport, a USB interface can be expanded into a plurality of USB interface that work alone, be connected with a plurality of USB device, be widely used in the LAN (Local Area Network) of stelliform connection topology configuration.HUB can directly be connected with computer need not external power supply, and simply handy, computer is identified installation automatically, need not driver, and plug and play.
Inventor, in realizing process of the present invention, finds that prior art at least exists following defect:
On HUB of the prior art, there is no port numbering, cannot set up the physical port of HUB and be connected to the corresponding relation between the equipment on HUB, thereby cause positioning the equipment being connected on HUB.
Summary of the invention
The invention provides method and the main frame of the USB device in a kind of HUB of location group, to solve the defect that cannot position the equipment being connected on HUB in prior art.
The invention provides the method for the USB device in a kind of HUB of location group, be applied to comprise in the system of main frame, HUB group and USB device, described HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, described first order HUB is direct-connected by self subtending port and described main frame, and direct-connected by self common port and the subtending port of one or more second level HUB, said method comprising the steps of:
S1, described main frame obtain the device path information of USB device, and described USB device is connected on the common port of other HUB except described first order HUB in described HUB group;
S2, described main frame read the data on last of device path information of described USB device, the data that read are saved in port information, and according to the device path information of described USB device, obtain the device path information of the HUB direct-connected with described USB device, using described HUB as current HUB;
S3, described main frame judge that whether described current HUB is the first order HUB in described HUB group, if so, performs step S6; Otherwise, execution step S4;
S4, described main frame read in the device path information of described current HUB the data on last, the data that read are added in described port information, and according to the device path information of described current HUB, obtain the device path information of the higher level HUB of described current HUB, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group;
S5, described main frame be the current HUB after upgrading using described higher level HUB, and returns to step S3;
S6, described main frame read in the device path information of described current HUB the data on last, and the HUB ID using the data that read as described USB device obtains the HUB port numbers of described USB device according to described port information.
The present invention also provides a kind of main frame, be applied to comprise in the system of main frame, HUB group and USB device, described HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, described first order HUB is direct-connected by self subtending port and described main frame, and direct-connected by self common port and the subtending port of one or more second level HUB, described main frame comprises:
The first acquisition module, for obtaining the device path information of USB device, described USB device is connected on the common port of other HUB except described first order HUB in described HUB group;
The first read module, for reading the data on last of device path information of the described USB device that described the first acquisition module obtains, is saved in the data that read in port information;
The second acquisition module, for the device path information of the described USB device obtained according to described the first acquisition module, obtains the device path information of the HUB direct-connected with described USB device, using described HUB as current HUB, and triggers the first judge module;
The first judge module, for judging whether described current HUB is the first order HUB of described HUB group;
The second read module, while not being the first order HUB of described HUB group for judging described current HUB at described the first judge module, read in the device path information of described current HUB the data on last, the data that read are added in described port information, and according to the device path information of described current HUB, obtain the device path information of the higher level HUB of described current HUB, current HUB using described higher level HUB after upgrading, and trigger described the first judge module, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group,
Third reading delivery piece, while being the first order HUB of described HUB group for judging described current HUB at described the first judge module, read in the device path information of described current HUB the data on last, the HUB ID using the data that read as described USB device;
The 3rd acquisition module, while being the first order HUB of described HUB group for judging described current HUB at described the first judge module, obtains the HUB port numbers of described USB device according to described port information.
The beneficial effect that the present invention reaches: the device path information of the kernel events that main frame basis listens to or the USB device being polled to, obtain HUB port numbers and the HUB ID of USB device, the location of realization to the USB device on HUB, and according to HUB port numbers and HUB ID, USB device is operated, can a plurality of USB device of parallel processing.
Accompanying drawing explanation
Fig. 1 is a kind of system architecture schematic diagram of locating the USB device in HUB group in the embodiment of the present invention;
Fig. 2 is a kind of method flow diagram of locating the USB device in HUB group in the embodiment of the present invention;
Fig. 3 is the schematic diagram of the mode of operation of the demonstration USB device in the embodiment of the present invention;
Fig. 4 is the method flow diagram of the USB device in the another kind location HUB group in the embodiment of the present invention;
Fig. 5 is the structural representation of a kind of main frame in the embodiment of the present invention;
Fig. 6 is the structural representation of the another kind of main frame in the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
The embodiment of the present invention provides the method for the USB device in a kind of HUB of location group, be applied to comprise in the system of main frame, HUB group and USB device, this system architecture as shown in Figure 1, wherein, HUB group at least comprises first order HUB and second level HUB, also can further comprise one or more levels HUB under the HUB of the second level, each HUB can comprise 1 cascade port and 4 common ports, cascade port is for connecting main frame or adjacent higher level HUB, and common port is for connecting USB device or the adjacent HUB of subordinate.
Particularly, the first order HUB in HUB group is connected with main frame by the cascade port of self, and other HUB in HUB group except first order HUB are connected with the common port of adjacent higher level HUB by the cascade port of self; The HUB of subordinate in HUB group is connected other HUB outside the ,HUB Zu Zhongchu HUB of subordinate by self common port and is connected with the cascade port of the adjacent HUB of subordinate by self common port with USB device.
Said system also can further comprise controllable device, and controllable device is connected with the HUB of subordinate in main frame and HUB group, and the common port receiving from the instruction ,Dui HUB of subordinate of main frame powers on and lower electricity operation.
Based on said system, the method for the USB device in the location HUB group in the embodiment of the present invention as shown in Figure 2, comprises the following steps:
Step 201, whether host supervision has USB device to be connected on the port of HUB group, if so, performs step 202; Otherwise whether continue monitoring has USB device to be inserted on the port of HUB group.
Particularly, the kernel events that main frame can monitoring system kernel be dished out, when listening to the kernel events that system kernel dishes out default, defines on the port that USB device is connected to HUB group.Wherein, the kernel events that default kernel events can be corresponding for the operation with USB device being connected to HUB port.When USB device is inserted into the port of the HUB group being connected with main frame, the system kernel above-mentioned default kernel events of dishing out.
In the present embodiment, the kernel events that main frame can use Netlink socket monitoring system kernel to dish out.
Step 202, main frame obtains the device path information of USB device from the kernel events listening to.
For example, main frame calls recvmsg(sockfd, & smsg, 0) function obtains kernel events, and the device path information of the USB device getting from this kernel events is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ".
Step 203, main frame, according to the device path information of USB device, reads the property file of this USB device, and in dependency file, obtains the identification information of this USB device.
Wherein, the identification information of USB device is included in the property file of USB device, can comprise Product Identifying and supplier's sign.
For example, when the device path information of USB device is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", main frame is by calling respectively udev_device_get_sysattr_value (Device, " idVendor ") function and udev_device_get_sysattr_value (Device, " idProduct ") function, according to the said equipment routing information, open property file idVendor and the idProduct under catalogue " 2-1.3.2.2 " by name, Product Identifying and the supplier's sign of from corresponding property file, obtaining USB device are respectively " 0x2008 " and " 0x7639 ", the identification information of this USB device is (0x2008, 0x7639).
Step 204, main frame, according to the identification information of USB device, judges that whether USB device is the equipment that needs location, if so, performs step 205; Otherwise, process ends.
Particularly, main frame can judge whether the identification information of USB device is included in the first default identified group, if so, determines that this USB device is the equipment that needs location; Otherwise, determine that this USB device is not the equipment that needs location.Wherein, the first default identified group can identify for one or more groups for USB device being carried out to initialization operation predefined identification information before, and every group of sign can comprise Product Identifying and supplier's sign.
For example, the first default identified group is (0x2008,0x7639) and (0x096e, 0x0304), and when the identification information of USB device is (0x2008,0x7639), main frame judges that this USB device is for needing the equipment of location.
Step 205, main frame reads the data on last of device path information of USB device, and the data that read are saved in port information.
Particularly, when second level HUB in USB device and HUB group is direct-connected, main frame can read the data on last of device path information of USB device, using the data that read as level ports, number is saved in port information; When other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can be initialized as the value of variable n total progression M of HUB group, read the data on last of device path information of USB device, the data that read are saved in port information as n level port numbers.
For example, third level HUB in USB device and HUB group is direct-connected, total progression M=3 of HUB group, when the device path information of USB device is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", main frame reads the data " 3 " on last of the said equipment routing information, and " 3 " are saved in port information as three grades of port numbers.
Step 206, main frame, according to the device path information of USB device, obtains the device path information of the HUB direct-connected with USB device, using this HUB as current HUB.
Particularly, main frame can intercept the content being positioned at before last space character from the device path information of USB device, and the content that intercepting is obtained is as the device path information with the direct-connected HUB of USB device.
For example, USB device and third level HUB are direct-connected, when the device path information of USB device is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", main frame is by calling udev_device_get_parent (Device) function, obtain the device path information of the third level HUB direct-connected with USB device, i.e. "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", and using above-mentioned HUB as current HUB.
Step 207, main frame judges that whether current HUB is the first order HUB in HUB group, if so, performs step 210; Otherwise, perform step 208.
Step 208, main frame reads in the device path information of current HUB the data on last, and the data that read are added in port information.
Particularly, when other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can subtract 1 by the value of variable n, read in the device path information of current HUB the data on last, the data that read are added in port information as n level port numbers.
For example, the value of variable n is 3, when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", main frame can be updated to 2 by variable n, read the data " 2 " on last of the said equipment routing information, " 2 " are added in port information as level ports number.
Step 209, main frame, according to the device path information of current HUB, obtains the device path information of the higher level HUB of current HUB, the current HUB using this higher level HUB after upgrading, and return to step 207.
Particularly, main frame can intercept and be positioned at last space character content before from the device path information of current HUB, and the content that intercepting is obtained is as the device path information of the higher level HUB of current HUB.Wherein, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group.
For example, when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", main frame can be by calling udev_device_get_parent (Hub) function, obtain the device path information of the higher level HUB of current HUB, i.e. "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4 ".
Step 210, main frame reads in the device path information of current HUB the data on last, and the HUB ID using the data that read as USB device obtains the HUB port numbers of USB device according to port information.
Particularly, when second level HUB in USB device and HUB group is direct-connected, the HUB port numbers that main frame can be using the level ports in port information number as USB device; When other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can calculate according to port information
Figure BDA0000402994510000071
hUB port numbers using the result obtaining as USB device, wherein, P nfor the n level port numbers in port information, n is integer, and 1 < n≤M, and M is total progression of HUB group.
For example, in port information, comprise one-level port numbers " 4 ", level ports number " 2 " and three grades of port numbers " 3 ", when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4 ", main frame reads in the device path information of current HUB the data " 4 " on last, HUB ID by " 4 " as USB device, and according to port information, calculate the HUB port numbers=3+(2-1 of USB device) * 4=7.
Step 211, main frame, according to the HUB port numbers of USB device and HUB ID, shows the mode of operation of this USB device.
Particularly, main frame can call predefined function, and the parameter using the HUB port numbers of USB device and HUBID as this function shows HUB port numbers, HUB ID and the mode of operation of this USB device.
For example, the HUB port numbers of USB device is that 7, HUB ID is 4 o'clock, main frame calls PrintPortInfo function, and the parameter by " HUB port numbers=7, HUB ID=4; port status " as this function shows HUB port numbers, HUB ID and the mode of operation of this USB device, as shown in Figure 3.
Step 212, main frame, according to the identification information of USB device, judges current operation, if current operation is download system operation, performs step 213; If current operation is initialization operation, perform step 215.
Particularly, main frame can judge the identification information of USB device, if the identification information of USB device is the first default sign, determines that current operation is download system operation; If the identification information of USB device is the second default sign, determine that current operation is initialization operation.Wherein, the first default sign can, for USB device being carried out to download system operation predefined identification information before, can comprise the first Product Identifying and the first supplier sign; The second default sign can, for predefined identification information after USB device is carried out to download system operation, before execution initialization operation, can comprise the second Product Identifying and the second supplier sign.
For example, the first default be designated (0x2008,0x7639), second presets while being designated (0x096e, 0x0304), if the identification information of USB device is (0x2008,0x7639), main frame judgement current operation is download system operation; When if the identification information of USB device is (0x096e, 0x0304), main frame judgement current operation is initialization operation.
Step 213, main frame writes chip operating system in USB device, upgrades the identification information of this USB device.
Particularly, main frame can be the second default identification information by the update of identification information of USB device.Wherein, the second default sign can, for predefined identification information after USB device is carried out to download system operation, before execution initialization operation, can comprise the second Product Identifying and the second supplier sign.
For example, when the identification information of USB device is (0x2008,0x7639), main frame can be set to respectively " 0x096e " and " 0x0304 " by the Product Identifying of USB device and supplier's sign.
Step 214, main frame is according to the HUB port numbers of USB device and HUB ID, to controllable device, sends lower electric instruction and the instruction that powers on, and controlled under the port that above-mentioned USB device is connected to electricity and powered on, and return to step 204 by controllable device.
Particularly, main frame can be first according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction, control electricity under the port that above-mentioned USB device is connected to, and after waiting for Preset Time, again according to the HUB port numbers of USB device and HUB ID, to controllable device, send the instruction that powers on, control the port that above-mentioned USB device is connected to and power on.
For example, the HUB port numbers of USB device is 7, HUB ID is 4, when Preset Time is 5 seconds, main frame sends lower electric instruction to controllable device, control HUB ID and be 4 and the HUB port numbers port that is 7 under electricity, and after waiting for 5 seconds, to controllable device, send the instruction that powers on, control HUB ID and be 4 and HUB port numbers be 7 port powers on.
Step 215, main frame, according to the HUB port numbers of USB device and HUB ID, generates hardware sequence number, this hardware sequence number is written in USB device, and returns to step 201.
Particularly, main frame can use HUB port numbers and the synthetic hardware sequence number of HUB ID of USB device, also can use system time, serial number, HUB port numbers and HUB ID to synthesize hardware sequence number.In the present embodiment, main frame can subtract 1 by HUB port numbers, according to the difference obtaining and the synthetic hardware sequence number of HUB ID, or according to the synthetic hardware sequence number of the difference obtaining, system time, serial number and HUB ID.
For example, the HUB port numbers of USB device is that 7, HUB ID is 4, and system time is 121010, when serial number is 8acdb0e0, and the hardware sequence number 8acdb1210100460e that main frame generates.
In the technical scheme that the embodiment of the present invention provides, main frame obtains the device path information of USB device according to the kernel events listening to, according to the HUB port numbers of this device path acquisition of information USB device and HUB ID, the location of realization to the USB device on HUB, and according to HUB port numbers and HUB ID, USB device is operated, can a plurality of USB device of parallel processing.
It should be noted that, in embodiments of the present invention, main frame can also be located the USB device in HUB group by the mode of poll.As shown in Figure 4, the method flow diagram for the USB device in the another kind location HUB group in the embodiment of the present invention, comprises the following steps:
Step 401, the property file of host computer polls USB device.
Particularly, main frame can, every default duration, be inquired about the property file of USB device under preset path.
For example, main frame can be every 5 seconds, the property file of "/sys/bus/usb/devices " lower inquiry USB device in path.
Step 402, main frame obtains the identification information of this USB device from the property file of the USB device that is polled to.
Particularly, when main frame is polled to after the property file of USB device under preset path, main frame can be opened this property file, reads the identification information of USB device from this property file.Wherein, the identification information of USB device can comprise Product Identifying and supplier's sign of USB device.
For example, main frame is polled to property file idVendor and the idProduct of USB device under "/sys/bus/usb/devices ", Product Identifying and the supplier's sign of from this property file, obtaining this USB device are respectively " 0x2008 " and " 0x7639 ", the identification information of this USB device is (0x2008,0x7639).
Step 403, main frame, according to the identification information of USB device, judges that whether this USB device is the equipment that needs location, if so, performs step 404; Otherwise, return to step 401.
Particularly, main frame can judge whether the identification information of USB device is included in the second default identified group, if so, determines that this USB is the equipment that needs location; Otherwise, determine that this USB is not the equipment that needs location.Wherein, the second default identified group can identify for one or more groups for the identification information of the USB device of needs location, and every group of sign can comprise Product Identifying and supplier's sign.
For example, the second default identified group is (0x1097,0x5226), (0x2008,0x7639), (0x3046,0x9527) and (0x096e, 0x0304), when the identification information of USB device is (0x2008,0x7639), main frame judges that this USB device is for needing the equipment of location.
Step 404, main frame is by the routing information of the property file of the USB device being polled to, as the device path information of USB device.
For example, the routing information of the property file of the USB device that host computer polls arrives when "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", the device path information that main frame can be using above-mentioned routing information as USB device.
Step 405, main frame reads the data on last of device path information of USB device, and the data that read are saved in port information.
Particularly, when second level HUB in USB device and HUB group is direct-connected, main frame can read the data on last of device path information of USB device, using the data that read as level ports, number is saved in port information; When other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can be initialized as the value of variable n total progression M of HUB group, read the data on last of device path information of USB device, the data that read are saved in port information as n level port numbers.
For example, third level HUB in USB device and HUB group is direct-connected, total progression M=3 of HUB group, when the device path information of USB device is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", main frame reads the data " 3 " on last of the said equipment routing information, and " 3 " are saved in port information as three grades of port numbers.
Step 406, main frame, according to the device path information of USB device, obtains the device path information of the HUB direct-connected with USB device, using this HUB as current HUB.
Particularly, main frame can intercept the content being positioned at before last space character from the device path information of USB device, and the content that intercepting is obtained is as the device path information with the direct-connected HUB of USB device.
For example, USB device and third level HUB are direct-connected, when the device path information of USB device is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2/2-1.4.2.3 ", main frame is by calling udev_device_get_parent (Device) function, obtain the device path information of the third level HUB direct-connected with USB device, i.e. "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", and using above-mentioned HUB as current HUB.
Step 407, main frame judges that whether current HUB is the first order HUB in HUB group, if so, performs step 410; Otherwise, perform step 408.
Step 408, main frame reads in the device path information of current HUB the data on last, and the data that read are added in port information.
Particularly, when other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can subtract 1 by the value of variable n, read in the device path information of current HUB the data on last, the data that read are added in port information as n level port numbers.
For example, the value of variable n is 3, when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", main frame can be updated to 2 by variable n, read the data " 2 " on last of the said equipment routing information, " 2 " are added in port information as level ports number.
Step 409, main frame, according to the device path information of current HUB, obtains the device path information of the higher level HUB of current HUB, the current HUB using this higher level HUB after upgrading, and return to step 407.
Particularly, main frame can intercept and be positioned at last space character content before from the device path information of current HUB, and the content that intercepting is obtained is as the device path information of the higher level HUB of current HUB.Wherein, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group.
For example, when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4.2 ", main frame can be by calling udev_device_get_parent (Hub) function, obtain the device path information of the higher level HUB of current HUB, i.e. "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4 ".
Step 410, main frame reads in the device path information of current HUB the data on last, and the HUB ID using the data that read as USB device obtains the HUB port numbers of USB device according to port information.
Particularly, when second level HUB in USB device and HUB group is direct-connected, the HUB port numbers that main frame can be using the level ports in port information number as USB device; When other HUB in USB device and HUB group except first order HUB and second level HUB are direct-connected, main frame can calculate according to port information
Figure BDA0000402994510000111
hUB port numbers using the result obtaining as USB device, wherein, P nfor the n level port numbers in port information, n is integer, and 1 < n≤M, and M is total progression of HUB group.
For example, in port information, comprise one-level port numbers " 4 ", level ports number " 2 " and three grades of port numbers " 3 ", when the device path information of current HUB is "/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4 ", main frame reads in the device path information of current HUB the data " 4 " on last, HUB ID by " 4 " as USB device, and according to port information, calculate the HUB port numbers=3+(2-1 of USB device) * 4=7.
Step 411, main frame, according to the HUB port numbers of USB device and HUB ID, shows the mode of operation of this USB device.
Particularly, main frame can call predefined function, and the parameter using the HUB port numbers of USB device and HUBID as this function shows HUB port numbers, HUB ID and the mode of operation of this USB device.
For example, the HUB port numbers of USB device is that 7, HUB ID is 4 o'clock, main frame calls PrintPortInfo function, and the parameter by " HUB port numbers=7, HUB ID=4; port status " as this function shows HUB port numbers, HUB ID and the mode of operation of this USB device, as shown in Figure 3.
Step 412, main frame, according to the identification information of USB device, judges current operation, if current operation is download system operation, performs step 413; If current operation is initialization operation, perform step 415.
Particularly, main frame can judge the identification information of USB device, if the identification information of USB device is the first default sign, determines that current operation is download system operation; If the identification information of USB device is the second default sign, determine that current operation is initialization operation.Wherein, the first default sign can, for USB device being carried out to download system operation predefined identification information before, can comprise the first Product Identifying and the first supplier sign; The second default sign can, for predefined identification information after USB device is carried out to download system operation, before execution initialization operation, can comprise the second Product Identifying and the second supplier sign.
For example, the first default be designated (0x2008,0x7639), second presets while being designated (0x096e, 0x0304), if the identification information of USB device is (0x2008,0x7639), main frame judgement current operation is download system operation; When if the identification information of USB device is (0x096e, 0x0304), main frame judgement current operation is initialization operation.
Step 413, main frame writes chip operating system in USB device, upgrades the identification information of this USB device.
Particularly, main frame can be the second default identification information by the update of identification information of USB device.Wherein, the second default sign can, for predefined identification information after USB device is carried out to download system operation, before execution initialization operation, can comprise the second Product Identifying and the second supplier sign.
For example, when the identification information of USB device is (0x2008,0x7639), main frame can be set to respectively " 0x096e " and " 0x0304 " by the Product Identifying of this USB device and supplier's sign, the identification information (0x096e, 0x0304) of the USB device after being upgraded.
Step 414, main frame is according to the HUB port numbers of USB device and HUB ID, to controllable device, sends lower electric instruction and the instruction that powers on, and controlled under the port that above-mentioned USB device is connected to electricity and powered on, and return to step 401 by controllable device.
Particularly, main frame can be first according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction, control electricity under the port that above-mentioned USB device is connected to, and after waiting for Preset Time, again according to the HUB port numbers of USB device and HUB ID, to controllable device, send the instruction that powers on, control the port that above-mentioned USB device is connected to and power on.
For example, the HUB port numbers of USB device is 7, HUB ID is 4, when Preset Time is 5 seconds, main frame sends lower electric instruction to controllable device, control HUB ID and be 4 and the HUB port numbers port that is 7 under electricity, and after waiting for 5 seconds, to controllable device, send the instruction that powers on, control HUB ID and be 4 and HUB port numbers be 7 port powers on.
Step 415, main frame, according to the HUB port numbers of USB device and HUB ID, generates hardware sequence number, and this hardware sequence number is written in USB device, and this USB device is set to not need the USB device of location, and returns to step 401.
Particularly, main frame can use HUB port numbers and the synthetic hardware sequence number of HUB ID of USB device, also can use system time, serial number, HUB port numbers and HUB ID to synthesize hardware sequence number.In the present embodiment, main frame can subtract 1 by HUB port numbers, according to the difference obtaining and the synthetic hardware sequence number of HUB ID, or according to the synthetic hardware sequence number of the difference obtaining, system time, serial number and HUB ID.In addition, main frame can be deleted the identification information of above-mentioned USB device from the second default identified group, thereby this USB device is set to not need the USB device of location.
For example, the HUB port numbers of USB device is 7, HUB ID is 4, system time is 121010, serial number is 8acdb0e0, the identification information of USB device is (0x096e, 0x0304), the second default identified group is ((0x1097, 0x5226), (0x2008, 0x7639), (0x3046, 0x9527) with (0x096e, in the time of 0x0304), main frame generates hardware sequence number 8acdb1210100460e, and by (0x096e, 0x0304) from the second default identified group, delete, after being upgraded second preset identified group (0x1097, 0x5226), (0x2008, 0x7639) with (0x3046, 0x9527).
In the technical scheme that the embodiment of the present invention provides, main frame obtains the device path information of USB device by the mode of poll, according to the HUB port numbers of this device path acquisition of information USB device and HUB ID, the location of realization to the USB device on HUB, and according to HUB port numbers and HUB ID, USB device is operated, can a plurality of USB device of parallel processing.
The embodiment of the present invention also provides a kind of main frame, its structure as shown in Figure 5, be applied to comprise in the system of main frame, HUB group and USB device, HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, first order HUB is direct-connected by self subtending port and main frame, and it is direct-connected to pass through self common port and the subtending port of one or more second level HUB, and above-mentioned main frame comprises:
The first acquisition module 501, for obtaining the device path information of USB device, USB device is connected on the common port of other HUB except first order HUB in HUB group;
Particularly, above-mentioned the first acquisition module 501, the kernel events of dishing out specifically for monitoring system kernel is obtained the device path information of USB device from the kernel events listening to.
The first read module 502, for reading the data on last of device path information of the USB device that the first acquisition module 501 obtains, is saved in the data that read in port information;
The second acquisition module 503, for the device path information of the USB device obtained according to the first acquisition module 501, obtains the device path information of the HUB direct-connected with USB device, using HUB as current HUB, and triggers the first judge module 504;
Particularly, above-mentioned the second acquisition module 503, specifically for intercepting the device path information of the USB device obtained from the first acquisition module 501, be positioned at the content before last space character, the content that intercepting is obtained is as the device path information with the direct-connected HUB of USB device, using HUB as current HUB, and trigger the first judge module 504;
The first judge module 504, for judging whether current HUB is the first order HUB of HUB group;
The second read module 505, while not being the first order HUB of HUB group for judging current HUB at the first judge module 504, read in the device path information of current HUB the data on last, the data that read are added in port information, and according to the device path information of current HUB, obtain the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and triggering the first judge module 504, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group;
Particularly, above-mentioned the second read module 505, while not being the first order HUB in HUB group specifically for judging current HUB at the first judge module 504, read in the device path information of current HUB the data on last, the data that read are added in port information, from the device path information of current HUB, intercepting is positioned at last space character content before, the content that intercepting is obtained is as the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and trigger the first judge module 504, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group.
Third reading delivery piece 506, while being the first order HUB of HUB group for judging current HUB at the first judge module 504, reads in the device path information of current HUB the data on last, the HUB ID using the data that read as USB device;
The 3rd acquisition module 507, while being the first order HUB of HUB group for judging current HUB at the first judge module 504, obtains the HUB port numbers of USB device according to port information.
Further, above-mentioned main frame, also comprises:
The 4th read module 508, for the device path information of the USB device obtained according to the first acquisition module 501, reads the property file of USB device, obtains the identification information of USB device in dependency file;
The second judge module 509, for the identification information of the USB device that gets according to the 4th read module 508, judges whether USB device is the equipment that needs location;
Particularly, above-mentioned the second judge module 509, specifically for judging whether the identification information of USB device is included in the first default identified group, if so, determines that USB device is the equipment that needs location; Otherwise, determine that USB device is not the equipment that needs location.
Correspondingly, above-mentioned the first read module 502, specifically for judge USB device at the second judge module 509, be while needing the equipment of location, read the data on last of device path information of the USB device that the first acquisition module 501 obtains, the data that read are saved in port information.
The present embodiment, USB device can with HUB group in second level HUB direct-connected;
Correspondingly, the first read module 502, specifically for reading the data on last of device path information of the USB device that the first acquisition module 501 obtains, number is saved in port information the data that read as level ports;
The 3rd acquisition module 507, while being the first order HUB in HUB group specifically for judging current HUB at the first judge module 504, the HUB port numbers using the level ports in port information number as USB device.
In addition, USB device can also be direct-connected with other HUB except first order HUB and second level HUB in HUB group;
Correspondingly, the first read module 502, specifically for the value of variable n being initialized as to total progression M of HUB group, read the data on last of device path information of the USB device that the first acquisition module 501 obtains, the data that read are added in port information as n level port numbers;
The second read module 505, while not being the first order HUB in HUB group specifically for judging current HUB at the first judge module 504, the value of variable n is subtracted to 1, read in the device path information of current HUB the data on last, the data that read are added in port information as n level port numbers, and according to the device path information of current HUB, obtain the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and trigger the first judge module 504, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group,
The 3rd acquisition module 507, while being the first order HUB in HUB group specifically for judging current HUB at the first judge module 504, calculates according to port information
Figure BDA0000402994510000161
hUB port numbers using the result obtaining as USB device, wherein, P nfor the n level port numbers in port information, n is integer, and 1 < n≤M, and M is total progression of HUB group.
Further, above-mentioned main frame also comprises:
Display module 510, for according to the HUB port numbers of USB device and HUB ID, shows the mode of operation of USB device.
The 4th judge module 511, for according to the identification information of USB device, judges current operation;
Particularly, above-mentioned the 4th judge module 511, judges specifically for the identification information to USB device, if the identification information of USB device is the first default sign, determines that current operation is download system operation; If the identification information of USB device is the second default sign, determine that current operation is initialization operation;
The first processing module 512, while being download system operation for judge current operation at the 4th judge module 511, in USB device, write chip operating system, upgrade the identification information of USB device, according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by controllable device controls under the port that USB device is connected to electric with power on;
Particularly, above-mentioned the first processing module 512, while being download system operation specifically for judge current operation at the 4th judge module 511, in USB device, write chip operating system, by the update of identification information of USB device, it is the second default identification information, according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by controllable device controls under the port that USB device is connected to electric with power on.
The second processing module 513, while being initialization operation for judging current operation at the 4th judge module 511, according to the HUB port numbers of USB device and HUB ID, generates hardware sequence number, and hardware sequence number is written in USB device.
In the technical scheme that the embodiment of the present invention provides, main frame obtains the device path information of USB device according to the kernel events listening to, according to the HUB port numbers of this device path acquisition of information USB device and HUB ID, the location of realization to the USB device on HUB, and according to HUB port numbers and HUB ID, USB device is operated, can a plurality of USB device of parallel processing.
The embodiment of the present invention also provides another kind of main frame, its structure as shown in Figure 6, be applied to comprise in the system of main frame, HUB group and USB device, HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, first order HUB is direct-connected by self subtending port and main frame, and it is direct-connected to pass through self common port and the subtending port of one or more second level HUB, and main frame comprises:
The first acquisition module 601, for obtaining the device path information of USB device, USB device is connected on the common port of other HUB except first order HUB in HUB group;
Particularly, above-mentioned the first acquisition module 601, specifically for the property file of poll USB device, the device path information using the routing information of the property file of the USB device being polled to as USB device.
The first read module 602, for reading the data on last of device path information of the USB device that the first acquisition module 601 obtains, is saved in the data that read in port information;
The second acquisition module 603, for the device path information of the USB device obtained according to the first acquisition module 601, obtains the device path information of the HUB direct-connected with USB device, using HUB as current HUB, and triggers the first judge module 604;
Particularly, above-mentioned the second acquisition module 603, specifically for intercepting the device path information of the USB device obtained from the first acquisition module 601, be positioned at the content before last space character, the content that intercepting is obtained is as the device path information with the direct-connected HUB of USB device, using HUB as current HUB, and trigger the first judge module 604;
The first judge module 604, for judging whether current HUB is the first order HUB of HUB group;
The second read module 605, while not being the first order HUB of HUB group for judging current HUB at the first judge module 604, read in the device path information of current HUB the data on last, the data that read are added in port information, and according to the device path information of current HUB, obtain the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and triggering the first judge module 604, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group;
Particularly, above-mentioned the second read module 605, while not being the first order HUB in HUB group specifically for judging current HUB at the first judge module 604, read in the device path information of current HUB the data on last, the data that read are added in port information, from the device path information of current HUB, intercepting is positioned at last space character content before, the content that intercepting is obtained is as the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and trigger the first judge module 604, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group.
Third reading delivery piece 606, while being the first order HUB of HUB group for judging current HUB at the first judge module 604, reads in the device path information of current HUB the data on last, the HUB ID using the data that read as USB device;
The 3rd acquisition module 607, while being the first order HUB of HUB group for judging current HUB at the first judge module 604, obtains the HUB port numbers of USB device according to port information.
Further, above-mentioned main frame, also comprises:
The 4th acquisition module 608, obtains the identification information of USB device for the property file of the USB device that is polled to from the first acquisition module 601;
The 3rd judge module 609, for the identification information of the USB device that gets according to the 4th acquisition module 608, judges whether USB device is the equipment that needs location;
Particularly, above-mentioned the 3rd judge module 609, specifically for judging whether the identification information of USB device is included in the second default identified group, if so, determines that USB device is the equipment that needs location; Otherwise, determine that USB device is not the equipment that needs location.
Correspondingly, above-mentioned the first read module 602, specifically for judge USB device at the 3rd judge module 609, be while needing the equipment of location, read the data on last of device path information of the USB device that the first acquisition module 601 obtains, the data that read are saved in port information.
In the present embodiment, USB device can with HUB group in second level HUB direct-connected;
Correspondingly, the first read module 602, specifically for reading the data on last of device path information of the USB device that the first acquisition module 601 obtains, number is saved in port information the data that read as level ports;
The 3rd acquisition module 607, while being the first order HUB in HUB group specifically for judging current HUB at the first judge module 604, the HUB port numbers using the level ports in port information number as USB device.
In addition, USB device can also be direct-connected with other HUB except first order HUB and second level HUB in HUB group;
Correspondingly, the first read module 602, specifically for the value of variable n being initialized as to total progression M of HUB group, read the data on last of device path information of the USB device that the first acquisition module 601 obtains, the data that read are added in port information as n level port numbers;
The second read module 605, while not being the first order HUB in HUB group specifically for judging current HUB at the first judge module 604, the value of variable n is subtracted to 1, read in the device path information of current HUB the data on last, the data that read are added in port information as n level port numbers, and according to the device path information of current HUB, obtain the device path information of the higher level HUB of current HUB, current HUB using higher level HUB after upgrading, and trigger the first judge module 604, the higher level HUB of current HUB is the HUB of the cascade direct port connection by common port and current HUB in HUB group,
The 3rd acquisition module 607, while being the first order HUB in HUB group specifically for judging current HUB at the first judge module 604, calculates according to port information
Figure BDA0000402994510000191
hUB port numbers using the result obtaining as USB device, wherein, P nfor the n level port numbers in port information, n is integer, and 1 < n≤M, and M is total progression of HUB group.
Further, above-mentioned main frame, also comprises:
Display module 610, for according to the HUB port numbers of USB device and HUB ID, shows the mode of operation of USB device.
The 4th judge module 611, for according to the identification information of USB device, judges current operation;
Particularly, above-mentioned the 4th judge module 611, judges specifically for the identification information to USB device, if the identification information of USB device is the first default sign, determines that current operation is download system operation; If the identification information of USB device is the second default sign, determine that current operation is initialization operation;
The first processing module 612, while being download system operation for judge current operation at the 4th judge module 611, in USB device, write chip operating system, upgrade the identification information of USB device, according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by controllable device controls under the port that USB device is connected to electric with power on;
Particularly, above-mentioned the first processing module 612, while being download system operation specifically for judge current operation at the 4th judge module 611, in USB device, write chip operating system, by the update of identification information of USB device, it is the second default identification information, according to the HUB port numbers of USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by controllable device controls under the port that USB device is connected to electric with power on.
The 3rd processing module 613, while being initialization operation for judging current operation at the 4th judge module 611, according to the HUB port numbers of USB device and HUB ID, generate hardware sequence number, hardware sequence number is written in USB device, and USB device is set to not need the USB device of location.
Particularly, the 3rd processing module 613, while being initialization operation specifically for judging current operation at the 4th judge module 611, according to the HUB port numbers of USB device and HUB ID, generate hardware sequence number, hardware sequence number is written in USB device, from the second default identified group, deletes the identification information of above-mentioned USB device.
In the technical scheme that the embodiment of the present invention provides, main frame obtains the device path information of USB device by the mode of poll, according to the HUB port numbers of this device path acquisition of information USB device and HUB ID, the location of realization to the USB device on HUB, and according to HUB port numbers and HUB ID, USB device is operated, can a plurality of USB device of parallel processing.
The software module that step in the method for describing in conjunction with embodiment disclosed herein can directly use hardware, processor to carry out, or the combination of the two is implemented.Software module can be placed in the storage medium of any other form known in random access memory (RAM), internal memory, ROM (read-only memory) (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited to this, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.

Claims (30)

1. a method of locating the USB device in HUB group, it is characterized in that, be applied to comprise in the system of main frame, HUB group and USB device, described HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, described first order HUB is direct-connected by self subtending port and described main frame, and it is direct-connected to pass through self common port and the subtending port of one or more second level HUB, said method comprising the steps of:
S1, described main frame obtain the device path information of USB device, and described USB device is connected on the common port of other HUB except described first order HUB in described HUB group;
S2, described main frame read the data on last of device path information of described USB device, the data that read are saved in port information, and according to the device path information of described USB device, obtain the device path information of the HUB direct-connected with described USB device, using described HUB as current HUB;
S3, described main frame judge that whether described current HUB is the first order HUB in described HUB group, if so, performs step S6; Otherwise, execution step S4;
S4, described main frame read in the device path information of described current HUB the data on last, the data that read are added in described port information, and according to the device path information of described current HUB, obtain the device path information of the higher level HUB of described current HUB, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group;
S5, described main frame be the current HUB after upgrading using described higher level HUB, and returns to step S3;
S6, described main frame read in the device path information of described current HUB the data on last, and the HUB ID using the data that read as described USB device obtains the HUB port numbers of described USB device according to described port information.
2. the method for claim 1, is characterized in that, described step S1, is specially:
The kernel events that described main frame monitoring system kernel is dished out is obtained the device path information of described USB device from the kernel events listening to.
3. method as claimed in claim 2, is characterized in that, after described step S1, also comprises:
Described main frame, according to the device path information of described USB device, reads the property file of described USB device, obtains the identification information of described USB device from described property file;
Described main frame, according to the identification information of described USB device, judges that whether described USB device is the equipment that needs location, if so, performs step S2; Otherwise, process ends.
4. method as claimed in claim 3, is characterized in that, described main frame, according to the identification information of described USB device, judges that whether described USB device is the equipment that needs location, is specially:
Described main frame judges whether the identification information of described USB device is included in the first default identified group, if so, determines that described USB device is the equipment that needs location; Otherwise, determine that described USB device is not the equipment that needs location.
5. the method for claim 1, is characterized in that, described step S1, is specially:
The property file of described host computer polls USB device, the device path information using the routing information of the property file of the USB device being polled to as described USB device.
6. method as claimed in claim 5, is characterized in that, after described step S1, also comprises:
Described main frame obtains the identification information of described USB device from the property file of the described USB device being polled to;
Described main frame, according to the identification information of described USB device, judges that whether described USB device is the equipment that needs location, if so, performs step S2; Otherwise, return to step S1.
7. method as claimed in claim 6, is characterized in that, described main frame, according to the identification information of described USB device, judges that whether described USB device is the equipment that needs location, is specially:
Described main frame judges whether the identification information of described USB device is included in the second default identified group, if so, determines that described USB device is the equipment that needs location; Otherwise, determine that described USB device is not the equipment that needs location.
8. the method for claim 1, is characterized in that, described main frame, according to the device path information of described USB device, obtains the device path information of the HUB direct-connected with described USB device, is specially:
Described main frame intercepts the content being positioned at before last space character from the device path information of described USB device, and the content that intercepting is obtained is as the device path information with the direct-connected HUB of described USB device;
Described main frame, according to the device path information of described current HUB, obtains the device path information of the higher level HUB of described current HUB, is specially:
Described main frame intercepts and is positioned at last space character content before from the device path information of described current HUB, and the content that intercepting is obtained is as the device path information of the higher level HUB of described current HUB.
9. the method for claim 1, is characterized in that, the second level HUB in described USB device and described HUB group is direct-connected;
In described step S2, described main frame reads the data on last of device path information of described USB device, and the data that read are saved in port information, is specially:
Described main frame reads the data on last of device path information of described USB device, using the data that read as level ports, number is saved in port information;
In described step S6, described main frame obtains the HUB port numbers of described USB device according to described port information, be specially:
The HUB port numbers of described main frame using the level ports in described port information number as described USB device.
10. the method for claim 1, is characterized in that, other HUB in described USB device and described HUB group except first order HUB and second level HUB are direct-connected;
In described step S2, described main frame reads the data on last of device path information of described USB device, and the data that read are saved in port information, is specially:
Described main frame is initialized as the value of variable n total progression M of described HUB group, reads the data on last of device path information of described USB device, and the data that read are added in port information as n level port numbers;
In described step S4, described main frame reads in the device path information of described current HUB the data on last, and the data that read are added in described port information, is specially:
Described main frame subtracts 1 by the value of variable n, reads in the device path information of described current HUB the data on last, and the data that read are added in described port information as n level port numbers;
In described step S6, described main frame obtains the HUB port numbers of described USB device according to described port information, be specially:
Described main frame calculates according to described port information
Figure FDA0000402994500000041
hUB port numbers using the result obtaining as described USB device, wherein, P nfor the n level port numbers in described port information, n is integer, and 1 < n≤M, and M is total progression of described HUB group.
11. the method for claim 1, is characterized in that, after described step S6, also comprise:
Described main frame, according to the HUB port numbers of described USB device and HUB ID, shows the mode of operation of described USB device.
12. the method for claim 1, is characterized in that, after described step S6, also comprise:
Described main frame, according to the identification information of described USB device, judges current operation;
If current operation is download system operation, described main frame writes chip operating system in USB device, upgrade the identification information of described USB device, according to the HUB port numbers of described USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by described controllable device, control under the port that described USB device is connected to electricity and power on;
If current operation is initialization operation, described main frame, according to the HUB port numbers of described USB device and HUB ID, generates hardware sequence number, and described hardware sequence number is written in described USB device.
13. methods as claimed in claim 7, is characterized in that, after described step S6, also comprise:
Described main frame, according to the identification information of described USB device, judges current operation;
If current operation is download system operation, described main frame writes chip operating system in USB device, upgrade the identification information of described USB device, according to the HUB port numbers of described USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by described controllable device, control under the port that described USB device is connected to electricity and power on;
If current operation is initialization operation, described main frame, according to the HUB port numbers of described USB device and HUB ID, generates hardware sequence number, and described hardware sequence number is written in described USB device, and described USB device is set to not need the USB device of location.
14. methods as described in claim 12 or 13, is characterized in that, described main frame according to the identification information of described USB device, judges current operation, is specially:
Described main frame judges the identification information of described USB device, if the identification information of described USB device is the first default sign, determines that current operation is download system operation; If the identification information of described USB device is the second default sign, determine that current operation is initialization operation;
Described main frame upgrades the identification information of described USB device, is specially:
Described main frame is the described second default identification information by the update of identification information of described USB device.
15. methods as claimed in claim 13, is characterized in that, the described USB device of described main frame is set to not need the USB device of location, is specially:
Described main frame is deleted the identification information of above-mentioned USB device from the described second default identified group.
16. 1 kinds of main frames, it is characterized in that, be applied to comprise in the system of main frame, HUB group and USB device, described HUB group consists of a plurality of HUB, at least comprise first order HUB and second level HUB, described first order HUB is direct-connected by self subtending port and described main frame, and it is direct-connected to pass through self common port and the subtending port of one or more second level HUB, and described main frame comprises:
The first acquisition module, for obtaining the device path information of USB device, described USB device is connected on the common port of other HUB except described first order HUB in described HUB group;
The first read module, for reading the data on last of device path information of the described USB device that described the first acquisition module obtains, is saved in the data that read in port information;
The second acquisition module, for the device path information of the described USB device obtained according to described the first acquisition module, obtains the device path information of the HUB direct-connected with described USB device, using described HUB as current HUB, and triggers the first judge module;
The first judge module, for judging whether described current HUB is the first order HUB of described HUB group;
The second read module, while not being the first order HUB of described HUB group for judging described current HUB at described the first judge module, read in the device path information of described current HUB the data on last, the data that read are added in described port information, and according to the device path information of described current HUB, obtain the device path information of the higher level HUB of described current HUB, current HUB using described higher level HUB after upgrading, and trigger described the first judge module, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group,
Third reading delivery piece, while being the first order HUB of described HUB group for judging described current HUB at described the first judge module, read in the device path information of described current HUB the data on last, the HUB ID using the data that read as described USB device;
The 3rd acquisition module, while being the first order HUB of described HUB group for judging described current HUB at described the first judge module, obtains the HUB port numbers of described USB device according to described port information.
17. main frames as claimed in claim 16, is characterized in that,
Described the first acquisition module, the kernel events of dishing out specifically for monitoring system kernel is obtained the device path information of described USB device from the kernel events listening to.
18. main frames as claimed in claim 17, is characterized in that, also comprise:
The 4th read module, for the device path information of the described USB device obtained according to described the first acquisition module, reads the property file of described USB device, obtains the identification information of described USB device from described property file;
The second judge module, for the identification information of the described USB device that gets according to described the 4th read module, judges whether described USB device is the equipment that needs location;
Described the first read module, specifically for judge described USB device at described the second judge module, be while needing the equipment of location, read the data on last of device path information of the described USB device that described the first acquisition module obtains, the data that read are saved in port information.
19. main frames as claimed in claim 18, is characterized in that,
Described the second judge module, specifically for judging whether the identification information of described USB device is included in the first default identified group, if so, determines that described USB device is the equipment that needs location; Otherwise, determine that described USB device is not the equipment that needs location.
20. main frames as claimed in claim 16, is characterized in that,
Described the first acquisition module, specifically for the property file of poll USB device, the device path information using the routing information of the property file of the USB device being polled to as described USB device.
21. main frames as claimed in claim 20, is characterized in that, also comprise:
The 4th acquisition module, obtains the identification information of described USB device for the property file of the USB device that is polled to from described the first acquisition module;
The 3rd judge module, for the identification information of the described USB device that gets according to the 4th acquisition module, judges whether described USB device is the equipment that needs location;
Described the first read module, specifically for judge described USB device at described the 3rd judge module, be while needing the equipment of location, read the data on last of device path information of the described USB device that described the first acquisition module obtains, the data that read are saved in port information.
22. main frames as claimed in claim 21, is characterized in that,
Described the 3rd judge module, specifically for judging whether the identification information of described USB device is included in the second default identified group, if so, determines that described USB device is the equipment that needs location; Otherwise, determine that described USB device is not the equipment that needs location.
23. main frames as claimed in claim 16, is characterized in that,
Described the second acquisition module, specifically for intercepting the device path information of the described USB device that gets from described the first acquisition module, be positioned at the content before last space character, the content that intercepting is obtained is as the device path information with the direct-connected HUB of described USB device, using described HUB as current HUB, and trigger the first judge module;
Described the second read module, while not being the first order HUB in described HUB group specifically for judging described current HUB at described the first judge module, read in the device path information of described current HUB the data on last, the data that read are added in described port information, from the device path information of described current HUB, intercepting is positioned at last space character content before, the content that intercepting is obtained is as the device path information of the higher level HUB of described current HUB, current HUB using described higher level HUB after upgrading, and trigger described the first judge module, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group.
24. main frames as claimed in claim 16, is characterized in that, the second level HUB in described USB device and described HUB group is direct-connected;
Described the first read module, specifically for reading the data on last of device path information of the described USB device that described the first acquisition module obtains, number is saved in port information the data that read as level ports;
Described the 3rd acquisition module, while being the first order HUB in described HUB group specifically for judging described current HUB at described the first judge module, the HUB port numbers using the level ports in described port information number as described USB device.
25. main frames as claimed in claim 16, is characterized in that, other HUB in described USB device and described HUB group except first order HUB and second level HUB are direct-connected;
Described the first read module, specifically for the value of variable n being initialized as to total progression M of described HUB group, read the data on last of device path information of the described USB device that described the first acquisition module obtains, the data that read are added in port information as n level port numbers;
Described the second read module, while not being the first order HUB in described HUB group specifically for judging described current HUB at described the first judge module, the value of variable n is subtracted to 1, read in the device path information of described current HUB the data on last, the data that read are added in described port information as n level port numbers, and according to the device path information of described current HUB, obtain the device path information of the higher level HUB of described current HUB, current HUB using described higher level HUB after upgrading, and trigger described the first judge module, the higher level HUB of described current HUB is the HUB of the cascade direct port connection by common port and described current HUB in described HUB group,
Described the 3rd acquisition module, while being the first order HUB in described HUB group specifically for judging described current HUB at described the first judge module, calculates according to described port information
Figure FDA0000402994500000081
hUB port numbers using the result obtaining as described USB device, wherein, P nfor the n level port numbers in described port information, n is integer, and 1 < n≤M, and M is total progression of described HUB group.
26. main frames as claimed in claim 16, is characterized in that, also comprise:
Display module, for according to the HUB port numbers of described USB device and HUB ID, shows the mode of operation of described USB device.
27. main frames as claimed in claim 16, is characterized in that, also comprise:
The 4th judge module, for according to the identification information of described USB device, judges current operation;
The first processing module, while being download system operation for judge current operation at described the 4th judge module, in USB device, write chip operating system, upgrade the identification information of described USB device, according to the HUB port numbers of described USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by described controllable device, control under the port that described USB device is connected to electricity and power on;
The second processing module, while being initialization operation for judging current operation at described the 4th judge module, according to the HUB port numbers of described USB device and HUB ID, generates hardware sequence number, and described hardware sequence number is written in described USB device.
28. main frames as claimed in claim 22, is characterized in that, also comprise:
The 4th judge module, for according to the identification information of described USB device, judges current operation;
The first processing module, while being download system operation for judge current operation at described the 4th judge module, in USB device, write chip operating system, upgrade the identification information of described USB device, according to the HUB port numbers of described USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by described controllable device, control under the port that described USB device is connected to electricity and power on;
The 3rd processing module, while being initialization operation for judging current operation at described the 4th judge module, according to the HUB port numbers of described USB device and HUB ID, generate hardware sequence number, described hardware sequence number is written in described USB device, and described USB device is set to not need the USB device of location.
29. main frames as described in claim 27 or 28, is characterized in that,
Described the 4th judge module, judges specifically for the identification information to described USB device, if the identification information of described USB device is the first default sign, determines that current operation is download system operation; If the identification information of described USB device is the second default sign, determine that current operation is initialization operation;
Described the first processing module, while being download system operation specifically for judge current operation at described the 4th judge module, in USB device, write chip operating system, by the update of identification information of described USB device, it is the described second default identification information, according to the HUB port numbers of described USB device and HUB ID, to controllable device, send lower electric instruction and the instruction that powers on, by described controllable device, control under the port that described USB device is connected to electricity and power on.
30. main frames as claimed in claim 28, is characterized in that,
Described the 3rd processing module, while being initialization operation specifically for judging current operation at described the 4th judge module, according to the HUB port numbers of described USB device and HUB ID, generate hardware sequence number, described hardware sequence number is written in described USB device, from the described second default identified group, deletes the identification information of above-mentioned USB device.
CN201310514597.7A 2013-10-28 2013-10-28 Method and host for positioning USB (universal serial bus) devices on HUB set Expired - Fee Related CN103559162B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310514597.7A CN103559162B (en) 2013-10-28 2013-10-28 Method and host for positioning USB (universal serial bus) devices on HUB set

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310514597.7A CN103559162B (en) 2013-10-28 2013-10-28 Method and host for positioning USB (universal serial bus) devices on HUB set

Publications (2)

Publication Number Publication Date
CN103559162A true CN103559162A (en) 2014-02-05
CN103559162B CN103559162B (en) 2017-01-25

Family

ID=50013412

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310514597.7A Expired - Fee Related CN103559162B (en) 2013-10-28 2013-10-28 Method and host for positioning USB (universal serial bus) devices on HUB set

Country Status (1)

Country Link
CN (1) CN103559162B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649175A (en) * 2016-10-19 2017-05-10 深圳市共进电子股份有限公司 Method for separating function of USB HUB interface
CN108829623A (en) * 2018-06-20 2018-11-16 郑州云海信息技术有限公司 A kind of USB port adaptation method and device
CN110568946A (en) * 2019-09-02 2019-12-13 腾讯科技(深圳)有限公司 Port control method, device and medium
CN112015686A (en) * 2019-05-28 2020-12-01 海能达通信股份有限公司 Equipment access port positioning method and equipment access device
CN112130061A (en) * 2020-11-26 2020-12-25 北京智芯微电子科技有限公司 Chip synchronous testing device and chip synchronous testing method
CN113791991A (en) * 2021-08-20 2021-12-14 浪潮金融信息技术有限公司 Flexible regulation and control method, system and medium for external equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0959438A2 (en) * 1998-05-23 1999-11-24 Ncr International Inc. Automated teller machine
CN101963950A (en) * 2010-09-30 2011-02-02 北京飞天诚信科技有限公司 Method for positioning USB port in connection of device
CN202795350U (en) * 2012-09-05 2013-03-13 武汉世纪金桥安全技术有限公司 Management device for USB ports

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0959438A2 (en) * 1998-05-23 1999-11-24 Ncr International Inc. Automated teller machine
CN101963950A (en) * 2010-09-30 2011-02-02 北京飞天诚信科技有限公司 Method for positioning USB port in connection of device
CN202795350U (en) * 2012-09-05 2013-03-13 武汉世纪金桥安全技术有限公司 Management device for USB ports

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
诸一民: "可寻址集线器的应用与探讨", 《有线电视技术》, vol. 2006, no. 1, 20 January 2006 (2006-01-20) *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649175A (en) * 2016-10-19 2017-05-10 深圳市共进电子股份有限公司 Method for separating function of USB HUB interface
CN106649175B (en) * 2016-10-19 2019-12-06 深圳市共进电子股份有限公司 Method for separating USB HUB interface functions
CN108829623A (en) * 2018-06-20 2018-11-16 郑州云海信息技术有限公司 A kind of USB port adaptation method and device
CN112015686A (en) * 2019-05-28 2020-12-01 海能达通信股份有限公司 Equipment access port positioning method and equipment access device
CN110568946A (en) * 2019-09-02 2019-12-13 腾讯科技(深圳)有限公司 Port control method, device and medium
CN110568946B (en) * 2019-09-02 2021-08-24 腾讯科技(深圳)有限公司 Port control method, device and medium
CN112130061A (en) * 2020-11-26 2020-12-25 北京智芯微电子科技有限公司 Chip synchronous testing device and chip synchronous testing method
CN112130061B (en) * 2020-11-26 2024-04-26 北京智芯微电子科技有限公司 Chip synchronous testing device and chip synchronous testing method
CN113791991A (en) * 2021-08-20 2021-12-14 浪潮金融信息技术有限公司 Flexible regulation and control method, system and medium for external equipment
CN113791991B (en) * 2021-08-20 2023-10-03 浪潮金融信息技术有限公司 Flexible regulation and control method, system and medium for external equipment

Also Published As

Publication number Publication date
CN103559162B (en) 2017-01-25

Similar Documents

Publication Publication Date Title
CN103559162A (en) Method and host for positioning USB (universal serial bus) devices on HUB set
US20180203437A1 (en) Containerized communications gateway
CN102308280B (en) Basic input/output system BIOS configuration data management method and system
CN104573093B (en) A kind of method and apparatus for managing file directory
CN104793995A (en) Method and device for controlling GPS invocation
CN104754032A (en) Method and device for deploying OpenStack
CN106569806A (en) Method achieving adaptive PCIE bandwidth distribution of BIOS, BIOS and motherboard
CN109542525A (en) A kind of method, apparatus, terminal and storage medium by BMC switching system memory configurations
CN104471553A (en) Method, device and system for aggregation of shared address devices
CN104268193A (en) Advertisement webpage intercepting method and device
CN107085503A (en) storage device, storage system and information processing method
CN109117159A (en) A kind of automatic identification refreshes the method and device of firmware
CN105069381A (en) Intelligent terminal based partition protection method and system
CN108184210A (en) A kind of multimode intelligent wireless communication system and its implementation based on multi-internet integration
CN105100901B (en) A kind of virtual memory card configuration method and system
CN109164987A (en) A kind of control method of magnetic disc array card, device and electronic equipment
CN109189638A (en) A kind of GPU driving detection method, device, terminal and storage medium
CN115421750A (en) Method, device, terminal and storage medium for noninductive upgrading of server firmware
CN110703988B (en) Storage pool creating method, system, terminal and storage medium for distributed storage
CN104980564A (en) Recharge socket and mobile terminal processing method based on recharge socket
CN107742076A (en) System is forbidden to put forward the method, apparatus, storage medium and terminal device of power
CN113806020A (en) Method and device for virtualizing BMC (baseboard management controller) system
CN104182367A (en) Storage control device and calling method thereof
CN103248719B (en) A kind of network equipment that supporting hard disk array and network system
CN102833249B (en) The method and system of the applications client logging in network server of mobile terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20170125

CF01 Termination of patent right due to non-payment of annual fee