Device communication method, system and apparatus, device, storage medium, and program product
By switching the configuration and address of the virtual device when the physical device is updated, the problem of low communication efficiency caused by USB device re-enumeration is solved, and more efficient device communication is achieved.
Patent Information
- Application Number
- PCT/CN2025/098343
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-07-31
- Filing Date
- 2025-05-30
- Publication Date
- 2026-02-05
AI Technical Summary
In existing technologies, when multiple USB devices are mapped to the same hardware UDC, the need to re-enumerate all devices when plugging and unplugging devices leads to low communication efficiency.
By identifying the associated virtual devices and switching their configurations when updating the physical device combination connected to the host, and using the corresponding communication port and device address for communication, all devices can be re-enumerated.
It improves device communication efficiency, reduces cumbersome operations when device status changes, and enhances system response speed.
Smart Images

Figure CN2025098343_05022026_PF_FP_ABST
Abstract
Description
Device communication method, system, apparatus, device, storage medium and program product
[0001] Cross-reference to Related Applications
[0002] The present application claims priority from the Chinese patent application No. 202411037039.0 filed on July 31, 2024, and entitled "Device communication method, system, apparatus, device, storage medium and program product", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0003] The present application relates to the technical field of computer device communication, and in particular to a device communication method, system, apparatus, electronic device, non-volatile readable storage medium and computer program product. BACKGROUND
[0004] In the Universal Serial Bus (USB) specification, different types of USB devices usually need to be implemented by independent USB device controllers (UDCs) to ensure that they do not affect each other during device enumeration and device interaction. There is a UDC in the Baseboard Management Controller (BMC), but it cannot meet the communication needs of multiple USB devices.
[0005] At present, 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.
[0006] However, the above USB devices are all mapped to the same UDC, and when the devices are plugged in or out, all USB devices on the UDC need to be re-enumerated, which is relatively cumbersome and reduces the efficiency of device communication. SUMMARY
[0007] Embodiments of the present application provide a device communication method, system, apparatus, electronic device, non-volatile readable storage medium and computer program product to solve the problem of low device communication efficiency in the prior art.
[0008] In a first aspect, embodiments of the present application provide a device communication method, the method comprising:
[0009] In a case where it is determined that the physical device combination currently connected by the host corresponds to the first virtual device, the first virtual device is communicatively connected to the 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;
[0010] In a case where the physical device connected by the host is updated, a second virtual device associated with the first virtual device is determined according to the updated physical device combination;
[0011] The second virtual device is communicatively connected to 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.
[0012] In a second aspect, an embodiment of the present application provides a device communication system, the system comprising:
[0013] A host and a physical device; the host comprises a communication configuration module, a device controller and a host controller;
[0014] 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 a virtual device through a communication port, and the physical device is connected to the host;
[0015] The communication configuration module is configured to perform the steps in the device communication method of the first aspect.
[0016] In a third aspect, an embodiment of the present application provides a device communication apparatus, the apparatus comprising:
[0017] The first device communication module is configured to, in a case where it is determined that the physical device combination currently connected by the host corresponds to the first virtual device, communicatively connect the first virtual device to the 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;
[0018] The physical device updating module is configured to, in a case where the physical device connected by the host is updated, determine a second virtual device associated with the first virtual device according to the updated physical device combination;
[0019] The second device communication module is configured to, based on a second configuration of the second virtual device, communicatively connect the second virtual device to 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.
[0020] In a fourth aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus; wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
[0021] a memory for storing a computer program;
[0022] a processor for executing the program stored on the memory, to implement the steps in the device communication method of the first aspect.
[0023] In a fifth aspect, a non-volatile readable storage medium is provided, having a computer program stored thereon, which, when executed by a processor, implements the steps in the device communication method of the first aspect.
[0024] In a sixth aspect, a computer program product is provided, comprising computer programs / instructions, which, when executed by a processor, implement the steps in the device communication method of the first aspect.
[0025] Compared with the prior art, the present application has the following advantages:
[0026] In the embodiments of the present application, the physical device group formed by the at least one physical device currently connected by the host can be corresponded to the first virtual device, and the first configuration of the first virtual device is used for communication, and 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 is directly switched to, and communication is performed based on the corresponding communication port and device address, thereby avoiding 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 address before communication can be performed, and the efficiency of device communication is improved.
[0027] The above description is only a summary of the technical solutions of the present application, in order to more clearly understand the technical means of the present application, the specific embodiments of the present application can be implemented according to the content of the description, and in order to make the above and other purposes, characteristics and advantages of the present application more obvious and easy to understand, the following will describe the specific embodiments of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiment description.
[0029] Fig. 1 is a step diagram of a device communication method provided by an embodiment of the present application;
[0030] Fig. 2 is an architecture schematic diagram of device communication provided by an embodiment of the present application;
[0031] Fig. 3 is a schematic diagram of a virtual device and a communication port provided by an embodiment of the present application;
[0032] FIG. 4 is a step diagram of another device communication method provided by an embodiment of the present application;
[0033] FIG. 5 is a software stack diagram of a virtual hub provided by an embodiment of the present application;
[0034] FIG. 6 is a flow diagram of device enumeration provided by an embodiment of the present application;
[0035] FIG. 7 is a schematic diagram of a device change state machine provided by an embodiment of the present application;
[0036] FIG. 8 is a schematic diagram of a function implementation of a virtual hub provided by an embodiment of the present application;
[0037] FIG. 9 is a schematic diagram of a device communication system provided by an embodiment of the present application;
[0038] FIG. 10 is a schematic diagram of a device communication apparatus provided by an embodiment of the present application;
[0039] FIG. 11 is a block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0040] Exemplary embodiments of the present application will be described herein below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it is understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thoroughly and completely understood, and will fully convey the scope of the application to those skilled in the art.
[0041] With the rapid development of information technology, the importance of BMC of a server node in maintaining normal operation of a data center is increasingly prominent. With the continuous enrichment of peripheral types, the function of BMC becomes more and more powerful. Keyboard Video Mouse (KVM) function is one of the most basic functions of BMC, which is used to realize remote monitoring and other operations, thereby guaranteeing the remote management capability of the server. By using KVM technology, BMC can internally implement mouse, keyboard, network card and virtual media and other devices. 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.
[0042] Therefore, a virtual USB hub and a virtual USB device are proposed. By virtualization technology, different types of USB devices can be mapped to the same hardware UDC as a virtual USB device, which is managed by software. This method effectively reuses the hardware resources of many low-speed USB devices, greatly reducing the hardware cost. However, when the device is enumerated, the UDC is taken as the minimum unit. The USB devices mapped to the same UDC are highly bound and can only be enumerated or unloaded at the same time. Whenever the state of a USB device changes, all devices need to be re-enumerated, which will reallocate the addresses for all devices, which is very inefficient, and the user can also see the state changes of these devices from the host side.
[0043] FIG. 1 is a step diagram of a device communication method provided by an embodiment of the present application, the method comprising:
[0044] In step 101, when it is determined that the physical device combination currently connected by the host corresponds to a first virtual device, the first virtual device is communicatively connected with the 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.
[0045] In the embodiments of the present disclosure, the execution subject of the device communication method can be a BMC, and a virtual hub (virtual USB hub) of software can be implemented in the BMC, and each method step is executed by the virtual USB hub. The virtual hub can have one upstream port and a plurality of downstream ports, the upstream port is connected with a USB host controller (UHC, USB Host Controller), and the downstream ports are connected with device controllers (UDC).
[0046] The host can be connected with at least one physical device (USB device), such as a mouse, a keyboard, etc., and a physical device combination can be formed based on the at least one physical device. Each virtual device corresponds to a physical device combination, i.e., corresponds to a plurality of physical devices. A corresponding configuration can be generated for each virtual device in advance, and the configuration includes a communication port (downstream port in the virtual hub) for connecting the virtual device and the device controller, and the configuration also includes a device address for configuring the device controller.
[0047] It can be understood that the device address refers to the device address corresponding to the virtual device. Since the virtual device corresponds to a plurality of physical devices, the device address corresponding to the virtual device can be a set of sub-device addresses corresponding to the plurality of physical devices respectively, and each physical device communicates based on the respective sub-device address; or can be one or more device addresses not corresponding to the plurality of physical devices, and the plurality of physical devices all use the one or more device addresses for communication.
[0048] The device address is configured to the device controller, and then the virtual device and the host controller can communicate based on the device controller after the device address is configured. When it is determined that the physical device combination currently connected by the host corresponds to the first virtual device, the first virtual device can be connected in communication with the host controller based on the first configuration of the first virtual device.
[0049] FIG. 2 is a schematic diagram of device communication provided by an embodiment of the present disclosure; FIG. 2 includes a baseboard management controller 201 in a host and a physical device 202. The baseboard management controller 201 includes a virtual hub, a device controller, a host controller, and an Ethereum module. The virtual hub is implemented in software, and the device controller, the host controller, and the Ethereum module are implemented in hardware.
[0050] FIG. 3 is a schematic diagram of a virtual device and a communication port provided by an embodiment of the present disclosure; FIG. 3 shows device combination logic of a virtual USB Hub, taking a mouse, a keyboard, and a hard disk as examples. A virtual USB Hub is connected to a host controller through a single upstream port and is associated with multiple virtual devices 302 through multiple communication ports (downstream ports) 301. The multiple virtual devices 302 share a UDC, but only one virtual device can be enabled at the same time. These virtual devices include common physical device combinations, and each physical device is configured with an input (IN) endpoint or an output (OUT) endpoint by the virtual USB Hub.
[0051] In step 102, when the physical device connected by the host is updated, a second virtual device associated with the first virtual device is determined according to the updated physical device combination.
[0052] In an embodiment of the present disclosure, when the physical device connected by the host is updated, for example, the update caused by plugging or unplugging of the physical device, a second virtual device corresponding to the current physical device combination can be determined according to the updated physical device combination. Since the first virtual device corresponds to the physical device before the update and the second virtual device corresponds to the physical device after the update, the physical devices corresponding to the first virtual device and the second virtual device are similar, and the first virtual device and the second virtual device have a correlation.
[0053] For example, the host is initially connected with a mouse, a keyboard, and a hard disk, and corresponds to a first virtual device. Then, the keyboard is unplugged, that is, the keyboard is unloaded, and thus the connected physical device is updated. According to the updated physical device combination, that is, 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.
[0054] In step 103, based on the second configuration of the second virtual device, the second virtual device is switched to be in communication connection with the host controller; the second configuration includes a second communication port used for connecting the second virtual device and the device controller, and a second device address used for configuring the device controller.
[0055] In the embodiments of the present disclosure, since each virtual device corresponds to a different communication port, when the second virtual device is switched to be in communication connection 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 corresponding to the second configuration in 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.
[0056] To sum up, in the embodiments of the present application, the physical device group formed by at least one physical device currently connected by the host can be corresponded to the first virtual device, and the first virtual device is used for communication by using the first configuration of the first virtual device. In addition, 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 is directly switched to be used for communication based on the corresponding communication port and device address. The problem that all physical devices in the virtual device need to be re-enumerated to determine the corresponding device address before communication when the physical device is updated is avoided, and the efficiency of device communication is improved.
[0057] FIG. 4 is a step diagram of another device communication method provided by the present application.
[0058] In step 401, when it is determined that the physical device group currently connected by the host corresponds to the first virtual device, the first virtual device is switched to be in communication connection with the host controller based on the first configuration of the first virtual device; the first configuration includes a first communication port used for connecting the first virtual device and the device controller, and a first device address used for configuring the device controller.
[0059] In step 402, when the physical device connected by the host is updated, the second virtual device associated with the first virtual device is determined according to the updated physical device group.
[0060] In step 403, based on the second configuration of the second virtual device, the second virtual device is switched to be in communication connection with the host controller; the second configuration includes a second communication port used for connecting the second virtual device and the device controller, and a second device address used for configuring the device controller.
[0061] The specific contents of steps 401-403 can refer to the contents of the above-mentioned embodiment of FIG. 1, which will not be repeated here.
[0062] In some embodiments of the present application, the device controller comprises an address register; the method further comprises:
[0063] Step A1, sending an address allocation request to the host controller;
[0064] 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.
[0065] In the embodiments of the present disclosure, in the USB architecture, a device needs to be enumerated by the UHC and allocated a device address, and can communicate normally with the UHC. The virtual USB Hub as a special USB device should be allocated an address first, and then can be used as a medium to transfer the information sent by the UHC for subsequent enumeration of physical devices. Therefore, for the virtual USB Hub, the third device address corresponding to the virtual USB Hub can be obtained.
[0066] The virtual USB Hub can send an address allocation request to the UHC, and the address allocation request can carry physical device information to indicate the physical device connected by the current 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 this device address into the address register. Then the virtual USB Hub can communicate with the UHC based on the device address.
[0067] In some embodiments of the present application, the method further comprises:
[0068] Step B1, combining at least one physical device to obtain a first virtual device and a second virtual device; each virtual device corresponds to a respective physical device combination;
[0069] Step B2, associating each virtual device to a different communication port, and obtaining a device address corresponding to each virtual device, to generate a first configuration comprising a first communication port and a first device address, and a second configuration comprising a second communication port and a second device address.
[0070] In the embodiments of the present disclosure, at least one physical device can be combined, and each physical device combination obtained is used as a virtual device to obtain a first virtual device and a second virtual device. Of course, more virtual devices can also be included. For example, the physical device combination "mouse, keyboard" can be used as a first virtual device, and the physical device combination "mouse, keyboard, hard disk" can be used as a second virtual device.
[0071] Each virtual device can be associated to a respective corresponding communication port, different virtual devices are isolated by the communication ports, when a specific virtual device needs to be used, the device controller is connected through the corresponding port, and then the specific virtual device can establish communication with the host controller.
[0072] Finally, based on the communication port and the device address of each virtual device, a corresponding configuration can be generated, 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.
[0073] In some embodiments of the present application, the address allocation request carries a port query interval; the step of associating each virtual device to a different communication port and obtaining the device address corresponding to each virtual device includes:
[0074] Receiving the port query instruction returned by the host controller; the port query instruction is generated based on the port query interval;
[0075] 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;
[0076] Associating the virtual devices in the virtual device sequence with the communication ports one by one;
[0077] Setting the address register to a preset value to obtain the device address corresponding to each virtual device.
[0078] In the embodiments of the present disclosure, the address allocation request sent to the UHC can also carry a port query interval. The UHC can continuously generate port query instructions according to the port query interval and send the port query instructions to the virtual USB Hub. The virtual USB Hub can sort the virtual devices according to the number of physical devices corresponding to the virtual devices in response to the port query instruction, and determine a virtual device sequence including each virtual device. It can be understood that since different physical devices also correspond to different endpoints, the virtual devices can be sorted based on the number of endpoints of the multiple physical devices corresponding to the virtual devices. According to actual needs, other parameters can also be used for sorting to form the virtual device sequence, which is not limited herein.
[0079] The virtual devices in the virtual device sequence are associated with the communication ports of the virtual USB Hub one by one. In addition, the address register is set 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, the corresponding device address needs to be determined, and the corresponding device address is obtained by the virtual USB Hub. Similarly, the virtual device needs to interact with the UHC to obtain the device address allocated by the UHC. Setting the address register to a preset value, for example, 0, can transfer the use right of the UDC to the virtual device, and then the virtual device can interact with the UHC and obtain its own device address, and store the device address in the address register.
[0080] In some embodiments of the present application, 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 comprises:
[0081] In the virtual device sequence, the first virtual device is determined, and the first virtual device is associated with the first communication port.
[0082] In response to the next port query instruction, the next virtual device in the virtual device sequence is continuously determined, and the next virtual device is associated with the next communication port, until each virtual device in the virtual device sequence is traversed.
[0083] In the embodiments of the present disclosure, 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. In the virtual device sequence, the first virtual device with the least number of physical devices is determined, and the first virtual device is associated with the first communication port.
[0084] The 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 associate 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.
[0085] In some embodiments of the present application, the step of setting the address register to a preset value to obtain the corresponding device address of each virtual device comprises:
[0086] The address register is set to a preset value; the virtual device is used to communicate with the host controller to obtain its own device address when the address register is the preset value.
[0087] When the host controller returns the corresponding device address to each virtual device, the corresponding device address of each virtual device is obtained.
[0088] In the embodiments of the present disclosure, in response to the port query instruction, the address register is set to the preset value, so that each virtual device can communicate with the UHC and obtain its own device address.
[0089] When the host controller returns the corresponding device address to each virtual device, the virtual USB Hub can obtain the device addresses.
[0090] In some embodiments of the present application, the step of setting the address register to the preset value comprises:
[0091] The address register is set to the preset value so that the first virtual device in the sequence of virtual devices communicates with the host controller.
[0092] After the host controller returns the device address of the first virtual device, the address register is set to the third device address.
[0093] 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.
[0094] In the embodiments of the present disclosure, the virtual devices can communicate with the UHC one by one to obtain their own second device addresses.
[0095] Then, in response to the port query instruction, the address register is set to the preset value, and the 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, the virtual USB Hub can obtain the device address of the first virtual device. Then, the third device address of the first virtual device is written back to the address register.
[0096] The UHC continues to send port query instructions based on the port query interval, and the virtual USB Hub continues to set the address register to the preset value in response to the next port query instruction, so that the next virtual device can communicate with the UHC and obtain the device address. Repeat the process until each virtual device obtains its own device address.
[0097] In some embodiments of the present application, the method further comprises:
[0098] According to the physical device included in each virtual device, determine the corresponding endpoint of each virtual device; the endpoint is used for the physical device to communicate with the host;
[0099] According to each virtual device and its corresponding endpoint, construct an endpoint mapping table; the endpoint mapping table is used for configuring a device controller.
[0100] In the embodiments of the present disclosure, 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 endpoints corresponding to each virtual device can be determined. According to each virtual device and the corresponding endpoints, an endpoint mapping table is constructed. Then, the target endpoint mapping table corresponding to the second virtual device is determined, and the device controller is configured according to the target endpoint mapping table, so that the physical device corresponding to the second virtual device communicates based on the corresponding endpoints.
[0101] It can be understood that each physical device can correspond to one endpoint. In addition to the endpoints corresponding to the physical devices in the virtual device, the virtual device can also have a control endpoint, and the content of the endpoints of the virtual device is not specifically limited here.
[0102] In some embodiments of the present application, the second virtual device has a plurality of virtual devices; according to the updated physical device combination, the step of determining the second virtual device associated with the first virtual device includes:
[0103] Obtaining the updated physical device combination of the physical device connected to the host to obtain the first device combination;
[0104] Matching the first device combination with the second device combination of the plurality of second virtual devices respectively; the second device combination represents the physical device combination corresponding to the second virtual device;
[0105] When the first device combination is consistent with the target second device combination, the target second virtual device associated with the first virtual device is determined; the target second virtual device corresponds to the target second device combination.
[0106] In the embodiments 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 the first device combination. For example, after the update, the host is connected to a mouse and a keyboard, and the first device combination is the mouse and the keyboard.
[0107] Since the second virtual device can actually have a plurality of virtual devices, the second device combination corresponding to each second virtual device can be matched with the first device combination. When the physical devices in the first device combination and the second device combination are all the same, the matching is successful. The virtual device corresponding to the second device combination matched successfully is the target second virtual device.
[0108] In some embodiments of the present application, the method further includes:
[0109] According to each virtual device and the corresponding device address, a device address table is constructed;
[0110] According to the second virtual device, a target device address corresponding to the second virtual device is obtained in the device address table;
[0111] Based on the target device address, the device controller is configured.
[0112] In the embodiments of the present disclosure, 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 the second virtual device corresponds to the second communication port and the second device address in the second configuration are determined, 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.
[0113] In some embodiments of the present application, the method further comprises:
[0114] When the host is connected to the 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 at least one physical device;
[0115] The third virtual device is associated with the third communication port, and a third device address corresponding to the third virtual device is obtained;
[0116] Based on the third communication port and the third device address, the third virtual device is switched to communicate with the host controller.
[0117] In the embodiments of the present disclosure, 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 the physical devices are combined, the device types can include a mouse and a keyboard. When the host is connected to a hard disk, the hard disk is a newly added physical device.
[0118] On the basis of the existing first virtual device and the second virtual device, the hard disk, which is a physical device, can be directly used as a third virtual device. Similarly, the third virtual device is associated with a corresponding third communication port, and a third device address corresponding to the third virtual device is obtained. The specific process is not repeated here.
[0119] By implementing the embodiments of the present disclosure, even if the newly added physical device does not belong to the existing device type, it can be directly used as a virtual device and configured based on a similar manner. This avoids the need to re-enumerate other existing physical devices when the newly added physical device is added, and thus the tedious operation of address allocation is not required, thereby improving the efficiency of device communication.
[0120] In some embodiments of the present application, the at least one physical device is combined to obtain the first virtual device and the second virtual device, and the step comprises:
[0121] acquire device type and usage frequency information of each of the at least one physical device;
[0122] combine the at least one physical device according to the device type and usage frequency information to obtain a first virtual device and a second virtual device.
[0123] In the embodiments of the present disclosure, the physical devices can be combined according to the device type and usage frequency information. For example, when the device type is considered, a mouse and a keyboard are usually required only one, so there is only one mouse and one keyboard in each virtual device, but the number of hard disks can be multiple, so the first virtual device can include one mouse, one keyboard and one hard disk, and the second virtual device can include one mouse, one keyboard and two hard disks. How to combine the physical devices to obtain the virtual devices is not specifically limited here.
[0124] When the physical devices are combined according to the device type of the physical devices, the usage frequency of the devices can also be considered. Some devices frequently used by users can be more easily combined into virtual devices, thereby being more in line with the use habits of users. For example, a hard disk is used to store data, and there can be a user who moves the hard disk to another location after storing data in the hard disk, or connects another hard disk to the host, so that more hard disks are included in the virtual device and different numbers of hard disks are included in different virtual devices, so that even if the user frequently plugs and unplugs the hard disk and the physical device is updated, there is a corresponding second virtual device, and the second device address and the second communication port of the corresponding second virtual device can be directly used.
[0125] The embodiments of the present disclosure combine the at least one physical device according to the device type and usage frequency information to obtain the virtual device. The virtual device that meets the use requirements of users can be combined, and the device communication efficiency is further improved.
[0126] In some embodiments of the present disclosure, the step of obtaining the first device combination after the physical device combination of the physical device connected by the host is updated includes:
[0127] When the host is connected to the newly added physical device, the first device combination corresponding to the physical device combination after the addition is determined; or
[0128] When the physical device connected by the host is unloaded, the first device combination corresponding to the physical device combination after the unloading is determined.
[0129] In the embodiments of the present disclosure, the change of the physical devices connected to the host can be that more physical devices are connected, or that the physical devices are reduced, i.e., the physical devices are mounted or unmounted. It can be understood that the device type of the added physical device can 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.
[0130] In the case of mounting or unmounting, the corresponding second virtual device can be determined according to the changed combination of physical devices, and subsequent communication configuration is performed, which will not be described here.
[0131] In some embodiments of the present application, the method further comprises:
[0132] When all the at least one physical device is unmounted, the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device are saved.
[0133] In the embodiments of the present disclosure, all the physical devices of the host can be unmounted by the user, resulting in that there is no combination of physical devices at present, i.e., there 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 connects a new physical device in the future, it can be directly used without the need to perform the operations of combination, association of ports, allocation of addresses and the like again according to the combination of the physical devices connected to the host.
[0134] The embodiments of the present disclosure are implemented by saving the configuration of each virtual device when all the at least one physical device is unmounted. The operations of device combination, association of communication ports, allocation of addresses and the like need not be performed again when a new physical device is mounted in the future, and the efficiency of device communication is improved.
[0135] In some embodiments of the present application, before the step of combining the at least one physical device to obtain the first virtual device and the second virtual device, the method further comprises:
[0136] In the case that the host is connected to the physical device, the at least one physical device connected to the host is acquired.
[0137] In the embodiments of the present disclosure, the device type of the physical device used for combination can be determined in real time according to the connection of the physical devices of the host. In the case that the host has connected to a plurality of physical devices, the combination is directly performed based on these physical devices.
[0138] In the embodiments of the present disclosure, the device type of the at least one physical device connected to the host is acquired in real time. The device combination can be performed according to the existing physical device connection, so that the subsequent virtual device can meet the current physical device connection requirement, and the accuracy of the device combination is improved.
[0139] In some embodiments of the present application, before the step of combining the at least one physical device to obtain the first virtual device and the second virtual device, the method further comprises:
[0140] Receiving the physical device information input by the user, and determining the at least one physical device indicated by the physical device information.
[0141] In the embodiments of the present disclosure, the physical device type used for device combination can be the physical device information (such as device code, type, number) input by the user directly, and the at least one physical device corresponding to the physical device information is determined according to the physical device information. The user can specify the physical device to be used in advance, and then the device combination can be performed according to the user-specified physical device.
[0142] In the embodiments of the present disclosure, the at least one physical device is acquired by receiving the physical device information input by the user, so that the device combination is not required according to the physical device actually connected to the host. The physical device information input by the user directly can be used to determine the use requirement of the user in advance, the appropriate virtual device can be determined, and the flexibility of device communication is improved.
[0143] In some embodiments of the present application, the method further comprises:
[0144] When each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is acquired, an enumeration completion message is sent to the host controller. The enumeration completion message is used to indicate that all virtual devices have completed enumeration.
[0145] In the embodiments of the present disclosure, the UHC can continuously send the port query instruction based on the port query interval, so that the virtual USB Hub continuously performs the address register setting and device address acquisition process. When each virtual device in the virtual device sequence is associated with a communication port and the corresponding device address is acquired, the enumeration completion message is reported to the host controller, and the UHC is informed that the enumeration is completed.
[0146] FIG. 5 is a software stack diagram of a virtual hub provided by the embodiments of the present application; FIG. 5 includes a left driving architecture stack 501 and a right flow stack 502. The flow stack 502 is used to implement device enumeration and device switching.
[0147] The driving architecture stack 501 includes a transport layer, a communication layer, a composite layer, a function layer, and a combination layer. The transport layer (musb layer) is at the bottom of the driving and is responsible for handling interrupts, underlying transmission, and providing an interface for UDC. The virtual USB Hub can be implemented based on the musb layer driving. The communication layer (UDC layer) is responsible for managing the communication between the USB device end and the UHC, and ensuring that the USB device can correctly exchange data with the Host. The composite layer (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 one USB device can provide multiple functions at the same time. The USB devices in the present application are all composite devices. The function layer (function layer) refers to the specific function module of the USB device, including storage devices, network card devices, keyboard and mouse devices.
[0148] The combination layer (combination layer) is at the top of the driving architecture stack, which is based on the function layer, combines the specific function modules implemented by the function layer, and enumerates all device combinations before the USB Hub is enumerated. After the enumeration is completed, the device addresses allocated by the UHC to each combination are saved, and the state of the devices under the USB Hub is continuously monitored. When the device state changes, the device state connected to the downstream port of the USB Hub is matched and switched.
[0149] FIG. 6 is a flowchart of device enumeration provided by the embodiment of the present disclosure, which includes:
[0150] Step 601, start; step 602, connect the physical device, detect the device type; step 603, report the device type, port number, and port query interval; step 604, allocate a third device address and write the third device address into an address register; step 605, perform device combination, establish an endpoint mapping table of a virtual device, and store the physical device combination corresponding to the virtual device; step 606, periodically send a port query instruction 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, judge whether the reporting of all virtual devices is completed; step 609, set the address register bit to a preset value and allocate a 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 the reporting of all virtual devices is not completed, continue to set the address register to the third device address and continue to enumerate the next virtual device; and step 612, end.
[0151] Figure 7 is a schematic diagram of a device change state machine provided by the embodiment of the present disclosure; when the enumeration flow design is not completed, the virtual USB Hub is in an idle state (Idle) 701, at which time the device has not started to work; after the device enumeration is completed, the virtual hub state 702 selects to switch the corresponding virtual device into the virtual device state 703 according to the device connection condition at this time; when the device is unloaded, the virtual hub state 702 detects the device hot plug, enters the virtual hub state 702, and selects to switch the corresponding virtual device into the virtual device state 703. When the device is inserted, the virtual hub state 702 first detects whether the device has been included in the enumerated device combination, if not, a third virtual device is added in the device address table and the endpoint mapping table; the UHC is notified to enumerate the new device to allocate the device address. After the enumeration is completed, the virtual hub state 702 reconfigures the UDC based on the added third virtual device, and enters the virtual device state 703.
[0152] Figure 8 is a schematic diagram of a function implementation of a 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 with a host controller (not shown), a downstream port 802 is connected with a device controller 803, the virtual hub can implement device enumeration, implement combination switching, stop monitoring and the like, and construct a device address table and an endpoint mapping table after the device enumeration is completed.
[0153] Figure 9 is a schematic diagram of a device communication system 900 provided by the embodiment of the present application, including:
[0154] a host 901 and a physical device 902; the host 901 includes a communication configuration module 9011, a device controller 9012, a host controller 9013,
[0155] 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 a communication port, and the physical device 9012 is connected to the host 901.
[0156] The communication configuration module 9011 is configured to perform the steps of the device communication method in any of the above embodiments.
[0157] Figure 10 is a schematic diagram of a device communication apparatus provided by the embodiment of the present application, including:
[0158] The first device communication module 1001 is configured to, when it is determined that the physical device combination currently connected by the host corresponds to the first virtual device, connect the first virtual device to the host controller in communication based on a first configuration of the first virtual device; the first configuration includes a first communication port used to connect the first virtual device to the device controller and a first device address used to configure the device controller;
[0159] The physical device updating module 1002 is configured to, when the physical device connected by the host has an update, determine a second virtual device associated with the first virtual device according to an updated physical device combination.
[0160] The second device communication module 1003 is configured to, based on a second configuration of the second virtual device, switch to the second virtual device to be connected to the host controller in communication; the second configuration includes a second communication port used to connect the second virtual device to the device controller and a second device address used to configure the device controller.
[0161] In some embodiments of the present application, the device controller includes an address register; the apparatus further includes:
[0162] The address request module is configured to send an address allocation request to the host controller;
[0163] The address writing module is configured to receive a third device address returned by the host controller and write the third device address into the address register; the host controller performs communication based on the third device address.
[0164] In some embodiments of the present application, the apparatus further includes:
[0165] The device combination module is configured 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;
[0166] The port address module is configured to associate each virtual device to 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.
[0167] In some embodiments of the present application, the address allocation request carries a port query interval; the port address module includes:
[0168] The first port query submodule is configured to receive a port query instruction returned by the host controller; the port query instruction is generated based on the port query interval;
[0169] The device sequence submodule is configured to, in response to the port query instruction, determine a virtual device sequence including each virtual device according to a number of physical devices corresponding to the virtual device;
[0170] a port association submodule, configured to associate the virtual devices in the sequence of virtual devices with the communication ports one by one;
[0171] a register setting submodule, configured to set the address register to a preset value to obtain the device address corresponding to each virtual device.
[0172] In some embodiments of the present application, the number of physical devices included in the virtual devices in the sequence of virtual devices is incremental; and the port association submodule comprises:
[0173] a first association unit, configured to determine a first virtual device in the sequence of virtual devices, and associate the first virtual device with a first communication port;
[0174] a traversal association unit, configured to continue to determine a next virtual device in the sequence of virtual devices in response to a next port query instruction, and associate the next virtual device with a next communication port, until each virtual device in the sequence of virtual devices is traversed.
[0175] In some embodiments of the present application, the register setting submodule comprises:
[0176] a first register setting unit, configured to set the address register to a preset value; and the virtual devices are configured to communicate with the host controller to obtain the respective device addresses when the address register is the preset value;
[0177] a return address obtaining unit, configured to obtain the device address corresponding to each virtual device when the host controller returns the corresponding device address to each virtual device.
[0178] In some embodiments of the present application, the first register setting unit comprises:
[0179] a second register setting unit, configured to set the address register to a preset value to enable the first virtual device in the sequence of virtual devices to communicate with the host controller;
[0180] an address obtaining unit, configured to set the address register to a third device address after the host controller returns the device address of the first virtual device;
[0181] a third register setting unit, configured to continue to set the address register to the preset value in response to a next port query instruction, until each virtual device obtains the respective corresponding device address.
[0182] In some embodiments of the present application, the device further comprises:
[0183] a virtual device endpoint module, configured to determine the endpoint corresponding to each virtual device according to the physical device included in each virtual device; and the endpoint is used for the physical device to communicate with the host.
[0184] an endpoint mapping table module configured 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.
[0185] In some embodiments of the present application, the second virtual device is multiple; the physical device updating module comprises:
[0186] a current combination submodule configured to obtain a physical device combination of the physical device connected by the host after being updated to obtain a first device combination
[0187] a current matching submodule configured to match the first device combination with a second device combination of each of the second virtual devices respectively; the second device combination represents a physical device combination corresponding to the second virtual device;
[0188] a current target submodule configured to determine a target second virtual device associated with the first virtual device when the first device combination is consistent with a target second device combination; the target second virtual device corresponds to the target second device combination.
[0189] In some embodiments of the present application, the device further comprises:
[0190] a device address table module configured to construct a device address table according to each virtual device and its corresponding device address;
[0191] an address table query module configured to obtain a target device address corresponding to the second virtual device in the device address table according to the second virtual device;
[0192] an address configuration module configured to configure the device controller based on the target device address.
[0193] In some embodiments of the present application, the device further comprises:
[0194] 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 at least one physical device;
[0195] a third port address submodule configured to associate the third virtual device to a third communication port and obtain a third device address corresponding to the third virtual device;
[0196] a third device communication submodule configured 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.
[0197] In some embodiments of the present application, the device combination module comprises:
[0198] The type frequency acquisition submodule is configured to acquire device type and usage frequency information of each physical device in the at least one physical device
[0199] The type frequency combination submodule is configured to combine the at least one physical device according to the device type and usage frequency information, to obtain the first virtual device and the second virtual device.
[0200] In some embodiments of the present application, the current combination submodule comprises:
[0201] The mounting unit is configured to determine the first device combination corresponding to the physical device combination after the host is connected to the added physical device; or
[0202] The unloading unit is configured to determine the first device combination corresponding to the physical device combination after the host is connected to the unloaded physical device.
[0203] In some embodiments of the present application, the apparatus further comprises:
[0204] The unloading saving module is configured to save the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device when all the physical devices connected to the host are unloaded.
[0205] In some embodiments of the present application, the apparatus further comprises:
[0206] The detection acquisition module is configured to acquire at least one physical device connected to the host when the host is connected to the physical device.
[0207] In some embodiments of the present application, the apparatus further comprises:
[0208] The user input module is configured to receive physical device information input by a user and determine at least one physical device indicated by the physical device information.
[0209] In some embodiments of the present application, the apparatus further comprises:
[0210] The enumeration prompt module is configured 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 acquires a corresponding device address; the enumeration completion message is used to indicate that all the virtual devices are enumerated.
[0211] Embodiments of the present application also provide an electronic device, as shown in FIG. 11, comprising 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 complete communication with each other through the communication bus 1704.
[0212] The memory 1703 is configured to store a computer program.
[0213] The processor 1701 is configured to implement the following steps when executing the program stored in the memory 1703: when it is determined that the combination of physical devices currently connected with the host corresponds to a first virtual device, connecting the first virtual device with the host controller in communication based on a first configuration of the first virtual device; the first configuration includes a first communication port for connecting the first virtual device with the device controller, and a first device address for configuring the device controller; when the physical devices connected with the host are updated, determining a second virtual device associated with the first virtual device according to the updated combination of physical devices; and switching to connect the second virtual device with the host controller in communication based on a second configuration of the second virtual device; the second configuration includes a second communication port for connecting the second virtual device with the device controller, and a second device address for configuring the device controller.
[0214] The processor 1701 can also implement other steps of the device communication method described above, which are not described here.
[0215] 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, etc. 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 only one type of bus.
[0216] The communication interface is used for communication between the above electronic device and other devices.
[0217] The memory can include a random access memory (RAM) and can also include a non-volatile memory, such as at least one disk memory. In some embodiments of the present application, the memory can also be at least one storage device located away from the aforementioned processor.
[0218] The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0219] In another embodiment provided by the present application, a non-volatile readable storage medium is also provided, which stores instructions, and when the instructions are run on a computer, the computer executes the device communication method in the above embodiment.
[0220] In another embodiment provided by the present application, a computer program product containing instructions is also provided, and when the instructions are run on a computer, the computer executes the device communication method in the above embodiment.
[0221] In the above embodiment, all or part of the embodiment can be realized by software, hardware, firmware or any combination thereof. When realized by software, all or part of the embodiment can be realized 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, all or part of the processes or functions according to the embodiments of the present application are generated. 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 non-volatile readable storage medium or transferred from one non-volatile readable storage medium to another non-volatile readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The non-volatile readable storage medium can be any available medium that the computer can access or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD (Digital Versatile Disc)), or a semiconductor medium (for example, a solid state disk (SSD)) and the like.
[0222] It should be noted that, in the specification, relational terms such as first and second and the like can be used solely to distinguish one entity or action from another entity or action without necessarily implying any actual relationship or order between such entities or actions. Also, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0223] Various embodiments are described herein with reference to particular applications with a specific configuration and contents for convenience. It is to be understood that the application is not limited to those precise applications and that changes can be made to the configuration and contents without departing from the scope of the application. Embodiments of the application are described in detail with reference to the drawings and the following description. The same reference numbers in different drawings denote the same or similar elements. The embodiments of the application can be implemented in various manners and the description is merely an example. It should be noted that the embodiments of the application are not limited to the description herein. The same, similar or identical components are denoted by the same reference numerals in the description of the drawings. The embodiments of the application are described in detail with reference to the drawings and the following description. The same reference numbers in different drawings denote the same or similar elements. The embodiments of the application can be implemented in various manners and the description is merely an example. It should be noted that the embodiments of the application are not limited to the description herein. The same, similar or identical components are denoted by the same reference numerals in the description of the drawings. The embodiments of the apparatus, electronic device, non-transitory computer readable storage medium and computer program product containing instructions of the application are basically similar to the method embodiments, and thus the description is relatively simple, and the relevant parts are described with reference to the description of the method embodiments.
[0224] The preferred embodiments of the application are merely used to explain the application and not to limit the scope of the application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the application shall fall within the scope of the application.
Claims
1. A device communication method characterized by, The method comprises: When determining that the host is currently connected to a first virtual device corresponding to a combination of physical devices, connecting the first virtual device to the host controller in communication based on a first configuration of the first virtual device; the first configuration comprises a first communication port configured to connect the first virtual device and a device controller, and a first device address configured to configure the device controller; When the physical devices connected to the host are updated, determining a second virtual device associated with the first virtual device according to the updated combination of physical devices; Switching to the second virtual device connected to the host controller in communication based on a second configuration of the second virtual device; the second configuration comprises a second communication port configured to connect the second virtual device and the device controller, and a second device address configured to configure the device controller.
2. The method of claim 1, wherein, The device controller comprises an address register; the method further comprises: Sending an address allocation request to the host controller; Receiving a 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.
3. The method of claim 2, wherein, The method further comprises: Combining at least one physical device to obtain the first virtual device and the second virtual device; each virtual device corresponds to a respective combination of physical devices; Associating each virtual device to a different communication port and obtaining a device address corresponding to each virtual device to generate the first configuration comprising the first communication port and the first device address and the second configuration comprising the second communication port and the second device address.
4. The method of claim 3, wherein, The address allocation request carries a port query interval; the step of associating each virtual device to a different communication port and obtaining a device address corresponding to each virtual device comprises: 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 comprising each virtual device according to the number of physical devices corresponding to the virtual device; Associating the virtual devices in the virtual device sequence to the communication ports one by one; Setting the address register to a preset value to obtain a device address corresponding to each virtual device.
5. The method of claim 4, wherein, The number of physical devices included in the virtual devices in the virtual device sequence is increasing; the step of associating the virtual devices in the virtual device sequence to the communication ports one by one comprises: Determining a first virtual device in the virtual device sequence and associating the first virtual device to a first communication port; In response to a next port query instruction, continue to determine a next virtual device in the virtual device sequence and associate the next virtual device to a next communication port until each virtual device in the virtual device sequence is traversed.
6. The method of claim 4, wherein, The step of setting the address register to a preset value to obtain a device address corresponding to each virtual device comprises: setting the address register to the preset value; the virtual device is configured to communicate with the host controller to obtain a respective device address when the address register is the preset value; obtaining the device address corresponding to each virtual device when the host controller returns the device address corresponding to each virtual device.
7. The method of claim 6, wherein, The step of setting the address register to the preset value comprises: setting the address register to the preset value to enable the first virtual device in the sequence of virtual devices to communicate with the host controller; setting the address register to the third device address after the host controller returns the device address of the first virtual device; in response to a next port query instruction, continuing to set the address register to the preset value until each virtual device obtains a respective device address.
8. The method of claim 1, wherein, The method further comprises: determining an endpoint corresponding to each virtual device according to the physical device included in each virtual device; the endpoint is configured to enable the physical device to communicate with the host; constructing an endpoint mapping table according to each virtual device and the endpoint corresponding thereto; the endpoint mapping table is configured to configure the device controller.
9. The method of claim 1, wherein, The second virtual device is multiple; the step of determining the second virtual device associated with the first virtual device according to the updated physical device combination comprises: obtaining 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 a second device combination 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 a target second device combination, determining a target second virtual device associated with the first virtual device; the target second virtual device corresponds to the target second device combination.
10. The method of claim 6, wherein, The method further comprises: constructing a device address table according to each virtual device and the device address corresponding thereto; obtaining a target device address corresponding to the second virtual device in the device address table according to the second virtual device; configuring the device controller based on the target device address.
11. The method of claim 3, wherein, The method further comprises: when the host is connected to a newly added physical device, constructing a third virtual device 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 to the third virtual device to communicate with the host controller.
12. The method of claim 3, wherein, The step of combining the at least one physical device to obtain the first virtual device and the second virtual device comprises: obtaining device type and usage frequency information of each physical device in the at least one physical device; combining the at least one physical device according to the device type and the usage frequency information to obtain the first virtual device and the second virtual device.
13. The method of claim 9, wherein, The step of obtaining the updated physical device combination of the host connected physical devices to obtain the first device combination comprises: When the host is connected to the added physical device, determining the first device combination corresponding to the updated physical device combination; or When the host connected physical device is unloaded, determining the first device combination corresponding to the unloaded physical device combination.
14. The method of claim 1, wherein, The method further comprises: When all the host connected physical devices are unloaded, saving the first configuration corresponding to the first virtual device and the second configuration corresponding to the second virtual device.
15. The method of claim 3, wherein, Before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further comprises: In the case that the host has been connected to the physical device, obtaining the at least one physical device connected by the host.
16. The method of claim 3, wherein, Before the step of combining at least one physical device to obtain the first virtual device and the second virtual device, the method further comprises: Receiving the physical device information input by the user, and determining the at least one physical device indicated by the physical device information.
17. The method of claim 5, wherein, 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, sending an enumeration completion message to the host controller; the enumeration completion message is configured to indicate that all virtual devices have completed enumeration.
18. A device communication system, characterized by 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 configured to perform the steps of the device communication method in any one of claims 1-17.
19. An apparatus for communicating comprising: The device comprises: The first device communication module is configured to, when determining that the first virtual device corresponds to the combination of the physical devices currently connected by the host, communicate the first virtual device with the host controller based on the first configuration of the first virtual device; the first configuration comprises a first communication port configured to connect the first virtual device and the device controller, and a first device address configured to configure the device controller; The physical device update module is configured to, when the host connected physical device is updated, determine the second virtual device associated with the first virtual device according to the updated physical device combination; The second device communication module is configured to, based on the second configuration of the second virtual device, switch the second virtual device to communicate with the host controller; the second configuration comprises a second communication port configured to connect the second virtual device and the device controller, and a second device address configured to configure the device controller.
20. An electronic device, comprising: It comprises: The memory is configured to save the computer program; The processor is configured to execute the computer program to implement the device communication method according to any one of claims 1-17.
21. A non-transitory readable storage medium, characterized in that, a computer program / instructions configured to, when executed by a processor, implement the device communication method of any one of claims 1 to 17.
22. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instructions are configured to, when executed by a processor, implement the device communication method of any one of claims 1 to 17.
Citation Information
Patent Citations
Virtual USB compound device enumeration
CN103154922A
Method and system for achieving rapid accessing of USB devices
CN105488000A
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
Equipment communication method, system and device, equipment, storage medium and program product
CN118568015A