WO2018188404A1 - Usb device configuration method and host - Google Patents

Usb device configuration method and host Download PDF

Info

Publication number
WO2018188404A1
WO2018188404A1 PCT/CN2018/075115 CN2018075115W WO2018188404A1 WO 2018188404 A1 WO2018188404 A1 WO 2018188404A1 CN 2018075115 W CN2018075115 W CN 2018075115W WO 2018188404 A1 WO2018188404 A1 WO 2018188404A1
Authority
WO
WIPO (PCT)
Prior art keywords
usb device
configuration
working mode
usb
response message
Prior art date
Application number
PCT/CN2018/075115
Other languages
French (fr)
Chinese (zh)
Inventor
朱良辉
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2018188404A1 publication Critical patent/WO2018188404A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2247Verification or detection of system hardware configuration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Definitions

  • the present application relates to, but is not limited to, data communication technology, and in particular, to a USB device configuration method and a host.
  • USB Universal Serial Bus
  • UHCI Universal Host Controller Interface
  • EHCI Enhanced Host Controller Interface
  • xHCI Extensible Host Controller Interface
  • the host polls the status of its root hub to determine whether there is a device (including the device on the child hub and the child hub). Then the host performs a series of configuration operations to make the USB device normal. enumerate.
  • the USB device needs to use different working modes to meet the requirements of the upper layer service when the host uses different operating systems.
  • the operating system used by the host includes: Windows operating system and non-Windows operating system (Mac operating system and Linux operating system).
  • the USB device When the host uses the Windows operating system, the USB device needs to work in the first working mode, and the host needs to configure the USB device in the first working mode; when the host uses the non-Windows operating system, the USB device needs to work in the second work. In the mode, the host needs to configure the USB device in the second mode.
  • the host uses the Windows operating system
  • the host and the USB device interact with the Microsoft descriptor. If the USB device receives the Microsoft descriptor sent by the host, the operating system used by the host is the Windows system. If the USB device does not receive the Microsoft descriptor sent by the host, it indicates that the operating system used by the host is a non-Windows system.
  • the embodiment of the invention provides a method for configuring a USB device and a host, which can be configured for a USB device in different working modes.
  • An embodiment of the present invention provides a method for configuring a USB device, where the method includes:
  • the USB device is configured according to a second configuration method corresponding to the second working mode.
  • the USB device is configured according to the first configuration method corresponding to the first working mode, including:
  • the USB device is configured according to all first configuration response messages.
  • the method further includes:
  • the determining, according to the USB custom response message, whether the USB device is successfully configured includes:
  • USB custom response message is a USB configured response message, determining that the USB device is successfully configured
  • USB custom response message is a USB unconfigured response message, it is determined that the configuration of the USB device fails.
  • the method further includes:
  • the configuring the USB device according to the second configuration method corresponding to the second working mode includes:
  • the USB device is configured according to all second configuration response messages.
  • the first working mode is an operating mode corresponding to the first type of operating system; and the second working mode is a working mode corresponding to the second type of operating system.
  • Embodiments of the present invention provide a computer readable storage medium storing computer executable instructions, which are implemented by a processor to implement the above-described configuration method of a USB device.
  • An embodiment of the present invention further provides a host, where the host includes: a control unit and a configuration unit;
  • the control unit is configured to control the USB device to adapt its working mode from the first working mode to the second working mode when the USB device fails to be configured according to the first configuration method corresponding to the first working mode.
  • the configuration unit is configured to configure the USB device according to a second configuration method corresponding to the second working mode.
  • the configuration unit includes: a sending subunit, a receiving subunit, and a configuration subunit;
  • the sending subunit is configured to send each of the predetermined first configuration request messages to the USB device;
  • the receiving subunit is configured to receive a first configuration response message corresponding to each first configuration request message returned by the USB device;
  • the configuration subunit is configured to configure the USB device according to all first configuration response messages.
  • control unit includes: a first detecting subunit and a first determining subunit;
  • the first detecting subunit is configured to send a USB custom request instruction to the USB device, and receive a USB custom response message returned by the USB device;
  • the first determining subunit is configured to determine, according to the USB custom response message, whether the USB device is successfully configured.
  • the first determining subunit is configured to determine that the USB device is successfully configured when the USB custom response message is a USB configured response message; when the USB custom response message is When the response message is not configured for the USB, it is determined that the configuration of the USB device has failed.
  • control unit includes: a second detecting subunit and a second judging subunit;
  • the second detecting subunit is configured to send a SCSI request instruction to the USB device, and receive a SCSI response message returned by the USB device;
  • the second determining subunit is configured to determine, according to the SCSI response message, whether the USB device is successfully configured.
  • the sending subunit is further configured to send the predetermined second configuration request message to the USB device;
  • the receiving subunit is further configured to receive a second configuration response message corresponding to each second configuration request message returned by the USB device;
  • the configuration subunit is further configured to configure the USB device according to all the second configuration response messages.
  • the first working mode is an operating mode corresponding to the first type of operating system; and the second working mode is a working mode corresponding to the second type of operating system.
  • Embodiments of the present invention also provide a storage medium storing one or more programs, and the one or more programs may be executed by one or more processors to implement the following steps:
  • the USB device is configured according to a second configuration method corresponding to the second working mode.
  • the USB device when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second mode. The working mode is then configured according to the second configuration method corresponding to the second working mode. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately.
  • the configuration method and the host of the USB device provided by the embodiment of the present invention can be configured for the USB device in different working modes, compared with the technical solution that the host can only be configured for the USB device in the same working mode;
  • the technical solution of the embodiment of the invention is simple and convenient to implement, convenient to popularize, and has a wider use range.
  • FIG. 1 is a schematic flowchart showing an implementation process of a USB device
  • FIG. 2 is a schematic flowchart of implementing a method for configuring a USB device according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a method for implementing a USB device according to a first configuration method according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of a first implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention
  • FIG. 5 is a schematic flowchart of a second implementation method for determining whether a USB device is successfully configured according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of correspondence between an operating system of a host and a working mode of a USB device according to an embodiment of the present invention
  • FIG. 7 is a schematic flowchart of a method for implementing a USB device according to a second configuration method according to an embodiment of the present disclosure
  • FIG. 8 is a schematic diagram of a first component structure of a host according to an embodiment of the present invention.
  • FIG. 9 is a schematic diagram showing a second component structure of a host according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a third component structure of a host according to an embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of an implementation process of a USB device configuration method. As shown in FIG. 1, the configuration method of the USB device may include the following steps:
  • Step 101 The host sends a standard configuration request message to the USB device.
  • Step 102 The USB device returns a standard configuration response message to the host.
  • Step 103 The host configures the USB device according to the standard configuration response message.
  • the host can only be configured for the USB device in the same working mode, and cannot be configured for the USB device in different working modes.
  • FIG. 2 is a schematic flowchart of an implementation manner of a method for configuring a USB device according to an embodiment of the present invention.
  • the configuration method of the USB device may include steps 201-202.
  • Step 201 When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second working mode.
  • FIG. 3 is a schematic flowchart of a method for implementing a USB device according to a first configuration method according to an embodiment of the present invention. As shown in FIG. 3, the method for configuring a USB device according to the first configuration method may include steps 301-303.
  • Step 301 Send a predetermined first configuration request message to the USB device.
  • the host when the USB device is inserted into the host, the host detects the USB device and then supplies current to the USB device, and also sends a predetermined first configuration request message to the USB device to the USB device.
  • the USB device when the USB device is inserted into the host, the USB device is enumerated into the host by means of a virtual optical drive, and the USB device can be directly installed or pushed to the host in the background, and then the host sends the predetermined to the USB device.
  • Each first configuration request message when the USB device is inserted into the host, the USB device is enumerated into the host by means of a virtual optical drive, and the USB device can be directly installed or pushed to the host in the background, and then the host sends the predetermined to the USB device.
  • Step 302 Receive a first configuration response message corresponding to each first configuration request message returned by the USB device.
  • the USB device after receiving the respective first configuration request messages sent by the host, the USB device needs to return a corresponding first configuration response message for each first configuration request message.
  • the correspondence between the first configuration request message and the first configuration response message may be as shown in Table 1 below:
  • First configuration request message First configuration response message First configuration request message First configuration response message First configuration request message 1 First configuration response message 1 First configuration request message 2 First configuration response message 2 ... ... First configuration request message M First configuration response message M
  • Step 303 Configure the USB device according to all the first configuration response messages.
  • the host may configure the USB device according to all the first configuration response messages.
  • the interaction between the host and the USB device mainly includes: interaction between the controller driver of the host operating system and the device, and interaction between the function driver of the host and the USB device. Only when the two are interactive, the USB device can work and communicate normally.
  • the configuration process of the USB device by the host is mainly based on the main information such as the interface class, the interface subclass, and the protocol class reported by the USB device, and the appropriate network card type and driver are selected for the USB device. Match and drive loading.
  • the host may first configure the USB device according to the first configuration method corresponding to the first working mode.
  • the host may control the USB device to The working mode is adapted from the first working mode to the second working mode, and the host can configure the USB device according to the second configuration method corresponding to the second working mode.
  • the host may first determine whether the USB device is successfully configured according to the first configuration method; When the configuration of the USB device fails, the host can configure the USB device according to the second configuration method corresponding to the second working mode. When the host successfully configures the USB device according to the first configuration method, the host can end the USB device. Configuration process.
  • FIG. 4 is a schematic flowchart of a first implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention. As shown in FIG. 4, the method for determining whether the USB device is successfully configured may include steps 401 to 403.
  • Step 401 Send a USB custom request instruction to the USB device.
  • the host may send a USB custom request instruction to the USB device, where the USB custom request command is mainly For obtaining the configuration information of the USB device, the USB device needs to report the relevant USB information after receiving the USB custom request command.
  • the USB custom request instruction may be implemented by a USB-based standard protocol. The USB custom request instruction based on the USB standard request extension is used to obtain the USB device configuration completion information, and the format of the USB custom request instruction needs to conform to the USB standard protocol.
  • the format of the USB custom request instruction may be: “C0 01 ⁇ ⁇ ⁇ 00 00 00 00", where "C0" indicates that the direction of the USB custom request instruction is the host to the USB device, and “C0” indicates that the instruction is a USB custom request instruction; "01” indicates that the configuration completion message is acquired.
  • Step 402 Receive a USB custom response message returned by the USB device.
  • the USB device after receiving the USB custom request message sent by the host, parses the USB custom request command and carries the configuration completion information in the USB custom response message. Returned to the host; wherein the USB custom response message includes: a USB configured response message or a USB unconfigured response message.
  • the USB custom request instruction and the configuration completion information are mutually negotiated between the host and the USB device, and the format of the USB custom response message returned by the USB device to the host also needs to comply with the USB standard protocol. For example: “00” indicates that the USB has configured a response message; “01” indicates that the USB is not configured with a response message.
  • Step 403 Determine, according to the USB custom response message, whether the USB device is successfully configured.
  • the host may determine whether the USB device configuration is successful according to the USB custom response message returned by the USB device.
  • the USB custom response message is a USB configured response message, indicating that the driver loading and installation of the USB device is normal, the host determines that the USB device configuration is successful; when the USB custom response message is USB When the response message is not configured, it indicates that the driver of the USB device is not loaded or installed properly, and the host determines that the configuration of the USB device fails.
  • the host can send a USB custom request command to the USB device through the above steps 401-403, and then the host determines whether the USB device is successfully configured according to the received USB custom response message.
  • the host fails to configure the USB device, the host can control the USB device to adapt its working mode from the first working mode to the second working mode, and the host can perform the USB device according to the second configuration method corresponding to the second working mode. Configuration.
  • FIG. 5 is a schematic flowchart of a second implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention. As shown in FIG. 5, the method for determining whether the USB device is successfully configured may include the following steps:
  • Step 501 Send a SCSI request instruction to the USB device.
  • the host may send the SCSI (Small Computer System Interface (SCSI)) to the USB device.
  • SCSI Small Computer System Interface
  • the SCSI request instruction is also used to obtain USB device configuration completion information, and the USB device needs to report related USB information after receiving the SCSI request instruction.
  • the SCSI request instruction may pass SCSI.
  • the protocol can be implemented. The host can negotiate with the USB device to add an index value to obtain the information about the configuration completion message. After the USB device receives the SCSI request command, the USB device can report the configuration completion information to the host according to the index value.
  • Step 502 Receive a SCSI response message returned by the USB device.
  • the USB device after receiving the SCSI request command sent by the host, parses the SCSI request command, and carries the configuration completion information in the SCSI response message and returns it to the host;
  • the SCSI response message includes: a SCSI configured response message or a SCSI unconfigured response message.
  • both the SCSI request instruction and the configuration completion information are mutually negotiated between the host and the USB device, and the format of the SCSI response message returned by the USB device to the host also needs to conform to the SCSI standard protocol.
  • Step 503 Determine, according to the SCSI response message, whether the USB device is successfully configured.
  • the host may determine whether the USB device configuration is successful according to the SCSI response message returned by the USB device. In an exemplary embodiment of the present invention, when the SCSI response message is a SCSI configured response message, indicating that the driver loading and installation of the USB device is normal, the host determines that the USB device configuration is successful; when the SCSI response message is a SCSI unconfigured response message When it indicates that the driver of the USB device is loaded or not installed properly, the host determines that the configuration of the USB device has failed.
  • the host can also send a SCSI request command to the USB device through the above steps 501-503, and then the host determines whether the USB device is successfully configured according to the received SCSI response message.
  • the host fails to configure the USB device, the host can control the USB device to adapt its working mode from the first working mode to the second working mode, and the host can perform the USB device according to the second configuration method corresponding to the second working mode. Configuration.
  • FIG. 6 is a schematic diagram of correspondence between an operating system of a host and an operating mode of a USB device according to an embodiment of the present invention. As shown in FIG. 6, when the operating system of the host is a Windows operating system, the USB device operates in the first working mode; when the operating system of the host is a non-Windows operating system, the USB device operates in the second working mode.
  • the USB device when the USB device fails to configure the USB device, it indicates that the operating system used by the host is a non-Windows operating system, and therefore, the USB device needs to adapt its working mode from the first working mode to The second mode of operation, in this way, the working mode of the USB device can correspond to the non-Windows operating system used by the host, and the USB device can be used normally.
  • Step 202 Configure the USB device according to the second configuration method corresponding to the second working mode.
  • FIG. 7 is a schematic flowchart of a method for implementing configuration of a USB device according to a second configuration method according to an embodiment of the present invention. As shown in FIG. 7, the method for configuring a USB device according to the second configuration method may include the following steps:
  • Step 701 Send a predetermined second configuration request message to the USB device.
  • the host may transmit a predetermined respective second configuration request message to the USB device.
  • Step 702 Receive a second configuration response message corresponding to each second configuration request message returned by the USB device.
  • the USB device after receiving the second configuration request message sent by the host, the USB device returns a second configuration response message corresponding to each second configuration request message to the host, and the host receives the USB device return.
  • the second configuration response message corresponding to each of the second configuration request messages.
  • the correspondence between the second configuration request message and the second configuration response message may be as shown in Table 2 below:
  • First configuration request message First configuration response message First configuration request message First configuration response message First configuration request message 1 First configuration response message 1 First configuration request message 2 First configuration response message 2 ... ... First configuration request message M First configuration response message M
  • the second configuration request message 1 corresponds to the second configuration response message 1; the second configuration request message 2 corresponds to the second configuration response message 2; ...; the second configuration request message M corresponds to the second configuration response message M Where M is a natural number greater than or equal to 1.
  • Step 703 Configure the USB device according to all the second configuration response messages.
  • the host may configure the USB device according to all the second configuration response messages.
  • the interaction between the host and the USB device mainly includes: interaction between the controller driver of the host operating system and the device, and interaction between the function driver of the host and the USB device. Only when the two are interactive, the USB device can work and communicate normally.
  • the configuration process of the USB device by the host is mainly based on the main information such as the interface class, the interface subclass, and the protocol class reported by the USB device, and the appropriate network card type and driver are selected for the USB device. Match and drive loading.
  • the first working mode may be an operating mode corresponding to the operating system of the first type; and the second working mode may be an operating mode corresponding to the operating system of the second type.
  • the first working mode may be a working mode when the operating system of the host is a Windows operating system
  • the second working mode may be a working mode when the operating system of the host is a non-Windows operating system
  • the first working mode may be an operation of the host
  • the second working mode may be a working mode when the operating system of the host is a Windows operating system.
  • the first configuration method when the first working mode is the working mode corresponding to the Windows operating system, the first configuration method may be a configuration method corresponding to the Windows operating system; when the second working mode is a working mode corresponding to the non-Windows operating system, The second configuration method may be a configuration method corresponding to a non-Windows operating system.
  • the first configuration method when the first working mode is the working mode corresponding to the non-Windows operating system, the first configuration method may be a configuration method corresponding to the non-Windows operating system; when the second working mode is the working mode corresponding to the Windows operating system, the second configuration The method can be a configuration method corresponding to the Windows operating system.
  • the host can configure the USB device according to the second configuration method corresponding to the second working mode. Therefore, compared with the technical solution that the host can only be configured for the USB device in the same working mode, the configuration method of the USB device according to the embodiment of the present invention can be configured for the USB device in different working modes.
  • the host when the host successfully configures the USB device according to the first configuration method corresponding to the first working mode, the host may end the configuration process of the USB device; further, the host corresponds to the second working mode. After the second configuration method configures the USB device, the host can end the configuration process of the USB device.
  • the method for configuring a USB device when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second working mode. The mode is then configured according to the second configuration method corresponding to the second working mode. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately.
  • the configuration method of the USB device according to the embodiment of the present invention can be configured for the USB device in different working modes, compared with the technical solution that the host can be configured only for the USB device in the same working mode;
  • the technical solution of the embodiment of the invention is simple and convenient to implement, convenient to popularize, and has a wider use range.
  • Embodiments of the present invention provide a computer readable storage medium storing computer executable instructions, which are implemented by a processor to implement the above-described configuration method of a USB device.
  • FIG. 8 is a schematic diagram of a first component structure of a host according to an embodiment of the present invention.
  • the host may include: a control unit 801 and a configuration unit 802;
  • the control unit 801 is configured to control the USB device to adapt its working mode from the first working mode to the second working when the USB device fails to be configured according to the first configuration method corresponding to the first working mode. mode;
  • the configuration unit 802 is configured to configure the USB device according to a second configuration method corresponding to the second working mode.
  • FIG. 9 is a schematic diagram of a second component structure of a host according to an embodiment of the present invention.
  • the configuration unit 802 includes: a sending subunit 8021, a receiving subunit 8022, and a configuration subunit 8023;
  • the sending subunit 8021 is configured to send each of the predetermined first configuration request messages to the USB device;
  • the receiving sub-unit 8022 is configured to receive a first configuration response message corresponding to each first configuration request message returned by the USB device;
  • the configuration subunit 8023 is configured to configure the USB device according to all first configuration response messages.
  • control unit 801 includes: a first detecting subunit 8011 and a first judging subunit 8012;
  • the first detecting sub-unit 8011 is configured to send a USB custom request instruction to the USB device, and receive a USB custom response message returned by the USB device, where the USB custom response message includes: USB configured a response message or a USB unconfigured response message;
  • the first determining sub-unit 8012 is configured to determine, according to the USB custom response message, whether the USB device is successfully configured.
  • the first determining sub-unit 8012 is configured to determine that the USB device configuration is successful when the USB custom response message is the USB configured response message; When the USB custom response message is the USB unconfigured response message, it is determined that the configuration of the USB device fails.
  • FIG. 10 is a schematic diagram of a third component structure of a host according to an embodiment of the present invention.
  • the control unit 801 includes: a second detecting subunit 8013 and a second judging subunit 8014;
  • the second detecting subunit 8013 is configured to send a SCSI request instruction to the USB device, and receive a SCSI response message returned by the USB device, where the SCSI response message includes: a SCSI configured response message or a SCSI unconfigured Response message
  • the second determining subunit 8014 is configured to determine whether the USB device is successfully configured according to the SCSI response message.
  • the sending subunit 8021 is further configured to send a predetermined second configuration request message to the USB device;
  • the receiving sub-unit 8022 is further configured to receive a second configuration response message corresponding to each second configuration request message returned by the USB device;
  • the configuration sub-unit 8023 is further configured to configure the USB device according to all the second configuration response messages.
  • the first working mode is an operating mode corresponding to a first type of operating system; and the second working mode is a working mode corresponding to a second type of operating system.
  • control unit 801 and the configuration unit 802 may each be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA) located in the host. ) and so on.
  • CPU central processing unit
  • MPU microprocessor
  • DSP digital signal processor
  • FPGA field programmable gate array
  • the respective units in the present embodiment may exist physically separately, or two or more units may be integrated in one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software function module.
  • the integrated unit can be stored in a readable storage medium if it is implemented in the form of a software function module and is not sold or used as a stand-alone product.
  • the technical solution of the embodiment is essentially or The portion contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including a plurality of instructions for causing a host (which may be a personal mobile device)
  • a terminal, a server, or a network device, or the like, or a processor performs all or part of the steps of the method described in this embodiment.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes.
  • the program instructions corresponding to the configuration method of the USB device in this embodiment may be stored on a storage medium such as an optical disk, a hard disk, a USB disk, or the like, and the program instructions corresponding to the configuration method of the USB device in the storage medium are read by an electronic device or When executed, the following steps are included:
  • the USB device is configured according to a second configuration method corresponding to the second working mode.
  • the host device of the embodiment of the present invention when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controls the USB device to adapt its working mode from the first working mode to the second working mode, and then according to The second configuration method corresponding to the second working mode configures the USB device. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately. Therefore, compared with the technical solution that the host can be configured only for the USB device in the same working mode, the host provided by the embodiment of the present invention can be configured for the USB device in different working modes; and, in the embodiment of the present invention, The technical solution is simple and convenient to implement, easy to popularize, and has a wider range of use.
  • computer storage medium includes volatile and nonvolatile, implemented in any method or technology for storing information, such as computer readable instructions, data structures, program modules or other data. Sex, removable and non-removable media.
  • Computer storage media include, but are not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), and Electrically Erasable Programmable Read-only Memory (EEPROM). Flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cassette, magnetic tape, disk storage or other magnetic storage device, or Any other medium used to store the desired information and that can be accessed by the computer.
  • communication media typically includes computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and can include any information delivery media. .
  • the configuration method and the host of the USB device provided by the embodiment of the present invention can be configured for the USB device in different working modes. Moreover, the technical solution of the embodiment of the present invention is simple and convenient to implement, popularized, and widely used.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Information Transfer Systems (AREA)

Abstract

A USB device configuration method and a host. The method comprises: when configuring a USB device according to a first configuration method corresponding to a first working mode fails, controlling the USB device to adapt the working mode thereof from the first working mode to a second working mode; and configuring the USB device according to a second configuration method corresponding to the second working mode.

Description

一种USB设备的配置方法及主机Configuration method and host of USB device 技术领域Technical field
本申请涉及但不限于数据通信技术,尤其是一种USB设备的配置方法及主机。The present application relates to, but is not limited to, data communication technology, and in particular, to a USB device configuration method and a host.
背景技术Background technique
近几年,用户对于USB(Universal Serial Bus,通用串行总线)接口的使用越来越频繁,选择性也越来越多。目前,越来越多的电脑厂商在主板芯片上增加了USB3.0主机控制器,结合之前的USB1.0、USB1.1以及使用最为广泛的USB2.0接口,接口标准从当初的OHCI(Open Host Controller Interface,开放式主机控制器接口)、UHCI(Universal Host Controller Interface,通用主机控制器接口)到后来的EHCI(Enhanced Host Controller Interface,增强主机控制器接口),再到最新的xHCI(Extensible Host Controller Interface,可扩展的主机控制器接口)。在USB设备的使用上,不同的接口标准也会带来影响USB设备使用的情况。In recent years, users have become more and more frequently using USB (Universal Serial Bus) interfaces and have more and more options. At present, more and more computer manufacturers have added a USB3.0 host controller to the motherboard chip, combining the previous USB1.0, USB1.1 and the most widely used USB2.0 interface. The interface standard is from the original OHCI (Open Host Controller Interface, Open Host Controller Interface, UHCI (Universal Host Controller Interface) to later EHCI (Enhanced Host Controller Interface), to the latest xHCI (Extensible Host) Controller Interface, an expandable host controller interface). In the use of USB devices, different interface standards can also affect the use of USB devices.
USB设备在插入主机的USB接口之后,主机会轮询它的根Hub的状态,判断是否有设备(包括子Hub和子Hub上的设备)连接;接着主机会进行一系列的配置操作使得USB设备正常枚举。在USB设备的配置过程中,在主机使用不同的操作系统下,USB设备需要使用不同的工作模式,以满足上层业务的需求。其中,主机使用的操作系统包括:Windows操作系统和非Windows操作系统(Mac操作系统和Linux操作系统)。当主机使用Windows操作系统时,USB设备需要工作在第一工作模式下,主机需要对第一工作模式下的USB设备进行配置;当主机使用非Windows操作系统时,USB设备需要工作在第二工作模式下,主机需要对第二模式下的USB设备进行配置。例如,当主机使用Windows操作系统时,当USB设备插入主机后,主机与USB设备会交互微软描述符,若USB设备收到主机下发的微软描述符,则表明主机使用的操作系统是Windows系统,若USB设备未收到主机下发的微软描述符,则表明主机使用的操作系统是非Windows系统。After the USB device is plugged into the USB interface of the host, the host polls the status of its root hub to determine whether there is a device (including the device on the child hub and the child hub). Then the host performs a series of configuration operations to make the USB device normal. enumerate. In the configuration process of the USB device, the USB device needs to use different working modes to meet the requirements of the upper layer service when the host uses different operating systems. Among them, the operating system used by the host includes: Windows operating system and non-Windows operating system (Mac operating system and Linux operating system). When the host uses the Windows operating system, the USB device needs to work in the first working mode, and the host needs to configure the USB device in the first working mode; when the host uses the non-Windows operating system, the USB device needs to work in the second work. In the mode, the host needs to configure the USB device in the second mode. For example, when the host uses the Windows operating system, when the USB device is plugged into the host, the host and the USB device interact with the Microsoft descriptor. If the USB device receives the Microsoft descriptor sent by the host, the operating system used by the host is the Windows system. If the USB device does not receive the Microsoft descriptor sent by the host, it indicates that the operating system used by the host is a non-Windows system.
发明内容Summary of the invention
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics detailed in this document. This Summary is not intended to limit the scope of the claims.
本发明实施例提供一种USB设备的配置方法及主机,可以针对不同工作模式下的USB设备进行配置。The embodiment of the invention provides a method for configuring a USB device and a host, which can be configured for a USB device in different working modes.
本发明实施例的技术方案是这样实现的:The technical solution of the embodiment of the present invention is implemented as follows:
本发明实施例提供了一种USB设备的配置方法,所述方法包括:An embodiment of the present invention provides a method for configuring a USB device, where the method includes:
当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controlling the USB device to adapt its working mode from the first working mode to the second working mode;
按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The USB device is configured according to a second configuration method corresponding to the second working mode.
在上述实施例中,按照第一工作模式对应的第一配置方法对USB设备进行配置,包括:In the above embodiment, the USB device is configured according to the first configuration method corresponding to the first working mode, including:
向所述USB设备发送预先确定的各个第一配置请求消息;Sending each of the predetermined first configuration request messages to the USB device;
接收所述USB设备返回的各个第一配置请求消息对应的第一配置响应消息;Receiving a first configuration response message corresponding to each first configuration request message returned by the USB device;
根据全部第一配置响应消息对所述USB设备进行配置。The USB device is configured according to all first configuration response messages.
在上述实施例中,所述方法还包括:In the above embodiment, the method further includes:
向所述USB设备发送USB自定义请求指令;Sending a USB custom request instruction to the USB device;
接收所述USB设备返回的USB自定义响应消息;Receiving a USB custom response message returned by the USB device;
根据所述USB自定义响应消息判断对所述USB设备是否配置成功。Determining whether the USB device is successfully configured according to the USB custom response message.
在上述实施例中,所述根据所述USB自定义响应消息判断对所述USB设备是否配置成功,包括:In the foregoing embodiment, the determining, according to the USB custom response message, whether the USB device is successfully configured, includes:
当所述USB自定义响应消息为USB已配置响应消息时,判定对所述USB设备配置成功;When the USB custom response message is a USB configured response message, determining that the USB device is successfully configured;
当所述USB自定义响应消息为USB未配置响应消息时,判定对所述USB设备配置失败。When the USB custom response message is a USB unconfigured response message, it is determined that the configuration of the USB device fails.
在上述实施例中,所述方法还包括:In the above embodiment, the method further includes:
向所述USB设备发送小型计算机系统接口SCSI请求指令;Sending a small computer system interface SCSI request command to the USB device;
接收所述USB设备返回的SCSI响应消息;Receiving a SCSI response message returned by the USB device;
根据所述SCSI响应消息判断对所述USB设备是否配置成功。Determining whether the USB device is successfully configured according to the SCSI response message.
在上述实施例中,所述按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置,包括:In the above embodiment, the configuring the USB device according to the second configuration method corresponding to the second working mode includes:
向所述USB设备发送预先确定的各个第二配置请求消息;Sending each predetermined second configuration request message to the USB device;
接收所述USB设备返回的各个第二配置请求消息对应的第二配置响应消息;Receiving a second configuration response message corresponding to each second configuration request message returned by the USB device;
根据全部第二配置响应消息对所述USB设备进行配置。The USB device is configured according to all second configuration response messages.
在上述实施例中,所述第一工作模式为第一类型的操作系统对应的工作模式;所述第二工作模式为第二类型的操作系统对应的工作模式。In the above embodiment, the first working mode is an operating mode corresponding to the first type of operating system; and the second working mode is a working mode corresponding to the second type of operating system.
本发明实施例提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令被处理器执行时实现上述的USB设备的配置方法。本发明实施例还提供了一种主机,所述主机包括:控制单元和配置单元;其中,Embodiments of the present invention provide a computer readable storage medium storing computer executable instructions, which are implemented by a processor to implement the above-described configuration method of a USB device. An embodiment of the present invention further provides a host, where the host includes: a control unit and a configuration unit;
所述控制单元,设置成当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;The control unit is configured to control the USB device to adapt its working mode from the first working mode to the second working mode when the USB device fails to be configured according to the first configuration method corresponding to the first working mode. ;
所述配置单元,设置成按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The configuration unit is configured to configure the USB device according to a second configuration method corresponding to the second working mode.
在上述实施例中,所述配置单元包括:发送子单元、接收子单元和配置子单元;其中,In the above embodiment, the configuration unit includes: a sending subunit, a receiving subunit, and a configuration subunit; wherein
所述发送子单元,设置成向所述USB设备发送预先确定的各个第一配置请求消息;The sending subunit is configured to send each of the predetermined first configuration request messages to the USB device;
所述接收子单元,设置成接收所述USB设备返回的各个第一配置请求消息对应的第一配置响应消息;The receiving subunit is configured to receive a first configuration response message corresponding to each first configuration request message returned by the USB device;
所述配置子单元,设置成根据全部第一配置响应消息对所述USB设备进行配置。The configuration subunit is configured to configure the USB device according to all first configuration response messages.
在上述实施例中,所述控制单元包括:第一检测子单元和第一判断子单元;其中,In the above embodiment, the control unit includes: a first detecting subunit and a first determining subunit; wherein
所述第一检测子单元,设置成向所述USB设备发送USB自定义请求指令;接收所述USB设备返回的USB自定义响应消息;The first detecting subunit is configured to send a USB custom request instruction to the USB device, and receive a USB custom response message returned by the USB device;
所述第一判断子单元,设置成根据所述USB自定义响应消息判断对所述USB设备是否配置成功。The first determining subunit is configured to determine, according to the USB custom response message, whether the USB device is successfully configured.
在上述实施例中,所述第一判断子单元,是设置成当所述USB自定义响应消息为USB已配置响应消息时,判定对所述USB设备配置成功;当所述USB自定义响应消息为USB未配置响应消息时,判定对所述USB设备配置失败。In the above embodiment, the first determining subunit is configured to determine that the USB device is successfully configured when the USB custom response message is a USB configured response message; when the USB custom response message is When the response message is not configured for the USB, it is determined that the configuration of the USB device has failed.
在上述实施例中,所述控制单元包括:第二检测子单元和第二判断子单元;其中,In the above embodiment, the control unit includes: a second detecting subunit and a second judging subunit; wherein
所述第二检测子单元,设置成向所述USB设备发送SCSI请求指令;接收所述USB设备返回的SCSI响应消息;The second detecting subunit is configured to send a SCSI request instruction to the USB device, and receive a SCSI response message returned by the USB device;
所述第二判断子单元,设置成根据所述SCSI响应消息判断对所述USB设备是否配置成功。The second determining subunit is configured to determine, according to the SCSI response message, whether the USB device is successfully configured.
在上述实施例中,所述发送子单元,还设置成向所述USB设备发送预先确定的各个第二配置请求消息;In the above embodiment, the sending subunit is further configured to send the predetermined second configuration request message to the USB device;
所述接收子单元,还设置成接收所述USB设备返回的各个第二配置请求消息对应的第二配置响应消息;The receiving subunit is further configured to receive a second configuration response message corresponding to each second configuration request message returned by the USB device;
所述配置子单元,还设置成根据全部第二配置响应消息对所述USB设备进行配置。The configuration subunit is further configured to configure the USB device according to all the second configuration response messages.
在上述实施例中,所述第一工作模式为第一类型的操作系统对应的工作模式;所述第二工作模式为第二类型的操作系统对应的工作模式。In the above embodiment, the first working mode is an operating mode corresponding to the first type of operating system; and the second working mode is a working mode corresponding to the second type of operating system.
本发明实施例还提供了一种存储介质,所述存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现以下 步骤:Embodiments of the present invention also provide a storage medium storing one or more programs, and the one or more programs may be executed by one or more processors to implement the following steps:
当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controlling the USB device to adapt its working mode from the first working mode to the second working mode;
按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The USB device is configured according to a second configuration method corresponding to the second working mode.
由此可见,本发明实施例的技术方案中,当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制USB设备将其工作模式从第一工作模式适配到第二工作模式,然后按照第二工作模式对应的第二配置方法对USB设备进行配置。也就是说,在本发明实施例的技术方案中,可以分别针对第一工作模式和第二工作模式下的USB设备进行配置。因此,与主机只能针对同一个工作模式下的USB设备进行配置的技术方案相比,本发明实施例提出的USB设备的配置方法及主机,可以针对不同工作模式下的USB设备进行配置;并且,本发明实施例的技术方案实现简单方便,便于普及,使用范围更广。Therefore, in the technical solution of the embodiment of the present invention, when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second mode. The working mode is then configured according to the second configuration method corresponding to the second working mode. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately. Therefore, the configuration method and the host of the USB device provided by the embodiment of the present invention can be configured for the USB device in different working modes, compared with the technical solution that the host can only be configured for the USB device in the same working mode; The technical solution of the embodiment of the invention is simple and convenient to implement, convenient to popularize, and has a wider use range.
在阅读并理解了附图和详细描述后,可以明白其他方面。Other aspects will be apparent upon reading and understanding the drawings and detailed description.
附图概述BRIEF abstract
图1为USB设备的配置方法的实现流程示意图;FIG. 1 is a schematic flowchart showing an implementation process of a USB device;
图2为本发明实施例中USB设备的配置方法的实现流程示意图;2 is a schematic flowchart of implementing a method for configuring a USB device according to an embodiment of the present invention;
图3为本发明实施例中按照第一配置方法对USB设备进行配置的实现方法流程示意图;FIG. 3 is a schematic flowchart of a method for implementing a USB device according to a first configuration method according to an embodiment of the present disclosure;
图4为本发明实施例中判断是否对USB设备配置成功的第一实现方法流程示意图;4 is a schematic flowchart of a first implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention;
图5为本发明实施例中判断是否对USB设备配置成功的第二实现方法流程示意图;FIG. 5 is a schematic flowchart of a second implementation method for determining whether a USB device is successfully configured according to an embodiment of the present invention;
图6为本发明实施例中主机的操作系统与USB设备的工作模式的对应关系示意图;6 is a schematic diagram of correspondence between an operating system of a host and a working mode of a USB device according to an embodiment of the present invention;
图7为本发明实施例中按照第二配置方法对USB设备进行配置的实现方法流程示意图;FIG. 7 is a schematic flowchart of a method for implementing a USB device according to a second configuration method according to an embodiment of the present disclosure;
图8为本发明实施例中主机的第一组成结构示意图;FIG. 8 is a schematic diagram of a first component structure of a host according to an embodiment of the present invention; FIG.
图9为本发明实施例中主机的第二组成结构示意图;FIG. 9 is a schematic diagram showing a second component structure of a host according to an embodiment of the present invention; FIG.
图10为本发明实施例中主机的第三组成结构示意图。FIG. 10 is a schematic diagram of a third component structure of a host according to an embodiment of the present invention.
本发明的实施方式Embodiments of the invention
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present invention will be clearly and completely described in the following with reference to the accompanying drawings.
图1为USB设备的配置方法的实现流程示意图。如图1所示,USB设备的配置方法可以包括以下步骤:FIG. 1 is a schematic flowchart of an implementation process of a USB device configuration method. As shown in FIG. 1, the configuration method of the USB device may include the following steps:
步骤101、主机向USB设备发送标准配置请求消息;Step 101: The host sends a standard configuration request message to the USB device.
步骤102、USB设备向主机返回标准配置响应消息;Step 102: The USB device returns a standard configuration response message to the host.
步骤103、主机根据标准配置响应消息对USB设备进行配置。Step 103: The host configures the USB device according to the standard configuration response message.
在实现中,发明人发现至少存在如下问题:In the implementation, the inventors found that at least the following problems exist:
采用上述USB设备的配置方法,主机只能针对同一个工作模式下的USB设备进行配置,而无法针对不同工作模式下的USB设备进行配置。With the above configuration method of the USB device, the host can only be configured for the USB device in the same working mode, and cannot be configured for the USB device in different working modes.
在本发明的示例性实施例中,图2为本发明实施例中USB设备的配置方法的实现流程示意图。如图2所示,USB设备的配置方法可以包括步骤201-步骤202。In an exemplary embodiment of the present invention, FIG. 2 is a schematic flowchart of an implementation manner of a method for configuring a USB device according to an embodiment of the present invention. As shown in FIG. 2, the configuration method of the USB device may include steps 201-202.
步骤201、当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制USB设备将其工作模式从第一工作模式适配到第二工作模式。Step 201: When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second working mode.
在本发明的示例性实施例中,当USB设备插入到主机时,主机检测到USB设备之后会为USB设备提供电流,然后主机可以先按照第一工作模式对应的第一配置方法对USB设备进行配置。图3为本发明实施例中按照第一配置方法对USB设备进行配置的实现方法流程示意图。如图3所示,按照第一配置方法对USB设备进行配置的方法可以包括步骤301-步骤303。In an exemplary embodiment of the present invention, when the USB device is inserted into the host, the host detects the USB device and then supplies current to the USB device, and then the host may first perform the USB device according to the first configuration method corresponding to the first working mode. Configuration. FIG. 3 is a schematic flowchart of a method for implementing a USB device according to a first configuration method according to an embodiment of the present invention. As shown in FIG. 3, the method for configuring a USB device according to the first configuration method may include steps 301-303.
步骤301、向USB设备发送预先确定的各个第一配置请求消息。Step 301: Send a predetermined first configuration request message to the USB device.
在本发明的示例性实施例中,当USB设备插入主机时,主机检测到USB 设备之后会为USB设备提供电流,还会向USB设备发送预先确定的各个第一配置请求消息给USB设备。在本发明的实施例中,当USB设备插入主机时,USB设备会以虚拟光驱的方式枚举到主机中,USB设备可以直接安装或者后台推送到主机中,然后主机向USB设备发送预先确定的各个第一配置请求消息。In an exemplary embodiment of the present invention, when the USB device is inserted into the host, the host detects the USB device and then supplies current to the USB device, and also sends a predetermined first configuration request message to the USB device to the USB device. In the embodiment of the present invention, when the USB device is inserted into the host, the USB device is enumerated into the host by means of a virtual optical drive, and the USB device can be directly installed or pushed to the host in the background, and then the host sends the predetermined to the USB device. Each first configuration request message.
步骤302、接收USB设备返回的各个第一配置请求消息对应的第一配置响应消息。Step 302: Receive a first configuration response message corresponding to each first configuration request message returned by the USB device.
在本发明的示例性实施例中,USB设备在接收到主机发送的各个第一配置请求消息之后,USB设备需要针对各个第一配置请求消息返回各自对应的第一配置响应消息。第一配置请求消息与第一配置响应消息的对应关系可以如下述表1所示:In an exemplary embodiment of the present invention, after receiving the respective first configuration request messages sent by the host, the USB device needs to return a corresponding first configuration response message for each first configuration request message. The correspondence between the first configuration request message and the first configuration response message may be as shown in Table 1 below:
第一配置请求消息First configuration request message 第一配置响应消息First configuration response message
第一配置请求消息1First configuration request message 1 第一配置响应消息1First configuration response message 1
第一配置请求消息2First configuration request message 2 第一配置响应消息2First configuration response message 2
... ...
第一配置请求消息MFirst configuration request message M 第一配置响应消息MFirst configuration response message M
表1Table 1
如上述表1所示,第一配置请求消息1对应第一配置响应消息1;第一配置请求消息2对应第一配置响应消息2;…;第一配置请求消息M对应第一配置响应消息M;其中,M为大于等于1的自然数。As shown in the above table 1, the first configuration request message 1 corresponds to the first configuration response message 1; the first configuration request message 2 corresponds to the first configuration response message 2; ...; the first configuration request message M corresponds to the first configuration response message M Where M is a natural number greater than or equal to 1.
步骤303、根据全部第一配置响应消息对USB设备进行配置。Step 303: Configure the USB device according to all the first configuration response messages.
在本发明的示例性实施例中,主机在接收到USB设备返回的全部第一配置响应消息之后,主机可以根据全部第一配置响应消息对USB设备进行配置。在主机对USB设备的配置过程中,主机与USB设备之间的交互主要包括:主机的操作系统的控制器驱动与设备的交互以及主机的功能驱动与USB设备之间的交互。只有两者交互完成,USB设备才能工作正常通信和使用。在本发明的示例性实施例中,主机对USB设备的配置过程主要是主机根据USB设备上报的接口类、接口子类、协议类等主要信息,选择合适的网卡类型和 驱动对USB设备进行适配和驱动加载。In an exemplary embodiment of the present invention, after receiving all the first configuration response messages returned by the USB device, the host may configure the USB device according to all the first configuration response messages. During the host-to-USB device configuration, the interaction between the host and the USB device mainly includes: interaction between the controller driver of the host operating system and the device, and interaction between the function driver of the host and the USB device. Only when the two are interactive, the USB device can work and communicate normally. In an exemplary embodiment of the present invention, the configuration process of the USB device by the host is mainly based on the main information such as the interface class, the interface subclass, and the protocol class reported by the USB device, and the appropriate network card type and driver are selected for the USB device. Match and drive loading.
根据上述的描述可知,通过上述的步骤301~303,主机可以先按照第一工作模式对应的第一配置方法对USB设备进行配置;当主机对USB设备配置失败时,主机可以控制USB设备将其工作模式从第一工作模式适配到第二工作模式,进而主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置。According to the foregoing description, the host may first configure the USB device according to the first configuration method corresponding to the first working mode. When the host fails to configure the USB device, the host may control the USB device to The working mode is adapted from the first working mode to the second working mode, and the host can configure the USB device according to the second configuration method corresponding to the second working mode.
在本发明的示例性实施例中,主机在按照第一工作模式对应的第一配置方法对USB设备进行配置之后,主机可以先判断按照第一配置方法是否对USB设备配置成功;当主机按照第一配置方法对USB设备配置失败时,主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置;当主机按照第一配置方法对USB设备配置成功时,主机可以结束对USB设备的配置流程。In an exemplary embodiment of the present invention, after the host configures the USB device according to the first configuration method corresponding to the first working mode, the host may first determine whether the USB device is successfully configured according to the first configuration method; When the configuration of the USB device fails, the host can configure the USB device according to the second configuration method corresponding to the second working mode. When the host successfully configures the USB device according to the first configuration method, the host can end the USB device. Configuration process.
图4为本发明实施例中判断是否对USB设备配置成功的第一实现方法流程示意图。如图4所示,判断是否对USB设备配置成功的方法可以包括步骤401-步骤403。FIG. 4 is a schematic flowchart of a first implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention. As shown in FIG. 4, the method for determining whether the USB device is successfully configured may include steps 401 to 403.
步骤401、向USB设备发送USB自定义请求指令。Step 401: Send a USB custom request instruction to the USB device.
在本发明的示例性实施例中,主机在按照第一工作模式对应的第一配置方法对USB设备进行配置之后,主机可以向USB设备发送USB自定义请求指令,该USB自定义请求指令主要是用于获取USB设备配置完成信息的,USB设备收到该USB自定义请求指令后需要上报相关的USB信息。在本发明的示例性实施例中,USB自定义请求指令可以通过基于USB标准协议实现。基于USB标准请求扩展的USB自定义请求指令用于获取USB设备配置完成信息,USB自定义请求指令的格式需要符合USB标准协议,例如:USB自定义请求指令的格式可以是:“C0 01 ×× ×× 00 00 00 00”,其中“C0”表示USB自定义请求指令的方向是主机到USB设备,并且“C0”表示该指令是USB自定义请求指令;“01”表示获取配置完成消息。In an exemplary embodiment of the present invention, after the host configures the USB device according to the first configuration method corresponding to the first working mode, the host may send a USB custom request instruction to the USB device, where the USB custom request command is mainly For obtaining the configuration information of the USB device, the USB device needs to report the relevant USB information after receiving the USB custom request command. In an exemplary embodiment of the present invention, the USB custom request instruction may be implemented by a USB-based standard protocol. The USB custom request instruction based on the USB standard request extension is used to obtain the USB device configuration completion information, and the format of the USB custom request instruction needs to conform to the USB standard protocol. For example, the format of the USB custom request instruction may be: “C0 01 ×× × × 00 00 00 00", where "C0" indicates that the direction of the USB custom request instruction is the host to the USB device, and "C0" indicates that the instruction is a USB custom request instruction; "01" indicates that the configuration completion message is acquired.
步骤402、接收USB设备返回的USB自定义响应消息。Step 402: Receive a USB custom response message returned by the USB device.
在本发明的示例性实施例中,USB设备在接收到主机发送的USB自定义请求消息之后,USB设备将对该USB自定义请求指令进行解析,并将配 置完成信息携带在USB自定义响应消息中返回给主机;其中,USB自定义响应消息包括:USB已配置响应消息或者USB未配置响应消息。在本发明的示例性实施例中,USB自定义请求指令和配置完成信息都是主机和USB设备互相协商好的,USB设备向主机返回的USB自定义响应消息的格式也需要符合USB标准协议,比如:“00”表示USB已配置响应消息;“01”表示USB未配置响应消息。In an exemplary embodiment of the present invention, after receiving the USB custom request message sent by the host, the USB device parses the USB custom request command and carries the configuration completion information in the USB custom response message. Returned to the host; wherein the USB custom response message includes: a USB configured response message or a USB unconfigured response message. In an exemplary embodiment of the present invention, the USB custom request instruction and the configuration completion information are mutually negotiated between the host and the USB device, and the format of the USB custom response message returned by the USB device to the host also needs to comply with the USB standard protocol. For example: “00” indicates that the USB has configured a response message; “01” indicates that the USB is not configured with a response message.
步骤403、根据USB自定义响应消息判断是否对USB设备配置成功。Step 403: Determine, according to the USB custom response message, whether the USB device is successfully configured.
在本发明的示例性实施例中,主机可以根据USB设备返回的USB自定义响应消息判断是否对USB设备配置成功。在本发明的示例性实施例中,当USB自定义响应消息为USB已配置响应消息时,表明USB设备的驱动加载和安装正常,主机判定对USB设备配置成功;当USB自定义响应消息为USB未配置响应消息时,表明USB设备的驱动加载或安装不正常,主机判定对USB设备配置失败。In an exemplary embodiment of the present invention, the host may determine whether the USB device configuration is successful according to the USB custom response message returned by the USB device. In an exemplary embodiment of the present invention, when the USB custom response message is a USB configured response message, indicating that the driver loading and installation of the USB device is normal, the host determines that the USB device configuration is successful; when the USB custom response message is USB When the response message is not configured, it indicates that the driver of the USB device is not loaded or installed properly, and the host determines that the configuration of the USB device fails.
根据上述的分析可知,通过上述的步骤401~403,主机可以向USB设备发送USB自定义请求指令,然后主机根据接收到的USB自定义响应消息判断对USB设备是否配置成功。当主机对USB设备配置失败时,主机可以控制USB设备可以将其工作模式从第一工作模式适配到第二工作模式,进而主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置。According to the above analysis, the host can send a USB custom request command to the USB device through the above steps 401-403, and then the host determines whether the USB device is successfully configured according to the received USB custom response message. When the host fails to configure the USB device, the host can control the USB device to adapt its working mode from the first working mode to the second working mode, and the host can perform the USB device according to the second configuration method corresponding to the second working mode. Configuration.
图5为本发明实施例中判断是否对USB设备配置成功的第二实现方法流程示意图。如图5所示,判断是否对USB设备配置成功的方法可以包括以下步骤:FIG. 5 is a schematic flowchart of a second implementation method for determining whether a USB device is successfully configured in an embodiment of the present invention. As shown in FIG. 5, the method for determining whether the USB device is successfully configured may include the following steps:
步骤501、向USB设备发送SCSI请求指令。Step 501: Send a SCSI request instruction to the USB device.
在本发明的示例性实施例中,主机在按照第一工作模式对应的第一配置方法对USB设备进行配置之后,主机可以向USB设备发送SCSI(小型计算机系统接口(Small Computer System Interface,SCSI)请求指令,该SCSI请求指令也是用于获取USB设备配置完成信息的,USB设备收到该SCSI请求指令后需要上报相关的USB信息。在本发明的示例性实施例中,SCSI请求指令可以通过SCSI协议来实现。主机可以和USB设备协商增加一个索引值表示获取配置完成消息的信息,USB设备收到该SCSI请求指令之后,USB 设备可以根据该索引值将配置完成信息上报给主机。In an exemplary embodiment of the present invention, after the host configures the USB device according to the first configuration method corresponding to the first working mode, the host may send the SCSI (Small Computer System Interface (SCSI)) to the USB device. Requesting an instruction, the SCSI request instruction is also used to obtain USB device configuration completion information, and the USB device needs to report related USB information after receiving the SCSI request instruction. In an exemplary embodiment of the present invention, the SCSI request instruction may pass SCSI. The protocol can be implemented. The host can negotiate with the USB device to add an index value to obtain the information about the configuration completion message. After the USB device receives the SCSI request command, the USB device can report the configuration completion information to the host according to the index value.
步骤502、接收USB设备返回的SCSI响应消息。Step 502: Receive a SCSI response message returned by the USB device.
在本发明的示例性实施例中,USB设备在接收到主机发送的SCSI请求指令之后,USB设备将对该SCSI请求指令进行解析,并将配置完成信息携带在SCSI响应消息中返回给主机;其中,SCSI响应消息包括:SCSI已配置响应消息或者SCSI未配置响应消息。在本发明的示例性实施例中,SCSI请求指令和配置完成信息都是主机和USB设备互相协商好的,USB设备向主机返回的SCSI响应消息的格式也需要符合SCSI标准协议。In an exemplary embodiment of the present invention, after receiving the SCSI request command sent by the host, the USB device parses the SCSI request command, and carries the configuration completion information in the SCSI response message and returns it to the host; The SCSI response message includes: a SCSI configured response message or a SCSI unconfigured response message. In an exemplary embodiment of the present invention, both the SCSI request instruction and the configuration completion information are mutually negotiated between the host and the USB device, and the format of the SCSI response message returned by the USB device to the host also needs to conform to the SCSI standard protocol.
步骤503、根据SCSI响应消息判断对USB设备是否配置成功。Step 503: Determine, according to the SCSI response message, whether the USB device is successfully configured.
在本发明的示例性实施例中,主机可以根据USB设备返回的SCSI响应消息判断是否对USB设备配置成功。在本发明的示例性实施例中,当SCSI响应消息为SCSI已配置响应消息时,表明USB设备的驱动加载和安装正常,主机判定对USB设备配置成功;当SCSI响应消息为SCSI未配置响应消息时,表明USB设备的驱动加载或安装不正常,主机判定对USB设备配置失败。In an exemplary embodiment of the present invention, the host may determine whether the USB device configuration is successful according to the SCSI response message returned by the USB device. In an exemplary embodiment of the present invention, when the SCSI response message is a SCSI configured response message, indicating that the driver loading and installation of the USB device is normal, the host determines that the USB device configuration is successful; when the SCSI response message is a SCSI unconfigured response message When it indicates that the driver of the USB device is loaded or not installed properly, the host determines that the configuration of the USB device has failed.
根据上述的分析可知,通过上述的步骤501~503,主机也可以向USB设备发送SCSI请求指令,然后主机根据接收到的SCSI响应消息判断对USB设备是否配置成功。当主机对USB设备配置失败时,主机可以控制USB设备可以将其工作模式从第一工作模式适配到第二工作模式,进而主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置。According to the above analysis, the host can also send a SCSI request command to the USB device through the above steps 501-503, and then the host determines whether the USB device is successfully configured according to the received SCSI response message. When the host fails to configure the USB device, the host can control the USB device to adapt its working mode from the first working mode to the second working mode, and the host can perform the USB device according to the second configuration method corresponding to the second working mode. Configuration.
在本发明的示例性实施例中,当主机对USB设备配置失败时,主机可以控制USB设备将其工作模式从第一工作模式适配到第二工作模式。图6为本发明实施例中主机的操作系统与USB设备的工作模式的对应关系示意图。如图6所示,当主机的操作系统为Windows操作系统时,USB设备工作在第一工作模式下;当主机的操作系统为非Windows操作系统时,USB设备工作在第二工作模式下。在本发明的示例性实施例中,当USB设备对USB设备配置失败时,表明主机使用的操作系统为非Windows操作系统,因此,USB设备需要将自身的工作模式从第一工作模式适配到第二工作模式,这样,USB设备的工作模式就可以与主机使用的非Windows操作系统相对应,USB 设备就可以正常使用。In an exemplary embodiment of the present invention, when the host fails to configure the USB device, the host may control the USB device to adapt its operating mode from the first operating mode to the second operating mode. FIG. 6 is a schematic diagram of correspondence between an operating system of a host and an operating mode of a USB device according to an embodiment of the present invention. As shown in FIG. 6, when the operating system of the host is a Windows operating system, the USB device operates in the first working mode; when the operating system of the host is a non-Windows operating system, the USB device operates in the second working mode. In an exemplary embodiment of the present invention, when the USB device fails to configure the USB device, it indicates that the operating system used by the host is a non-Windows operating system, and therefore, the USB device needs to adapt its working mode from the first working mode to The second mode of operation, in this way, the working mode of the USB device can correspond to the non-Windows operating system used by the host, and the USB device can be used normally.
步骤202、按照第二工作模式对应的第二配置方法对USB设备进行配置。Step 202: Configure the USB device according to the second configuration method corresponding to the second working mode.
在本发明的示例性实施例中,主机在控制USB设备将其工作模式从第一工作模式适配到第二工作模式之后,主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置。图7为本发明实施例中按照第二配置方法对USB设备进行配置的实现方法流程示意图。如图7所示,按照第二配置方法对USB设备进行配置的方法可以包括以下步骤:In an exemplary embodiment of the present invention, after the host controls the USB device to adapt its working mode from the first working mode to the second working mode, the host may perform the USB device according to the second configuration method corresponding to the second working mode. Configuration. FIG. 7 is a schematic flowchart of a method for implementing configuration of a USB device according to a second configuration method according to an embodiment of the present invention. As shown in FIG. 7, the method for configuring a USB device according to the second configuration method may include the following steps:
步骤701、向USB设备发送预先确定的各个第二配置请求消息。Step 701: Send a predetermined second configuration request message to the USB device.
在本发明的示例性实施例中,主机在控制USB设备将其工作模式从第一工作模式适配到第二工作模式之后,主机可以向USB设备发送预先确定的各个第二配置请求消息。In an exemplary embodiment of the present invention, after the host controls the USB device to adapt its operating mode from the first working mode to the second working mode, the host may transmit a predetermined respective second configuration request message to the USB device.
步骤702、接收USB设备返回的各个第二配置请求消息对应的第二配置响应消息。Step 702: Receive a second configuration response message corresponding to each second configuration request message returned by the USB device.
在本发明的示例性实施例中,USB设备在接收到主机发送的各个第二配置请求消息之后,USB设备向主机返回各个第二配置请求消息对应的第二配置响应消息,主机接收USB设备返回的各个第二配置请求消息对应的第二配置响应消息。第二配置请求消息与第二配置响应消息的对应关系可以如下述表2所示:In an exemplary embodiment of the present invention, after receiving the second configuration request message sent by the host, the USB device returns a second configuration response message corresponding to each second configuration request message to the host, and the host receives the USB device return. The second configuration response message corresponding to each of the second configuration request messages. The correspondence between the second configuration request message and the second configuration response message may be as shown in Table 2 below:
第一配置请求消息First configuration request message 第一配置响应消息First configuration response message
第一配置请求消息1First configuration request message 1 第一配置响应消息1First configuration response message 1
第一配置请求消息2First configuration request message 2 第一配置响应消息2First configuration response message 2
... ...
第一配置请求消息MFirst configuration request message M 第一配置响应消息MFirst configuration response message M
表2Table 2
如上述表2所示,第二配置请求消息1对应第二配置响应消息1;第二配置请求消息2对应第二配置响应消息2;…;第二配置请求消息M对应第二配置响应消息M;其中,M为大于等于1的自然数。As shown in the above table 2, the second configuration request message 1 corresponds to the second configuration response message 1; the second configuration request message 2 corresponds to the second configuration response message 2; ...; the second configuration request message M corresponds to the second configuration response message M Where M is a natural number greater than or equal to 1.
步骤703、根据全部第二配置响应消息对USB设备进行配置。Step 703: Configure the USB device according to all the second configuration response messages.
在本发明的示例性实施例中,主机在接收到USB设备返回的全部第二配置响应消息之后,主机可以根据全部第二配置响应消息对USB设备进行配置。在主机对USB设备的配置过程中,主机与USB设备之间的交互主要包括:主机的操作系统的控制器驱动与设备的交互以及主机的功能驱动与USB设备之间的交互。只有两者交互完成,USB设备才能工作正常通信和使用。在本发明的示例性实施例中,主机对USB设备的配置过程主要是主机根据USB设备上报的接口类、接口子类、协议类等主要信息,选择合适的网卡类型和驱动对USB设备进行适配和驱动加载。In an exemplary embodiment of the present invention, after receiving all the second configuration response messages returned by the USB device, the host may configure the USB device according to all the second configuration response messages. During the host-to-USB device configuration, the interaction between the host and the USB device mainly includes: interaction between the controller driver of the host operating system and the device, and interaction between the function driver of the host and the USB device. Only when the two are interactive, the USB device can work and communicate normally. In an exemplary embodiment of the present invention, the configuration process of the USB device by the host is mainly based on the main information such as the interface class, the interface subclass, and the protocol class reported by the USB device, and the appropriate network card type and driver are selected for the USB device. Match and drive loading.
在本发明的示例性实施例中,第一工作模式可以是第一类型的操作系统对应的工作模式;第二工作模式可以是第二类型的操作系统对应的工作模式。第一工作模式可以是主机的操作系统为Windows操作系统时的工作模式,第二工作模式可以是主机的操作系统为非Windows操作系统时的工作模式;或者,第一工作模式可以是主机的操作系统为非Windows操作系统时的工作模式,第二工作模式可以是主机的操作系统为Windows操作系统时的工作模式。相对应的,当第一工作模式为Windows操作系统对应的工作模式时,第一配置方法可以是Windows操作系统对应的配置方法;当第二工作模式为非Windows操作系统对应的工作模式时,第二配置方法可以是非Windows操作系统对应的配置方法。或者,当第一工作模式为非Windows操作系统对应的工作模式时,第一配置方法可以是非Windows操作系统对应的配置方法;当第二工作模式为Windows操作系统对应的工作模式时,第二配置方法可以是Windows操作系统对应的配置方法。In an exemplary embodiment of the present invention, the first working mode may be an operating mode corresponding to the operating system of the first type; and the second working mode may be an operating mode corresponding to the operating system of the second type. The first working mode may be a working mode when the operating system of the host is a Windows operating system, and the second working mode may be a working mode when the operating system of the host is a non-Windows operating system; or the first working mode may be an operation of the host The working mode when the system is a non-Windows operating system, and the second working mode may be a working mode when the operating system of the host is a Windows operating system. Correspondingly, when the first working mode is the working mode corresponding to the Windows operating system, the first configuration method may be a configuration method corresponding to the Windows operating system; when the second working mode is a working mode corresponding to the non-Windows operating system, The second configuration method may be a configuration method corresponding to a non-Windows operating system. Alternatively, when the first working mode is the working mode corresponding to the non-Windows operating system, the first configuration method may be a configuration method corresponding to the non-Windows operating system; when the second working mode is the working mode corresponding to the Windows operating system, the second configuration The method can be a configuration method corresponding to the Windows operating system.
根据上述的描述可知,通过上述的步骤701~703,主机可以按照第二工作模式对应的第二配置方法对USB设备进行配置。因此,和主机只能针对同一个工作模式下的USB设备进行配置的技术方案相比,本发明实施例提出的USB设备的配置方法,可以针对不同工作模式下的USB设备进行配置。According to the above description, the host can configure the USB device according to the second configuration method corresponding to the second working mode. Therefore, compared with the technical solution that the host can only be configured for the USB device in the same working mode, the configuration method of the USB device according to the embodiment of the present invention can be configured for the USB device in different working modes.
在本发明的示例性实施例中,当主机按照第一工作模式对应的第一配置方法对USB设备配置成功时,主机可以结束对USB设备的配置流程;此外,主机按照第二工作模式对应的第二配置方法对USB设备进行配置之后,主机 即可结束对USB设备的配置流程。In an exemplary embodiment of the present invention, when the host successfully configures the USB device according to the first configuration method corresponding to the first working mode, the host may end the configuration process of the USB device; further, the host corresponds to the second working mode. After the second configuration method configures the USB device, the host can end the configuration process of the USB device.
本发明实施例提出的USB设备的配置方法,当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制USB设备将其工作模式从第一工作模式适配到第二工作模式,然后按照第二工作模式对应的第二配置方法对USB设备进行配置。也就是说,在本发明实施例的技术方案中,可以分别针对第一工作模式和第二工作模式下的USB设备进行配置。因此,与主机只能针对同一个工作模式下的USB设备进行配置的技术方案相比,本发明实施例提出的USB设备的配置方法,可以针对不同工作模式下的USB设备进行配置;并且,本发明实施例的技术方案实现简单方便,便于普及,使用范围更广。The method for configuring a USB device according to the embodiment of the present invention, when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, the USB device is controlled to adapt its working mode from the first working mode to the second working mode. The mode is then configured according to the second configuration method corresponding to the second working mode. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately. Therefore, the configuration method of the USB device according to the embodiment of the present invention can be configured for the USB device in different working modes, compared with the technical solution that the host can be configured only for the USB device in the same working mode; The technical solution of the embodiment of the invention is simple and convenient to implement, convenient to popularize, and has a wider use range.
本发明实施例提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令被处理器执行时实现上述的USB设备的配置方法。Embodiments of the present invention provide a computer readable storage medium storing computer executable instructions, which are implemented by a processor to implement the above-described configuration method of a USB device.
图8为本发明实施例中主机的第一组成结构示意图。如图8所示,主机可以包括:控制单元801和配置单元802;其中,FIG. 8 is a schematic diagram of a first component structure of a host according to an embodiment of the present invention. As shown in FIG. 8, the host may include: a control unit 801 and a configuration unit 802;
所述控制单元801,设置成当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;The control unit 801 is configured to control the USB device to adapt its working mode from the first working mode to the second working when the USB device fails to be configured according to the first configuration method corresponding to the first working mode. mode;
所述配置单元802,设置成按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The configuration unit 802 is configured to configure the USB device according to a second configuration method corresponding to the second working mode.
图9为本发明实施例中主机的第二组成结构示意图。如图9所示,所述配置单元802包括:发送子单元8021、接收子单元8022和配置子单元8023;其中,FIG. 9 is a schematic diagram of a second component structure of a host according to an embodiment of the present invention. As shown in FIG. 9, the configuration unit 802 includes: a sending subunit 8021, a receiving subunit 8022, and a configuration subunit 8023;
所述发送子单元8021,设置成向所述USB设备发送预先确定的各个第一配置请求消息;The sending subunit 8021 is configured to send each of the predetermined first configuration request messages to the USB device;
所述接收子单元8022,设置成接收所述USB设备返回的各个第一配置请求消息对应的第一配置响应消息;The receiving sub-unit 8022 is configured to receive a first configuration response message corresponding to each first configuration request message returned by the USB device;
所述配置子单元8023,设置成根据全部第一配置响应消息对所述USB设备进行配置。The configuration subunit 8023 is configured to configure the USB device according to all first configuration response messages.
在示例性的实施方式中,所述控制单元801包括:第一检测子单元8011和第一判断子单元8012;其中,In an exemplary embodiment, the control unit 801 includes: a first detecting subunit 8011 and a first judging subunit 8012;
所述第一检测子单元8011,设置成向所述USB设备发送USB自定义请求指令;接收所述USB设备返回的USB自定义响应消息;其中,所述USB自定义响应消息包括:USB已配置响应消息或者USB未配置响应消息;The first detecting sub-unit 8011 is configured to send a USB custom request instruction to the USB device, and receive a USB custom response message returned by the USB device, where the USB custom response message includes: USB configured a response message or a USB unconfigured response message;
所述第一判断子单元8012,设置成根据所述USB自定义响应消息判断对所述USB设备是否配置成功。The first determining sub-unit 8012 is configured to determine, according to the USB custom response message, whether the USB device is successfully configured.
在示例性的实施方式中,所述第一判断子单元8012,是设置成当所述USB自定义响应消息为所述USB已配置响应消息时,判定对所述USB设备配置成功;当所述USB自定义响应消息为所述USB未配置响应消息时,判定对所述USB设备配置失败。In an exemplary embodiment, the first determining sub-unit 8012 is configured to determine that the USB device configuration is successful when the USB custom response message is the USB configured response message; When the USB custom response message is the USB unconfigured response message, it is determined that the configuration of the USB device fails.
图10为本发明实施例中主机的第三组成结构示意图。如图10所示,所述控制单元801包括:第二检测子单元8013和第二判断子单元8014;其中,FIG. 10 is a schematic diagram of a third component structure of a host according to an embodiment of the present invention. As shown in FIG. 10, the control unit 801 includes: a second detecting subunit 8013 and a second judging subunit 8014;
所述第二检测子单元8013,设置成向所述USB设备发送SCSI请求指令;接收所述USB设备返回的SCSI响应消息;其中,所述SCSI响应消息包括:SCSI已配置响应消息或者SCSI未配置响应消息;The second detecting subunit 8013 is configured to send a SCSI request instruction to the USB device, and receive a SCSI response message returned by the USB device, where the SCSI response message includes: a SCSI configured response message or a SCSI unconfigured Response message
所述第二判断子单元8014,设置成根据所述SCSI响应消息判断对所述USB设备是否配置成功。The second determining subunit 8014 is configured to determine whether the USB device is successfully configured according to the SCSI response message.
在示例性的实施方式中,所述发送子单元8021,还设置成向所述USB设备发送预先确定的各个第二配置请求消息;In an exemplary embodiment, the sending subunit 8021 is further configured to send a predetermined second configuration request message to the USB device;
所述接收子单元8022,还设置成接收所述USB设备返回的各个第二配置请求消息对应的第二配置响应消息;The receiving sub-unit 8022 is further configured to receive a second configuration response message corresponding to each second configuration request message returned by the USB device;
所述配置子单元8023,还设置成根据全部第二配置响应消息对所述USB设备进行配置。The configuration sub-unit 8023 is further configured to configure the USB device according to all the second configuration response messages.
在示例性的实施方式中,所述第一工作模式为第一类型的操作系统对应的工作模式;所述第二工作模式为第二类型的操作系统对应的工作模式。In an exemplary embodiment, the first working mode is an operating mode corresponding to a first type of operating system; and the second working mode is a working mode corresponding to a second type of operating system.
在实际应用中,所述控制单元801和配置单元802均可由位于主机中的中央处理器(CPU)、微处理器(MPU)、数字信号处理器(DSP)、或现 场可编程门阵列(FPGA)等实现。In practical applications, the control unit 801 and the configuration unit 802 may each be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA) located in the host. ) and so on.
另外,在本实施例中的各个单元可以单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, the respective units in the present embodiment may exist physically separately, or two or more units may be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software function module.
所述集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个可读取存储介质中,基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一台主机(可以是个人移动终端,服务器,或者网络设备等)或processor(处理器)执行本实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit can be stored in a readable storage medium if it is implemented in the form of a software function module and is not sold or used as a stand-alone product. Based on such understanding, the technical solution of the embodiment is essentially or The portion contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including a plurality of instructions for causing a host (which may be a personal mobile device) A terminal, a server, or a network device, or the like, or a processor, performs all or part of the steps of the method described in this embodiment. The foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes.
本实施例中USB设备的配置方法对应的程序指令可以被存储在光盘,硬盘,U盘等存储介质上,当存储介质中的与USB设备的配置方法对应的程序指令被一电子设备读取或被执行时,包括如下步骤:The program instructions corresponding to the configuration method of the USB device in this embodiment may be stored on a storage medium such as an optical disk, a hard disk, a USB disk, or the like, and the program instructions corresponding to the configuration method of the USB device in the storage medium are read by an electronic device or When executed, the following steps are included:
当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controlling the USB device to adapt its working mode from the first working mode to the second working mode;
按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The USB device is configured according to a second configuration method corresponding to the second working mode.
本发明实施例提出的主机,当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制USB设备将其工作模式从第一工作模式适配到第二工作模式,然后按照第二工作模式对应的第二配置方法对USB设备进行配置。也就是说,在本发明实施例的技术方案中,可以分别针对第一工作模式和第二工作模式下的USB设备进行配置。因此,与主机只能针对同一个工作模式下的USB设备进行配置的技术方案相比,本发明实施例提出的主机,可以针对不同工作模式下的USB设备进行配置;并且,本发明实施例的技术方案实现简单方便,便于普及,使用范围更广。The host device of the embodiment of the present invention, when the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controls the USB device to adapt its working mode from the first working mode to the second working mode, and then according to The second configuration method corresponding to the second working mode configures the USB device. That is to say, in the technical solution of the embodiment of the present invention, the USB device in the first working mode and the second working mode may be configured separately. Therefore, compared with the technical solution that the host can be configured only for the USB device in the same working mode, the host provided by the embodiment of the present invention can be configured for the USB device in different working modes; and, in the embodiment of the present invention, The technical solution is simple and convenient to implement, easy to popularize, and has a wider range of use.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、装置中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组 合。在硬件实施方式中,在以上描述中提及的功能模块/单元之间的划分不一定对应于物理组件的划分;例如,一个物理组件可以具有多个功能,或者一个功能或步骤可以由若干物理组件合作执行。某些组件或所有组件可以被实施为由处理器,如数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于随机存取存储器(RAM,Random Access Memory)、只读存储器(ROM,Read-Only Memory)、电可擦除只读存储器(EEPROM,Electrically Erasable Programmable Read-only Memory)、闪存或其他存储器技术、光盘只读存储器(CD-ROM,Compact Disc Read-Only Memory)、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those of ordinary skill in the art will appreciate that all or some of the steps, systems, and functional blocks/units of the methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be composed of several physical The components work together. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer readable medium, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and nonvolatile, implemented in any method or technology for storing information, such as computer readable instructions, data structures, program modules or other data. Sex, removable and non-removable media. Computer storage media include, but are not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), and Electrically Erasable Programmable Read-only Memory (EEPROM). Flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cassette, magnetic tape, disk storage or other magnetic storage device, or Any other medium used to store the desired information and that can be accessed by the computer. Moreover, it is well known to those skilled in the art that communication media typically includes computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and can include any information delivery media. .
本领域的普通技术人员可以理解,可以对本申请的技术方案进行修改或者等同替换,而不脱离本申请技术方案的精神和范围,均应涵盖在本申请的权利要求范围当中。A person skilled in the art can understand that the technical solutions of the present application can be modified or equivalent, without departing from the spirit and scope of the technical solutions of the present application, and should be included in the scope of the claims of the present application.
工业实用性Industrial applicability
通过本发明实施例提出的USB设备的配置方法及主机,可以针对不同工作模式下的USB设备进行配置;并且,本发明实施例的技术方案实现简单方便,便于普及,使用范围更广。The configuration method and the host of the USB device provided by the embodiment of the present invention can be configured for the USB device in different working modes. Moreover, the technical solution of the embodiment of the present invention is simple and convenient to implement, popularized, and widely used.

Claims (15)

  1. 一种通用串行总线USB设备的配置方法,包括:A method for configuring a universal serial bus USB device, comprising:
    当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controlling the USB device to adapt its working mode from the first working mode to the second working mode;
    按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The USB device is configured according to a second configuration method corresponding to the second working mode.
  2. 根据权利要求1所述的方法,其中,按照第一工作模式对应的第一配置方法对USB设备进行配置,包括:The method of claim 1, wherein configuring the USB device according to the first configuration method corresponding to the first working mode comprises:
    向所述USB设备发送预先确定的各个第一配置请求消息;Sending each of the predetermined first configuration request messages to the USB device;
    接收所述USB设备返回的各个第一配置请求消息对应的第一配置响应消息;Receiving a first configuration response message corresponding to each first configuration request message returned by the USB device;
    根据全部第一配置响应消息对所述USB设备进行配置。The USB device is configured according to all first configuration response messages.
  3. 根据权利要求1所述的方法,所述方法还包括:The method of claim 1 further comprising:
    向所述USB设备发送USB自定义请求指令;Sending a USB custom request instruction to the USB device;
    接收所述USB设备返回的USB自定义响应消息;Receiving a USB custom response message returned by the USB device;
    根据所述USB自定义响应消息判断对所述USB设备是否配置成功。Determining whether the USB device is successfully configured according to the USB custom response message.
  4. 根据权利要求3所述的方法,其中,所述根据所述USB自定义响应消息判断对所述USB设备是否配置成功,包括:The method of claim 3, wherein the determining, according to the USB custom response message, whether the USB device is successfully configured comprises:
    当所述USB自定义响应消息为USB已配置响应消息时,判定对所述USB设备配置成功;When the USB custom response message is a USB configured response message, determining that the USB device is successfully configured;
    当所述USB自定义响应消息为USB未配置响应消息时,判定对所述USB设备配置失败。When the USB custom response message is a USB unconfigured response message, it is determined that the configuration of the USB device fails.
  5. 根据权利要求1所述的方法,所述方法还包括:The method of claim 1 further comprising:
    向所述USB设备发送小型计算机系统接口SCSI请求指令;Sending a small computer system interface SCSI request command to the USB device;
    接收所述USB设备返回的SCSI响应消息;Receiving a SCSI response message returned by the USB device;
    根据所述SCSI响应消息判断对所述USB设备是否配置成功。Determining whether the USB device is successfully configured according to the SCSI response message.
  6. 根据权利要求1所述的方法,其中,所述按照所述第二工作模式对应 的第二配置方法对所述USB设备进行配置,包括:The method of claim 1, wherein the configuring the USB device according to the second configuration method corresponding to the second working mode comprises:
    向所述USB设备发送预先确定的各个第二配置请求消息;Sending each predetermined second configuration request message to the USB device;
    接收所述USB设备返回的各个第二配置请求消息对应的第二配置响应消息;Receiving a second configuration response message corresponding to each second configuration request message returned by the USB device;
    根据全部第二配置响应消息对所述USB设备进行配置。The USB device is configured according to all second configuration response messages.
  7. 根据权利要求1至6任一项所述的USB设备的配置方法,其中,所述第一工作模式为第一类型的操作系统对应的工作模式;所述第二工作模式为第二类型的操作系统对应的工作模式。The configuration method of the USB device according to any one of claims 1 to 6, wherein the first working mode is an operating mode corresponding to a first type of operating system; and the second working mode is a second type of operation The corresponding working mode of the system.
  8. 一种主机,包括:控制单元和配置单元;其中,A host includes: a control unit and a configuration unit; wherein
    所述控制单元,设置成当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;The control unit is configured to control the USB device to adapt its working mode from the first working mode to the second working mode when the USB device fails to be configured according to the first configuration method corresponding to the first working mode. ;
    所述配置单元,设置成按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The configuration unit is configured to configure the USB device according to a second configuration method corresponding to the second working mode.
  9. 根据权利要求8所述的主机,其中,所述配置单元包括:发送子单元、接收子单元和配置子单元;其中,The host according to claim 8, wherein the configuration unit comprises: a transmitting subunit, a receiving subunit, and a configuration subunit; wherein
    所述发送子单元,设置成向所述USB设备发送预先确定的各个第一配置请求消息;The sending subunit is configured to send each of the predetermined first configuration request messages to the USB device;
    所述接收子单元,设置成接收所述USB设备返回的各个第一配置请求消息对应的第一配置响应消息;The receiving subunit is configured to receive a first configuration response message corresponding to each first configuration request message returned by the USB device;
    所述配置子单元,设置成根据全部第一配置响应消息对所述USB设备进行配置。The configuration subunit is configured to configure the USB device according to all first configuration response messages.
  10. 根据权利要求8所述的主机,其中,所述控制单元包括:第一检测子单元和第一判断子单元;其中,The host according to claim 8, wherein the control unit comprises: a first detecting subunit and a first judging subunit; wherein
    所述第一检测子单元,设置成向所述USB设备发送USB自定义请求指令;接收所述USB设备返回的USB自定义响应消息;The first detecting subunit is configured to send a USB custom request instruction to the USB device, and receive a USB custom response message returned by the USB device;
    所述第一判断子单元,设置成根据所述USB自定义响应消息判断对所述 USB设备是否配置成功。The first determining subunit is configured to determine, according to the USB custom response message, whether the USB device is successfully configured.
  11. 根据权利要求10所述的主机,其中,所述第一判断子单元,是设置成当所述USB自定义响应消息为USB已配置响应消息时,判定对所述USB设备配置成功;当所述USB自定义响应消息为USB未配置响应消息时,判定对所述USB设备配置失败。The host according to claim 10, wherein the first determining subunit is configured to determine that the USB device is successfully configured when the USB custom response message is a USB configured response message; When the USB custom response message is a USB unconfigured response message, it is determined that the configuration of the USB device fails.
  12. 根据权利要求8所述的主机,其中,所述控制单元包括:第二检测子单元和第二判断子单元;其中,The host according to claim 8, wherein the control unit comprises: a second detecting subunit and a second judging subunit; wherein
    所述第二检测子单元,设置成向所述USB设备发送SCSI请求指令;接收所述USB设备返回的SCSI响应消息;The second detecting subunit is configured to send a SCSI request instruction to the USB device, and receive a SCSI response message returned by the USB device;
    所述第二判断子单元,设置成根据所述SCSI响应消息判断对所述USB设备是否配置成功。The second determining subunit is configured to determine, according to the SCSI response message, whether the USB device is successfully configured.
  13. 根据权利要求12所述的主机,其中,所述发送子单元,还设置成向所述USB设备发送预先确定的各个第二配置请求消息;The host according to claim 12, wherein the sending subunit is further configured to send a predetermined second configuration request message to the USB device;
    所述接收子单元,还设置成接收所述USB设备返回的各个第二配置请求消息对应的第二配置响应消息;The receiving subunit is further configured to receive a second configuration response message corresponding to each second configuration request message returned by the USB device;
    所述配置子单元,还设置成根据全部第二配置响应消息对所述USB设备进行配置。The configuration subunit is further configured to configure the USB device according to all the second configuration response messages.
  14. 根据权利要求8-13任一项所述的主机,其中,所述第一工作模式为第一类型的操作系统对应的工作模式;所述第二工作模式为第二类型的操作系统对应的工作模式。The host according to any one of claims 8 to 13, wherein the first working mode is a working mode corresponding to a first type of operating system; and the second working mode is a work corresponding to a second type of operating system. mode.
  15. 一种存储介质,存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现以下步骤:A storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the following steps:
    当按照第一工作模式对应的第一配置方法对USB设备进行配置失败时,控制所述USB设备将其工作模式从所述第一工作模式适配到第二工作模式;When the configuration of the USB device fails according to the first configuration method corresponding to the first working mode, controlling the USB device to adapt its working mode from the first working mode to the second working mode;
    按照所述第二工作模式对应的第二配置方法对所述USB设备进行配置。The USB device is configured according to a second configuration method corresponding to the second working mode.
PCT/CN2018/075115 2017-04-14 2018-02-02 Usb device configuration method and host WO2018188404A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710244472.5A CN108733519B (en) 2017-04-14 2017-04-14 Configuration method of USB (universal serial bus) equipment and host
CN201710244472.5 2017-04-14

Publications (1)

Publication Number Publication Date
WO2018188404A1 true WO2018188404A1 (en) 2018-10-18

Family

ID=63792256

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/075115 WO2018188404A1 (en) 2017-04-14 2018-02-02 Usb device configuration method and host

Country Status (2)

Country Link
CN (1) CN108733519B (en)
WO (1) WO2018188404A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063320A (en) * 2011-01-06 2011-05-18 华为终端有限公司 Work mode switching methods, USB (Universal Serial Bus) equipment and host machine equipment
CN102981981A (en) * 2012-11-20 2013-03-20 中兴通讯股份有限公司 USB (Universal Serial Bus) equipment, communication system and working mode switching method thereof
CN104516842A (en) * 2013-09-29 2015-04-15 中兴通讯股份有限公司 Method for universal serial bus (USB) equipment quick adaptation operating system and USB equipment
CN104881388A (en) * 2015-06-12 2015-09-02 哈尔滨工业大学 FPGA (field programmable gate array) based USB3.0 interface module
CN105120123A (en) * 2015-09-15 2015-12-02 烽火通信科技股份有限公司 Working mode selection system based on DSL link

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117251A (en) * 2009-12-31 2011-07-06 比亚迪股份有限公司 Method for selecting application mode of universal serial bus (USB) equipment and USB equipment
US8661164B2 (en) * 2010-08-24 2014-02-25 Mediatek Inc. Method of USB device enumeration including detecting the operating system type of the USB host
CN101957807B (en) * 2010-09-16 2012-08-08 飞天诚信科技股份有限公司 Method for USB device to recognize version type of Windows operating system
EP2719248A2 (en) * 2011-06-10 2014-04-16 Yota Devices IPR Ltd Method of installing a driver to emulate a network card
CN104156328B (en) * 2013-05-15 2019-02-05 中兴通讯股份有限公司 A kind of method and USB device identifying OS Type

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063320A (en) * 2011-01-06 2011-05-18 华为终端有限公司 Work mode switching methods, USB (Universal Serial Bus) equipment and host machine equipment
CN102981981A (en) * 2012-11-20 2013-03-20 中兴通讯股份有限公司 USB (Universal Serial Bus) equipment, communication system and working mode switching method thereof
CN104516842A (en) * 2013-09-29 2015-04-15 中兴通讯股份有限公司 Method for universal serial bus (USB) equipment quick adaptation operating system and USB equipment
CN104881388A (en) * 2015-06-12 2015-09-02 哈尔滨工业大学 FPGA (field programmable gate array) based USB3.0 interface module
CN105120123A (en) * 2015-09-15 2015-12-02 烽火通信科技股份有限公司 Working mode selection system based on DSL link

Also Published As

Publication number Publication date
CN108733519B (en) 2022-08-16
CN108733519A (en) 2018-11-02

Similar Documents

Publication Publication Date Title
US10152443B2 (en) System and method for providing personality switching in a solid state drive device
US9600294B2 (en) Port throttling across an operating system restart during a hot upgrade
US9875093B2 (en) Rack server device firmware update using network switch
CN103412769B (en) External card parameter configuration, equipment and system
RU2614569C2 (en) Rack with automatic recovery function and method of automatic recovery for this rack
US10761730B2 (en) Method for configuring disk array of electronic device and related electronic device
WO2018054026A1 (en) Electronic terminal, and device and method for managing application program
US20170177380A1 (en) Motherboard and a method for boot-up
US9239807B2 (en) Providing bus resiliency in a hybrid memory system
CN114615527A (en) Hot-plug equipment information transmission method, computer equipment and readable medium
WO2018188404A1 (en) Usb device configuration method and host
US11586509B2 (en) Operating system repairs via electronic devices
US20180074981A1 (en) Associating data buses and management bus connections for peripheral devices
US9977757B2 (en) Prevented inter-integrated circuit address conflict service system and method thereof
US20140325198A1 (en) Electronic device and loading method of control program
US20240134631A1 (en) Information handling system with a dynamic basic input/output system configuration map
US20240134652A1 (en) Computer and method of booting computer
US20140317331A1 (en) External electronic device and interface controller and external electronic device control method
US20090157840A1 (en) Controlling Shared Access Of A Media Tray
CN107451035B (en) Error state data providing method for computer device
TW201642127A (en) Motherboard and method for booting
JP6364819B2 (en) Information processing apparatus, information processing system, activation control method, and program
CN117827297A (en) Sideband bare engine provisioning
CN114003535A (en) Equipment bandwidth configuration method and system, electronic equipment and storage medium
CN117369841A (en) Firmware activation method, device, related equipment and computer readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18784809

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18784809

Country of ref document: EP

Kind code of ref document: A1