Summary of the invention
In view of this, the invention provides a kind of method that USB device multi-protocols are selected automatically.
Method in the present invention, according to the order preset, can select the usb protocol that equipment can be made normally to work automatically according to the driver whether installing agreement in computing machine.Compare the method for manual selection protocol, the inventive method does not need computing machine to install the driving of default protocol, as long as namely the driving of installing the agreement that any one USB supports can normally work, has higher ease for use, saves the use cost of user.
The performing step of the inventive method:
USB device arranges agreement selecting sequence before dispatching from the factory, and comprises more than one agreement that USB device is supported.Agreement is set before dispatching from the factory and selects time-out time.
When USB device is connected to computing machine by user, USB device, according to the agreement selecting sequence pre-set before dispatching from the factory, is selected the 1st agreement supported, is designated as agreement 1.USB device starts timing by inner timing unit.
Can be USB device install driver after COMPUTER DETECTION to USB device, after driver successful installation, according to usb protocol regulation, computing machine can send to USB device and arrange configuration order.
If what USB device received before timing unit time-out that computing machine sends arranges configuration order, then complete agreement and select, stop timing unit, use agreement 1 and compunication; If what USB device did not receive before timing unit time-out that computing machine sends arranges configuration order, then select the 2nd agreement supported, be designated as agreement 2.Timing unit restarts timing.
Repeat above step until receive and arrange configuration order, or all agreements did not all receive before timing unit time-out and arrange configuration order.
Described agreement selecting sequence is preserved in the usb device.
Preferably, USB device according to the final agreement selected, automatically can revise agreement selecting sequence, and the agreement finally selected selected as the 1st, other agreement sorts successively according to original order.
Preferably, user can send order by computing machine to USB device and revise agreement selecting sequence.From USB device connects computing machine next time, amended agreement selecting sequence will be used.
Described time-out time is preserved in the usb device.
Preferably, user can send order by computing machine to USB device and revise time-out time.From USB device connects computing machine next time, amended time-out time will be used.
Described timing unit can be the real-time clock of hardware, timer, also can be the clock of software simulation.
Described selection protocol, refers to according to usb protocol, and reporting facility connection status also sends the process of USB descriptor (USB Descriptor).
As seen from the above technical solution, present invention achieves the method that usb protocol is selected automatically, automatically can select the agreement of installing driving, reach the object improving equipment easy applied performance.
According to an aspect of the present invention, a kind of USB device is provided to select to start the method for agreement,
Step 1: the selecting sequence presetting at least two agreements supporting described USB device in described USB device;
Step 2: when described USB device is connected to computing machine, according to the described selecting sequence preset, selects the first agreement to start;
Step 3: if start unsuccessful according to described first agreement, then described USB device is according to the agreement selecting sequence preset, and selects other agreements to start;
Step 4: if all accord selected according to described selecting sequence all starts unsuccessful, then described USB device stops starting.
According to an aspect of the present invention, in described USB device, there is timing unit,
In described step 1, in described USB device, preset timeout value;
In described step 2, when described USB device is connected to computing machine, described timing unit starts timing;
If be provided with the driver of described first agreement in described computing machine, then described USB device uses described first agreement and described compunication, and described timing unit stops timing;
If do not install the driver of described first agreement in described computing machine, then, after described timing unit judges time-out, enter step 3, described timing unit restarts timing simultaneously;
In described step 3, if be provided with the driver of other agreements described in described computing machine, then described USB device uses other agreements described and described compunication, and described timing unit stops timing;
If do not install the driver of other agreements described in described computing machine, then after described timing unit judges time-out, described USB device is according to the agreement selecting sequence preset, and continue to select other agreements remaining to start, described timing unit restarts timing simultaneously.
According to an aspect of the present invention, when described USB device communicates with described computing machine, to described computing machine, described USB device reports that it is in connection status, and to the USB descriptor that described computing machine transmission protocol compliant specifies.
According to an aspect of the present invention, described computing machine sends to described USB device and arranges configuration order;
Described USB device receive described configuration order is set after complete agreement select, and use selected by described agreement and described compunication.
According to an aspect of the present invention, described USB device, according to the final agreement selected, is automatically revised the selecting sequence of agreement, the agreement finally selected is set to the first agreement, and other agreement still sorts successively according to the original order preset.
According to an aspect of the present invention, user is revised the selecting sequence of agreement by described computing machine to described USB device transmission order or arranges described timeout value.
According to an aspect of the present invention, described 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, described agreement at least comprises: UASP agreement, CCID agreement, HID agreement.
Embodiment
For making object of the present invention, technical scheme and advantage clearly understand, to develop simultaneously embodiment referring to accompanying drawing, the present invention is described in more detail.
Embodiment one
In the present embodiment, USB device supports HID and CCID two kinds of agreements.
Fig. 1 is the process flow diagram of the method for the automatic selection protocol of USB device in the present embodiment.As shown in Figure 1, in the present embodiment, the method for automatic selection protocol comprises:
Step 101, before USB device is dispatched from the factory, arranges agreement selecting sequence: CCID->HID, that is, first CCID agreement boot sequence is better than HID agreement.
Step 102, when user uses USB device, is connected to computing machine by USB device.USB device selects CCID agreement first automatically.That is, to computing machine, USB device reports that it is in connection status, and to the USB descriptor that computing machine transmission CCID agreement specifies.Time of day in USB device starts timing.
If the driver of CCID agreement installed by computing machine, then perform step 103, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 104 after receiving configuration order, and agreement selection course completes.USB device uses CCID agreement and compunication, and timing unit stops timing.
If the driver of CCID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.The hardware timer of USB device [is " timing unit " above, should keep term consistent] after a time out, triggered interrupts program, performs step 105, to computing machine, USB device reports that it is in connection status again, and to the USB descriptor that computing machine transmission HID agreement specifies.Timing unit restarts timing.
If the driver of HID agreement installed by computing machine, perform step 106, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 107 after receiving configuration order, and agreement selection course completes.USB device uses HID agreement and compunication, and timing unit stops timing.
If the driver of HID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 108, USB device does not find the agreement of support to the timing unit of USB device, completes agreement and selects.In this case, USB device fails to set up and the communication of computing machine, after needing to install the driver of CCID agreement or HID agreement, reconnects USB device.
So far, this flow process terminates.
From above-mentioned flow process, in the method for the automatic selection protocol of the present embodiment, by what whether receive in the time-out time that limits at timing unit that main frame sends, configuration order is set, judges whether computing machine has installed CCID or HID agreement.By arranging rational time-out time, the time that agreement can be made to select is in the acceptable scope of user, and ensure can not because time-out time is too short mistake miss out computing machine send configuration order is set, thus the present invention can realize the automatic selection of usb protocol.
Embodiment two
In the present embodiment, USB device supports HID, CCID and UASP tri-kinds of agreements, and supports amendment agreement selecting sequence automatically.
UASP agreement, i.e. USB Attached SCSI Protocol are the agreements that a kind of Large Copacity USB storage device is commonly used.
Fig. 2 is the process flow diagram that in the present embodiment, the automatic selection protocol of USB device also revises the method for agreement selecting sequence automatically.As shown in Figure 2, in the present embodiment automatic selection protocol and automatically the method for amendment agreement selecting sequence comprise:
Step 201, before USB device is dispatched from the factory, arranges agreement selecting sequence: UASP->CCID->HID.
Step 202, when user uses USB device, is connected to computing machine by USB device.USB device selects UASP agreement.That is, to computing machine, USB device reports that it is in connection status, and to the USB descriptor that computing machine transmission UASP agreement specifies.Timing unit in USB device starts timing.
If the driver of UASP agreement installed by computing machine, perform step 203, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 204 after receiving configuration order, and agreement selection course completes.USB device uses UASP agreement and compunication, and timing unit stops timing.Because the final agreement selected is the 1st agreement of order of dispatching from the factory, do not need amendment agreement selecting sequence.
If the driver of UASP agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 205, to computing machine, USB device reports that it is in connection status to the timing unit of USB device again, and to the USB descriptor that computing machine transmission CCID agreement specifies.Timing unit restarts timing.
If the driver of CCID agreement installed by computing machine, perform step 206, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 207 after receiving configuration order, and agreement selection course completes.USB device uses CCID agreement and compunication, and timing unit stops timing.
Step 208, it is CCID->UASP->HID that USB device revises agreement selecting sequence automatically.
If the driver of CCID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 209, to computing machine, USB device reports that it is in connection status to the timing unit of USB device again, and to the USB descriptor that computing machine transmission HID agreement specifies.Timing unit restarts timing.
If the driver of HID agreement installed by computing machine, perform step 210, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 211 after receiving configuration order, and agreement selection course completes.USB device uses HID agreement and compunication, and timing unit stops timing.
Step 212, it is HID->UASP->CCID that USB device revises agreement selecting sequence automatically.
If the driver of HID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 213, USB device does not find the agreement of support to the timing unit of USB device, completes agreement and selects.In this case, USB device fails to set up and the communication of computing machine, after needing to install the driver of UASP agreement or CCID agreement or HID agreement, reconnects USB device.
So far, this flow process terminates.
From above-mentioned flow process, after the method for the automatic selection protocol of the present embodiment, can automatically revise agreement selecting sequence according to final selection situation.Like this, upper once connect USB device time, preferentially can select the agreement that last success is selected.Under normal circumstances, according to new agreement selecting sequence, the 1st agreement namely can be chosen successfully, no longer needs to select those not have the agreement of install driver, saves the time that agreement is selected, further increase the ease for use of the inventive method.
Embodiment three
In the present embodiment, USB device supports HID, CCID and UASP tri-kinds of agreements.Support amendment agreement selecting sequence automatically in this embodiment, and support that user revises agreement selecting sequence and time-out time.
Fig. 3 is the automatic selection protocol of USB device automatic amendment agreement selecting sequence in the present embodiment, then is revised the process flow diagram of method of agreement selecting sequence and time-out time by user.As shown in Figure 3, the method in the present embodiment comprises:
Step 301, before USB device is dispatched from the factory, arranges agreement selecting sequence: UASP->CCID->HID.
Step 302, when user uses USB device, is connected to computing machine by USB device.USB device selects UASP agreement.That is, to computing machine, USB device reports that it is in connection status, and to the USB descriptor that computing machine transmission UASP agreement specifies.Timing unit in USB device starts timing.
If the driver of UASP agreement installed by computing machine, perform step 303, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 304 after receiving configuration order, and agreement selection course completes.USB device uses UASP agreement and compunication, and timing unit stops timing.Because the final agreement selected is the 1st agreement of order of dispatching from the factory, do not need amendment agreement selecting sequence.After step 304 completes, perform step 314.
If the driver of UASP agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 305, to computing machine, USB device reports that it is in connection status to the timing unit of USB device again, and to the USB descriptor that computing machine transmission CCID agreement specifies.Timing unit restarts timing.
If the driver of CCID agreement installed by computing machine, perform step 306, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 307 after receiving configuration order, and agreement selection course completes.USB device uses CCID agreement and compunication, and timing unit stops timing.
Step 308, it is CCID->UASP->HID that USB device revises agreement selecting sequence automatically.
After step 308 completes, perform step 314.
If the driver of CCID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 309, to computing machine, USB device reports that it is in connection status to the timing unit of USB device again, and to the USB descriptor that computing machine transmission HID agreement specifies.Timing unit restarts timing.
If the driver of HID agreement installed by computing machine, perform step 310, according to usb protocol, computing machine can send to USB device and arrange configuration order.
USB device performs step 311 after receiving configuration order, and agreement selection course completes.USB device uses HID agreement and compunication, and timing unit stops timing.
Step 312, it is HID->UASP->CCID that USB device revises agreement selecting sequence automatically.
After step 312 completes, perform step 314.
If the driver of HID agreement do not installed by computing machine, computing machine can not send to USB device and arrange configuration order.After a time out, perform step 313, USB device does not find the agreement of support to the timing unit of USB device, completes agreement and selects.In this case, USB device fails to set up and the communication of computing machine, after needing to install the driver of UASP agreement or CCID agreement or HID agreement, reconnects USB device.
Step 314, when USB device and computing machine can proper communication, user can send order amendment agreement selecting sequence, e.g., is revised as CCID->HID->UASP.User can send order amendment time-out time.
So far, this flow process terminates.
From above-mentioned flow process, after the method for the automatic selection protocol of the present embodiment, can automatically revise agreement selecting sequence according to final selection situation.However, user may upper once connect USB device before, the driver of other agreements is installed, and wish can upper once connect USB device when, use new agreement of installing.At this moment, user can will wish when connecting USB device that the agreement used is set to the 1st agreement next time, and other agreements after which.Like this, namely can select next time wish use agreement, even and if this protocol-driven can not work, other agreements also can be selected to work on.User can revise time-out time, saves the time that agreement is selected.By the flow process of the present embodiment, the dirigibility of the inventive method can be improved.