Multi-device communication method, apparatus, and electronic device
Patent Information
- Application Number
- CN202610973678.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-01
- Publication Date
- 2026-10-13
AI Technical Summary
然而,主机需要通常按照固定地址列表依次轮询所有从机,可能会存在无效通信的情况,并且随着从机数量的增加,完成一轮完整轮询的周期呈线性增长,数据更新响应迟缓,导致通信效率较低
上述多设备通信方法、装置及电子设备,确定多个从设备通信中处于在线状态的目标设备;基于目标设备的属性参数,为目标设备在通信周期中分配通信时间段;在通信周期中,按照分配的通信时间段与目标设备通信。该方式根据处于在线状态的目标设备的属性参数分配通信时间段,减少了主设备与从设备之间的无效沟通,提高了主从架构下多设备通信的效率,并可以对不同属性的设备进行差异化通信时间段的分配,可以及时确定较为重要的设备的状态以及解决其产生的问题,维护了生产生活的安全性。
Smart Images

Figure CN122909212A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a multi-device communication method, apparatus, and electronic device. Background Technology
[0002] When multiple industrial devices need to communicate, a master-slave communication system can be formed. The master device in the system typically uses a polling mechanism to communicate with the slave devices. However, the master usually needs to poll all slave devices sequentially according to a fixed address list, which may result in invalid communication. Furthermore, as the number of slave devices increases, the cycle time for completing a full polling round increases linearly, leading to slow data update response and low communication efficiency. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a multi-device communication method, apparatus and electronic device to reduce invalid communication between master and slave devices and improve the efficiency of multi-device communication under master-slave architecture.
[0004] In a first aspect, embodiments of the present invention provide a multi-device communication method; the method is applied to a master device; the master device is connected to multiple slave devices in a communication connection; the method includes: determining a target device that is online in the communication between the multiple slave devices; allocating a communication time period for the target device in a communication cycle based on the attribute parameters of the target device; and communicating with the target device in the communication cycle according to the allocated communication time period.
[0005] Preferably, the step of determining the target device that is online in the communication of multiple slave devices includes: obtaining the communication address of each slave device; sending a status confirmation request to the communication address of each slave device; and for each slave device, if a response to the status confirmation request is received from the slave device, determining the slave device that sent the response as the target device.
[0006] Preferably, the aforementioned attribute parameters are used to indicate the priority of the target device; the step of allocating a communication time period for the target device in the communication cycle based on the attribute parameters of the target device includes: determining the number of target time periods corresponding to the communication cycle based on the priority of the target device; and allocating a communication time period for the target device in the communication cycle according to the number of target time periods.
[0007] Preferably, there are multiple target devices; the step of determining the number of target time periods corresponding to the communication cycle based on the priority of the target devices includes: for each target device, determining the number of time periods corresponding to the target device based on the priority of the target device; and determining the number of target time periods corresponding to the communication cycle based on the sum of the number of time periods corresponding to multiple target devices.
[0008] Preferably, the step of determining the target time period corresponding to the communication cycle based on the sum of the number of time periods corresponding to multiple target devices includes: adding the sum of the number of time periods corresponding to multiple target devices to a preset number of reserved time periods to obtain the target time period corresponding to the communication cycle; the master device communicating with the offline slave device or the newly added slave device during the time period of the reserved time period.
[0009] Preferably, the target device has a corresponding number of target time periods; the number of target time periods is determined based on the priority of the target device; there are multiple target devices; the step of allocating communication time periods for the target device in the communication cycle according to the number of target time periods includes: performing the following operations on each target device in descending order of priority: determining the time period allocation step size of the target device based on the number of target time periods and the number of time periods corresponding to the target device; determining the communication time period corresponding to the target device from the multiple communication time periods included in the communication cycle according to the time period allocation step size.
[0010] Preferably, the step of determining the communication time period corresponding to the target device from multiple communication time periods included in the communication cycle according to the time period allocation step size includes: when the number of time periods corresponding to the target device is greater than one, determining the first communication time period in the communication cycle that does not correspond to other target devices as the target communication time period corresponding to the target device; determining the next communication time period corresponding to the target device based on the communication time period in the communication cycle with the time period allocation step size as the interval between the target communication time period and the communication time period in the communication cycle; determining the next communication time period as the target communication time period of the target device; continuing to determine the next communication time period corresponding to the target device based on the communication time period with the time period allocation step size as the interval between the target communication time period and the communication time period in the communication cycle, until the number of determined communication time periods corresponding to the target device is equal to the number of time periods corresponding to the target device.
[0011] Preferably, the above method further includes: after a communication cycle, determining a target device currently online among multiple slave devices based on the communication result between the communication time period and the target device; if the current target device has changed from the target device corresponding to the communication cycle, allocating a communication time period for the current target device in the next communication cycle based on the attribute parameters of the current target device; and communicating with the current target device in the next communication cycle according to the allocated communication time period.
[0012] Secondly, embodiments of the present invention provide a multi-device communication apparatus; the apparatus is disposed on a master device; the master device is communicatively connected to multiple slave devices; the apparatus includes: a target device determination module, used to determine a target device that is online in the communication of multiple slave devices; a time period allocation module, used to allocate a communication time period for the target device in the communication cycle based on the attribute parameters of the target device; and a communication module, used to communicate with the target device in the communication cycle according to the allocated communication time period.
[0013] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described multi-device communication method.
[0014] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to implement the aforementioned multi-device communication method.
[0015] The embodiments of the present invention bring the following beneficial effects: The aforementioned multi-device communication method, apparatus, and electronic device identify a target device that is online in a multi-device communication process; allocate communication time slots for the target device within a communication cycle based on the target device's attribute parameters; and communicate with the target device according to the allocated communication time slots within the communication cycle. This method allocates communication time slots based on the attribute parameters of the online target device, reducing ineffective communication between the master and slave devices, improving the efficiency of multi-device communication in a master-slave architecture, and allowing for differentiated allocation of communication time slots for devices with different attributes. This enables timely identification of the status of critical devices and resolution of any issues arising from them, thus maintaining the safety of production and daily life.
[0016] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0017] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0018] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating a multi-device communication method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a multi-device communication device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] In production and daily life, multiple devices with communication needs typically communicate using a master-slave architecture, such as heating heat pumps, swimming pool heat pumps, and smart home systems. The master device (also known as the "master") usually maintains a fixed address list and indiscriminately polls the addresses of all slave devices (also known as "slaves"). However, the number of slave devices is large, and their online status is uncertain. Devices may come online or go offline at any time due to power outages, malfunctions, etc. In the above method, the master device communicates ineffectively with offline devices, resulting in low communication efficiency. As the number of slave devices increases, the cycle for completing a full polling round increases linearly, leading to slow data update response.
[0022] Furthermore, the above method allocates the same communication resources to all devices, and high-priority devices cannot obtain lower communication latency and higher transmission frequency, making it difficult to respond to emergencies in a timely manner.
[0023] In view of the above problems, the present invention provides a multi-device communication method, apparatus and electronic device, which can be applied to multi-device communication process in master-slave architecture.
[0024] To facilitate understanding of this embodiment, a multi-device communication method disclosed in this invention will first be described in detail. The device is located on a master device; the master device is communicatively connected to multiple slave devices. The master device and slave devices can be of the same type or different types. The multiple slave devices can also be of the same type or different types. The master device may have preset device functions, such as a heat pump function, or it may only be used to communicate with slave devices and control their operating status. Specific configurations can be made according to requirements, and will not be described here.
[0025] like Figure 1 As shown, the method includes the following steps: Step S102: Identify multiple target devices that are online in slave device communication.
[0026] After the system, including master and slave devices, starts up or resets, the master device can obtain the communication addresses of each slave device and communicate with each slave device in turn. If a slave device returns a response signal to the target device, it can be determined that the slave device is online, and further, the slave device can be identified as the target device.
[0027] To reduce misjudgments caused by network fluctuations or response delays, the master device can communicate with each slave device multiple times. If, during these multiple communications, a slave device returns a response signal to the target device at least once, it can be determined that the slave device is online, and further, it can be identified as the target device.
[0028] Step S104: Based on the attribute parameters of the target device, allocate a communication time period for the target device in the communication cycle.
[0029] The aforementioned attribute parameters are used to represent the type, power, etc., of the target device, and can also be used to represent the priority of the target device. The priority of the target device can be manually set or determined based on its type, power, etc. For example, when multiple slave devices are of different types, the slave device of the first type is set to a higher priority, and the slave device of the second type is set to a lower priority; when multiple slave devices are of the same type, the slave device with greater power can be set to a higher priority. Specific settings can be configured according to requirements and are not limited here.
[0030] Different attribute parameters typically correspond to different numbers of communication time slots. For example, if the target device's priority level is 1, the corresponding number of communication time slots is 3, so three communication time slots need to be allocated to the target device in the communication cycle; if the target device's device type is Type 1, and the enemy camp's number of communication time slots is 2, then two communication time slots need to be allocated to the target device in the communication cycle.
[0031] In a communication cycle, the master device typically needs to communicate with all target devices. Therefore, the communication cycle needs to include the communication time periods corresponding to all target devices. To prevent communication between the master device and each target device from interfering with each other, the master device is usually allowed to communicate with only one target device within the same communication time period. Multiple communication time periods for the same target device within a communication cycle are usually non-contiguous; however, in practical applications, they can also be set to be continuous, and there is no restriction on this.
[0032] Time Division Multiple Access (TDMA) technology is typically used to divide the communication time corresponding to the communication channel between the master and slave devices into small communication time slots. These communication time slots are called "time slots," and each slave device communicates with the master device only within its assigned time slot. The duration of different communication time slots is usually the same, but it can also be different, depending on the requirements. There are no restrictions here.
[0033] In a communication cycle, in addition to communicating with the target device, the master device can reserve one or more communication time periods to communicate with the slave device that is offline, in order to determine whether the slave device has entered the online state.
[0034] Step S106: During the communication cycle, communicate with the target device according to the allocated communication time period.
[0035] After allocating communication time slots to target devices, the master device can be controlled to communicate with the corresponding target devices during their respective communication time slots. During communication between the master device and the target device, if the target device fails to return response data to the master device, it can be determined that the device is not online, thus confirming that the slave device is not the target device.
[0036] If, during a communication cycle, the master device communicates with an offline slave device and the slave device returns a response signal, it can be determined that the slave device is online, and thus the slave device can be identified as the target device.
[0037] Therefore, the target device may change after the communication cycle ends. Furthermore, a communication time slot for the next communication cycle can be allocated to the changed target device, thereby controlling the master device to communicate with the changed target device according to the allocated communication time slot in the next communication cycle. If the target device does not change after the communication cycle ends, the current communication time slot allocation result can still be used to control the communication between the master device and the target device.
[0038] The aforementioned multi-device communication method identifies the target device that is online in a multi-device communication process; based on the target device's attribute parameters, it allocates a communication time slot for the target device within a communication cycle; and within the communication cycle, it communicates with the target device according to the allocated communication time slot. This method allocates communication time slots based on the attribute parameters of the online target device, reducing ineffective communication between the master and slave devices, improving the efficiency of multi-device communication in a master-slave architecture, and allowing for differentiated allocation of communication time slots for devices with different attributes. It also enables timely identification of the status of critical devices and resolution of any issues arising from them, thus maintaining the safety of production and daily life.
[0039] The following embodiments provide a specific method for identifying target devices that are online in multiple slave device communications.
[0040] In practical applications, the master device can pre-configure, establish, and maintain a dynamic address pool to record the status information of each slave device. The number of devices in the address pool is related to the maximum number of devices that can be connected to the communication port. As shown in Table 1, the address pool data can include the following fields: Table 1
[0041] The master device can obtain the communication addresses of each slave device from the dynamic address pool and send status confirmation requests to the communication addresses of each slave device; for each slave device, if a response to the status confirmation request is received from the slave device, the slave device that sent the response is identified as the target device.
[0042] In practical applications, the master device can perform three rounds of fast polling (e.g., every 50ms) on all addresses in the dynamic address pool to send a status acknowledgment request to each address. If a slave device receives a response more than once, its communication status is marked as "online"; if a device does not respond to the status acknowledgment request in all three rounds, its communication status is marked as "offline". An initial communication status list can also be quickly established based on the communication status of multiple slave devices to record whether each slave device is online or offline.
[0043] The following embodiments provide a specific method for allocating communication time periods for a target device within a communication cycle based on the target device's attribute parameters.
[0044] In practical applications, the aforementioned attribute parameters can be used to indicate the priority of a target device. Different priorities typically correspond to different numbers of time slots, that is, the number of communication time slots occupied by a target device of that priority within a communication cycle. The number of target time slots corresponding to a communication cycle can be determined based on the priority of the target device. This usually requires statistically analyzing the number of time slots corresponding to the priorities of multiple target devices, then determining the statistically obtained number as the number of target time slots for that communication cycle. Furthermore, communication time slots are allocated to the target devices within the communication cycle according to the number of target time slots.
[0045] When there are multiple target devices, for each target device, the number of time periods corresponding to that target device is determined based on its priority; that is, the number of time periods corresponding to the priority of that target device is determined as the number of time periods corresponding to that target device. Further, the target number of time periods corresponding to the communication cycle can be determined based on the sum of the number of time periods corresponding to multiple target devices. For example, the sum of the number of time periods corresponding to multiple target devices can be directly determined as the target number of time periods corresponding to the current communication cycle. When a reserved time period is preset, the sum of the number of time periods corresponding to multiple target devices can be added to the preset reserved time period to obtain the target number of time periods corresponding to the communication cycle. The master device communicates with offline slave devices or newly added slave devices during the reserved time period.
[0046] When using TMD technology and a multi-slot allocation strategy to allocate different numbers of communication time slots to slave devices of different priorities, priority levels i = 1, 2, ... can be pre-set. The number of time slots per cycle for level i = S_i; the number of devices at level i = N_i; the base number of time slots = Σ(N_i × S_i), for online computing devices; the total number of time slots = base number of time slots + reserved number of time slots. The reserved number of time slots is equivalent to the reserved time period, typically one or two.
[0047] After determining the number of target time slots corresponding to the current communication cycle and the number of time slots corresponding to each target device, the following operations can be performed on each target device in descending order of priority: Based on the number of target time slots and the number of time slots corresponding to each target device, determine the time slot allocation step size for each target device. This time slot allocation step size is typically the number of time slots between two adjacent time slots of the target device within the communication cycle. For each target device, the ratio between the number of target time slots and the number of time slots corresponding to the target device can be obtained, and this ratio can be rounded down to the nearest integer; the resulting integer is the time slot allocation step size.
[0048] After determining the time period allocation step size, the communication time period corresponding to the target device needs to be determined from the multiple communication time periods contained in the communication cycle according to the time period allocation step size. When the number of time periods corresponding to the target device is greater than one, the first communication time period in the communication cycle that does not correspond to other target devices is first determined as the target communication time period corresponding to the target device. When the first and second time periods in the communication cycle both correspond to other target devices, the third time period can be determined as the first target communication time period of the current target device. Then, based on the communication time periods in the communication cycle with the time period allocation step size of the target communication time period, the next communication time period corresponding to the target device is determined. For example, when the time period allocation step size corresponding to the current target device is 2, the first target communication time period is the third time period in the communication cycle, so the sixth time period in the communication cycle can be determined as the next communication time period corresponding to the target device; if the sixth time period already corresponds to other target devices, the next communication time period corresponding to the target device can be postponed to the nearest idle time period after the sixth time period.
[0049] If the number of determined communication time periods does not reach the number of time periods corresponding to the target device, the next communication time period is determined as the target communication time period of the target device; continue to allocate communication time periods with step sizes based on the interval between the target communication time period and the communication period in the communication cycle, and determine the next communication time period corresponding to the target device, until the number of determined communication time periods corresponding to the target device is equal to the number of time periods corresponding to the target device.
[0050] In one specific embodiment, the target devices include device A, device B, and device C, and a reserved time period is set. The address pool configuration corresponding to the target devices is shown in Table 2. Table 2
[0051] The number of target time slots corresponding to the communication cycle = 1×3 + 2×2 + 1×1 + 1 = 9; the time slot allocation step size for device A is calculated as 8 / 3 = 2, so the order of communication time slots corresponding to A in the communication cycle is: 1, 4, 7; the time slot allocation step size for device B is 8 / 2 = 4, so the order of communication time slots corresponding to B1 in the communication cycle is: 2, 6, and the order of communication time slots corresponding to B2 in the communication cycle is: 3, 8; the step size for device C is 8 / 1 = 8, so the order of communication time slots corresponding to C in the communication cycle is: 5. The final communication time slot allocation results are shown in Table 3.
[0052] Table 3
[0053] Throughout the communication cycle, the host performs polling communication access to the slave devices in the order shown in Table 3 above, specifically: A, B1, B2, A, C, B1, A, B2, and a certain offline device.
[0054] After a communication cycle, based on the communication time period and the communication results with the target device, the target device currently online among multiple slave devices is determined. Typically, the slave device that sent response data can be identified as the current target device. If the current target device changes from the target device corresponding to the communication cycle, a communication time period needs to be allocated to the current target device in the next communication cycle based on its attribute parameters. The specific implementation is similar to the initial allocation of the communication time period and will not be elaborated here. In the next communication cycle, the master device communicates with the current target device according to the allocated communication time period.
[0055] Corresponding to the embodiments of the above-described multi-device communication method, this embodiment also provides a multi-device communication apparatus. This apparatus is located on a master device; the master device is communicatively connected to multiple slave devices. For example... Figure 2 As shown, the device includes: The target device determination module 202 is used to determine multiple target devices that are online in slave device communication. The time period allocation module 204 is used to allocate a communication time period to the target device in the communication cycle based on the target device's attribute parameters; The communication module 206 is used to communicate with the target device according to the allocated communication time period during the communication cycle.
[0056] The aforementioned multi-device communication device identifies target devices that are online in a multi-device communication process; based on the target device's attribute parameters, it allocates communication time slots for the target device within a communication cycle; and within the communication cycle, it communicates with the target device according to the allocated communication time slots. This method allocates communication time slots based on the attribute parameters of the online target devices, reducing ineffective communication between master and slave devices, improving the efficiency of multi-device communication in a master-slave architecture, and allowing for differentiated allocation of communication time slots for devices with different attributes. It also enables timely identification of the status of critical devices and resolution of any issues arising from them, thus maintaining the safety of production and daily life.
[0057] The aforementioned target device determination module is also used to: obtain the communication address of each slave device; send a status confirmation request to the communication address of each slave device; and for each slave device, if a response to the status confirmation request is received from the slave device, determine the slave device that sent the response as the target device.
[0058] The aforementioned attribute parameters are used to indicate the priority of the target device; the time period allocation module is also used to: determine the target time slot number corresponding to the communication cycle based on the priority of the target device; and allocate communication time periods to the target device in the communication cycle according to the target time period number.
[0059] The aforementioned target devices are multiple; the time period allocation module is also used to: for each target device, determine the number of time periods corresponding to the target device based on the priority of the target device; and determine the number of target time periods corresponding to the communication cycle based on the sum of the number of time periods corresponding to multiple target devices.
[0060] The aforementioned time period allocation module is also used to: add the sum of the number of time periods corresponding to multiple target devices to the preset number of reserved time periods to obtain the number of target time periods corresponding to the communication cycle; and for the master device to communicate with the offline slave device or the newly added slave device during the time period of the reserved time period.
[0061] The aforementioned target devices have a corresponding number of target time periods; the number of target time periods is determined based on the priority of the target devices; there are multiple target devices; the time period allocation module is also used to: perform the following operations on each target device in descending order of priority: determine the time period allocation step size of the target device based on the number of target time periods and the number of time periods corresponding to the target device; determine the communication time period corresponding to the target device from the multiple communication time periods contained in the communication cycle according to the time period allocation step size.
[0062] The aforementioned time period allocation module is also used to: when the number of time periods corresponding to the target device is greater than one, determine the first communication time period in the communication cycle that does not correspond to other target devices as the target communication time period corresponding to the target device; determine the next communication time period corresponding to the target device based on the interval between the target communication time period in the communication cycle and the time period allocation step size; determine the next communication time period as the target communication time period of the target device; continue to execute the communication time period allocation step size based on the interval between the target communication time period in the communication cycle and the time period allocation step size to determine the next communication time period corresponding to the target device, until the number of determined communication time periods corresponding to the target device is equal to the number of time periods corresponding to the target device.
[0063] The aforementioned device further includes: a target device update module, used to determine, after a communication cycle, a target device currently online among multiple slave devices based on the communication result between the target device and the communication time period; a time period update allocation module, used to allocate a communication time period for the current target device in the next communication cycle based on the attribute parameters of the current target device if the target device has changed from the target device corresponding to the communication cycle; and a second communication module, used to communicate with the current target device in the next communication cycle according to the allocated communication time period.
[0064] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described multi-device communication method.
[0065] See Figure 3 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described multi-device communication method.
[0066] Furthermore, Figure 3 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.
[0067] The memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0068] The processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 100 or by instructions in software form. The processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0069] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the above-described multi-device communication method.
[0070] The present disclosure provides a multi-device communication method, apparatus, and electronic device, including a computer-readable storage medium storing program code, wherein the program code includes instructions that can be used to execute the methods described in the preceding method embodiments.
[0071] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0072] Furthermore, in the description of the embodiments of this disclosure, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this disclosure based on the specific circumstances.
[0073] 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 solutions of this disclosure, in essence, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include 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 methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0074] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0075] Finally, it should be noted that the above embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A multi-device communication method, characterized in that, The method is applied to the main device; The master device is communicatively connected to multiple slave devices; the method includes: Identify the target device that is online in the plurality of slave device communications; Based on the attribute parameters of the target device, a communication time period is allocated to the target device in the communication cycle; During the communication cycle, communication is conducted with the target device according to the allocated communication time period.
2. The method according to claim 1, characterized in that, The step of determining the target device that is online in the plurality of slave device communications includes: Obtain the communication address of each of the slave devices; Send a status confirmation request to the communication address of each of the slave devices; For each of the slave devices, if a response to the status confirmation request is received from the slave device, the slave device that sent the response is identified as the target device.
3. The method according to claim 1, characterized in that, The attribute parameters are used to indicate the priority of the target device; The step of allocating communication time periods to the target device within a communication cycle based on the target device's attribute parameters includes: Based on the priority of the target device, determine the number of target time periods corresponding to the communication cycle; The target device is allocated a communication time period in the communication cycle according to the target time period quantity.
4. The method according to claim 3, characterized in that, There are multiple target devices; The step of determining the number of target time periods corresponding to the communication cycle based on the priority of the target device includes: For each target device, the number of time periods corresponding to the target device is determined based on the priority of the target device; The number of target time periods corresponding to the communication cycle is determined based on the sum of the number of time periods corresponding to the multiple target devices.
5. The method according to claim 4, characterized in that, The step of determining the number of target time periods corresponding to a communication cycle based on the sum of the number of time periods corresponding to multiple target devices includes: The sum of the number of time periods corresponding to multiple target devices is added to the preset number of reserved time periods to obtain the number of target time periods corresponding to the communication cycle; the master device communicates with the offline slave device or the newly added slave device during the time period of the reserved time period.
6. The method according to claim 3, characterized in that, The target device has a corresponding number of target time periods; the number of target time periods is determined based on the priority of the target device; there are multiple target devices. The step of allocating communication time periods to the target device in the communication cycle according to the target time period quantity includes: Perform the following operations on each of the multiple target devices in descending order of priority: Based on the number of target time periods and the number of time periods corresponding to the target device, the time period allocation step size for the target device is determined; The communication time period corresponding to the target device is determined from multiple communication time periods included in the communication cycle according to the time period allocation step size.
7. The method according to claim 6, characterized in that, The step of determining the communication time period corresponding to the target device from multiple communication time periods included in the communication cycle according to the time period allocation step size includes: When the number of time periods corresponding to the target device is greater than one, the first communication time period in the communication cycle that does not correspond to other target devices is determined as the target communication time period corresponding to the target device. Based on the interval between the target communication time period and the communication period in the communication cycle, a communication time period with a step size is allocated to the time period, and the next communication time period corresponding to the target device is determined; The next communication time period is determined as the target communication time period of the target device; Continue executing communication time periods with step sizes allocated to the time periods based on the interval between the target communication time period and the communication period in the communication cycle, determine the next communication time period corresponding to the target device, until the number of determined communication time periods corresponding to the target device is equal to the number of time periods corresponding to the target device.
8. A multi-device communication device, characterized in that, The device is installed in the main equipment; The master device is communicatively connected to multiple slave devices; the device includes: A target device determination module is used to determine the target device that is online in the communication of the plurality of slave devices; The time period allocation module is used to allocate a communication time period to the target device in the communication cycle based on the attribute parameters of the target device; A communication module is used to communicate with the target device during the communication cycle, according to the allocated communication time period.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the multi-device communication method according to any one of claims 1-7.
10. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the multi-device communication method according to any one of claims 1-7.