Device communication method, system, apparatus, device, storage medium and program product
Through virtualization technology, the USB device is mapped to the same UDC and dynamically switched the virtual device configuration when the physical device combination is updated, solving the problem of low communication efficiency of USB devices and achieving efficient device communication.
Patent Information
- Application Number
- CN202411037039.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2044-07-31
AI Technical Summary
In the prior art, USB devices need to re-enumerate all devices when plugging and unplugging, resulting in low communication efficiency and unable to meet the efficient communication needs of multiple USB devices.
Through virtualization technology, different types of USB devices are mapped to the same hardware UDC, managed using software, and dynamically switched the configuration of virtual devices when physical device combinations are updated to avoid all devices re-enumerating device addresses.
Improve the efficiency of device communication, reduce the enumeration process during physical device updates, and improve the flexibility and efficiency of device communication.
Smart Images

Figure CN118568015B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer device communication technology, and in particular to a device communication method, system, apparatus, electronic device, computer-readable storage medium and computer program product. Background Art
[0002] In the Universal Serial Bus (USB) specification, different types of USB devices usually need to be implemented by independent USB device controllers (UDC) to ensure that they do not affect each other during device enumeration and device interaction. The Baseboard Management Controller (BMC) has UDC, but it cannot meet the communication needs of multiple USB devices.
[0003] Currently, through virtualization technology, different types of USB devices can be mapped to the same hardware UDC and managed using software, so that one UDC can meet the communication needs of multiple USB devices.
[0004] However, the above USB devices are all mapped to the same UDC. When the device is plugged in or out, all USB devices on the UDC need to be re-enumerated, which is cumbersome and reduces the communication efficiency of the devices. Summary of the invention
[0005] Embodiments of the present invention provide a device communication method, system, apparatus, electronic device, computer-readable storage medium, and computer program product to solve the problem of low device communication efficiency in the prior art.
[0006] In a first aspect, an embodiment of the present invention provides a device communication method, the method comprising:
[0007] When determining that the physical device combination currently connected to the host corresponds to the first virtual device, based on a first configuration of the first virtual device, the first virtual device is communicatively connected to the host controller; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller;
[0008] When the physical device connected to the host is updated, determining the second virtual device associated with the first virtual device according to the updated physical device combination;
[0009] Based on a second configuration of the second virtual device, switching is performed to enable the second virtual device to communicate with the host controller; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller.
[0010] In a second aspect, an embodiment of the present invention provides a device communication system, the system comprising:
[0011] A host and a physical device; the host includes a communication configuration module, a device controller and a host controller;
[0012] The communication configuration module is connected to the host controller and the device controller, the host controller is connected to the device controller, the device controller is connected to the virtual device through the communication port, and the physical device is connected to the host;
[0013] The communication configuration module is used to execute the steps in the device communication method described in the first aspect above.
[0014] In a third aspect, an embodiment of the present invention provides a device communication apparatus, the apparatus comprising:
[0015] A first device communication module, configured to, when determining that a physical device combination currently connected to the host corresponds to a first virtual device, connect the first virtual device to a host controller based on a first configuration of the first virtual device; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller;
[0016] A physical device update module, configured to determine, when the physical device connected to the host is updated, the second virtual device associated with the first virtual device according to the updated physical device combination;
[0017] The second device communication module is used to switch to the communication connection between the second virtual device and the host controller based on the second configuration of the second virtual device; the second configuration includes a second communication port for connecting the second virtual device and the device controller and a second device address for configuring the device controller.
[0018] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising: a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0019] Memory, used to store computer programs;
[0020] The processor is used to implement the steps in the device communication method described in the first aspect when executing the program stored in the memory.
[0021] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the device communication method described in the first aspect above.
[0022] In a sixth aspect, an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in the device communication method described in the first aspect above.
[0023] Compared with the prior art, the present invention has the following advantages:
[0024] In an embodiment of the present invention, a physical device combination formed by at least one physical device currently connected to the host can be mapped to a first virtual device, and communication can be performed using a first configuration of the first virtual device. Moreover, when the physical device is updated, a second virtual device associated with the first virtual device can be determined, and then the second configuration of the second virtual device can be directly switched to communicate based on the corresponding communication port and device address. This avoids the problem that when the physical device is updated, all physical devices in the virtual device need to be re-enumerated to determine the corresponding device addresses before communication can be performed, thereby improving the efficiency of device communication.
[0025] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for describing the embodiments are briefly introduced below.
[0027] Figure 1 A step diagram of a device communication method provided by an embodiment of the present invention;
[0028] Figure 2 A schematic diagram of the architecture of device communication provided by an embodiment of the present invention;
[0029] Figure 3 A schematic diagram of a virtual device and a communication port provided by an embodiment of the present invention;
[0030] Figure 4 A step diagram of another device communication method provided by an embodiment of the present invention;
[0031] Figure 5A software stack diagram of a virtual hub provided by an embodiment of the present invention;
[0032] Figure 6 A flowchart of device enumeration provided for an embodiment of the present invention;
[0033] Figure 7 A schematic diagram of a device change state machine provided by an embodiment of the present invention;
[0034] Figure 8 A schematic diagram of the function implementation of a virtual hub provided by an embodiment of the present invention;
[0035] Fig. 9 A schematic diagram of a device communication system provided by an embodiment of the present invention;
[0036] Fig.10 A schematic diagram of a device communication apparatus provided by an embodiment of the present invention;
[0037] Fig.11 A block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can also be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0039] With the rapid development of information technology, the importance of the BMC of server nodes in maintaining the normal operation of data centers has become increasingly prominent. With the continuous enrichment of peripheral types, the functions of BMC have become more and more powerful. The keyboard, video, mouse (KVM) function is one of the most basic functions of BMC, which is used to implement remote monitoring and other operations, thereby ensuring the remote management capabilities of the server. Using KVM technology, BMC can implement devices such as mouse, keyboard, network card and virtual media internally. At present, the number of USBs is increasing, but the growth rate of internal resources of BMC chips is slow, and the cost of hardware expansion is high.
[0040] Therefore, virtual USB hubs and virtual USB devices are proposed. Through virtualization technology, different types of USB devices can be mapped to the same hardware UDC as a virtual USB device and managed by software. This method effectively reuses the hardware resources of many low-speed USB devices and greatly reduces hardware costs. However, when enumerating devices, UDC is used as the smallest unit. As a result, USB devices mapped to the same UDC are highly bound and can only be enumerated or uninstalled at the same time. Whenever the status of a USB device changes, all devices need to be re-enumerated. This process will reallocate addresses for all devices, which is very inefficient, and users can also see the status changes of these devices from the host side.
[0041] Figure 1 1 is a step diagram of a device communication method provided by an embodiment of the present invention, the method comprising:
[0042] Step 101, when it is determined that the physical device combination currently connected to the host corresponds to the first virtual device, based on the first configuration of the first virtual device, the first virtual device is communicatively connected to the host controller; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller;
[0043] In the embodiment of the present disclosure, the execution subject of the device communication method may be a BMC, and a software virtual hub (virtual USB Hub) may be implemented in the BMC, and each method step is executed by the virtual USB Hub. The virtual hub may have an upstream port and several downstream ports, the upstream port is connected to a USB host controller (UHC, USB Host Controller), and the downstream port is connected to a device controller (UDC).
[0044] The host can be connected to at least one physical device (USB device), such as a mouse, keyboard, etc., and a physical device combination can be formed based on at least one physical device. Each virtual device corresponds to a physical device combination, that is, corresponds to multiple physical devices. A corresponding configuration can be generated in advance for each virtual device, including a communication port (downstream port in a virtual hub) for connecting the virtual device and the device controller, and the configuration also includes a device address for configuring the device controller.
[0045] It can be understood that the device address refers to the device address corresponding to the virtual device. Since the virtual device corresponds to multiple physical devices, the device address corresponding to the virtual device can be a collection of sub-device addresses corresponding to multiple physical devices respectively, and each physical device communicates based on its corresponding sub-device address; it can also be one or more device addresses that do not correspond to multiple physical devices, and multiple physical devices use the one or more device addresses to communicate.
[0046] The device address is configured to the device controller, and the virtual device and the host controller can communicate based on the device controller configured with the device address. When it is determined that the physical device combination currently connected to the host corresponds to the first virtual device, the first virtual device can be connected to the host controller for communication based on the first configuration of the first virtual device.
[0047] Figure 2 is a schematic diagram of the architecture of device communication provided by an embodiment of the present disclosure; Figure 2 The baseboard management controller 201 in the host and the physical device 202 are included. The baseboard management controller 201 includes a virtual hub, a device controller, a host controller, and an Ethernet module (Ethereum). Among them, the virtual hub is implemented by software, and the device controller, the host controller, and the Ethernet module are implemented by hardware.
[0048] Figure 3 is a schematic diagram of a virtual device and a communication port provided by an embodiment of the present disclosure; Figure 3 The device combination logic of the virtual USB Hub is shown, taking the mouse, keyboard and hard disk as examples. A virtual USB Hub is connected to the host controller through a single upstream port and is associated with multiple virtual devices 302 through multiple communication ports (downstream ports) 301. Multiple virtual devices 302 share a UDC, but only one virtual device can be enabled at the same time. These virtual devices include commonly used physical device combinations, and each physical device is configured with an input (IN) endpoint or an output (OUT) endpoint by the virtual USB Hub.
[0049] Step 102, when the physical device connected to the host is updated, determine the second virtual device associated with the first virtual device according to the updated physical device combination;
[0050] In the disclosed embodiment, when the physical device connected to the host is updated, such as an update caused by plugging and unplugging the physical device, the updated physical device combination can be determined based on the physical device connected after the update. Since the virtual device is actually a combination of physical devices, it can be matched to determine the second virtual device corresponding to the current physical device combination. Since the physical device corresponds to the first virtual device before the update and corresponds to the second virtual device after the update, the physical devices corresponding to the first virtual device and the second virtual device are similar, and there is an association between the first virtual device and the second virtual device.
[0051] For example, the host is initially connected with a mouse, a keyboard, and a hard disk, which correspond to the first virtual device, and then the keyboard is unplugged, that is, the keyboard is uninstalled, and the physical device connected at this time is updated. According to the updated physical device combination, namely the mouse and the hard disk, a second virtual device can be determined, and the second virtual device includes the mouse and the hard disk.
[0052] Step 103, based on a second configuration of the second virtual device, switching to a communication connection between the second virtual device and the host controller; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller.
[0053] In the disclosed embodiment, since each virtual device corresponds to a different communication port, when switching to the second virtual device to communicate with the host controller based on the second configuration of the second virtual device, the second virtual device and the device controller need to be connected through the second communication port in the second configuration corresponding to the second virtual device. In addition, the device controller needs to be configured based on the second device address so that the host controller can communicate with the second virtual device based on the device controller configured with the second device address.
[0054] In summary, in the embodiments of the present invention, a physical device combination formed by at least one physical device currently connected to the host can be mapped to a first virtual device, and communication can be performed using a first configuration of the first virtual device. Moreover, when the physical device is updated, the second virtual device associated with the first virtual device can be determined, and then the second configuration of the second virtual device can be directly switched to communicate based on the corresponding communication port and device address. This avoids the problem that when the physical device is updated, all physical devices in the virtual device need to be re-enumerated to determine the corresponding device addresses before communication can be performed, thereby improving the efficiency of device communication.
[0055] Figure 4 It is a step diagram of another device communication method provided by the present invention.
[0056] Step 401, when it is determined that the physical device combination currently connected to the host corresponds to the first virtual device, based on the first configuration of the first virtual device, the first virtual device is communicatively connected to the host controller; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller;
[0057] Step 402, when the physical device connected to the host is updated, determine the second virtual device associated with the first virtual device according to the updated physical device combination;
[0058] Step 403: Based on a second configuration of the second virtual device, switch to a communication connection between the second virtual device and the host controller; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller.
[0059] For details of steps 401-403, please refer to the above Figure 1 The contents of the embodiments will not be repeated here.
[0060] Optionally, the device controller includes an address register; and the method further includes:
[0061] Step A1, sending an address allocation request to the host controller;
[0062] Step A2, receiving the third device address returned by the host controller, and writing the third device address into the address register; the host controller communicates based on the third device address.
[0063] In the disclosed embodiment, in the USB architecture, the device needs to be enumerated by the UHC and assigned a device address before it can communicate normally with the UHC. As a special USB device, the virtual USB Hub should first be assigned an address, and then it can be used as a medium to transmit the information sent by the UHC for subsequent physical device enumeration. Therefore, for the virtual USB Hub, the third device address corresponding to the virtual USB Hub can be obtained.
[0064] The virtual USB Hub can send an address allocation request to the UHC, which can carry physical device information to indicate the physical device currently connected to the host, the communication port number, etc. After receiving the address allocation request, the UHC returns the allocated third device address to the virtual USB Hub of the BMC, and the virtual USB Hub writes the device address to the address register, and then the virtual USB Hub can communicate with the UHC based on the device address.
[0065] Optionally, the method further includes:
[0066] Step B1, combining at least one physical device to obtain the first virtual device and the second virtual device; each virtual device corresponds to a respective physical device combination;
[0067] Step B2, associate each virtual device with a different communication port, and obtain the device address corresponding to each virtual device to generate the first configuration including the first communication port and the first device address and the second configuration including the second communication port and the second device address.
[0068] In the disclosed embodiment, at least one physical device may be combined, and each physical device combination obtained may be used as a virtual device to obtain a first virtual device and a second virtual device, and more virtual devices may also be included. For example, the physical device combination "mouse, keyboard" may be used as the first virtual device, and the physical device combination "mouse, keyboard, hard disk" may be used as the second virtual device.
[0069] Each virtual device can be associated with its own corresponding communication port, and different virtual devices are isolated through the communication port. When a specific virtual device needs to be used, the device controller is connected through the corresponding port, so that the specific virtual device can establish communication with the host controller.
[0070] Finally, a corresponding configuration may be generated based on the communication port and device address of each virtual device, for example, a first configuration including a first communication port and a first device address and a second configuration including a second communication port and a second device address.
[0071] Optionally, the address allocation request carries a port query interval; the step of associating each virtual device with a different communication port and obtaining a device address corresponding to each virtual device includes:
[0072] receiving a port query instruction returned by the host controller; the port query instruction is generated based on the port query interval;
[0073] In response to the port query instruction, determining a virtual device sequence including each virtual device according to the number of physical devices corresponding to the virtual device;
[0074] Associating the virtual devices in the virtual device sequence with the communication ports one by one;
[0075] The address register is set to a preset value to obtain a device address corresponding to each virtual device.
[0076] In the disclosed embodiment, the address allocation request sent to the UHC may also carry a port query interval. The UHC may continuously generate port query instructions according to the port query interval, and send the port query instructions to the virtual USB Hub. In response to the port query instruction, the virtual USB Hub may sort the virtual devices according to the number of physical devices corresponding to the virtual devices, and determine a virtual device sequence including each virtual device. It is understandable that, since different physical devices also correspond to different endpoints, the virtual devices may be sorted based on the number of endpoints of the virtual devices corresponding to multiple physical devices. According to actual needs, sorting may also be performed based on other parameters to form a virtual device sequence, which is not limited here.
[0077] Associate the virtual devices in the virtual device sequence with the communication ports of the virtual USB Hub one by one. In addition, set the address register to a preset value to obtain the corresponding device address of the virtual device. Since the virtual device is also a device that needs to communicate with the UHC, it is necessary to determine the corresponding device address and obtain the corresponding device address from the virtual USB Hub. Similarly, the virtual device needs to interact with the UHC to obtain the device address assigned by the UHC. Setting the address register to a preset value, such as 0, can transfer the right to use the UDC to the virtual device, and then the virtual device can interact with the UHC and obtain its own device address, and then store the device address in the address register.
[0078] Optionally, the number of physical devices included in the virtual devices in the virtual device sequence increases; the step of associating the virtual devices in the virtual device sequence with the communication ports one by one includes:
[0079] Determining a first virtual device in the virtual device sequence, and associating the first virtual device with a first communication port;
[0080] In response to the next port query instruction, continue to determine the next virtual device in the virtual device sequence, and associate the next virtual device with the next communication port until each virtual device in the virtual device sequence is traversed.
[0081] In the disclosed embodiment, the virtual devices can be sorted from small to large according to the number of physical devices, and the number of physical devices included in the virtual devices in the virtual device sequence increases. A first virtual device is determined in the virtual device sequence, and the first virtual device has the least physical devices, and the first virtual device is associated with the first communication port.
[0082] UHC continues to send port query instructions based on the port query interval, and the virtual USB Hub continues to determine the next virtual device in the virtual device sequence and associates the next virtual device with the next communication port until each virtual device in the virtual device sequence is traversed so that each virtual device is associated with a communication port.
[0083] Optionally, the step of setting the address register to a preset value to obtain a device address corresponding to each virtual device includes:
[0084] The address register is set to the preset value; the virtual device is used to communicate with the host controller to obtain the respective device addresses when the address register is the preset value;
[0085] When the host controller returns the corresponding device address to each virtual device, the device address corresponding to each virtual device is obtained.
[0086] In the disclosed embodiment, in response to the port query instruction, the address register is set to a preset value so that the virtual device can communicate with the UHC, and each virtual device communicates with the UHC and obtains its own device address.
[0087] When the host controller returns the corresponding device address to each virtual device, the virtual USB Hub can obtain these device addresses.
[0088] Optionally, the step of setting the address register to the preset value includes:
[0089] Setting the address register to the preset value so that a first virtual device in the sequence of virtual devices communicates with the host controller;
[0090] After the host controller returns the device address of the first virtual device, setting the address register to the third device address;
[0091] In response to the next port query instruction, the address register continues to be set to the preset value until each virtual device obtains its corresponding device address.
[0092] In the embodiment of the present disclosure, the virtual devices may communicate with the UHC one by one and separately to obtain their own second device addresses.
[0093] In response to the port query instruction, the address register is set to a preset value, the first virtual device in the virtual device sequence communicates with the host controller, and after the host controller returns the device address of the first virtual device, the virtual USB Hub can obtain the device address of the first virtual device, and then rewrite its own third device address into the address register.
[0094] The UHC continues to send port query instructions based on the port query interval, and the virtual USB Hub responds to the next port query instruction and continues to reset the address register to the preset value, so that the next virtual device can communicate with the UHC and obtain the device address. Repeat this process until each virtual device obtains its own device address.
[0095] Optionally, the method further includes:
[0096] Determine an endpoint corresponding to each virtual device according to the physical device included in each virtual device; the endpoint is used for the physical device to communicate with the host;
[0097] An endpoint mapping table is constructed according to each virtual device and its corresponding endpoint; the endpoint mapping table is used to configure the device controller.
[0098] In the disclosed embodiment, the number of endpoints used by each physical device is different according to the function and complexity of the physical device, and each physical device can communicate with the host according to one or more endpoints. According to the physical devices included in each virtual device and the endpoints corresponding to each physical device, the endpoint corresponding to each virtual device can be determined. According to each virtual device and its corresponding endpoint, an endpoint mapping table is constructed. Then, the target endpoint mapping table corresponding to the second virtual device is determined, and according to the target endpoint mapping table, the device controller is configured so that the physical device corresponding to the second virtual device communicates based on the corresponding endpoint.
[0099] It is understandable that each physical device may correspond to an endpoint. In addition to the endpoints corresponding to the physical devices in the virtual device, the virtual device may also have a control endpoint, and the endpoint content of the virtual device is not specifically limited here.
[0100] Optionally, there are multiple second virtual devices; the step of determining the second virtual device associated with the first virtual device according to the updated physical device combination includes:
[0101] Acquire an updated physical device combination of the physical devices connected to the host to obtain a first device combination;
[0102] Matching the first device combination with second device combinations of multiple second virtual devices respectively; the second device combination represents a physical device combination corresponding to the second virtual device;
[0103] When the first device combination is consistent with the target second device combination, a target second virtual device associated with the first virtual device is determined; the target second virtual device corresponds to the target second device combination.
[0104] In the embodiment of the present disclosure, when the physical device connected to the host is updated, the physical device connected to the host after the update is obtained to obtain a first device combination. For example, after the update, the host is connected to a mouse and a keyboard, and the first device combination is a mouse and a keyboard.
[0105] Since there can be multiple second virtual devices, the second device combination corresponding to each second virtual device can be matched with the first device combination. If the physical devices in the first device combination and the second device combination are the same, the match is successful. The virtual device corresponding to the successfully matched second device combination is the target second virtual device.
[0106] Optionally, the method further includes:
[0107] Construct a device address table according to each virtual device and its corresponding device address;
[0108] According to the second virtual device, obtaining, in the device address table, a target device address corresponding to the second virtual device;
[0109] Based on the target device address, the device controller is configured.
[0110] In the disclosed embodiment, the virtual USB Hub obtains the device address of each virtual device, and then a device address table storing the mapping relationship between the virtual device and the device address can be constructed. When determining that the second virtual device corresponds to the second communication port and the second device address in the second configuration, the second device address corresponding to the second virtual device, i.e., the target device address, can be directly queried in the device address table.
[0111] Optionally, the method further includes:
[0112] When the host is connected to a newly added physical device, a third virtual device is constructed according to the newly added physical device; the device type of the newly added physical device is different from the device type of the at least one physical device;
[0113] Associating the third virtual device to the third communication port, and obtaining a third device address corresponding to the third virtual device;
[0114] Based on the third communication port and the third device address, switching is performed so that the third virtual device is in communication connection with the host controller.
[0115] In the disclosed embodiment, the host can also be connected to a new physical device, and the device type of the newly added device is different from the device type of at least one physical device. For example, when combining physical devices, the device type can include a mouse and a keyboard, and when the host is connected to a hard disk, the hard disk is a newly added physical device.
[0116] Based on the existing first virtual device and second virtual device, the physical device of the hard disk can be directly used as a third virtual device, and similarly, the third virtual device can be associated with the corresponding third communication port, and the third device address corresponding to the third virtual device can be obtained. The specific process will not be repeated here.
[0117] By implementing the embodiments of the present disclosure, even if a newly added physical device does not belong to an existing device type, it can be directly used as a virtual device and configured in a similar manner. This avoids the need to re-enumerate other existing physical devices when adding a new physical device, and thus eliminates the need for tedious operations such as address allocation, thereby improving the efficiency of device communication.
[0118] Optionally, the step of combining at least one physical device to obtain a first virtual device and a second virtual device includes:
[0119] Obtaining device type and usage frequency information of each physical device in at least one physical device;
[0120] The at least one physical device is combined according to the device type and the usage frequency information to obtain a first virtual device and a second virtual device.
[0121] In the disclosed embodiment, physical devices may be combined according to device type and usage frequency information. For example, when considering the device type, usually only one mouse and keyboard are needed, then only one mouse and keyboard may exist in each virtual device, but the number of hard disks may be multiple, then the first virtual device may include 1 mouse, 1 keyboard and 1 hard disk, and the second virtual device may include 1 mouse, 1 keyboard and 2 hard disks. How to combine physical devices to obtain virtual devices is not specifically limited here.
[0122] When combining physical devices according to their device types, the frequency of device use can also be considered. This allows some devices that users often use to be more easily combined into virtual devices, which can better meet the user's usage habits. For example, a hard disk is used to store data. After storing data on the hard disk, the user may move the hard disk to another location, or connect other hard disks to the host. In this case, more hard disks can be included in the virtual device, and different numbers of hard disks can be included in different virtual devices. This allows a corresponding second virtual device to be available even if the user frequently plugs in and unplugs the hard disk and updates the physical device. The second device address and second communication port of the corresponding second virtual device can be used directly.
[0123] By implementing the embodiments of the present disclosure, at least one physical device is combined according to the device type and usage frequency information to obtain a virtual device, which can combine a virtual device that better meets the user's usage requirements and further improves the communication efficiency of the devices.
[0124] Optionally, the step of obtaining an updated physical device combination of the physical devices connected to the host to obtain a first device combination includes:
[0125] When the host is connected to a newly added physical device, determining a first device combination corresponding to the newly added physical device combination; or
[0126] When a physical device connected to the host is uninstalled, a first device combination corresponding to the uninstalled physical device combination is determined.
[0127] In the disclosed embodiment, the change in the physical device connected to the host may be that more physical devices are connected, or the physical devices are reduced, that is, the physical device is mounted or unmounted. It can be understood that the device type of the newly added physical device here may be one of the at least one device type corresponding to the at least one physical device used for combination. If not, a third virtual device needs to be added.
[0128] In the case of mounting or unmounting, the corresponding second virtual device can be determined according to the changed physical device combination to perform subsequent communication configuration, which will not be described in detail here.
[0129] Optionally, the method further includes:
[0130] When the at least one physical device is uninstalled, the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device are saved.
[0131] In the disclosed embodiment, all physical devices of the host may be uninstalled by the user, resulting in no physical device combination, that is, no corresponding virtual device. At this time, the configuration of each virtual device (including the associated communication port and the corresponding device address) can be saved, so that when the user subsequently connects a new physical device, it can be used directly without the need to perform operations such as combination, port association, address allocation, etc. according to the physical device connected to the host again.
[0132] By implementing the embodiments of the present disclosure, the configuration of each virtual device is saved when at least one physical device is uninstalled, so as to avoid the need to re-combine devices, associate communication ports, allocate addresses, etc. when a new physical device is subsequently mounted, thereby improving the efficiency of device communication.
[0133] Optionally, before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further includes:
[0134] In a case where the host is connected to a physical device, the at least one physical device connected to the host is obtained.
[0135] In the disclosed embodiment, the device type of the physical device used for device combination can be determined in real time according to the physical device connection status of the host. When the host is already connected to several physical devices, the combination is directly based on these physical devices.
[0136] By implementing the embodiments of the present disclosure, when at least one physical device is connected to the host, the device type of at least one physical device is obtained in real time. Device combination can be performed according to the existing physical device connection situation, so that the subsequent virtual device can meet the current physical device connection requirements, thereby improving the accuracy of device combination.
[0137] Optionally, before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further includes:
[0138] Receive physical device information input by a user, and determine the at least one physical device indicated by the physical device information.
[0139] In the embodiment of the present disclosure, the physical device type used for device combination can be physical device information (such as device code, type, number) directly received from the user, and at least one corresponding physical device is determined according to the physical device information. The user can pre-specify the physical devices that he needs to use, and then the device combination can be performed according to these user-specified physical devices.
[0140] By implementing the embodiments of the present disclosure, physical device information input by a user is received to obtain at least one physical device. There is no need to combine devices according to the physical devices currently actually connected to the host. The physical device information input by the user is directly received, and the user's usage needs can be determined in advance, and a suitable virtual device can be determined, thereby improving the flexibility of device communication.
[0141] Optionally, the method further includes:
[0142] When each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is obtained, an enumeration completion message is sent to the host controller; the enumeration completion message is used to indicate that the enumeration of all virtual devices is completed.
[0143] In the disclosed embodiment, the UHC can continuously send port query instructions based on the port query interval, so that the virtual USB Hub continuously performs the process of address register setting and device address acquisition. When each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is obtained, an enumeration completion message is reported to the host controller to inform the UHC that the enumeration is completed.
[0144] Figure 5 is a software stack diagram of a virtual hub provided by an embodiment of the present invention; Figure 5 It includes a driver architecture stack 501 on the left and a process stack 502 on the right. The process stack 502 is used to implement device enumeration and device switching.
[0145] The driver architecture stack 501 includes a transport layer, a communication layer, a composite layer, a functional layer, and a combination layer. The transport layer (musb layer) is located at the bottom layer of the driver and is responsible for processing interrupts, bottom-level transmissions, and providing an interface for UDC. The virtual USB Hub can be implemented based on the musb layer driver. The communication layer (UDC layer) is responsible for managing the communication between the USB device end and the UHC to ensure that the USB device can correctly exchange data with the Host. The composite layer refers to a composite USB device, which can present multiple independent device interfaces to the host through a physical USB connection, so that a USB device can provide multiple functions at the same time. The USB devices in the present invention are all composite devices. The functional layer refers to the specific functional modules of the USB device, including storage devices, network card devices, and keyboard and mouse devices.
[0146] The top layer of the driver architecture stack is the combination layer. This layer combines the specific functional modules implemented in the function layer based on the function layer, and exhaustively enumerates all device combinations before enumerating the USB Hub, and all combinations are included in the enumeration. After the enumeration is completed, the device address assigned to each combination by the UHC is saved, and the device status under the USB Hub is continuously monitored. When the device status changes, the device status connected to the downstream port of the USB Hub is matched and the switch is completed.
[0147] Figure 6 It is a flowchart of device enumeration provided by an embodiment of the present disclosure; it includes:
[0148] Step 601, start; Step 602, physical device connection, device type detection; Step 603, report device type, port number, port query interval; Step 604, assign a third device address, and write the third device address into an address register; Step 605, perform device combination, establish an endpoint mapping table for virtual devices, and store the physical device combination corresponding to the virtual device; Step 606, periodically send port query instructions according to the port query interval; Step 607, select virtual devices one by one according to the number of endpoints of the virtual device, associate them to different communication ports, and report them; Step 608, determine whether all virtual devices have been reported; Step 609, set the address register bit preset value, and assign the device address of the virtual device; Step 610, construct an address mapping table according to the device address of the virtual device; Step 611, if all virtual devices have not been reported, continue to set the address register to the third device address, and continue to enumerate the next virtual device; Step 612, end.
[0149] Figure 7 It is a schematic diagram of the device change state machine provided by the embodiment of the present disclosure; when the enumeration process design is not completed, the virtual USB Hub is in the idle state (Idle) 701, and the device has not started working at this time; after the device enumeration is completed, the virtual hub state 702 selects to switch the corresponding virtual device to enter the virtual device state 703 according to the device connection status at this time; when the device is uninstalled, the virtual hub state 702 detects the hot plug of the device, enters the virtual hub state 702, and selects to switch the corresponding virtual device to enter the virtual device state 703. When the device is inserted, the virtual hub state 702 first detects whether the device is already included in the enumerated device combination. If not, a third virtual device is added to the device address table and the endpoint mapping table; the UHC is notified to enumerate the new device to assign a device address. After the enumeration is completed, the virtual hub state 702 reconfigures the UDC based on the newly added third virtual device and enters the virtual device state 703.
[0150] Figure 8 It is a functional implementation diagram of the virtual hub provided by the embodiment of the present disclosure; the virtual hub (USB Hub) includes an upstream port 801, the upstream port 801 is connected to the host controller (not shown), and the downstream port 802 is connected to the device controller 803. The virtual hub can realize device enumeration, combination switching, stop monitoring and other functions. After completing the device enumeration, a device address table and an endpoint mapping table are constructed.
[0151] Fig. 9 is a schematic diagram of a device communication system 900 provided in an embodiment of the present invention, including:
[0152] Host 901 and physical device 902; Host 901 includes communication configuration module 9011, device controller 9012, host controller 9013;
[0153] The communication configuration module 9011 is connected to the host controller 9013 and the device controller 9012, the host controller 9013 is connected to the device controller 9012, the device controller 9012 is connected to the virtual device through the communication port, and the physical device 9012 is connected to the host 90;
[0154] The communication configuration module 9011 is used to execute the steps of the device communication method in any of the above embodiments.
[0155] Fig.10 1 is a schematic diagram of a device communication apparatus provided by an embodiment of the present invention, including:
[0156] The first device communication module 1001 is used to, when it is determined that the physical device combination currently connected to the host corresponds to the first virtual device, communicate and connect the first virtual device with the host controller based on the first configuration of the first virtual device; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller;
[0157] A physical device update module 1002, configured to determine, when the physical device connected to the host is updated, the second virtual device associated with the first virtual device according to the updated physical device combination;
[0158] The second device communication module 1003 is used to switch to the communication connection between the second virtual device and the host controller based on the second configuration of the second virtual device; the second configuration includes a second communication port for connecting the second virtual device and the device controller and a second device address for configuring the device controller.
[0159] Optionally, the device controller includes an address register; the apparatus further includes:
[0160] An address request module, used for sending an address allocation request to the host controller;
[0161] The address writing module is used to receive the third device address returned by the host controller and write the third device address into the address register; the host controller communicates based on the third device address.
[0162] Optionally, the device further comprises:
[0163] A device combination module, used to combine at least one physical device to obtain the first virtual device and the second virtual device; each virtual device corresponds to a respective physical device combination;
[0164] A port address module is used to associate each virtual device with a different communication port and obtain a device address corresponding to each virtual device to generate the first configuration including the first communication port and the first device address and the second configuration including the second communication port and the second device address.
[0165] Optionally, the address allocation request carries a port query interval; the port address module includes:
[0166] A first port query submodule, configured to receive a port query instruction returned by the host controller; the port query instruction is generated based on the port query interval;
[0167] A device sequence submodule, for responding to the port query instruction and determining a virtual device sequence including each virtual device according to the number of physical devices corresponding to the virtual device;
[0168] A port association submodule, used to associate the virtual devices in the virtual device sequence with the communication ports one by one;
[0169] The register setting submodule is used to set the address register to a preset value to obtain the device address corresponding to each virtual device.
[0170] Optionally, the number of physical devices included in the virtual devices in the virtual device sequence increases; the port association submodule includes:
[0171] A first associating unit, configured to determine a first virtual device in the virtual device sequence, and associate the first virtual device with a first communication port;
[0172] The traversal association unit is used to respond to the next port query instruction, continue to determine the next virtual device in the virtual device sequence, and associate the next virtual device with the next communication port until each virtual device in the virtual device sequence is traversed.
[0173] Optional, register setting submodule, including:
[0174] A first register setting unit is used to set the address register to the preset value; the virtual device is used to communicate with the host controller to obtain the respective device addresses when the address register is the preset value;
[0175] The return address acquisition unit is used to acquire the device address corresponding to each virtual device when the host controller returns the corresponding device address to each virtual device.
[0176] Optionally, the first register setting unit includes:
[0177] a second register setting subunit, configured to set the address register to the preset value so that the first virtual device in the virtual device sequence communicates with the host controller;
[0178] An address acquisition subunit, configured to set the address register to the third device address after the host controller returns the device address of the first virtual device;
[0179] The third register setting subunit is used to respond to the next port query instruction and continue to set the address register to the preset value until each virtual device obtains its corresponding device address.
[0180] Optionally, the device further comprises:
[0181] A virtual device endpoint module, used to determine an endpoint corresponding to each virtual device according to the physical device included in each virtual device; the endpoint is used for the physical device to communicate with the host;
[0182] The endpoint mapping table module is used to construct an endpoint mapping table according to each virtual device and its corresponding endpoint; the endpoint mapping table is used to configure the device controller.
[0183] Optionally, the second virtual device has multiple physical device update modules, including:
[0184] The current combination submodule is used to obtain the updated physical device combination of the physical devices connected to the host to obtain a first device combination;
[0185] The current matching submodule is used to match the first device combination with the second device combinations of multiple second virtual devices respectively; the second device combination represents the physical device combination corresponding to the second virtual device;
[0186] The current target submodule is used to determine the target second virtual device associated with the first virtual device when the first device combination is consistent with the target second device combination; the target second virtual device corresponds to the target second device combination.
[0187] Optionally, the device further comprises:
[0188] The device address table module is used to construct a device address table according to each virtual device and its corresponding device address;
[0189] An address table query module, configured to obtain, according to the second virtual device, a target device address corresponding to the second virtual device in the device address table;
[0190] An address configuration module is used to configure the device controller based on the target device address.
[0191] Optionally, the device further comprises:
[0192] A third device construction submodule, configured to construct a third virtual device according to a newly added physical device when the host is connected to the newly added physical device; the device type of the newly added physical device is different from the device type of the at least one physical device;
[0193] A third port address submodule, used to associate the third virtual device with a third communication port, and obtain a third device address corresponding to the third virtual device;
[0194] The third device communication submodule is used to switch to a communication connection between the third virtual device and the host controller based on the third communication port and the third device address.
[0195] Optional equipment combination modules include:
[0196] A type frequency acquisition submodule, used to acquire device type and usage frequency information of each physical device in at least one physical device;
[0197] The type frequency combination submodule is used to combine the at least one physical device according to the device type and the usage frequency information to obtain a first virtual device and a second virtual device.
[0198] Optional, currently combined submodules include:
[0199] A mounting unit, configured to determine, when the host is connected to a newly added physical device, a first device combination corresponding to the newly added physical device combination; or
[0200] The uninstallation unit is used to determine a first device combination corresponding to the uninstalled physical device combination when the physical device connected to the host is uninstalled.
[0201] Optionally, the device further comprises:
[0202] The uninstallation and saving module is used to save the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device when all physical devices connected to the host are uninstalled.
[0203] Optionally, the device further comprises:
[0204] The detection and acquisition module is used to acquire the at least one physical device connected to the host when the host is connected to the physical device.
[0205] Optionally, the device further comprises:
[0206] The user input module is used to receive physical device information input by a user and determine the at least one physical device indicated by the physical device information.
[0207] Optionally, the device further comprises:
[0208] The enumeration prompt module is used to send an enumeration completion message to the host controller when each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is obtained; the enumeration completion message is used to indicate that all virtual devices are enumerated.
[0209] The embodiment of the present invention further provides an electronic device, such as Fig.11 As shown, it includes a processor 1701 , a communication interface 1702 , a memory 1703 and a communication bus 1704 , wherein the processor 1701 , the communication interface 1702 , and the memory 1703 communicate with each other via the communication bus 1704 .
[0210] The memory 1703 is used to store computer programs.
[0211] When the processor 1701 is used to execute the program stored in the memory 1703, the following steps are implemented: when it is determined that the physical device combination currently connected to the host corresponds to the first virtual device, based on the first configuration of the first virtual device, the first virtual device is communicatively connected to the host controller; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller; when the physical device connected to the host is updated, the second virtual device associated with the first virtual device is determined according to the updated physical device combination; based on the second configuration of the second virtual device, the second virtual device is switched to communicate with the host controller; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller.
[0212] Among them, the processor 1701 can also implement other steps in the above-mentioned device communication method, which will not be repeated here.
[0213] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0214] The communication interface is used for communication between the above electronic device and other devices.
[0215] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0216] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0217] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer executes the device communication method described in the above embodiment.
[0218] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the device communication method described in the above embodiment.
[0219] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0220] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0221] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For the embodiments of the device, electronic device, computer-readable storage medium and computer program products containing instructions, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0222] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A device communication method, characterized in that: The method comprises: When determining that the physical device combination currently connected to the host corresponds to the first virtual device, based on a first configuration of the first virtual device, the first virtual device is communicatively connected to the host controller; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller; When the physical device connected to the host is updated, determining the second virtual device associated with the first virtual device according to the updated physical device combination; Based on a second configuration of the second virtual device, switching to the second virtual device to communicate with the host controller; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller; The method further comprises: Obtaining device type and usage frequency information of each physical device in at least one physical device; The at least one physical device is combined according to the device type and the usage frequency information to obtain a first virtual device and a second virtual device.
2. The method according to claim 1, characterized in that The device controller includes an address register; the method further includes: Sending an address allocation request to the host controller; The third device address returned by the host controller is received, and the third device address is written into the address register; and the host controller communicates based on the third device address.
3. The method according to claim 2, characterized in that The method further comprises: Combine at least one physical device to obtain the first virtual device and the second virtual device; each virtual device corresponds to a respective physical device combination; Each virtual device is associated with a different communication port, and a device address corresponding to each virtual device is obtained to generate the first configuration including the first communication port and the first device address and the second configuration including the second communication port and the second device address.
4. The method according to claim 3, characterized in that The address allocation request carries a port query interval; the step of associating each virtual device with a different communication port and obtaining a device address corresponding to each virtual device includes: receiving a port query instruction returned by the host controller; the port query instruction is generated based on the port query interval; In response to the port query instruction, determining a virtual device sequence including each virtual device according to the number of physical devices corresponding to the virtual device; Associating the virtual devices in the virtual device sequence with the communication ports one by one; The address register is set to a preset value to obtain a device address corresponding to each virtual device.
5. The method according to claim 4, characterized in that The number of physical devices included in the virtual devices in the virtual device sequence increases gradually; the step of associating the virtual devices in the virtual device sequence with the communication ports one by one comprises: Determining a first virtual device in the virtual device sequence, and associating the first virtual device with a first communication port; In response to the next port query instruction, continue to determine the next virtual device in the virtual device sequence, and associate the next virtual device with the next communication port until each virtual device in the virtual device sequence is traversed.
6. The method according to claim 4, characterized in that The step of setting the address register to a preset value to obtain a device address corresponding to each virtual device includes: The address register is set to the preset value; the virtual device is used to communicate with the host controller to obtain the respective device addresses when the address register is the preset value; When the host controller returns the corresponding device address to each virtual device, the device address corresponding to each virtual device is obtained.
7. The method according to claim 6, characterized in that The step of setting the address register to the preset value comprises: Setting the address register to the preset value so that a first virtual device in the sequence of virtual devices communicates with the host controller; After the host controller returns the device address of the first virtual device, setting the address register to the third device address; In response to the next port query instruction, the address register continues to be set to the preset value until each virtual device obtains its corresponding device address.
8. The method according to claim 1, characterized in that The method further comprises: Determine an endpoint corresponding to each virtual device according to the physical device included in each virtual device; the endpoint is used for the physical device to communicate with the host; An endpoint mapping table is constructed according to each virtual device and its corresponding endpoint; the endpoint mapping table is used to configure the device controller.
9. The method according to claim 1, characterized in that: There are multiple second virtual devices; the step of determining the second virtual device associated with the first virtual device according to the updated physical device combination includes: Acquire an updated physical device combination of the physical devices connected to the host to obtain a first device combination; Matching the first device combination with second device combinations of multiple second virtual devices respectively; the second device combination represents a physical device combination corresponding to the second virtual device; When the first device combination is consistent with the target second device combination, a target second virtual device associated with the first virtual device is determined; the target second virtual device corresponds to the target second device combination.
10. The method according to claim 6, characterized in that The method further comprises: Construct a device address table according to each virtual device and its corresponding device address; According to the second virtual device, obtaining, in the device address table, a target device address corresponding to the second virtual device; Based on the target device address, the device controller is configured.
11. The method according to claim 3, characterized in that The method further comprises: When the host is connected to a newly added physical device, a third virtual device is constructed according to the newly added physical device; the device type of the newly added physical device is different from the device type of the at least one physical device; Associating the third virtual device to a third communication port, and obtaining a third device address corresponding to the third virtual device; Based on the third communication port and the third device address, switching is performed so that the third virtual device is in communication connection with the host controller.
12. The method according to claim 9, characterized in that The step of obtaining the updated physical device combination of the physical devices connected to the host to obtain the first device combination includes: When the host is connected to a newly added physical device, determining a first device combination corresponding to the newly added physical device combination; or When a physical device connected to the host is uninstalled, a first device combination corresponding to the uninstalled physical device combination is determined.
13. The method according to claim 1, characterized in that The method further comprises: When all physical devices connected to the host are uninstalled, the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device are saved.
14. The method according to claim 3, characterized in that Before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further includes: In a case where the host is connected to a physical device, the at least one physical device connected to the host is obtained.
15. The method according to claim 3, characterized in that Before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further includes: Receive physical device information input by a user, and determine the at least one physical device indicated by the physical device information.
16. The method according to claim 5, characterized in that The method further comprises: When each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is obtained, an enumeration completion message is sent to the host controller; the enumeration completion message is used to indicate that all virtual devices are enumerated.
17. A device communication system, characterized in that: The system comprises: a host and a physical device; the host comprises a communication configuration module, a device controller and a host controller; The communication configuration module is connected to the host controller and the device controller, the host controller is connected to the device controller, the device controller is connected to the virtual device through the communication port, and the physical device is connected to the host; The communication configuration module is used to execute the steps of the device communication method described in any one of claims 1-16.
18. A device communication apparatus, characterized in that: The device comprises: A first device communication module, configured to, when determining that a physical device combination currently connected to the host corresponds to a first virtual device, connect the first virtual device to a host controller based on a first configuration of the first virtual device; the first configuration includes a first communication port for connecting the first virtual device and the device controller, and a first device address for configuring the device controller; A physical device update module, configured to determine, when the physical device connected to the host is updated, the second virtual device associated with the first virtual device according to the updated physical device combination; A second device communication module, used to switch to a communication connection between the second virtual device and the host controller based on a second configuration of the second virtual device; the second configuration includes a second communication port for connecting the second virtual device and the device controller, and a second device address for configuring the device controller; The device also includes: A type frequency acquisition module, used to acquire device type and usage frequency information of each physical device in at least one physical device; The type frequency combination module is used to combine the at least one physical device according to the device type and the usage frequency information to obtain a first virtual device and a second virtual device.
19. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the device communication method according to any one of claims 1 to 16.
20. A computer-readable storage medium, characterized in that: Used to store computer programs / instructions; wherein when the computer programs / instructions are executed by a processor, the device communication method as described in any one of claims 1 to 16 is implemented.
21. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the device communication method according to any one of claims 1 to 16 is implemented.
Citation Information
Patent Citations
Method and system for achieving rapid accessing of USB devices
CN105488000A
Method and device for managing USB device by virtual machine, and storage medium
CN110413376A
Method for dynamically provisioning virtualized functions in USB equipment by means of virtual USB hub
CN111581128A
USB device and virtual machine hot binding method and device and storage medium
CN112631721A
Many computers of USB switch
CN204595844U
