Summary of the invention
In view of this, the invention provides the method that a kind of USB device multi-protocols are selected automatically.
Method among the present invention can come automatic selection can make the usb protocol of equipment operate as normal according to the driver whether agreement is installed in the computing machine according to predefined order.Compare and manually select the method for agreement, the inventive method does not need computing machine that the driving of default protocol is installed, as long as the driving that the agreement that any one USB supports is installed promptly can operate as normal, has higher ease for use, practices thrift user's use cost.
The performing step of the inventive method:
The agreement selecting sequence is set before USB device dispatches from the factory, comprises the above agreement that USB device is supported.Agreement is set before dispatching from the factory selects time-out time.
When the user was connected to computing machine with USB device, USB device was selected the agreement of the 1st support according to the agreement selecting sequence that is provided with in advance before dispatching from the factory, and is designated as agreement 1.USB device picks up counting through the timing unit of inside.
COMPUTER DETECTION can be the USB device install driver behind USB device, after driver was installed successfully, according to the usb protocol regulation, computing machine can send to USB device configuration order is set.
If USB device is received the configuration order that is provided with that computing machine sends before overtime at timing unit, then accomplish agreement and select, stop timing unit, use agreement 1 and compunication; If USB device is not received the configuration order that is provided with that computing machine sends before overtime at timing unit, then select the agreement of the 2nd support, be designated as agreement 2.Timing unit restarts timing.
Repeat above step and up to receiving configuration order is set, perhaps all agreements were not all received before timing unit is overtime configuration order are set.
Said agreement selecting sequence is kept in the USB device.
Preferably, USB device can automatically be revised the agreement selecting sequence according to the agreement of final selection, and the agreement of finally selecting is selected as the 1st, and other agreement sorts according to original order successively.
Preferably, the user can send order to USB device through computing machine and revise the agreement selecting sequence.Begin from the computing machine of USB device connection next time, will use amended agreement selecting sequence.
Said time-out time is kept in the USB device.
Preferably, the user can send order to USB device through computing machine and revise time-out time.Begin from the computing machine of USB device connection next time, will use amended time-out time.
Said timing unit can be real-time clock, the timer of hardware, also can be the clock of software simulation.
Said selection agreement is meant according to usb protocol, reporting facility connection status and the process of sending USB descriptor (USB Descriptor).
Visible by technique scheme, the present invention has realized the method that usb protocol is selected automatically, can select the agreement of installing drive automatically, has reached the purpose that improves equipment easy applied performance.
According to an aspect of the present invention, the method that provides a kind of USB device to select to start agreement,
Step 1: the preset selecting sequence of supporting at least two agreements of said USB device in said USB device;
Step 2: when said USB device is connected to computing machine,, select first agreement to start according to preset said selecting sequence;
Step 3: if unsuccessful according to said first agreement startup, then said USB device selects other agreements to start according to preset agreement selecting sequence;
Step 4: unsuccessful if all accord of selecting according to said selecting sequence all starts, then said USB device stops to start.
According to an aspect of the present invention, have timing unit in the said USB device,
In said step 1, preset time-out time value in said USB device;
In said step 2, when said USB device was connected to computing machine, said timing unit picked up counting;
If the driver of said first agreement is installed in the said computing machine, then said USB device uses said first agreement and said compunication, and said timing unit stops timing;
If the driver of said first agreement is not installed in the said computing machine, then said timing unit judge overtime after, get into step 3, said timing unit restarts timing simultaneously;
In said step 3, if the driver of said other agreements is installed in the said computing machine, then said USB device uses said other agreements and said compunication, and said timing unit stops timing;
If the driver of said other agreements is not installed in the said computing machine; Then said timing unit judge overtime after; Said USB device continues to select remaining other agreements to start according to preset agreement selecting sequence, and said timing unit restarts timing simultaneously.
According to an aspect of the present invention, when said USB device and said computing machine communicated, it was in connection status to said USB device to said computing machine report, and sends the USB descriptor of protocol compliant regulation to said computing machine.
According to an aspect of the present invention, said computing machine sends to said USB device configuration order is set;
Said USB device receives that said the setting accomplish agreement after the configuration order and select, and uses selected said agreement and said compunication.
According to an aspect of the present invention, said USB device is automatically revised the selecting sequence of agreement according to the final agreement of selecting, and the agreement of finally selecting is set to first agreement, and other agreement still sorts according to original preset order successively.
According to an aspect of the present invention, the user sends to said USB device through said computing machine and orders the selecting sequence of revising agreement or said time-out time value is set.
According to an aspect of the present invention, said timing unit is real-time clock, the timer of hardware configuration, or passes through the clock of software timing.
According to an aspect of the present invention, said agreement comprises at least: UASP agreement, CCID agreement, HID agreement.
Embodiment
For making the object of the invention, technical scheme and advantage clearer, below with reference to the accompanying drawing embodiment that develops simultaneously, to further explain of the present invention.
Embodiment one
In the present embodiment, USB device is supported HID and two kinds of agreements of CCID.
Fig. 1 selects the process flow diagram of the method for agreement automatically for USB device in the present embodiment.As shown in Figure 1, select the method for agreement to comprise in the present embodiment automatically:
Step 101 before USB device dispatches from the factory, is provided with agreement selecting sequence: CCID->HID, that is, first CCID agreement boot sequence is superior to the HID agreement.
Step 102 when the user uses USB device, is connected to computing machine with USB device.USB device is selected the CCID agreement at first automatically.That is, it is in connection status to USB device to the computing machine report, and sends the USB descriptor of CCID agreement regulation to computing machine.Time of day in the USB device picks up counting.
If computing machine has been installed the driver of CCID agreement, then execution in step 103, and according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 104 after the configuration order, and the agreement selection course is accomplished.USB device uses CCID agreement and compunication, and timing unit stops timing.
If computing machine is not installed the driver of CCID agreement, computing machine can not send to USB device configuration order is set.[front is " timing unit " to the hardware timer of USB device; Should keep the term consistent] after overtime, trigger interrupt routine, execution in step 105; Again it is in connection status to USB device to the computing machine report, and sends the USB descriptor of HID agreement regulation to computing machine.Timing unit restarts timing.
If computing machine has been installed the driver of HID agreement, execution in step 106, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 107 after the configuration order, and the agreement selection course is accomplished.USB device uses HID agreement and compunication, and timing unit stops timing.
If computing machine is not installed the driver of HID agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 108, USB device does not find the agreement of support, accomplishes agreement and selects.In this case, USB device fails to set up and the communicating by letter of computing machine, and after needing the driver of CCID agreement or HID agreement is installed, connects USB device again.
So far, this flow process finishes.
Visible by above-mentioned flow process, present embodiment is selected in the method for agreement automatically, through whether receiving the configuration order that is provided with of main frame transmission in the time-out time that limits at timing unit, judges whether computing machine has installed CCID or HID agreement.Through rational time-out time is set; The time that can make the agreement selection is in the acceptable scope of user; And guarantee not can computing machine sends that configuration order is set because of too short and wrong having missed of time-out time, thereby the present invention can realize the automatic selection of usb protocol.
Embodiment two
In the present embodiment, USB device is supported HID, CCID and three kinds of agreements of UASP, and supports to revise automatically the agreement selecting sequence.
The UASP agreement, promptly USB Attached SCSI Protocol is a kind of high capacity USB memory device agreement commonly used.
Fig. 2 selects agreement automatically for USB device in the present embodiment and revises the process flow diagram of the method for agreement selecting sequence automatically.As shown in Figure 2, select agreement and the automatic method of revising the agreement selecting sequence to comprise in the present embodiment automatically:
Step 201 before USB device dispatches from the factory, is provided with agreement selecting sequence: UASP->CCID->HID.
Step 202 when the user uses USB device, is connected to computing machine with USB device.USB device is selected the UASP agreement.That is, it is in connection status to USB device to the computing machine report, and sends the USB descriptor of UASP agreement regulation to computing machine.Timing unit in the USB device picks up counting.
If computing machine has been installed the driver of UASP agreement, execution in step 203, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 204 after the configuration order, and the agreement selection course is accomplished.USB device uses UASP agreement and compunication, and timing unit stops timing.Because of the final agreement of selecting is the 1st agreement in proper order of dispatching from the factory, need not revise the agreement selecting sequence.
If computing machine is not installed the driver of UASP agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 205, it is in connection status to USB device to the computing machine report again, and sends the USB descriptor of CCID agreement regulation to computing machine.Timing unit restarts timing.
If computing machine has been installed the driver of CCID agreement, execution in step 206, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 207 after the configuration order, and the agreement selection course is accomplished.USB device uses CCID agreement and compunication, and timing unit stops timing.
It is CCID-that step 208, USB device are revised the agreement selecting sequence automatically>UASP->HID.
If computing machine is not installed the driver of CCID agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 209, it is in connection status to USB device to the computing machine report again, and sends the USB descriptor of HID agreement regulation to computing machine.Timing unit restarts timing.
If computing machine has been installed the driver of HID agreement, execution in step 210, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 211 after the configuration order, and the agreement selection course is accomplished.USB device uses HID agreement and compunication, and timing unit stops timing.
It is HID-that step 212, USB device are revised the agreement selecting sequence automatically>UASP->CCID.
If computing machine is not installed the driver of HID agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 213, USB device does not find the agreement of support, accomplishes agreement and selects.In this case, USB device fails to set up and the communicating by letter of computing machine, and after needing the driver of UASP agreement or CCID agreement or HID agreement is installed, connects USB device again.
So far, this flow process finishes.
Visible by above-mentioned flow process, after present embodiment is selected the method for agreement automatically, can automatically revise the agreement selecting sequence according to final selection situation.Like this, when connecting USB device next time, the agreement that can preferentially select last success to select.Generally, according to new agreement selecting sequence, the 1st agreement promptly can be chosen to merit, no longer need select those agreements that does not have install driver, has saved the time that agreement is selected, and has further improved the ease for use of the inventive method.
Embodiment three
In the present embodiment, USB device is supported HID, CCID and three kinds of agreements of UASP.Support among this embodiment to revise the agreement selecting sequence automatically, and support user's modification agreement selecting sequence and time-out time.
Fig. 3 selects agreement automatically and revises the agreement selecting sequence automatically for USB device in the present embodiment, again by the process flow diagram of the method for user's modification agreement selecting sequence and time-out time.As shown in Figure 3, the method in the present embodiment comprises:
Step 301 before USB device dispatches from the factory, is provided with agreement selecting sequence: UASP->CCID->HID.
Step 302 when the user uses USB device, is connected to computing machine with USB device.USB device is selected the UASP agreement.That is, it is in connection status to USB device to the computing machine report, and sends the USB descriptor of UASP agreement regulation to computing machine.Timing unit in the USB device picks up counting.
If computing machine has been installed the driver of UASP agreement, execution in step 303, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 304 after the configuration order, and the agreement selection course is accomplished.USB device uses UASP agreement and compunication, and timing unit stops timing.Because of the final agreement of selecting is the 1st agreement in proper order of dispatching from the factory, need not revise the agreement selecting sequence.After step 304 is accomplished, execution in step 314.
If computing machine is not installed the driver of UASP agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 305, it is in connection status to USB device to the computing machine report again, and sends the USB descriptor of CCID agreement regulation to computing machine.Timing unit restarts timing.
If computing machine has been installed the driver of CCID agreement, execution in step 306, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 307 after the configuration order, and the agreement selection course is accomplished.USB device uses CCID agreement and compunication, and timing unit stops timing.
It is CCID-that step 308, USB device are revised the agreement selecting sequence automatically>UASP->HID.
After step 308 is accomplished, execution in step 314.
If computing machine is not installed the driver of CCID agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 309, it is in connection status to USB device to the computing machine report again, and sends the USB descriptor of HID agreement regulation to computing machine.Timing unit restarts timing.
If computing machine has been installed the driver of HID agreement, execution in step 310, according to usb protocol, computing machine can send to USB device configuration order is set.
USB device is received execution in step 311 after the configuration order, and the agreement selection course is accomplished.USB device uses HID agreement and compunication, and timing unit stops timing.
It is HID-that step 312, USB device are revised the agreement selecting sequence automatically>UASP->CCID.
After step 312 is accomplished, execution in step 314.
If computing machine is not installed the driver of HID agreement, computing machine can not send to USB device configuration order is set.The timing unit of USB device after overtime, execution in step 313, USB device does not find the agreement of support, accomplishes agreement and selects.In this case, USB device fails to set up and the communicating by letter of computing machine, and after needing the driver of UASP agreement or CCID agreement or HID agreement is installed, connects USB device again.
Step 314, under USB device and computing machine can the situation of proper communication, the user can send order and revise the agreement selecting sequence, as, be revised as CCID->HID->UASP.The user can send order and revise time-out time.
So far, this flow process finishes.
Visible by above-mentioned flow process, after present embodiment is selected the method for agreement automatically, can automatically revise the agreement selecting sequence according to final selection situation.However, the user possibly install the driver of other agreements next time before connecting USB device, and hoped and can use new agreement of installing connect in the USB device next time.At this moment, the user hopes in the time of can connecting USB device that the agreement of using is set to the 1st agreement next time, and other agreements are after it.Like this, promptly can select to hope the agreement used next time, even and if this protocol-driven can not be worked, also can select other agreements to work on.The user can revise time-out time, saves the time that agreement is selected.Through the flow process of present embodiment, can improve the dirigibility of the inventive method.