Summary of the invention
The purpose of the embodiment of the invention is, a kind of method and corresponding USB device of USB device port switching is provided, and makes described USB device utilization order accordingly and can realize fast on the computing machine that respective drive was installed that port switches;
For achieving the above object, the embodiment of the invention provides a kind of method of USB device port switching, comprising:
After detecting described USB device and main frame be connected, send monochromatic light disc apparatus information to described main frame, described monochromatic light disc apparatus information comprises the mask information that is used to shield described monochromatic light disc apparatus first function, described mask information makes described main frame by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, and shielding enables the order of first function;
If receive the switching command that described main frame sends by described automatic operating file, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and send the information of described equipment complex to described main frame, the information of described equipment complex comprises the descriptor of first port of device identification pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, and the descriptor of described first port is used to notify this equipment complex of described main frame to support described first function;
If receive the order that enables described first function that described main frame sends, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and sends equipment complex information to described main frame.
The embodiment of the invention also provides a kind of USB device, comprising:
Whether detecting unit is used to detect described USB device and is connected with main frame;
First transmitting element, be used for after described detecting unit detects described USB device and main frame is connected, send monochromatic light disc apparatus information to described main frame, described monochromatic light disc apparatus information comprises the mask information that shields described monochromatic light disc apparatus first function, described mask information makes described main frame by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, and shielding enables the order of first function;
First receiving element is used to receive the switching command that described main frame sends by described automatic operating file;
Second receiving element is used to receive the order that enables first function that described main frame sends;
Switch unit is used for the described order that enables first function that the described switching command that receives based on described first receiving element or described second receiving element receive, and described USB device is switched to equipment complex from described monochromatic light disc apparatus;
Second transmitting element, be used for described switch unit with described USB device after described monochromatic light disc apparatus switches to equipment complex, send the information of described equipment complex to described main frame, the information of described equipment complex comprises the descriptor of first port of pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, and the descriptor of described first port is used to notify this equipment complex of described main frame to support described first function.
The embodiment of the invention has following beneficial effect: after corresponding USB device driving is installed on computers, described computing machine can comparatively fast send corresponding USB order, needn't be after making described USB device receive described order again through in steps former, thereby directly switch to the multiport state fast, improved the work efficiency of man-machine interaction, better embodied the characteristics of USB device as a kind of high speed, quick digital device.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing.
The embodiment of the invention utilizes USB to order the technology of quick port switching for the USB device that is connected with computing machine.With USB device with after computing machine is connected, described USB device can report monochromatic light dish information, computing machine by in the monochromatic light disc apparatus information that detects described USB device and report with the computing machine registration table in equipment complex information in whether have identical device identification pid information, switch thereby finish port.
Embodiment one,
Fig. 1 is the schematic flow diagram of method of the USB device port switching of the embodiment of the invention one.This process flow diagram may further comprise the steps:
101, after detecting described USB device and computing machine be connected, send monochromatic light disc apparatus information to described computing machine, described monochromatic light disc apparatus information comprises the mask information that is used to shield described monochromatic light disc apparatus first function, described mask information makes described computing machine by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, and shielding enables the order of first function;
102, if receive the switching command that described computing machine sends by described automatic operating file, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and send the information of described equipment complex to described computing machine, the information of described equipment complex comprises the descriptor of first port of device identification pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, and the descriptor of described first port is used to notify this equipment complex of described computing machine to support described first function;
103, if receive the order that enables described first function that described computing machine sends, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and sends equipment complex information to described computing machine.
In the embodiment of the invention, computer system is a windows xp operating system, when described USB device with after computing machine normally is connected, described USB device can send monochromatic light disc apparatus information to described computing machine, described computing machine obtains important informations such as the controller of described USB device, device attribute, port form, mask information, device identification PID by reading the described monochromatic light disc apparatus information that receives, and then utilizes the respective protocol in the system that described USB device is carried out corresponding configuration.Wherein said mask information is first function that is mainly used in the described monochromatic light disc apparatus of shielding, the device identification pid information mainly is the product identification code of the described USB device that is used to inform that computing machine is attached thereto, so that whether record in the described computer detection system registration table and the identical information of described device identification pid information, if detect identical device identification pid information is arranged in the registration table, the corresponding driving program was installed before described USB device is described on this computing machine; If detect identical device identification pid information is not arranged in the registration table, the corresponding driving program was not installed before described USB device is described on this computing machine; After described computing machine got access to the monochromatic light disc apparatus information of described USB device, the disc drives that carries in the attribute selecting system of meeting according to USB device loaded described monochromatic light disc apparatus.
When on the computing machine of described USB device at present embodiment the corresponding driving program not being installed, the automatic operating file that starts in the described USB device is understood after having loaded described monochromatic light disc apparatus by the disc drives that carries by system, and described automatic operating file is installed the driving of described USB device automatically in described computer operating system.Because mask information has shielded first function of described monochromatic light disc apparatus, so in the driving process was installed, computing machine had just shielded the order that enables first function, makes installation process finish smoothly.After described USB device drive installation finishes, computing machine can send switching command to described USB device by described automatic operating file, after described USB device receives described switching command, switch to equipment complex from described monochromatic light disc apparatus, promptly switch to the multiport state from monochromatic light disc apparatus port status, and send the information of described equipment complex to described computing machine, the information of described equipment complex comprises the descriptor of first port of device identification pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, the descriptor of described first port is used to notify first port of described this equipment complex of computing machine to support described first function, and the information of described equipment complex is recorded in the registration table, so described computing machine has read the information of described equipment complex and just according to the respective protocol in the system described equipment complex has been disposed accordingly, load corresponding the driving for each port of equipment complex such as system, so that described equipment complex can operate as normal, wherein said driving is for being installed in the driving of the USB device in the described computer system by described automatic operating file.
When once more with described USB device with after described computing machine is connected, when the device identification pid information of the equipment complex in the device identification pid information of described COMPUTER DETECTION in the monochromatic light disc apparatus information that described USB device sends and the system registry is consistent, illustrate that described USB device installed the corresponding driving program on the computing machine of present embodiment, so described system is the driving that described monochromatic light disc apparatus loads first port correspondence of described equipment complex in the registration table, again because described first port is supported first function, so, first function is also supported in the driving of described first port correspondence, after loading the driving of first port correspondence of described equipment complex, described monochromatic light disc apparatus just activates first function in the described driving, described computing machine just sends the order that enables described first function according to usb protocol to described USB device, after then described USB device receives the described order that enables first function, switch to equipment complex from described monochromatic light disc apparatus at once, and send equipment complex information to described computing machine.So described computing machine has read the information of described equipment complex and just according to the respective protocol in the system described equipment complex has been disposed accordingly, load corresponding the driving for each port of equipment complex such as system, so that described equipment complex can operate as normal.
The advantage of present embodiment is, after corresponding USB device driving is installed on computers, described computing machine can comparatively fast send corresponding USB order, needn't be after making described USB device receive the corresponding command again through in steps former, thereby directly switch to the multiport state fast, improved the work efficiency of man-machine interaction.
Need to prove that the monochromatic light disc apparatus information in the present embodiment has comprised facility information and the single port information that described technical field personnel can understand; Equipment complex information in the present embodiment has comprised the information of the whole equipment complex that described technical field personnel can understand and the information of each port.
Embodiment two,
Fig. 2 is the schematic flow diagram of method of the USB device port switching of the embodiment of the invention two.As shown in Figure 2, may further comprise the steps:
201, after detecting described USB device and main frame be connected, send monochromatic light disc apparatus information to described main frame, described monochromatic light disc apparatus information comprises and is used to inform that the described monochromatic light disc apparatus of described main frame do not support the device descriptor of Remote Wake Up function, described device descriptor makes described main frame by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, and shielding enables the USB order of Remote Wake Up function;
202, after described drive installation finishes, described main frame is deleted monochromatic light disc apparatus information in the described main frame by the delete instruction of storing in the described automatic operating file;
203, if receive the switching command that described main frame sends by described automatic operating file, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and send the information of described equipment complex to described main frame, the information of described equipment complex comprises the descriptor of first port of device identification pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, and the descriptor of described first port is used to notify first port of described this equipment complex of main frame to support described Remote Wake Up function;
204, if receive the USB order that enables described Remote Wake Up function that described main frame sends, then described USB device switches to equipment complex from described monochromatic light disc apparatus, and sends equipment complex information to described main frame.
In the embodiment of the invention, computer system is a windows xp operating system, when described USB device with after computing machine normally is connected, described USB device can send monochromatic light disc apparatus information to described computing machine, described computing machine obtains important informations such as the controller of described USB device, device attribute, port form, device descriptor by reading the described monochromatic light disc apparatus information that receives, and then utilizes the respective protocol in the system that described USB device is carried out necessary configuration.Wherein said device descriptor dispatches from the factory except version number, supplier number VID information, device identification pid information and the equipment that is used to inform the described USB device of main frame the information such as label, is used to also inform that the described monochromatic light disc apparatus of described main frame do not support the Remote Wake Up function.Wherein said device identification pid information mainly is the product identification code of the described USB device that is used to inform that computing machine is attached thereto, so that whether record in the described computer detection system registration table and the identical information of described device identification pid information, there is identical device identification pid information the corresponding driving program to be installed before described USB device is described in the registration table on this computing machine if detect; Do not have identical device identification pid information to illustrate in the registration table corresponding driving program was not installed on this computing machine before the described USB device if detect; Described computing machine get access to after the monochromatic light disc apparatus information that described USB device sends can be in system registry the information of the described monochromatic light disc apparatus of record, and the disc drives that carries in the attribute selecting system according to USB device loads described monochromatic light disc apparatus.
When on the computing machine of described USB device at present embodiment the corresponding driving program not being installed, what carry in the attribute selecting system of system according to USB device loads with the corresponding disc drives of described attribute, can start the automatic operating file in the described USB device behind the intact described monochromatic light disc apparatus of described system loads, described automatic operating file is installed the driving of described USB device automatically in described computer operating system.Because device descriptor has informed that the described monochromatic light disc apparatus of described main frame do not support the Remote Wake Up function, so in the driving process is installed, described system has just shielded the USB order that enables the Remote Wake Up function, after having guaranteed that installation procedure finishes, computing machine continues the described automatic operating file of operation and carries out necessary setting.
After described USB device drive installation finishes, computing machine just can send by automatic operating file and allow described USB device switch to the order of equipment complex, and this moment is in case described USB device is carried out the information that the port switching will report equipment complex, comprising the device identification pid information of equipment complex.Because according to agreement, system is as long as find whether have the facility information that reports to retrieve has the information consistent with described reporting information in the registration table, in case described system discovery has the information of described unanimity, system just can load the equipment complex that reports by the disc drives that carries, and realizes the content of mapping reporting equipment.So step for fear of the content that repeats described mapping reporting equipment, the described monochromatic light disc apparatus information of computing machine record before transmission makes in the delete instruction deletion system registry that described USB device stores in can be by described automatic operating file before switching to the order of equipment complex is comprising the pid information of equipment.
After the described monochromatic light disc apparatus information that writes down before in the deletion system registry, computing machine can send switching command to described USB device by described automatic operating file, after described USB device receives described switching command, switch to equipment complex from described monochromatic light disc apparatus, promptly switch to the multiport state from monochromatic light disc apparatus port status, and sending the information of described equipment complex to described computing machine, the information of described equipment complex comprises the descriptor of first port of device identification pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex.After described computing machine receives the information (information of described equipment complex comprises device identification pid information and each port information of whole equipment complex) of described equipment complex, can in the detection system file whether the information identical with the pid information of described equipment complex be arranged, owing in step 202, deleted the pid information of the monochromatic light disc apparatus identical with the pid information of described equipment complex, so computing machine does not detect described identical pid information in system registry, but in system file, detecting the activation bit that includes identical described pid information, described activation bit is the activation bit during mounted USB device drives in the step 201.Because equipment complex wants operate as normal must give all load driver of each port, system gives each port load driver of equipment complex to finish the configuration to equipment complex according to described activation bit.Load first port that drives the wherein said equipment complex in back and supported the Remote Wake Up function, thereby made the descriptor of described first port inform that first port of described this equipment complex of main frame supports described Remote Wake Up function.Computing machine drives the activation bit of the described driving of record in system registry and the information of equipment complex according to mounted described USB device in the file, described activation bit is the activation bit of the port correspondence of described equipment complex, has also comprised the device identification pid information of equipment complex in this activation bit.The information of equipment complex comprises the information of first port support Remote Wake Up function of this equipment complex.
When once more with described USB device with after described computing machine is connected, when the device identification pid information of the equipment complex in the device identification pid information of described COMPUTER DETECTION in the monochromatic light disc apparatus information that described USB device sends and the system registry is consistent, illustrate that described USB device installed the corresponding driving program on the computing machine of present embodiment, so described system is the driving that described monochromatic light disc apparatus loads first port correspondence of described equipment complex in the registration table, again because described first port is supported the Remote Wake Up function, so, the Remote Wake Up function is also supported in the driving of described first port correspondence, after loading the driving of first port correspondence of described equipment complex, described monochromatic light disc apparatus just activates the Remote Wake Up function in the described driving, described computing machine just sends the USB order that enables described Remote Wake Up function according to usb protocol to described USB device, after then described USB device receives the described USB order that enables the Remote Wake Up function, switch to equipment complex from described monochromatic light disc apparatus at once, and send equipment complex information to described computing machine.So described computing machine has read the information of described equipment complex and just according to the respective protocol in the system described equipment complex has been disposed accordingly, load corresponding the driving for each port of equipment complex such as system, so that described equipment complex can operate as normal.
In embodiments of the present invention, computer system is a windows xp operating system, and USB device is a wireless data card, and pid information is 1003, is exemplified below according to the step in the method for above-mentioned USB device port switching:
With after computing machine is connected, its can send the monochromatic light disc apparatus information of wireless data card to windows xp operating system with wireless data card, and described monochromatic light disc apparatus information comprises device descriptor.Described device descriptor dispatches from the factory except version number, supplier number VID information, device identification pid information and the equipment that is used to inform the described USB device of main frame the information such as label, be used to also inform that the described wireless data card of described system temporarily do not support the Remote Wake Up function, because the D5 position Remote Wake Up function in the bmAttributes territory on the single port of equipment has been set to 0; Described device identification pid information is 1003, it is after 1003 the monochromatic light disc apparatus information that described windows xp operating system receives the equipment identification information pid information, can detect that to have or not the equipment identification information pid information in the registration table be the information of 1003 equipment complex, not having discovering device identification information pid information after the detection is the information of 1003 equipment complex, the task that the driver of described wireless data card just can be finished port switching illustrates that described wireless data card the corresponding driving program was not installed on this computing machine, so will be installed.The disc drives of the wireless data card that carries in the attribute selecting system of system according to described wireless data card loads described monochromatic light disc apparatus, and the recording unit identification information is 1003 monochromatic light disc apparatus information in registration table.Loaded the automatic operating file Autorun that maps out described wireless data card behind the monochromatic light disc apparatus, the driving that described wireless data card is installed on computers according to described automatic operating file Autorun by described system.For fear of loading the step that the monochromatic light dish drives once more, so described system after the drive installation step finishes, is 1003 monochromatic light disc apparatus information by the equipment identification information of delete instruction deletion record in registration table among the described automatic operating file Autorun.Described subsequently system sends by described automatic operating file Autorun and makes described network interface card wireless data card switch to the switching command of multiport state, described wireless data card switches to the multiport state after receiving described switching command, promptly map out first port, second port and the 3rd port, described first port is the Modem port, second port is PCUI (PC User Interface, it is user port, be used to realize that USB device is connected with the data on PC backstage), described the 3rd port is the CD port, and the reporting equipment identification information is 1003 equipment complex information.It is after 1003 the equipment complex information that described computing machine receives described equipment identification information, and whether the equipment identification information identical with described equipment complex is arranged in can the detection system file is 1003 information.Owing to deleted recording unit identification information in the registration table and be 1003 monochromatic light disc apparatus information, so computing machine does not detect described 1003 identical equipment identification informations in system registry, but in system file, detecting the activation bit that includes identical described 1003 equipment identification informations, described activation bit is the activation bit during mounted described wireless data card drives.First port, second port and the 3rd port load driver that system gives equipment complex according to described activation bit are so that equipment complex can operate as normal.And be 1 with the D5 position Remote Wake Up function setting in the bmAttributes territory on the Modem port in the described equipment complex, thereby make described wireless data card support the Remote Wake Up function by load driver.Computing machine drives the activation bit of the described driving of record in system registry and the information of wireless data card equipment complex according to mounted described USB device in the system file, and described activation bit is each self-corresponding activation bit of three ports of described equipment complex.The information of equipment complex comprises the information of first port (being the Modem port) the support Remote Wake Up function of this equipment complex.Pull up wireless data card after finishing using.
When once more with described wireless data card with after described computing machine is connected, when the device identification 1003 of the equipment complex in the device identification 1003 of described COMPUTER DETECTION in the monochromatic light disc apparatus information that described wireless data card sends and the system registry is consistent, illustrate that described wireless data is stuck on the computing machine of present embodiment the corresponding driving program was installed.Because the monochromatic light disc apparatus that reports is a port, so being described monochromatic light disc apparatus, described system loads the driving that device identification in the registration table is 1003 the described equipment complex first port correspondence, because being described first port of 1003 equipment complex, device identification supports the Remote Wake Up function again, so the Remote Wake Up function is also supported in the driving of described first port correspondence certainly.After loading the driving of the described equipment complex first port correspondence, described monochromatic light disc apparatus just activates the Remote Wake Up function in the described driving, described computing machine just sends the USB order that enables described Remote Wake Up function: Set_feature_D (abbreviation of the USB order of Remote Wake Up functional character is set) according to usb protocol to described wireless data card, described wireless data card one receives this Set_feature_D order and immediately it is responded, switch to the multiport state from the single port state, promptly map out the Modem port, three ports of PCUI and CD port, and report the information of the equipment complex of described wireless data card to give operating system, finish port and switch.The information that described computing machine has read described equipment complex just disposes described equipment complex accordingly according to the respective protocol in the system, so that described equipment complex can operate as normal.Described so from now on wireless data card computing machine therewith can comparatively fast be finished the task that port switches once connecting, and has saved the steps necessary of original switching equipment complex.
The embodiment of the invention is compared advantage with embodiment one and is, after corresponding USB device driving is installed on computers, by the information of the equipment complex of record support Remote Wake Up function and the activation bit of described equipment correspondence in registration table, needn't be after making described USB device receive the described order that enables described first function again through existing step, thereby switch to the multiport state fast, improved user's work efficiency, better embodied the characteristics of described USB device as the quick communication facilities of a kind of high speed.
Need to prove that the monochromatic light disc apparatus information in the present embodiment has comprised facility information and the single port information that described technical field personnel can understand; Equipment complex information in the present embodiment has comprised the information of the whole equipment complex that described technical field personnel can understand and the information of each port.
Embodiment three,
In order to implement above method better, the embodiment of the invention three correspondingly provides a kind of USB device, it comprises detecting unit 301, first transmitting element 302, first receiving element 303, second receiving element 304, switch unit 305 and second transmitting element 306, can also comprise storage unit 307, as shown in Figure 3, its each several part function is as follows:
Whether detecting unit 301 is mainly used in the described USB device of detection and is connected with main frame;
First transmitting element 302, be used for after described detecting unit 301 detects described USB device and main frame is connected, send monochromatic light disc apparatus information to described main frame, described monochromatic light disc apparatus information comprises the mask information that shields described monochromatic light disc apparatus first function, described mask information makes described main frame by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, and shielding enables the order of first function;
Described first function can be the Remote Wake Up function, and the described order that enables first function can be for enabling the USB order of Remote Wake Up function.Wherein said first transmitting element 302 can specifically be used for after described detecting unit 301 detects described USB device and main frame is connected, send to described main frame and to comprise and be used to inform that the described monochromatic light disc apparatus of described main frame do not support the monochromatic light disc apparatus information of the device descriptor of described first function, make described main frame by loading the monochromatic light disc apparatus and then start automatic operating file when the driving of described USB device being installed, shielded the order that enables first function.
First receiving element 303 is mainly used in and receives the switching command that described main frame sends by described automatic operating file;
Second receiving element 304 is mainly used in and receives the order that enables first function that described main frame sends;
Switch unit 305 is mainly used in the described order that enables first function that the described switching command that receives based on described first receiving element or described second receiving element receive, and described USB device is switched to equipment complex from described monochromatic light disc apparatus;
Second transmitting element 306, be mainly used in described switch unit with described USB device after described monochromatic light disc apparatus switches to equipment complex, send the information of described equipment complex to described main frame, the information of described equipment complex comprises the descriptor of first port of pid information identical with the device identification pid information of described monochromatic light disc apparatus and described equipment complex, and the descriptor of described first port is used to notify this equipment complex of described main frame to support described first function;
Storage unit 307, storage be can be used for and important information and files such as facility information, automatic operating file comprised, store delete instruction in the described automatic operating file, described delete instruction is used for the monochromatic light disc apparatus information of the described main frame of deletion after described drive installation finishes.
Main frame described in the present embodiment can be computing machine, and described USB device can be wireless data card, wireless network card.
The advantage of present embodiment is, described USB device can be carried out the switching of equipment complex according to the different command that receives, after corresponding USB device driving is installed especially on computers, described computing machine can comparatively fast send corresponding USB order, needn't be after making described USB device receive described order again through in steps former, thereby directly switch to the multiport state fast, improved the work efficiency of man-machine interaction, better embodied the characteristics of USB device as a kind of high speed, quick digital device.
Certainly, above embodiment is as preferred implementation of the present invention, should be understood that, above-mentioned embodiment is exemplary, and it is also nonrestrictive, concerning the one of ordinary skilled in the art, can be without departing from the inventive concept of the premise the present invention be carried out multiple change and or or revises this kind change and or or revise and must think in the application scope of disclosure.