Methods, apparatus and computer-readable storage media for identifying multiple devices

By obtaining a list of device protocol groups and polling to identify devices, the problem of low efficiency in identifying multiple devices is solved, enabling automated device management and rapid reconnection, and reducing data loss.

CN115408316BActive Publication Date: 2026-03-06RICOH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-28
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently identify and connect multiple medical devices of different brands or models, resulting in significant data acquisition difficulties and substantial data loss when devices are disconnected.

Method used

By acquiring the port list and device protocol group list of the target system, the device is identified by polling according to the device interaction mode. The identification device includes an information acquisition module, a port polling module, and an exception handling module, which handles changes in device connection status and automatically identifies and reconnects to the device.

Benefits of technology

It improves device identification efficiency, reduces data loss, and enables automated management and rapid reconnection of device connections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115408316B_ABST
    Figure CN115408316B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, and computer-readable storage medium for identifying multiple devices. The identification method includes: performing a polling operation for each port in a port list; the polling operation includes: determining a target device protocol group from a plurality of device protocol groups based on the device interaction mode on the port; polling each device protocol in the target device protocol group; and using the currently polled device protocol to identify the device connected to the port. This invention can improve device identification efficiency and can also automatically handle normal and abnormal device disconnections.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of device identification and management technology, and in particular to a method, apparatus and computer-readable storage medium for identifying multiple devices. Background Technology

[0002] In smart home systems, smart building systems, and healthcare systems, it is often necessary to collect data from multiple devices simultaneously. For example, medical big data requires the collection of monitoring data from numerous devices for scientific research and clinical use. Figure 1 In the data acquisition system of a medical device shown, a microcontroller unit (MCU) or microprocessor unit (MPU) connects multiple medical devices with serial ports via a hub to collect data from each device. However, the data output of medical devices from different brands or different models of the same brand may follow different protocols. These protocol differences significantly increase the difficulty of acquiring data from multiple devices simultaneously. Furthermore, during data acquisition, disconnection, reconnection, or replacement of devices can lead to substantial data loss.

[0003] Current medical data collection tools (such as Philips IntellVUE and Mindray BeneLink) mostly only support the connection of devices from the same manufacturer and are not compatible with medical devices from other manufacturers. Other tools, such as VitalRecorder, have complex interface configurations and high technical barriers. Therefore, there is an urgent need for a multi-device identification method that can improve device recognition efficiency. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method, apparatus and computer-readable storage medium for identifying multiple devices, which can improve the efficiency of device identification.

[0005] To address the aforementioned technical problems, embodiments of the present invention provide the following technical solutions:

[0006] Obtain the port list and device protocol group list of the target system, wherein the port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0007] A polling operation is performed on each port in the port list, the polling operation including:

[0008] Based on the device interaction mode on the port, a target device protocol packet is determined from the plurality of device protocol packets;

[0009] Poll each device protocol in the target device protocol group, and use the currently polled device protocol to identify the device connected to the port.

[0010] Preferably, the device protocol group further includes a list of existing devices for each device protocol, wherein the list of existing devices records all existing devices that support that device protocol; the method further includes:

[0011] The connected device list is shared among the ports in the port list, and the connected device list records the devices that have been connected to each port of the target system.

[0012] After adding the binding relationship between the first port and the first device to the list of connected devices, the first mutually exclusive device that is mutually exclusive with the first device and the first mutually exclusive device protocol adopted by the first mutually exclusive device are determined according to the preset device mutual exclusion relationship. The device mutual exclusion relationship is used to indicate the devices that the target system will not connect to at the same time. The mutually exclusive device of any device includes at least the device itself.

[0013] If the list of existing devices under the first mutually exclusive device protocol includes only the first mutually exclusive device, then the first mutually exclusive device protocol will be removed from its corresponding device protocol group.

[0014] Preferably, the method further includes:

[0015] Monitor the device connection status of each port in the list of connected devices;

[0016] If the device connection status of the second device on the second port is detected to be disconnected or abnormal, the second port is closed and the binding relationship between the second port and the second device is deleted from the list of connected devices.

[0017] Based on the device mutual exclusion relationship, determine the second mutually exclusive device that is mutually exclusive with the second device and the second mutual exclusion device protocol adopted by the second mutually exclusive device;

[0018] If the second mutually exclusive device protocol has been removed from its device protocol group, the second mutually exclusive device protocol shall be added to its device protocol group.

[0019] Preferably, polling each device protocol in the target device protocol group and identifying the device connected to the port using the currently polled device protocol specifically includes: if a device is successfully identified, adding the binding relationship between the port and the identified device to the list of connected devices; if a device is not identified, continuing to poll the next device protocol in the target device protocol group until a device is successfully identified or all device protocols in the target device protocol group have been polled.

[0020] Preferably, if a device is still not identified after all device protocols in the target device protocol group have been polled, it is determined that the port is not connected to a device or the connected device is an unknown protocol device.

[0021] Preferably, the method further includes:

[0022] Close the port after determining that no device is connected to the port or that the connected device is an unknown protocol device.

[0023] Preferably, the plurality of device protocol groups include a first device protocol group and a second device protocol group, wherein the first device protocol group corresponds to a first device interaction mode in which the device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which the device only sends data when it receives a data request.

[0024] The step of determining a target device protocol packet from the plurality of device protocol packets based on the device interaction mode on the port includes: determining whether data automatically sent by the device is received on the port; if so, determining the target device protocol packet as the first device protocol packet; otherwise, determining the target device protocol packet as the second device protocol packet.

[0025] Preferably, polling each device protocol in the target device protocol group and identifying the device connected to the port using the currently polled device protocol includes:

[0026] If the target device protocol group is the first device protocol group, the data received on the port is parsed using the currently polled device protocol to obtain the device identifier; if the device identifier cannot be parsed, a request message is sent on the port to request the device identifier if the currently polled device protocol supports interactive commands.

[0027] If the target device protocol packet is the second device protocol packet, a request message is sent on the port to request the device identifier using the currently polled device protocol.

[0028] Preferably, the device interaction mode is further used to indicate whether the data automatically sent by the device carries a device identifier when the device automatically sends data on the port;

[0029] The plurality of device protocol groups include a second device protocol group, a third device protocol group, and a fourth device protocol group. The second device protocol group corresponds to a second device interaction mode in which the device sends data only when it receives a data request. The third device protocol group corresponds to a third device interaction mode in which the device automatically sends data and the data carries a device identifier. The fourth device protocol group corresponds to a fourth device interaction mode in which the device automatically sends data without carrying a device identifier but supports interactive commands.

[0030] The step of determining a target device protocol group from the plurality of device protocol groups based on the device interaction mode on the port includes: determining whether data automatically sent by the device is received on the port; if so, determining the target device protocol group as the third device protocol group or the fourth device protocol group; otherwise, determining the target device protocol group as the second device protocol group.

[0031] Preferably, polling each device protocol in the target device protocol group and identifying the device connected to the port using the currently polled device protocol includes:

[0032] If the target device protocol group is the second device protocol group, poll each device protocol in the second device protocol group, and use the currently polled device protocol to send a request message on the port to request the device identifier;

[0033] If the target device protocol group is the third device protocol group or the fourth device protocol group, first poll each device protocol in the third device protocol group, and use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier is still not parsed after polling the device protocols in the third device protocol group, then continue to poll each device protocol in the fourth device protocol group, and use the currently polled device protocol to send a request message on the port to request the device identifier.

[0034] Preferably, determining whether data automatically sent by the device is received on the port specifically involves: detecting whether data is received on the port within the first time window Tw1, where the length of the first time window Tw1 is N1 times the first period, and the first period is the maximum transmission interval of all existing devices automatically sending data in the third device protocol group and the fourth device protocol group, and N1 is greater than or equal to 1.

[0035] During the polling process of each device protocol in the second device protocol group, if the device identifier sent by the device is not obtained after sending a request message a preset first time number using the currently polled second device protocol, or if the device identifier sent by the device is not obtained within the second time window Tw2 after sending the request message, then the next device protocol in the second device protocol group is polled again. The length of the second time window Tw2 is N2 times the first waiting time, where the first waiting time is the maximum waiting time between the existing device in the second device protocol receiving the request message and sending the device identifier, and N2 is greater than or equal to 1.

[0036] During the polling process of each device protocol in the third device protocol group, if the number of times the currently polled first device protocol parses the data received on the port but fails to obtain the device identifier reaches a preset second number, then the next device protocol in the third device protocol group is polled again.

[0037] During the polling process of each device protocol in the fourth device protocol group, if the device identifier sent by the device is not obtained after sending a request message a preset third time using the currently polled third device protocol, or if a response message is not received within the third time window Tw3 after sending the request message, then the next device protocol in the fourth device protocol group is polled again. The length of the third time window Tw3 is N3 times the second waiting time, where the second waiting time is the maximum waiting time between receiving the request message and sending the device identifier for all existing devices in the third device protocol, and N3 is greater than or equal to 1.

[0038] Preferably, the method further includes:

[0039] According to the preset polling period TW0, obtain the newly opened ports in the port list, and perform the polling operation for each newly opened port;

[0040] Wherein, the polling period TW0 is the larger of the first time and the second time;

[0041] The first time is N4 times the total polling time for all device protocols in the third device protocol group and the fourth device protocol group, where N4 is greater than or equal to 1;

[0042] The second time is N5 times the sum of the total polling time for all device protocols in the second device protocol group and the first time window Tw1, where N5 is greater than or equal to 1.

[0043] Preferably, before obtaining the port list and device protocol packet list of the target system, the method further includes:

[0044] Determine all device protocols supported by the ports of the target system, and group all device protocols according to the device interaction mode of each device protocol to obtain a list of device protocol groups and the device protocols under each device protocol group;

[0045] Connect the existing device to the port of the target system, obtain the device configuration parameters and device identifier when the existing device successfully accesses the target system, and save them in the device protocol to which the existing device belongs in the device protocol group.

[0046] Preferably, if the target device protocol does not define that the device identifier is carried in the data sent by the device, a preset data content in the data sent by the device is designated as the device identifier.

[0047] This invention also provides a multi-device identification device, comprising:

[0048] The information acquisition module is used to acquire the port list and device protocol group list of the target system. The port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0049] The port polling module is used to perform a polling operation for each port in the port list. The polling operation includes: determining a target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port; polling each device protocol in the target device protocol group; and using the currently polled device protocol to identify the device connected to the port.

[0050] Preferably, the device protocol group further includes a list of existing devices under each device protocol, and the list of existing devices records the device identifiers of all existing devices that support that device protocol; the identification device further includes:

[0051] An information sharing module is used to share the list of connected devices among the ports in the port list, wherein the list of connected devices records the devices that have been connected to each port of the target system.

[0052] The first information maintenance module is used to, after adding the binding relationship between the first port and the first device to the list of connected devices, determine the first mutually exclusive device that is mutually exclusive with the first device and the first mutually exclusive device protocol adopted by the first mutually exclusive device according to the preset device mutual exclusion relationship. The device mutual exclusion relationship is used to indicate devices that the target system will not connect to simultaneously. The mutually exclusive device of any device includes at least the device itself. If the list of existing devices under the first mutually exclusive device protocol only includes the first mutually exclusive device, the first mutually exclusive device protocol is deleted from its device protocol group.

[0053] Preferably, the identification device further includes:

[0054] The port detection module is used to monitor the device connection status of each port in the connected device list;

[0055] An exception handling module is configured to, upon detecting a connection loss or connection anomaly in the device connection status of a second device on the second port, close the second port and delete the binding relationship between the second port and the second device from the connected device list; and, based on the device mutual exclusion relationship, determine a second mutually exclusive device that is mutually exclusive with the second device and the second mutually exclusive device protocol used by the second mutually exclusive device; and, if the second mutually exclusive device protocol has been deleted from its respective device protocol group, add the second mutually exclusive device protocol to its respective device protocol group.

[0056] Preferably, the port polling module is further configured to, during the process of polling each device protocol in the target device protocol group and using the currently polled device protocol to identify the device connected to the port: if a device is successfully identified, the binding relationship between the port and the identified device is added to the list of connected devices; if a device is not identified, the next device protocol in the target device protocol group is polled until a device is successfully identified or all device protocols in the target device protocol group have been polled.

[0057] Preferably, the port polling module is further configured to determine that the port is not connected to a device or the connected device is an unknown device if the device protocol in the target device protocol group has been polled to the end and the device still cannot be identified.

[0058] Preferably, the identification device further includes:

[0059] The port control module is used to close the ports of unconnected devices or devices with unknown protocols after the polling operation.

[0060] Preferably, the plurality of device protocol groups include a first device protocol group and a second device protocol group, wherein the first device protocol group corresponds to a first device interaction mode in which the device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which the device only sends data when it receives a data request.

[0061] The port polling module includes:

[0062] The first judgment module is used to determine whether data automatically sent by the device is received on the port. If so, the target device protocol packet is determined to be the first device protocol packet; otherwise, the target device protocol packet is determined to be the second device protocol packet.

[0063] Preferably, the port polling module further includes:

[0064] The first processing module is configured to, when the target device protocol group is the first device protocol group, use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier cannot be parsed, then when the currently polled device protocol supports interactive commands, send a request message on the port to request the device identifier.

[0065] The second processing module is used to send a request message on the port to request a device identifier when the target device protocol group is the second device protocol group, using the currently polled device protocol.

[0066] Preferably, the device interaction mode is further used to indicate whether the data automatically sent by the device carries a device identifier when the device automatically sends data on the port;

[0067] The plurality of device protocol groups include a second device protocol group, a third device protocol group, and a fourth device protocol group. The second device protocol group corresponds to a second device interaction mode in which the device sends data only when it receives a data request. The third device protocol group corresponds to a third device interaction mode in which the device automatically sends data and the data carries a device identifier. The fourth device protocol group corresponds to a fourth device interaction mode in which the device automatically sends data without carrying a device identifier but supports interactive commands.

[0068] The port polling module includes:

[0069] The second judgment module is used to determine whether data automatically sent by the device is received on the port. If so, the target device protocol packet is determined to be the third device protocol packet or the fourth device protocol packet; otherwise, the target device protocol packet is determined to be the second device protocol packet.

[0070] Preferably, the port polling module further includes:

[0071] The third processing module is configured to, when the target device protocol group is the second device protocol group, poll each device protocol in the second device protocol group, and send a request message on the port to request a device identifier using the currently polled device protocol;

[0072] The fourth processing module is configured to, when the target device protocol group is the third device protocol group or the fourth device protocol group, first poll each device protocol in the third device protocol group, and use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier is still not parsed after polling the device protocols in the third device protocol group, then continue to poll each device protocol in the fourth device protocol group, and use the currently polled device protocol to send a request message on the port to request the device identifier.

[0073] Preferably, the second judgment module is further used to detect whether data is received on the port within the first time window Tw1. The length of the first time window Tw1 is N1 times the first period. The first period is the maximum transmission interval for all existing devices to automatically send data in the third device protocol group and the fourth device protocol group. N1 is greater than or equal to 1.

[0074] The third processing module is further configured to, during the polling process of each device protocol in the second device protocol group, if the device identifier sent by the device is not obtained after the number of times the request message is sent using the currently polled second device protocol reaches a preset first number, or if the device identifier sent by the device is not obtained within the second time window Tw2 after the request message is sent, then continue to poll the next device protocol in the second device protocol group. The length of the second time window Tw2 is N2 times the first waiting time, where the first waiting time is the maximum waiting time between the received request message and the sent device identifier of the existing device in the second device protocol, and N2 is greater than or equal to 1.

[0075] The fourth processing module is further configured to, during the polling process of each device protocol in the third device protocol group, if the number of times the currently polled first device protocol parses the data received on the port but fails to obtain the device identifier reaches a preset second number, then continue polling the next device protocol in the third device protocol group; and, during the polling process of each device protocol in the fourth device protocol group, if the number of times the currently polled third device protocol sends request messages reaches a preset third number and still fails to obtain the device identifier sent by the device, or if no response message sent by the device is received within the third time window Tw3 after sending the request message, then continue polling the next device protocol in the fourth device protocol group. The length of the third time window Tw3 is N3 times the second waiting time, where the second waiting time is the maximum waiting time between the receipt of the request message and the sending of the device identifier by all existing devices in the third device protocol, and N3 is greater than or equal to 1.

[0076] Preferably, the identification device further includes:

[0077] The polling control module is used to obtain newly opened ports from the port list according to a preset polling period TW0, and to perform the polling operation for each newly opened port; wherein,

[0078] Wherein, the polling period TW0 is the larger of the first time and the second time;

[0079] The first time is N4 times the total polling time for all device protocols in the third device protocol group and the fourth device protocol group, where N4 is greater than or equal to 1;

[0080] The second time is N5 times the sum of the total polling time for all device protocols in the second device protocol group and the first time window Tw1, where N5 is greater than or equal to 1.

[0081] Preferably, the identification device further includes:

[0082] The protocol preprocessing module is used to determine all device protocols supported by the ports of the target system, and group all device protocols according to the device interaction mode of each device protocol to obtain the device protocol group list and the device protocols under each device protocol group.

[0083] The information pre-configuration module is used to connect the existing device to the port of the target system, obtain the device configuration parameters and device identifier when the existing device successfully accesses the target system, and store them in the device protocol to which the existing device belongs in the device protocol group.

[0084] Preferably, the protocol preprocessing module is further configured to designate a preset data content in the data sent by the device as the device identifier when the target device protocol does not define that the device identifier is carried in the data sent by the device.

[0085] This invention also provides a multi-device identification device, comprising:

[0086] Processor; and

[0087] A memory, in which computer program instructions are stored,

[0088] When the computer program instructions are executed by the processor, the processor performs the following steps:

[0089] Obtain the port list and device protocol group list of the target system, wherein the port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port, and the device interaction mode is at least used to indicate whether the device automatically sends data.

[0090] A polling operation is performed on each port in the port list, the polling operation including:

[0091] Based on the device interaction mode on the port, a target device protocol packet is determined from the plurality of device protocol packets;

[0092] Poll each device protocol in the target device protocol group, and use the currently polled device protocol to identify the device connected to the port.

[0093] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the multi-device identification method described above.

[0094] The embodiments of the present invention have the following beneficial effects:

[0095] This invention can automatically identify devices connected to each port in parallel on a multi-port system, improving device identification efficiency. Furthermore, this invention can automatically handle normal and abnormal device disconnections during the connection process, and quickly identify and reconnect devices after reconnection. Attached Figure Description

[0096] Figure 1 A schematic diagram of a data acquisition system for a medical device in the prior art;

[0097] Figure 2 This is a schematic diagram illustrating an application scenario of the multi-device identification method according to an embodiment of the present invention;

[0098] Figure 3 This is a flowchart illustrating the multi-device identification method provided in an embodiment of the present invention;

[0099] Figure 4 This is a schematic diagram illustrating the workflow of a multi-device identification method according to an embodiment of the present invention;

[0100] Figure 5 This is a schematic diagram illustrating device identification according to an embodiment of the present invention;

[0101] Figure 6 This is a schematic diagram illustrating how the program works during system initialization in an embodiment of the present invention;

[0102] Figure 7 This is a schematic diagram illustrating the workflow of the pre-configuration steps in an embodiment of the present invention;

[0103] Figure 8 This is a schematic diagram illustrating the workflow of a thread bound to a single port in an embodiment of the present invention.

[0104] Figure 9 This is a schematic diagram illustrating the process of the program automatically identifying devices in each group in an embodiment of the present invention;

[0105] Figure 10 This is a schematic diagram illustrating the normal or abnormal disconnection of the processing device in an embodiment of the present invention;

[0106] Figure 11 This is a schematic diagram illustrating the periodic polling operation in an embodiment of the present invention;

[0107] Figure 12 This is a structural block diagram of a multi-device identification device according to an embodiment of the present invention;

[0108] Figure 13 This is another structural block diagram of the multi-device identification device according to an embodiment of the present invention. Detailed Implementation

[0109] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0110] The terms “first,” “second,” etc., used in the specification and claims of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The terms “and / or” in the specification and claims indicate at least one of the connected objects.

[0111] One known method for collecting data from multiple devices involves first programming all supported device protocols into the system, and then using the stored protocols to poll all ports sequentially to automatically identify and connect multiple devices. This method requires polling all protocols on each port until the device on that port is identified. Because of the large number of protocols being polled, the polling time is long, resulting in a significant loss of valuable time during the polling phase.

[0112] This invention provides a method for multi-device identification, which can identify multiple devices connected to a port, reducing polling time and improving device identification efficiency. Furthermore, in scenarios where abnormal issues cause abnormal connection drops, devices typically do not send connection drop messages normally when disconnecting, and the port does not automatically release. This invention addresses transmission interruptions during data acquisition and abnormal interruptions during device connection, further improving the automation and efficiency of multi-device identification.

[0113] Figure 2 This diagram illustrates an application scenario of the multi-device identification method according to an embodiment of the present invention. In this embodiment, the target system for collecting data from multiple devices has multiple ports, which can connect to various devices to collect their data. For example, the connection methods between the target system and the devices include, but are not limited to: connecting to a device with a serial port via a hub, connecting to a device with a network port via a router, connecting to a device with a Bluetooth interface via Bluetooth, and other connection methods. Specifically, the target system can be a microcontroller unit (MCU) or a microprocessor unit (MPU), or it can be a computer system with computing and processing capabilities.

[0114] Before collecting data, the target system needs to identify the devices connected to the port in order to communicate with the devices using their respective device protocols to collect data. To improve identification efficiency, this embodiment of the invention pre-determines the device protocols (including data parsing protocols and communication protocols) that the target system needs to support for various devices based on the devices for which data collection is required. Then, based on the device interaction modes of each device protocol, all device protocols supported by the target system are grouped to obtain a device protocol group list. Here, the device interaction mode is at least used to indicate whether the device automatically sends data. Thus, the resulting device protocol group list includes multiple device protocol groups corresponding to different device interaction modes, and each device protocol group includes at least one device protocol supported by the target system on the port.

[0115] After grouping the device protocols on the ports supported by the target system, embodiments of the present invention can perform targeted polling on each port according to the device interaction mode on each port, thereby reducing polling time, improving the polling efficiency of device protocols and device identification efficiency, and thus reducing problems such as data loss caused by excessively long polling time.

[0116] like Figure 3 As shown, this embodiment of the invention provides a method for multi-device identification, including:

[0117] Step 301: Obtain the port list and device protocol group list of the target system. The port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0118] Step 302: Perform a polling operation for each port in the port list. The polling operation includes:

[0119] Based on the device interaction mode on the port, a target device protocol packet is determined from the plurality of device protocol packets;

[0120] Poll each device protocol in the target device protocol group, and use the currently polled device protocol to identify the device connected to the port.

[0121] Here, during the process of identifying the device connected to the port using the currently polled device protocol, if the device is successfully identified, the binding relationship between the port and the identified device is added to the connected device list; if the device is not identified, the process continues to poll for the next device protocol in the target device protocol group until a device is successfully identified or all device protocols in the target device protocol group have been polled. Here, the connected device list records the devices already connected to each port of the target system.

[0122] As can be seen from the above steps, when polling device protocols on a port, the embodiments of the present invention determine the target device protocol group corresponding to the port based on the device interaction mode of the port, and then only poll the device protocols in the target device protocol group on the port, thereby avoiding the problem of excessively long polling time caused by polling all device protocols.

[0123] Prior to step 301 above, embodiments of the present invention can group device protocols and configure and save device configuration information through protocol preprocessing steps and information preconfiguration steps.

[0124] Specifically, in the protocol preprocessing step, all device protocols supported by the ports of the target system are determined, and all device protocols are grouped according to the device interaction mode of each device protocol to obtain the device protocol group list and the device protocols under each device protocol group.

[0125] In the information pre-configuration step, the existing device is connected to the port of the target system (pre-connection). The device configuration parameters and device identifier of the existing device when it successfully connects to the target system are obtained and stored under the corresponding device protocol in the device protocol group to which the existing device belongs. Here, the device configuration parameters can be one parameter selected by the device from multiple parameters supported by the protocol. For example, if the device protocol defines multiple baud rates, and the device uses one of them, during the pre-connection process, the port baud rate is configured to match the baud rate used by the device through debugging, thus enabling a successful connection. The specific baud rate and other parameters are then stored under the device protocol. When the device protocol is subsequently polled, the device configuration parameters under that device protocol will be used to interact with the device.

[0126] In addition, in the above protocol preprocessing steps, if the target device protocol does not define that the device identifier is carried in the data sent by the device, the embodiments of the present invention can also designate the preset data content in the data sent by the device as the device identifier.

[0127] The following provides two implementation methods for device interaction modes.

[0128] As the first implementation method of device interaction mode:

[0129] The device interaction mode is used to indicate whether the device automatically sends data. In other words, different device interaction modes can be determined based on whether the device automatically sends data on the port after connecting to the target system. Thus, the device interaction modes can be divided into two types: 1) a first device interaction mode where the device automatically sends data; and 2) a second device interaction mode where the device does not automatically send data, but only sends data when a data request is received. Correspondingly, the device protocol packet list includes two groups: 1) a first device protocol packet corresponding to the first device interaction mode; and 2) a second device protocol packet corresponding to the second device interaction mode.

[0130] When the device interaction mode adopts the first implementation method described above, in step 302, a target device protocol group is determined from the multiple device protocol groups according to the device interaction mode on the port. Specifically, it is determined whether data automatically sent by the device is received on the port. If so, the target device protocol group is determined to be the first device protocol group; otherwise, the target device protocol group is determined to be the second device protocol group.

[0131] When the device interaction mode adopts the first implementation method described above, in step 302, the device connected to the port is identified using the currently polled device protocol, specifically as follows:

[0132] 1) If the target device protocol group is the first device protocol group, the data received on the port is parsed using the currently polled device protocol to obtain the device identifier; if the device identifier cannot be parsed, a request message is sent on the port to request the device identifier if the currently polled device protocol supports interactive commands. If the device identifier of the device connected to the port is obtained, the device connected to the port is considered to have been identified.

[0133] 2) If the target device protocol group is the second device protocol group, a request message is sent on the port to request the device identifier using the currently polled device protocol.

[0134] As a second way to implement device interaction mode:

[0135] The device interaction mode is used not only to indicate whether the device automatically sends data, but also to indicate whether the automatically sent data carries a device identifier when the device automatically sends data on the port. In other words, different device interaction modes can be determined based on whether the device automatically sends data on the port after connecting to the target system, and whether the automatically sent data carries a device identifier. Thus, the device interaction modes can be divided into three types: 1) a second device interaction mode where the device does not automatically send data, but only sends data when receiving a data request; 2) a third device interaction mode where the device automatically sends data and the data carries a device identifier; and 3) a fourth device interaction mode where the automatically sent data does not carry a device identifier but supports interactive commands. Correspondingly, the device protocol group list includes three groups: 1) a second device protocol group corresponding to the second device interaction mode; 2) a third device protocol group corresponding to the third device interaction mode; and 3) a fourth device protocol group corresponding to the fourth device interaction mode.

[0136] When the device interaction mode adopts the second implementation method described above, in step 302, a target device protocol group is determined from the plurality of device protocol groups according to the device interaction mode on the port. Specifically, it is determined whether data automatically sent by the device is received on the port. If so, the target device protocol group is determined to be the third device protocol group or the fourth device protocol group; otherwise, the target device protocol group is determined to be the second device protocol group.

[0137] Here, determining whether data automatically sent by the device is received on a certain port is specifically as follows: detecting whether data is received on the port within the first time window Tw1. The length of the first time window Tw1 is N1 times the first period. The first period is the maximum transmission interval of all existing devices automatically sending data in the third device protocol group and the fourth device protocol group, and N1 is greater than or equal to 1.

[0138] When the device interaction mode adopts the second implementation method described above, in step 302, the device connected to the port is identified using the currently polled device protocol, specifically as follows:

[0139] 1) If the target device protocol group is the second device protocol group, poll each device protocol in the second device protocol group, and send a request message on the port to request the device identifier using the currently polled device protocol.

[0140] Here, during the polling process of each device protocol in the second device protocol group, if the device identifier sent by the device is not obtained after sending a request message a preset first time number using the currently polled second device protocol, or if the device identifier sent by the device is not obtained within the second time window Tw2 after sending the request message, then the next device protocol in the second device protocol group is polled again. The length of the second time window Tw2 is N2 times the first waiting time, where the first waiting time is the maximum waiting time between the receiving of the request message and the sending of the device identifier by the existing device in the second device protocol, and N2 is greater than or equal to 1.

[0141] 2) If the target device protocol group is the third device protocol group or the fourth device protocol group, first poll each device protocol in the third device protocol group, and use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier is still not parsed after polling the device protocols in the third device protocol group, then continue to poll each device protocol in the fourth device protocol group, and use the currently polled device protocol to send a request message on the port to request the device identifier.

[0142] Here, during the process of polling each device protocol in the third device protocol group, if the number of times the currently polled first device protocol parses the data received on the port but fails to obtain the device identifier reaches a preset second number, then the next device protocol in the third device protocol group is continued to be polled.

[0143] During the polling process of each device protocol in the fourth device protocol group, if the device identifier sent by the device is not obtained after sending a request message a preset third time using the currently polled third device protocol, or if a response message is not received within the third time window Tw3 after sending the request message, then the next device protocol in the fourth device protocol group is polled again. The length of the third time window Tw3 is N3 times the second waiting time, where the second waiting time is the maximum waiting time between receiving the request message and sending the device identifier for all existing devices in the third device protocol, and N3 is greater than or equal to 1.

[0144] In step 302 of this embodiment of the invention, if no device is identified after polling all device protocols in the target device protocol group, it is determined that the port is not connected to a device or the connected device is an unknown protocol device. An unknown protocol device refers to a device using a device protocol not supported by the target system. Furthermore, after polling each port, or after polling all ports, ports with unconnected devices or connected devices with unknown protocols can be closed to conserve port resources. It should be noted that closing a port is usually performed after polling; closing a port is not a purpose of polling.

[0145] In many application scenarios, the devices that the target system may connect to are usually known in advance. For example, all devices in a medical institution that need to use the target system for data collection may be connected to a port of the target system. Here, "existing devices" refers to the various devices that are predetermined and may connect to the target system. Other devices besides the existing devices will not connect to the target system. Furthermore, there may be mutual exclusion relationships between the various existing devices. Thus, embodiments of the present invention can utilize the information of existing devices to establish device mutual exclusion relationships to further improve the efficiency of device polling and identification.

[0146] Specifically, the device mutual exclusion relationship is used to indicate which devices will not be connected to the target system simultaneously. For example, assuming the target system of a medical institution connects to at most one pulse oximeter, then all pulse oximeters are mutually exclusive devices. That is, if a pulse oximeter is already connected to a port of the target system, then no other pulse oximeter will be connected to other ports of the target system. As another example, the mutual exclusion of any device includes at least that device itself; that is, a device will not be connected to different ports of the target system simultaneously. In other words, if a pulse oximeter is already connected to a port of the target system, then that pulse oximeter will not appear on other ports of the target system.

[0147] Thus, in this embodiment of the invention, the device protocol group also includes a list of existing devices under each device protocol, and the list of existing devices records the device identifiers of all existing devices supporting that device protocol. Furthermore, this embodiment of the invention also shares the list of connected devices among the ports in the port list. Thus, in step 302 above, after adding the binding relationship between a port and a device (here referred to as the first port and the first device) to the list of connected devices, a first mutually exclusive device and the first mutually exclusive device protocol used by the first mutually exclusive device are determined according to a preset device mutual exclusion relationship. Then, if the list of existing devices under the first mutually exclusive device protocol only includes the first mutually exclusive device, the first mutually exclusive device protocol is deleted from its device protocol group, thereby reducing the number of device protocols in the device protocol group and thus reducing the polling time required to poll each device protocol in the device protocol group.

[0148] For example, suppose the existing devices include pulse oximeters 1 to 3, where pulse oximeter 1 uses device protocol 1, and pulse oximeters 2 to 3 all use device protocol 4; device protocol group 1 includes device protocols 1 to 3, and device protocol group 2 includes device protocols 4 to 5; the list of existing devices under device protocol 1 only includes the device identifier of pulse oximeter 1, and the list of existing devices under device protocol 4 only includes the device identifiers of pulse oximeters 2 to 3. The target system can connect to at most one pulse oximeter, therefore, each pulse oximeter is a mutually exclusive device. When the target system identifies that pulse oximeter 1 is connected to port 1 by performing the above polling operation, it will add a binding relationship between port 1 and pulse oximeter 1 to the list of connected devices. Then, based on the mutual exclusion relationship of the devices, the mutual exclusion devices of pulse oximeter 1 are determined to be pulse oximeters 1 to 3 (including pulse oximeter 1 itself). These mutually exclusive devices use mutual exclusion device protocols including device protocol 1 and device protocol 4. Furthermore, all devices in the existing device lists under device protocol 1 and device protocol 4 are mutually exclusive devices. Therefore, device protocol 1 can be deleted from device protocol group 1, and device protocol 4 can be deleted from device protocol group 2. As a result, the updated device protocol group 1 only includes device protocols 2 to 3, and the updated device protocol group 2 only includes device protocol 5. In this way, when polling the above device protocol groups in the future, fewer device protocols can be polled, which improves the polling efficiency and device identification efficiency.

[0149] In practical applications, devices connected to a port may malfunction for various reasons (such as device failure, power outage, manual disconnection, or replacement of the device connected to the port). To promptly detect these anomalies and automatically identify newly connected devices on the port, this embodiment of the invention can also monitor the device connection status of each port in the connected device list. If a device on a port (referred to here as the second device on the second port) is detected to have a disconnected or abnormal connection, the second port is closed, and the binding relationship between the second port and the second device is removed from the connected device list. Then, based on the device mutual exclusion relationship, a second mutually exclusive device and its protocol are determined. If the second mutually exclusive device protocol has been removed from its device protocol group, it is added back to its device protocol group.

[0150] Continuing with the above example, when the device connection status of pulse oximeter 1 on port 1 is disconnected or abnormal, this embodiment of the invention will close port 1, and at the same time, re-add device protocol 1 to device protocol group 1 and re-add device protocol 4 to device protocol group 2.

[0151] Specifically, when the device interaction mode adopts the second implementation method described above, that is, when the device interaction mode includes the second, third, and fourth device interaction modes described above, detecting whether the device connection status of a certain device on a certain port (here referred to as the second device on the second port) has been disconnected or abnormal can be done as follows:

[0152] (1) When the device interaction mode on the second port is the third device interaction mode in which the device automatically sends data and the data carries the device identifier, the connection disconnection means that no data is received on the second port within the preset time window TweA. The connection abnormality means that after receiving the data received on the second port for the fourth time T4, it is detected again that the data received on the second port does not match the device protocol used by the second device when the data received on the second port does not match the device protocol used by the second device.

[0153] (2) When the device interaction mode on the second port is the fourth device interaction mode where the device automatically sends data and the data does not carry a device identifier, the connection disconnection means that after no data is received on the second port in the preset time window TweB1, a request message is sent on the second port to request the device identifier, and a response is still not received in the time window TweB2; the connection abnormality means that when it is detected that the data received on the second port does not match the device protocol used by the second device, after receiving the fifth T5 data on the second port, when it is detected again that the data received on the second port does not match the device protocol used by the second device, after sending a request message on the second port to request the device identifier, the number of times the erroneous response data is received reaches the sixth T6.

[0154] (3) When the device interaction mode on the second port is the second device interaction mode in which the device does not automatically send data, the connection disconnection means that after the preset time window TweC1 does not receive data on the second port, a request message is sent on the second port to request the device identifier, and then the response data is not received in the time window TweC2.

[0155] Here, the time windows TweA and TweB1 mentioned above are typically first preset multiples of the maximum interval at which the second device automatically sends data, and this first preset multiple is usually greater than or equal to 1. Time windows TweB2, TweC1, and TweC2 are typically second preset multiples of the maximum interval between receiving a request message and sending a response message, and this second preset multiple is usually greater than or equal to 1. T4, T5, and T6 are typically integers greater than or equal to 1.

[0156] In the device interaction mode, the first implementation method described above is used to detect whether the device connection status of a certain device on a certain port has been disconnected or abnormal. The specific implementation under the second implementation method described above can also be used for detection. For the sake of saving space, it will not be described in detail here.

[0157] In this embodiment of the invention, when the target system is run for the first time, all ports in the port list can be polled by executing steps 301-302 above. Here, when the port is a serial port or a network port, all ports in the port list refer to ports that the target system has successfully opened; when the port is a Bluetooth interface, all ports in the port list refer to ports of devices that the target system has connected to.

[0158] During the execution of the above method, some ports may be reconnected to new devices. In order to automatically discover newly connected devices, this embodiment of the invention periodically executes the polling operation in step 302. Specifically, the target system can obtain the newly opened ports in the port list according to a preset polling period TW0, and perform the polling operation for each newly opened port. Since an already opened port cannot be opened again, the target system opens each port in the port list according to the preset polling period TW0, and uses the successfully opened port as the newly opened port.

[0159] Preferably, the polling period TW0 is the larger of the first time and the second time. The first time is N4 times the total polling time for all device protocols in the third and fourth device protocol groups, where N4 is greater than or equal to 1. The second time is N5 times the sum of the total polling time for all device protocols in the second device protocol group and the first time window Tw1, where N5 is greater than or equal to 1.

[0160] Through the above steps, the embodiments of the present invention can automatically handle normal and abnormal disconnections of the device during the device connection process, and quickly identify the device and complete the reconnection after the device is reconnected.

[0161] To better aid in understanding the above solutions, the following sections, along with several accompanying diagrams and specific examples, will further illustrate the implementation of these solutions.

[0162] like Figure 4 As shown, this example stores relevant information in a database through preprocessing steps (including protocol preprocessing and preconfiguration steps). In the processing steps, the method of this embodiment of the invention is used for automatic device identification. The preprocessing steps are executed when the method of this embodiment of the invention is used for the first time in the target system; subsequent uses do not require further preprocessing and directly execute the processing steps.

[0163] Specifically, in step 401 of the protocol preprocessing step, all device protocols supported by the target system and all devices that the system may connect to are grouped according to the device interaction mode, resulting in multiple device protocol groups. Each device protocol group includes at least one device protocol. In step 402, for devices whose device protocols do not have an explicit device identifier (device ID), the special data content sent by the device is designated as the device ID. The device protocol groups can be stored in a database.

[0164] In step 403 of the pre-configuration process, pre-connection of each existing device is performed in a semi-manual, semi-automatic manner. Each existing device is connected to a port of the target system. Then, by configuring device parameters and debugging the devices, the existing devices are enabled to access the target system and correctly parse the data sent by the existing devices, obtaining the device identifier and the device configuration parameters when the existing devices successfully access the target system. Finally, the device identifier and device configuration parameters of the existing devices are stored in the database, specifically under the device protocol to which the existing device belongs in the device protocol group.

[0165] In this way, the database stores various device protocol groups. Each device protocol group contains at least one device protocol, and each device protocol contains the device identifier and device configuration parameters of at least one existing device. Table 1 provides a data structure of device protocol groups that can be used in this example in the database. It can be seen that each device protocol group can contain at least one device protocol, and each device protocol stores the device identifier and device configuration parameters of the device using that protocol.

[0166]

[0167]

[0168] Table 1

[0169] In the processing steps, the method of this embodiment of the invention is used to automatically identify devices on the ports. First, the main program is started. In step 411 of the initialization step, all device protocols supported by the target system that are pre-stored in the database are loaded. In step 412, the port identifiers (port IDs) of all ports of the target system are loaded. Then, if this method is being used for the first time, all existing devices that may be connected need to be pre-connected (i.e., by executing step 403 to obtain the device identifier and its device configuration parameters). If this method is not being used for the first time, it can automatically identify and access devices through periodic polling, and simultaneously handle issues such as abnormal interruptions and automatic reconnection during device connection.

[0170] In this example, device protocols are grouped into groups A, B, and C based on whether the device automatically sends data on the port and whether the data carries a device identifier when automatically sending data on the port. Additionally, devices with no devices on the port or whose devices are not recorded in the program's list of supported devices are grouped into group D. The resulting grouping results are shown in Table 2. It can be seen that groups A, B, and C represent the third, fourth, and second device protocol groups in the second implementation described above, respectively.

[0171]

[0172] Table 2

[0173] Figure 5 This diagram illustrates a method for device identification in a scenario where the target system connects devices via a hub. Here:

[0174] Case 1: Existing devices supported by the main program are already connected to the port, which can be further divided into:

[0175] For case 1.1.1 in group A: The device automatically sends data to the port, and the data contains a device ID field.

[0176] For case 1.1.2 in group B: The device automatically sends data to the port, but the data does not contain an ID field. The main program sends an interactive command to the device through the port, and after interacting with the device, obtains data containing the device ID.

[0177] For case 1.2 in group C: The device does not automatically send data to the port. The main program sends interactive commands to the device through the port and obtains data containing the device ID after interacting with the device.

[0178] Case 2: No device is connected to the port.

[0179] Case 3: A device not supported by the program is connected to the port, for example, the device is not recorded in the program's list of supported devices. The correspondence between the above cases and device protocol packets is as follows:

[0180] As shown in Table 3.

[0181]

[0182] Table 3

[0183] Figure 6 This explains how the program works during system initialization.

[0184] The system information initialization process is divided into two parts: software and hardware. Software initialization primarily initializes device protocol-related content (including data parsing protocols and communication protocols) and pre-configuration information (device configuration information), which is loaded into the program during system initialization. Hardware initialization involves reading all port identifiers of the hardware on which the program resides.

[0185] Figure 7 The workflow of the pre-configuration step is illustrated. The main purpose of the pre-configuration step is to verify that the hardware performance is intact, the connection between the target system and the device to be connected is intact, and to confirm that the device can work properly by pre-testing the device.

[0186] In the pre-configuration step, users can pre-connect devices one by one. First, the user confirms that the device is correctly connected to the target system. Then, the user selects the appropriate device from the device list, sets the serial port configuration information to meet the device's requirements, and then determines whether the device and the target system have successfully established a connection. If a connection is successfully established between the device and the target system, the pre-configured device configuration information is saved to the database and the running program; otherwise, the user re-checks all settings and physical connections.

[0187] Figure 8 The workflow for threads bound to a single port is provided. The following example uses a serial port to illustrate the workflow:

[0188] Step 801: The main program opens the serial port. Here, for each serial port, if it is opened successfully, a thread is bound to that serial port to manage all subsequent actions of that serial port.

[0189] Step 802: After the serial port is successfully bound to its own thread, the thread monitors whether there is data input on the serial port. If there is data input, it means that the serial port belongs to case 1.1 or case 3. At this time, step 803 is executed. If there is no data input within the time window Tw1, it means that the serial port belongs to case 2, case 1.2 or case 3.2. At this time, step 805 is executed.

[0190] Step 803: Poll the device protocols in group A. When polling a device protocol, if the device identifier of device An in group A is identified in the received data, the device connected to the port is considered device An, and the serial port is bound to device An. If T2 data points are received but no device in group A is identified, continue polling the next device protocol in group A until a device identifier is identified or all device protocols in group A have been polled. If no device identifier is identified after polling all device protocols in group A, proceed to step 804.

[0191] Step 804: Poll the device protocols in group B. For each device protocol polled, the thread sends an interactive command to the serial port according to that protocol and waits to receive the device's response message to obtain the device identifier. If the device identifier of device Bn in group B is identified in the received data, the device connected to the port is considered to be device Bn, and the serial port is bound to device Bn. If, after sending interactive commands (request messages for device identifiers) T3 times and receiving response messages T1 times, the device in group B is still not identified, or no response message is received within the time window Tw3 after sending the request message, the polling continues for the next device protocol in group B until a device identifier is identified or all device protocols in group B have been polled. If no device identifier is identified after polling all device protocols in group B, the device is considered not to be a device type (Dn) supported by the program.

[0192] Step 805: Poll the device protocols of group C. The thread sends an interactive command (a request message requesting a device identifier) ​​to the serial port and waits to receive a response message from the device to obtain the device identifier. If the device identifier of device Cn in group C is identified in the received data, the device connected to the port is considered to be device Cn, and the serial port is bound to device Cn. If the device in group C is still not identified after sending the interactive command to obtain the device ID T1 times, or if no response message is received within the time window Tw2 after sending the interactive command, the next device protocol in group C is polled until a device identifier is identified or all device protocols in group C have been polled. If no device identifier is identified after polling all device protocols in group C, it is considered that no device is connected to the serial port (case 2), or the device is a device type (Dn) that the program does not support.

[0193] After identifying the device identifier, the thread sends a message of successful identification to the main program, along with the identified device identifier. The main program then updates the list of connected devices in all threads. This list records the binding relationship between the device's serial port identifier and the device identifier.

[0194] It should also be noted that the values ​​of T1, T2 and T3 in steps 803 to 805 above can be the same or different. Specifically, they can be set according to the requirements of recognition efficiency and recognition reliability. This embodiment of the invention does not make specific limitations in this regard.

[0195] Figure 9 The process of the program automatically identifying the workings of devices in each group is illustrated (using serial ports as an example).

[0196] At the start of each polling cycle (Tw0), the program sends a command to open the port on each port to open all ports (serial ports). For each port, if the port is successfully opened, a thread is bound to that port.

[0197] For equipment An belonging to equipment group A (e.g., ... Figure 9 In the example shown, there is a device An on port 1. The thread on port 1 detects that data has been received on port 1, and then polls all device protocols in group A (using each polled protocol to check if there is a qualified device identifier in the received data). Once a device identifier containing device An is detected, the thread binds the port to device An and sends a message to the main program. This message carries the device identifier of device An that has been detected. Then the main program sends update messages to the threads bound to each port to update the list of connected devices, that is, to add the binding relationship between port 1 and device An to the list of connected devices.

[0198] For equipment Bn belonging to equipment group B (such as...) Figure 9 In the example shown, there is a device Bn on port 2. When a thread on port 2 detects data received on port 2, it first polls all protocols of device group A. If, during each polling of protocols, no device identifier belonging to device group A is found in the received T2 data, it continues to poll the protocols of device group B. At this time, the thread bound to port 2 sequentially sends commands corresponding to each device protocol in device group B to request the device identifier. Once the device identifier of device Bn from device group B is detected in the response data, it is considered that port 2 is connected to device Bn. Subsequently, the thread on port 2 establishes the binding relationship between port 2 and device Bn, and sends the message that device Bn has been detected to the main program. Then, the main program updates the list of connected devices to each thread.

[0199] For equipment Cn belonging to equipment group C (such as...) Figure 9 As shown in the example, there is a device Cn on port 3. After a waiting time window Tw1, the thread on port 3 does not detect any data on port 3. At this time, the device protocols in device group C are polled. Port 3 requests the device identifier by sending a command corresponding to each device protocol in device group C. Once the device ID of device Cn is detected in the response data, a binding relationship is established between port 3 and device Cn, and a message indicating that device Cn has been detected is sent to the main program. Then, the main program updates the list of connected devices to each thread.

[0200] For equipment Dn belonging to equipment group D (e.g. Figure 9In the example shown, there is a device Dn on port 4. In Case 3.2, after waiting time window Tw1, if the thread on port 4 does not detect any data on port 4, it first requests a device identifier by sending a command corresponding to each device protocol in device group C. If, for each device protocol, no device identifier belonging to device group C is found within time window Tw2 after sending the command, or if no device identifier is obtained after sending commands a number of times T1, then the device on port 4 is regarded as device Dn. In Case 3.1, when the thread on port 4 detects data on port 4, it first polls all device protocols in group A. If, during polling for each protocol, no device identifier belonging to group A is found in the received data T2 times, it continues to poll the protocols in group B. It polls the devices in group B by sending commands corresponding to each device in group B. If, for each protocol, no device identifier in group B is obtained after sending commands T3 times, or no device identifier in group B is obtained within the time window Tw3 after sending the command, then the device on port 4 is regarded as device Dn.

[0201] For case 2 shown on port 5, if the thread on port 5 does not receive any response when polling all device protocols in group C, it is assumed that there are no devices on port 5.

[0202] In this embodiment of the invention, device protocols are grouped according to the device interaction mode, and then identified at the port according to the device protocol group. Taking the serial port as an example, each serial port polls different device protocol groups based on the data status of the serial port. Once the device identifier is identified, the polling will stop immediately, thereby effectively reducing the number of polling protocols and improving the efficiency of device identification.

[0203] Furthermore, the above examples of the present invention also improve device identification efficiency by optimizing the number of times data is sent / received and the time window. The parameters in the above examples include:

[0204] T1~T3: Count of received or transmitted data. By detecting multiple received data entries, the presence of the corresponding device identifier is confirmed, avoiding identification failures due to data corruption during transmission. Furthermore, the number of receptions and identifications is limited, ensuring identification efficiency. For example, for a specific device protocol, after the first received data fails to identify the device identifier, data is received again to confirm the identifier.

[0205] Tw0: The polling period of the target system. The target system retrieves newly opened ports from the port list according to a preset polling period Tw0, and performs the polling operation in step 302 for each newly opened port. Here, Tw0 is the larger of the first time and the second time. For example, the first time can be twice the total polling time of the device protocols in groups A and B, and the second time can be twice the sum of the total polling time of the device protocols in group C and Tw1.

[0206] Tw1: The time window for waiting for data when polling begins. N1 times the maximum transmission interval between two data transmissions when using the automatic data transmission protocols of devices in Group A and Group B, to ensure that the port can receive data when a device from Group A or Group B is connected to the port and sends data to it. For example, N1 is 2.

[0207] Tw2: Polling the Group C device protocol, the time window for waiting for data after sending a command. In the Group C device protocol, the maximum waiting time for a response after sending an interactive command is N² times, to ensure that the port can receive data when a Group C device connects to the port and sends data to the port.

[0208] Tw3: When polling Group B devices, the time window for waiting for data after sending a command. This is N3 times the maximum waiting time for a response after sending a command using the Group B device protocol, ensuring the port can receive data when a Group B device is connected to the port and sending data.

[0209] In addition, embodiments of the present invention further improve polling efficiency by setting up device mutual exclusion relationships to avoid polling mutually exclusive devices when polling device protocols.

[0210] Figure 10 This illustrates the process by which the present invention handles normal or abnormal disconnection of devices in each device protocol packet in the above example. The thread bound to the port will release port resources upon automatic detection of device disconnection, specifically:

[0211] For device An belonging to group A (e.g., ... Figure 10As shown, there is a device An on port 1. In case a, the thread on port 1 detects that no data has been received within the time window TweA, so it assumes that device An has been disconnected. The thread closes port 1 and notifies the main program to release the port resources of port 1. The main process releases the port resources of port 1 and sends update messages to the threads bound to each port to update the list of connected devices. In case b, the thread on port 1 detects that the data on port 1 does not match the data of device An. It waits to receive T4 data before re-checking the data. If the check result is always a data mismatch, it is determined that the connection is abnormal, that is, the device on port 1 is not device An. The thread closes port 1 and notifies the main program to release the port resources of port 1. The main process releases the port resources of port 1 and sends update messages to the threads bound to each port to update the list of connected devices.

[0212] For equipment Bn belonging to equipment group B (such as...) Figure 10 In the example shown, there is a device Bn on port 2. In case a, the thread on port 2 detects that data disappears within the time window TweB1 and sends a command to port 2 to request a response from device Bn. If no response is received after waiting for the time window TweB2, it assumes that device Bn has been disconnected, closes port 2, and notifies the main program to release the port resources of port 2. The main process releases the port resources of port 2 and sends update messages to the threads bound to each port to update the list of connected devices. In case b, the thread on port 2 detects that the data on port 2 does not match the data of device Bn. After waiting for T5 data receptions, it re-checks the data. If the check result is still a mismatch, it sends a command to device Bn through the port to request a response. If erroneous response data is received T6 times, it assumes that the device on port 2 is not device Bn, closes port 2, and notifies the main program to release the port resources of port 2. The main process releases the port resources of port 2 and sends update messages to the threads bound to each port to update the list of connected devices.

[0213] For equipment Cn belonging to equipment group C (such as...) Figure 10 As shown, there is a device Cn on port 3. The thread on port 3 detects that the data disappears within the time window TweC. It sends a command to port 3 to request a response from device Cn. If no data is received after waiting for the time window TweC, it assumes that device Cn has disconnected. The thread closes port 3 and notifies the main program to release the port resources of port 3. The main process releases the port resources of port 3 and sends update messages to the threads bound to each port to update the list of connected devices.

[0214] Figure 11This diagram illustrates a periodic polling operation. Threads on each port periodically poll the devices on that port, monitoring their connection status to ensure timely port release and device reconnection. The polling period is Tw0. At the start of each polling period, the threads bound to each port attempt to open their respective ports. If the port was previously open, a failure message is returned; if the port was previously closed, it may open successfully and return a success response message to the thread. In this case, the port is treated as a newly opened port and participates in the current polling round.

[0215] Based on the above-described multi-device identification method, this embodiment of the invention also provides a multi-device identification device, such as... Figure 12 As shown, it includes:

[0216] The information acquisition module 121 is used to acquire a port list and a device protocol group list of the target system. The port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0217] The port polling module 122 is used to perform a polling operation for each port in the port list. The polling operation includes: determining a target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port; polling each device protocol in the target device protocol group; and using the currently polled device protocol to identify the device connected to the port.

[0218] Through the above modules, the embodiments of the present invention can improve the device identification efficiency on the port.

[0219] Preferably, the port polling module is further configured to, during the process of polling each device protocol in the target device protocol group and using the currently polled device protocol to identify the device connected to the port: if a device is successfully identified, the binding relationship between the port and the identified device is added to the list of connected devices; if a device is not identified, the next device protocol in the target device protocol group is polled until a device is successfully identified or all device protocols in the target device protocol group have been polled.

[0220] Preferably, the port polling module is further configured to determine that the port is not connected to a device or the connected device is an unknown device if the device protocol in the target device protocol group has been polled to the end and the device still cannot be identified.

[0221] Preferably, the identification device further includes:

[0222] The port control module is used to close the ports of unconnected devices or devices with unknown protocols after the polling operation.

[0223] Preferably, the device protocol group further includes a list of existing devices under each device protocol, and the list of existing devices records the device identifiers of all existing devices that support that device protocol; the identification device further includes:

[0224] An information sharing module is used to share the list of connected devices among the ports in the port list;

[0225] The first information maintenance module is used to, after adding the binding relationship between the first port and the first device to the list of connected devices, determine the first mutually exclusive device that is mutually exclusive with the first device and the first mutually exclusive device protocol adopted by the first mutually exclusive device according to the preset device mutual exclusion relationship. The device mutual exclusion relationship is used to indicate devices that the target system will not connect to simultaneously. The mutually exclusive device of any device includes at least the device itself. If the list of existing devices under the first mutually exclusive device protocol only includes the first mutually exclusive device, the first mutually exclusive device protocol is deleted from its device protocol group.

[0226] Preferably, the identification device further includes:

[0227] The port detection module is used to monitor the device connection status of each port in the connected device list;

[0228] An exception handling module is configured to, upon detecting a connection loss or connection anomaly in the device connection status of a second device on the second port, close the second port and delete the binding relationship between the second port and the second device from the connected device list; and, based on the device mutual exclusion relationship, determine a second mutually exclusive device that is mutually exclusive with the second device and the second mutually exclusive device protocol used by the second mutually exclusive device; and, if the second mutually exclusive device protocol has been deleted from its respective device protocol group, add the second mutually exclusive device protocol to its respective device protocol group.

[0229] Preferably, the plurality of device protocol groups include a first device protocol group and a second device protocol group, wherein the first device protocol group corresponds to a first device interaction mode in which the device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which the device only sends data when it receives a data request.

[0230] The port polling module includes:

[0231] The first judgment module is used to determine whether data automatically sent by the device is received on the port. If so, the target device protocol packet is determined to be the first device protocol packet; otherwise, the target device protocol packet is determined to be the second device protocol packet.

[0232] Preferably, the port polling module further includes:

[0233] The first processing module is configured to, when the target device protocol group is the first device protocol group, use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier cannot be parsed, then when the currently polled device protocol supports interactive commands, use the currently polled device protocol to send a request message on the port to request the device identifier.

[0234] The second processing module is used to send a request message on the port to request a device identifier when the target device protocol group is the second device protocol group, using the currently polled device protocol.

[0235] Preferably, the device interaction mode is further used to indicate whether the data automatically sent by the device carries a device identifier when the device automatically sends data on the port;

[0236] The plurality of device protocol groups include a second device protocol group, a third device protocol group, and a fourth device protocol group. The second device protocol group corresponds to a second device interaction mode in which the device sends data only when it receives a data request. The third device protocol group corresponds to a third device interaction mode in which the device automatically sends data and the data carries a device identifier. The fourth device protocol group corresponds to a fourth device interaction mode in which the device automatically sends data without carrying a device identifier but supports interactive commands.

[0237] The port polling module includes:

[0238] The second judgment module is used to determine whether data automatically sent by the device is received on the port. If so, the target device protocol packet is determined to be the third device protocol packet or the fourth device protocol packet; otherwise, the target device protocol packet is determined to be the second device protocol packet.

[0239] Preferably, the port polling module further includes:

[0240] The third processing module is configured to, when the target device protocol group is the second device protocol group, poll each device protocol in the second device protocol group, and send a request message on the port to request a device identifier using the currently polled device protocol;

[0241] The fourth processing module is configured to, when the target device protocol group is the third device protocol group or the fourth device protocol group, first poll each device protocol in the third device protocol group, and use the currently polled device protocol to parse the data received on the port to obtain the device identifier; if the device identifier is still not parsed after polling the device protocols in the third device protocol group, then continue to poll each device protocol in the fourth device protocol group, and use the currently polled device protocol to send a request message on the port to request the device identifier.

[0242] Preferably, the second judgment module is further used to detect whether data is received on the port within the first time window Tw1. The length of the first time window Tw1 is N1 times the first period. The first period is the maximum transmission interval for all existing devices to automatically send data in the third device protocol group and the fourth device protocol group. N1 is greater than or equal to 1.

[0243] The third processing module is further configured to, during the polling process of each device protocol in the second device protocol group, if the device identifier sent by the device is not obtained after the number of times the request message is sent using the currently polled second device protocol reaches a preset first number, or if the device identifier sent by the device is not obtained within the second time window Tw2 after the request message is sent, then continue to poll the next device protocol in the second device protocol group. The length of the second time window Tw2 is N2 times the first waiting time, where the first waiting time is the maximum waiting time between the received request message and the sent device identifier of the existing device in the second device protocol, and N2 is greater than or equal to 1.

[0244] The fourth processing module is further configured to, during the polling process of each device protocol in the third device protocol group, if the number of times the currently polled first device protocol parses the data received on the port but fails to obtain the device identifier reaches a preset second number, then continue polling the next device protocol in the third device protocol group; and, during the polling process of each device protocol in the fourth device protocol group, if the number of times the currently polled third device protocol sends request messages reaches a preset third number and still fails to obtain the device identifier sent by the device, or if no response message sent by the device is received within the third time window Tw3 after sending the request message, then continue polling the next device protocol in the fourth device protocol group. The length of the third time window Tw3 is N3 times the second waiting time, where the second waiting time is the maximum waiting time between the receipt of the request message and the sending of the device identifier by all existing devices in the third device protocol, and N3 is greater than or equal to 1.

[0245] Preferably, the identification device further includes:

[0246] The polling control module is used to obtain newly opened ports from the port list according to a preset polling period TW0, and to perform the polling operation for each newly opened port; wherein,

[0247] Wherein, the polling period TW0 is the larger of the first time and the second time;

[0248] The first time is N4 times the total polling time for all device protocols in the third device protocol group and the fourth device protocol group, where N4 is greater than or equal to 1;

[0249] The second time is N5 times the sum of the total polling time for all device protocols in the second device protocol group and the first time window Tw1, where N5 is greater than or equal to 1.

[0250] Preferably, the identification device further includes:

[0251] The protocol preprocessing module is used to determine all device protocols supported by the ports of the target system, and group all device protocols according to the device interaction mode of each device protocol to obtain the device protocol group list and the device protocols under each device protocol group.

[0252] The information pre-configuration module is used to connect the existing device to the port of the target system, obtain the device configuration parameters and device identifier when the existing device successfully accesses the target system, and store them in the device protocol to which the existing device belongs in the device protocol group.

[0253] Preferably, the protocol preprocessing module is further configured to designate a preset data content in the data sent by the device as the device identifier when the target device protocol does not define that the device identifier is carried in the data sent by the device.

[0254] Please refer to Figure 13 The present invention also provides a hardware structure block diagram of a multi-device identification device, such as... Figure 13 As shown, the multi-device identification device 1300 includes:

[0255] Processor 1302; and

[0256] Memory 1304, wherein computer program instructions are stored.

[0257] When the computer program instructions are executed by the processor, the processor 1302 performs the following steps:

[0258] Obtain the port list and device protocol group list of the target system, wherein the port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0259] A polling operation is performed on each port in the port list, the polling operation including:

[0260] Based on the device interaction mode on the port, a target device protocol packet is determined from the plurality of device protocol packets;

[0261] Poll each device protocol in the target device protocol group, and use the currently polled device protocol to identify the device connected to the port.

[0262] Furthermore, such as Figure 13 As shown, the multi-device identification device 1300 may also include a network interface 1301, an input device 1303, a hard disk 13013, and a display device 1306.

[0263] The various interfaces and devices described above can be interconnected via a bus architecture. The bus architecture can include any number of interconnected buses and bridges. Specifically, one or more processors with computing capabilities, represented by processor 1302, may be connected together, including a central processing unit (CPU) and / or a graphics processing unit (GPU), and various circuits of one or more memories, represented by memory 1304. The bus architecture can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits. It is understood that the bus architecture is used to implement communication between these components. In addition to the data bus, the bus architecture also includes a power bus, a control bus, and a status signal bus, which are well known in the art and will not be described in detail herein.

[0264] The network interface 1301 can be connected to a network (such as the Internet, local area network, etc.), receive data (such as training data) from the network, and save the received data to the hard disk 13013.

[0265] The input device 1303 can receive various instructions input by the operator and send them to the processor 1302 for execution. The input device 1303 may include a keyboard or a clicking device (e.g., a mouse, trackball, touchpad, or touchscreen).

[0266] The display device 1306 can display the results obtained by the processor 1302 executing instructions, such as the progress of model training and the answer prediction results.

[0267] The memory 1304 is used to store programs and data necessary for the operation of the operating system, as well as intermediate results and other data during the calculation process of the processor 1302.

[0268] It is understood that the memory 1304 in the embodiments of the present invention may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. The memory 1304 of the apparatus and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0269] In some implementations, memory 1304 stores elements, executable modules or data structures, or subsets thereof, or extended sets thereof: operating system 13041 and application program 13042.

[0270] The operating system 13041 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 13042 includes various applications, such as a browser, used to implement various application functions. The program implementing the method of this embodiment can be included in the application program 13042.

[0271] The multi-device identification method disclosed in the above embodiments of the present invention can be applied to, or implemented by, processor 1302. Processor 1302 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above multi-device identification method can be completed by integrated logic circuits in the hardware of processor 1302 or by instructions in software form. Processor 1302 may be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 1304. Processor 1302 reads the information in memory 1304 and completes the steps of the above method in conjunction with its hardware.

[0272] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0273] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented within the processor or externally.

[0274] Specifically, when the computer program is executed by the processor 1302, it can also perform the following steps:

[0275] It should be noted that the device in this embodiment is the same as the one described above. Figure 3The apparatus corresponding to the method shown above is applicable to the embodiments of this device, and can achieve the same technical effect. The apparatus provided by the embodiments of the present invention can implement all the method steps implemented in the above method embodiments and can achieve the same technical effect. Therefore, the parts that are the same as those in the method embodiments and the beneficial effects will not be described in detail here.

[0276] In some embodiments of the present invention, a computer-readable storage medium is also provided, on which a program is stored, which, when executed by a processor, performs the following steps:

[0277] Obtain the port list and device protocol group list of the target system, wherein the port list includes at least one port, and the device protocol group list includes multiple device protocol groups corresponding to different device interaction modes. Each device protocol group includes at least one device protocol supported by the target system on the port. The device interaction mode is used to indicate whether the device automatically sends data.

[0278] A polling operation is performed on each port in the port list, the polling operation including:

[0279] Based on the device interaction mode on the port, a target device protocol packet is determined from the plurality of device protocol packets;

[0280] Poll each device protocol in the target device protocol group, and use the currently polled device protocol to attempt to identify the device connected to the port.

[0281] When executed by the processor, this program can implement all the above-mentioned methods for identifying multiple devices and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0282] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0283] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0284] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0285] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.

[0286] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0287] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the multi-device identification method described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, disks, or optical discs.

[0288] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method of multi-device identification, the method comprising: The method comprises: acquiring a port list and a device protocol group list of a target system, wherein the port list comprises at least one port, the device protocol group list comprises a plurality of device protocol groups corresponding to different device interaction modes, each device protocol group comprises at least one device protocol supported by the target system on the port, and the device interaction mode is used to indicate whether the device automatically sends data; performing a polling operation on each port in the port list, the polling operation comprising: determining a target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port; polling each device protocol in the target device protocol group to identify the device connected to the port using the currently polled device protocol; wherein the plurality of device protocol groups comprises a first device protocol group and a second device protocol group, wherein the first device protocol group corresponds to a first device interaction mode in which the device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which the device only sends data when receiving a data request; the determining of the target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port comprises: judging whether the device automatically sends data on the port, if yes, determining the target device protocol group as the first device protocol group, otherwise, determining the target device protocol group as the second device protocol group.

2. The method of claim 1, wherein, each device protocol group further comprises an existing device list under each device protocol, and the existing device list records all existing devices supporting the device protocol; the method further comprises: sharing a connected device list among the ports in the port list, wherein the connected device list records the devices that have been connected to each port of the target system; after adding a binding relationship between the first port and the first device in the connected device list, determining a first mutual exclusion device mutually exclusive with the first device and a first mutual exclusion device protocol used by the first mutual exclusion device according to a preset device mutual exclusion relationship, wherein the device mutual exclusion relationship is used to indicate devices that cannot be simultaneously connected by the target system, and the mutual exclusion device of any device at least comprises the any device itself; in a case where the first mutual exclusion device is only included in an existing device list under the first mutual exclusion device protocol, deleting the first mutual exclusion device protocol from the device protocol group to which the first mutual exclusion device protocol belongs.

3. The method of claim 2, wherein, The method further comprises: monitoring the device connection state of each port in the connected device list; in a case where the device connection state of the second device on the second port is disconnected or abnormally connected, closing the second port and deleting the binding relationship between the second port and the second device in the connected device list; determining a second mutual exclusion device mutually exclusive with the second device and a second mutual exclusion device protocol used by the second mutual exclusion device according to the device mutual exclusion relationship; in a case where the second mutual exclusion device protocol has been deleted from the device protocol group to which the second mutual exclusion device protocol belongs, adding the second mutual exclusion device protocol to the device protocol group to which the second mutual exclusion device protocol belongs.

4. The method of claim 2, wherein, The polling each device protocol in the target device protocol group, using the currently polled device protocol, identifies the connected device on the port, and specifically includes: if the device is successfully identified, adding a binding relationship between the port and the identified device in the connected device list; if the device is not identified, continuing to poll the next device protocol in the target device protocol group until the device is successfully identified or all device protocols in the target device protocol group are polled.

5. The method of claim 4, wherein, When all device protocols in the target device protocol group are polled, if the device is still not identified, it is determined that the port is not connected to a device or the connected device is a device with an unknown protocol.

6. The method of claim 5, wherein, After the polling operation, the method further includes: Closing the port not connected to a device or the connected device being a device with an unknown protocol.

7. The method of claim 1, wherein The polling each device protocol in the target device protocol group, using the currently polled device protocol, identifies the connected device on the port, includes: In the case that the target device protocol group is the first device protocol group, using the currently polled device protocol, the data received on the port is parsed to obtain the device identifier; if the device identifier cannot be parsed, when the currently polled device protocol supports the interactive command, a request message is sent on the port to request the device identifier; In the case that the target device protocol group is the second device protocol group, using the currently polled device protocol, a request message is sent on the port to request the device identifier.

8. The method according to any one of claims 1 to 6, characterized in that, The device interaction mode is further used to indicate whether the device identifier is carried in the data automatically sent by the device; The plurality of device protocol groups includes a second device protocol group, a third device protocol group, and a fourth device protocol group, wherein the second device protocol group corresponds to a second device interaction mode in which the device only sends data when receiving a data request, the third device protocol group corresponds to a third device interaction mode in which the device automatically sends data and the data carries a device identifier, and the fourth device protocol group corresponds to a fourth device interaction mode in which the device automatically sends data without carrying a device identifier but supports an interactive command. The target device protocol group is determined from the plurality of device protocol groups according to the device interaction mode on the port, including: determining whether the data automatically sent by the device is received on the port, if yes, determining the target device protocol group to be the third device protocol group or the fourth device protocol group; otherwise, determining the target device protocol group to be the second device protocol group.

9. The method of claim 8, wherein, The polling each device protocol in the target device protocol group, using the currently polled device protocol, identifies the connected device on the port, includes: In the case that the target device protocol group is the second device protocol group, polling each device protocol in the second device protocol group, using the currently polled device protocol, a request message is sent on the port to request the device identifier. If the target device protocol packet is the third device protocol packet or the fourth device protocol packet, each device protocol in the third device protocol packet is polled first, and the current polled device protocol is used to parse the data received on the port to obtain the device identification; if the device identification is not parsed when the polling of the device protocols in the third device protocol packet is completed, each device protocol in the fourth device protocol packet is polled, and the current polled device protocol is used to send a request message on the port to request the device identification.

10. The method of claim 9, wherein, whether the data automatically sent by the device is received on the port, specifically, whether the data is received on the port within a first time window Tw1, the length of the first time window Tw1 being N1 times of a first period, the first period being the maximum sending interval of the data automatically sent by all existing devices in the third device protocol packet and the fourth device protocol packet, and N1 being greater than or equal to 1; in the process of polling each device protocol in the second device protocol packet, if the device identification sent by the device is not obtained when the number of times of sending the request message reaches a preset first number of times or the device identification sent by the device is not obtained within a second time window Tw2 after the request message is sent, the next device protocol in the second device protocol packet is polled, the length of the second time window Tw2 being N2 times of a first waiting time, the first waiting time being the maximum waiting time of the existing devices in the second device protocol from receiving the request message to sending the device identification, and N2 being greater than or equal to 1; in the process of polling each device protocol in the third device protocol packet, if the number of times of parsing the data received on the port but not obtaining the device identification reaches a preset second number of times when the current polled first device protocol is used, the next device protocol in the third device protocol packet is polled; in the process of polling each device protocol in the fourth device protocol packet, if the device identification sent by the device is not obtained when the number of times of sending the request message reaches a preset third number of times or the response message sent by the device is not received within a third time window Tw3 after the request message is sent, the next device protocol in the fourth device protocol packet is polled, the length of the third time window Tw3 being N3 times of a second waiting time, the second waiting time being the maximum waiting time of all existing devices in the third device protocol from receiving the request message to sending the device identification, and N3 being greater than or equal to 1.

11. The method of claim 10, wherein, Further comprising: acquiring a newly opened port in the port list according to a preset polling period TW0, and performing the polling operation for each newly opened port; wherein the polling period TW0 is the larger one of the first time and the second time. The first time is N4 times of the total polling time of polling all device protocols in the third device protocol group and the fourth device protocol group, N4 is greater than or equal to 1; The second time is N5 times of the sum of the total polling time of polling all device protocols in the second device protocol group and the first time window Tw1, N5 is greater than or equal to 1.

12. The method of claim 2, wherein, Before obtaining the port list and the device protocol group list of the target system, the method further comprises: determining all device protocols supported by the ports of the target system, grouping the all device protocols according to the device interaction modes of the respective device protocols to obtain the device protocol group list and the device protocols under each device protocol group; and connecting an existing device with the ports of the target system, obtaining the device configuration parameters and the device identifier when the existing device successfully accesses the target system, and saving the device configuration parameters and the device identifier in the device protocol to which the existing device belongs.

13. The method of claim 12, wherein, In the case that the target device protocol does not define to carry the device identifier in the data sent by the device, a preset data content in the data sent by the device is designated as the device identifier.

14. A multi-device identification apparatus, comprising: Comprise: an information obtaining module, configured to obtain a port list and a device protocol group list of a target system, wherein the port list comprises at least one port, the device protocol group list comprises a plurality of device protocol groups corresponding to different device interaction modes, each device protocol group comprises at least one device protocol supported by the target system on the port, and the device interaction mode is used to indicate whether the device automatically sends data; a port polling module, configured to perform a polling operation for each port in the port list, the polling operation comprising: determining a target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port; polling each device protocol in the target device protocol group, and identifying a connected device on the port by using the currently polled device protocol; The plurality of device protocol groups comprise a first device protocol group and a second device protocol group, wherein the first device protocol group corresponds to a first device interaction mode in which the device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which the device only sends data when receiving a data request; The port polling module comprises: a first judging module, configured to judge whether data automatically sent by the device is received on the port, if yes, determining that the target device protocol group is the first device protocol group, otherwise, determining that the target device protocol group is the second device protocol group.

15. The identification device of claim 14, wherein, The device protocol group further comprises an existing device list under each device protocol, and the existing device list records device identifiers of all existing devices supporting the device protocol; and the identification device further comprises: an information sharing module, configured to share a connected device list between the ports in the port list, and the connected device list records devices that have been connected on the respective ports of the target system. The first information maintenance module is configured to, after adding the binding relationship between the first port and the first device in the connected device list, determine a first mutually exclusive device mutually exclusive with the first device and a first mutually exclusive device protocol adopted by the first mutually exclusive device according to a preset device mutual exclusion relationship, the device mutual exclusion relationship being used to indicate devices that the target system will not connect simultaneously, and the mutually exclusive device of any device at least including the any device itself; and delete the first mutually exclusive device protocol from a device protocol group to which the first mutually exclusive device protocol belongs in a case where the first mutually exclusive device is only included in an existing device list under the first mutually exclusive device protocol.

16. The identification device of claim 15, wherein, Further comprising: a port detection module configured to monitor a device connection state of each port in the connected device list; an exception handling module configured to, in a case where a device connection state of a second device on a second port is monitored to be disconnected or abnormal, close the second port and delete a binding relationship between the second port and the second device in the connected device list; and determine a second mutually exclusive device mutually exclusive with the second device and a second mutually exclusive device protocol adopted by the second mutually exclusive device according to the device mutual exclusion relationship; in a case where the second mutually exclusive device protocol has been deleted from a device protocol group to which the second mutually exclusive device protocol belongs, add the second mutually exclusive device protocol to the device protocol group to which the second mutually exclusive device protocol belongs.

17. The identification apparatus according to claim 15, wherein the port polling module is further configured to, in the process of polling each device protocol in the target device protocol group, using a currently polled device protocol, identifying a connected device on the port: if the device is successfully identified, adding a binding relationship between the port and the identified device in the connected device list; and if the device is not identified, continuing to poll a next device protocol in the target device protocol group until the device is successfully identified or all device protocols in the target device protocol group have been polled.

18. The identification apparatus according to claim 17, wherein the port polling module is further configured to, when all device protocols in the target device protocol group have been polled, if the device is still not identified, determining that the port is not connected to a device or the connected device is an unknown device. Further comprising:

19. The identification device of claim 18, wherein, a port control module configured to, after the polling operation, close a port not connected to a device or connected to a device with an unknown protocol.

20. The identification apparatus according to claim 14, wherein the port polling module further comprises: a first processing module configured to, in a case where the target device protocol group is the first device protocol group, using a currently polled device protocol, parsing data received on the port to obtain a device identifier; and if the device identifier is not parsed, sending a request message on the port to request the device identifier when the currently polled device protocol supports an interactive command. ​ The second processing module is configured to, in a case where the target device protocol packet is the second device protocol packet, send a request message on the port to request a device identifier by using a currently polled device protocol.

21. The identification device according to any one of claims 14 to 19, characterized in that The device interaction mode is further configured to indicate whether the device identifier is carried in the data automatically sent by the device; The plurality of device protocol packets comprise a second device protocol packet, a third device protocol packet and a fourth device protocol packet, wherein the second device protocol packet corresponds to a second device interaction mode in which the device only sends data when receiving a data request, the third device protocol packet corresponds to a third device interaction mode in which the device automatically sends data and carries the device identifier in the data, and the fourth device protocol packet corresponds to a fourth device interaction mode in which the device automatically sends data without carrying the device identifier but supports an interaction command. The port polling module comprises: The second judging module is configured to determine whether the data automatically sent by the device is received on the port, and if yes, determine that the target device protocol packet is the third device protocol packet or the fourth device protocol packet; otherwise, determine that the target device protocol packet is the second device protocol packet.

22. The identification apparatus according to claim 21, wherein The port polling module further comprises: The third processing module is configured to, in a case where the target device protocol packet is the second device protocol packet, poll each device protocol in the second device protocol packet, and send a request message on the port to request a device identifier by using a currently polled device protocol. The fourth processing module is configured to, in a case where the target device protocol packet is the third device protocol packet or the fourth device protocol packet, poll each device protocol in the third device protocol packet first, and parse the data received on the port to obtain a device identifier by using a currently polled device protocol; if the device identifier is not parsed when the polling of the device protocol in the third device protocol packet is completed, continue to poll each device protocol in the fourth device protocol packet, and send a request message on the port to request a device identifier by using a currently polled device protocol.

23. The identification apparatus according to claim 22, wherein The second judging module is further configured to detect whether the data is received on the port within a first time window Tw1, the length of the first time window Tw1 being N1 times of a first period, the first period being a maximum sending interval of all existing devices automatically sending data in the third device protocol packet and the fourth device protocol packet, and N1 being greater than or equal to 1. the third processing module is further configured to, in the process of polling each device protocol in the second device protocol group, if the device identifier sent by the device is still not acquired when the number of times of sending the request message reaches a preset first number of times or when the device identifier sent by the device is still not acquired within a second time window Tw2 after the request message is sent, continue to poll a next device protocol in the second device protocol group, the length of the second time window Tw2 being N2 times of a first waiting time, the first waiting time being a maximum waiting time between when an existing device in the second device protocol receives the request message and when the device identifier is sent, and N2 being greater than or equal to 1; the fourth processing module is further configured to, in the process of polling each device protocol in the third device protocol group, if the number of times of analyzing the data received on the port but failing to acquire the device identifier reaches a preset second number of times when the current polled first device protocol is used, continue to poll a next device protocol in the third device protocol group, and in the process of polling each device protocol in the fourth device protocol group, if the device identifier sent by the device is still not acquired when the number of times of sending the request message reaches a preset third number of times or when the response message sent by the device is still not received within a third time window Tw3 after the request message is sent, continue to poll a next device protocol in the fourth device protocol group, the length of the third time window Tw3 being N3 times of a second waiting time, the second waiting time being a maximum waiting time between when all existing devices in the third device protocol receive the request message and when the device identifier is sent, and N3 being greater than or equal to 1.

24. The identification device of claim 23, wherein, Further comprising: a polling control module configured to acquire a newly opened port in the port list according to a preset polling period TW0, and perform the polling operation on each newly opened port; wherein, the polling period TW0 is the larger one of a first time and a second time; the first time is N4 times of a total polling time of polling all device protocols in the third device protocol group and the fourth device protocol group, and N4 is greater than or equal to 1; the second time is N5 times of a sum of a total polling time of polling all device protocols in the second device protocol group and the first time window Tw1, and N5 is greater than or equal to 1.

25. The identification apparatus of claim 15, wherein, Further comprising: a protocol preprocessing module configured to determine all device protocols supported by a port of the target system, group the all device protocols according to device interaction modes of the device protocols, and obtain the device protocol group list and the device protocols under each device protocol group; an information preconfiguration module configured to connect an existing device with the port of the target system, acquire a device configuration parameter and a device identifier when the existing device successfully accesses the target system, and save the device configuration parameter and the device identifier under a device protocol to which the existing device belongs in the device protocol group.

26. The identification device of claim 25, wherein The protocol preprocessing module is further configured to, in a case where the target device protocol does not define carrying of device identification in device-sent data, specify preset data content in the device-sent data as the device identification.

27. A multi-device identification apparatus, comprising: a processor; and a memory having computer program instructions stored therein, wherein the computer program instructions, when executed by the processor, cause the processor to perform the following steps: obtaining a port list and a device protocol group list of a target system, wherein the port list comprises at least one port, the device protocol group list comprises a plurality of device protocol groups corresponding to different device interaction modes, each device protocol group comprises at least one device protocol supported by the target system on the port, and the device interaction mode is used at least to indicate whether a device automatically sends data; performing a polling operation for each port in the port list, the polling operation comprising: determining a target device protocol group from the plurality of device protocol groups according to a device interaction mode on the port; polling each device protocol in the target device protocol group to identify a device connected to the port using a currently polled device protocol; wherein the plurality of device protocol groups comprises a first device protocol group and a second device protocol group, the first device protocol group corresponds to a first device interaction mode in which a device automatically sends data, and the second device protocol group corresponds to a second device interaction mode in which a device sends data only when receiving a data request; the determining of the target device protocol group from the plurality of device protocol groups according to the device interaction mode on the port comprises: judging whether device-automatically-sent data is received on the port, and if yes, determining the target device protocol group as the first device protocol group, otherwise, determining the target device protocol group as the second device protocol group.

28. A computer-readable storage medium, the computer-readable storage medium storing a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the multi-device identification method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Communication system with serial ports for automatically identifying device types and communication protocols and method thereof

    EP3182295A1

  • Packet communication device which selects an appropriate operation mode

    US20080172514A1