Communication control method and device, and storage medium
By querying the online status of the slave before the host polls and establishing an online slave hanger, the problems of inefficiency and poor compatibility caused by disconnecting the slave in the communication system are solved, and more efficient and compatible communication is achieved.
Patent Information
- Application Number
- CN202411197786.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2025-01-10
AI Technical Summary
The existing communication system based on master-slave architecture cannot skip slaves that are disconnected due to unconnection or communication errors during host polling, resulting in reduced communication efficiency and requiring pre-specified communication protocols between the host and slaves, resulting in Poor compatibility.
By adding an online slave query process before the host polls, an online slave hanger is established, and the target protocol is selected according to the slave's communication protocol, skipping the dropped slave and optimized protocol versions, to improve communication efficiency and compatibility.
The communication efficiency and compatibility of the communication system are improved, and the protocol version can be dynamically adjusted to adapt to the changes of slaves, ensuring stable communication between the master and slaves.
Smart Images

Figure CN119299509A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of communication technology, and specifically relates to a communication control method, device and storage medium. Background Art
[0002] The communication system based on the master-slave architecture is an important way for smart home appliances to communicate with internal modules and external devices, and undertakes the key tasks of data transmission and command exchange. Taking the communication system based on the RS-485 bus as an example, a host controls the communication with multiple slaves, among which the host's microcontroller unit (Microcontroller Unit, MCU) can be connected to the RS-485 converter through its internal universal asynchronous receiver / transmitter (UART) interface, and then communicate with other slaves on the RS-485 bus. However, with the continuous increase in the functions of smart home appliances and the continuous improvement of their intelligence level, the number of UART interfaces of the MCU itself is difficult to meet the communication needs between all internal modules or external devices of smart home appliances.
[0003] In order to alleviate the problem of insufficient UART interface resources, the prior art proposes a multiplexed communication control method, in which a unique address is assigned to each device, and the host communicates with each slave one by one in a polling manner based on the address, and a timer is used to manage the communication time between the host and each slave, so that a single serial interface can switch between multiple devices, thereby realizing multi-device communication.
[0004] However, during the host polling period, the existing communication control method cannot skip the slave that is offline due to disconnection or communication error, resulting in reduced communication efficiency of the communication system; and the communication protocol of both the host and the slave needs to be pre-defined before polling, resulting in poor compatibility of the communication system. Summary of the invention
[0005] The present application provides a communication control method, device and storage medium to solve the problems of low communication efficiency and poor compatibility of existing communication control methods.
[0006] In a first aspect, the present application provides a communication control method, which is applied to a host in a communication system, wherein the communication system includes the host and multiple slaves, and the method includes:
[0007] Sending a first unicast frame to each of the plurality of slaves, wherein the first unicast frame is used to query whether the slave is online, and if no query response to the first unicast frame is received from any slave, repeating this step until a query response from some slaves is received, wherein the query response includes a communication protocol supported by the slave;
[0008] Determine the unresponsive slave and resend the first unicast frame to the unresponsive slave;
[0009] All slaves corresponding to the received query responses are added to the online slave library, and based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host, a target protocol for the host to communicate with the slaves in the online slave library is determined.
[0010] In a possible implementation, the method further includes:
[0011] Sending a second unicast frame to each slave in the online slave library, wherein the second unicast frame is used to set the slave to adopt the target protocol;
[0012] If a setting response to the second unicast frame is not received from the first slave in the online slave library, the second unicast frame is sent to the first slave again. If a setting response from the first slave is still not received after the second unicast frame is sent to the first slave for the first number of times, the first slave is deleted from the online slave library.
[0013] In a possible implementation, the method further includes:
[0014] Sending a third unicast frame to the second slave in the online slave library and entering a waiting state;
[0015] If the host does not receive a response from the second slave and the duration of entering the waiting state exceeds a first duration, the host enters an idle state;
[0016] If the host receives a response from the second slave, the host enters a receiving state and processes the received data, and if the processing of the received data is completed, or if an error occurs in processing the received data and the duration of entering the receiving state exceeds a second duration, the host enters an idle state;
[0017] If the host does not receive any response from the second slave within a third continuous time period, the second slave is deleted from the online slave library.
[0018] In a possible implementation, the method further includes:
[0019] Sending polling requests to the slaves in the online slave library in sequence according to a preset polling interval;
[0020] After sending a polling request to a third slave in the online slave library and receiving a polling response from the third slave, if it is determined that the third slave needs to be controlled, recording the address of the third slave and sending a control frame to the third slave;
[0021] If the control response of the third slave is not received, the control frame is sent to the third slave again, and this step is repeated until the control response of the third slave is received, or until the number of times the control frame is sent to the third slave reaches the second number, then the polling request is continued to be sent to the next slave of the third slave.
[0022] In a possible implementation, the method further includes:
[0023] If the number of slaves in the online slave library is zero, the step of sending the first unicast frame to the multiple slaves is performed again, and the unresponsive slaves are determined, and the first unicast frame is sent to the unresponsive slaves again to redetermine the online slave library based on the received query response.
[0024] In a possible implementation, the method further includes:
[0025] If the number of slaves in the online slave library is greater than zero and less than a first preset number, then after each second preset number of rounds of polling, the first unicast frame is sent again to other slaves outside the online slave library to redetermine the online slave library based on the received query response.
[0026] In a second aspect, the present application provides a communication control method, which is applied to a slave in a communication system, wherein the communication system includes a master and a plurality of slaves, and the method includes:
[0027] receiving a first unicast frame sent by the host, where the first unicast frame is used to query whether the slave is online;
[0028] If the address of the first unicast frame is the address of the slave, the first unicast frame is parsed and a query response for the first unicast frame is sent to the host, the query response including the communication protocol supported by the slave, the query response being used to determine whether the slave is online, and for determining a target protocol for communication between the host and the slave.
[0029] In a possible implementation, the method further includes: receiving a second unicast frame sent by the host, where the second unicast frame is used to set the slave to adopt the target protocol;
[0030] A setup response to the second unicast frame is sent to the host.
[0031] In a third aspect, the present application provides a communication control device, applied to a host in a communication system, the device comprising:
[0032] a transceiver module, configured to send a first unicast frame to each of the plurality of slaves, wherein the first unicast frame is used to query whether the slave is online, and when no query response to the first unicast frame is received from any slave, repeatedly performing this step until a query response from some slaves is received, wherein the query response includes a communication protocol supported by the slave;
[0033] A processing module, for determining a slave that does not respond;
[0034] The transceiver module is further configured to resend the first unicast frame to the non-responding slave;
[0035] The processing module is also used to add all slaves corresponding to the received query responses to the online slave library, and determine the target protocol for the host to communicate with the slaves in the online slave library based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host.
[0036] In a possible implementation, the transceiver module is further used to send a second unicast frame to each slave in the online slave library, where the second unicast frame is used to set the slave to adopt the target protocol;
[0037] The transceiver module is further configured to send the second unicast frame to the first slave again when a setting response to the second unicast frame from the first slave in the online slave library is not received;
[0038] The processing module is further configured to delete the first slave from the online slave library if no set response from the first slave is received after the number of times the second unicast frame is sent to the first slave reaches a first number.
[0039] In a possible implementation, the transceiver module is further used to send a third unicast frame to the second slave in the online slave library and enter a waiting state;
[0040] The processing module is configured to cause the host to enter an idle state when the host does not receive a response from the second slave and the duration of entering the waiting state exceeds a first duration;
[0041] The processing module is configured to, when the host receives a response from the second slave, cause the host to enter a receiving state and process the received data, and when the processing of the received data is completed, or when an error occurs in processing the received data and the duration of entering the receiving state exceeds a second duration, cause the host to enter an idle state;
[0042] The processing module is further configured to delete the second slave from the online slave library when the host does not receive any response from the second slave within a third continuous time period.
[0043] In a possible implementation, the transceiver module is further configured to sequentially send polling requests to the slaves in the online slave library according to a preset polling interval;
[0044] The processing module is further configured to, after sending a polling request to a third slave in the online slave library and receiving a polling response from the third slave, record the address of the third slave if it is determined that the third slave needs to be controlled;
[0045] The transceiver module is further used to send a control frame to the third slave;
[0046] The transceiver module is also used to send the control frame to the third slave again when the control response of the third slave is not received, and repeat this step until the control response of the third slave is received, or until the number of times the control frame is sent to the third slave reaches a second number, and then continue to send a polling request to the next slave of the third slave.
[0047] In one possible implementation, the transceiver module is further used to, when the number of slaves in the online slave library is zero, again execute the sending of the first unicast frame to the multiple slaves respectively, and to determine the unresponsive slaves and again send the first unicast frame to the unresponsive slaves. The processing module is further used to redetermine the online slave library based on the received query response.
[0048] In a fourth aspect, the present application provides a communication control device, applied to a slave in a communication system, the device comprising:
[0049] A transceiver module, used for receiving a first unicast frame sent by the host, where the first unicast frame is used for querying whether the slave is online;
[0050] a processing module, configured to parse the first unicast frame when the address of the first unicast frame is the address of the slave;
[0051] The transceiver module is also used to send a query response to the first unicast frame to the host, the query response includes the communication protocol supported by the slave, the query response is used to determine whether the slave is online, and to determine the target protocol for communication between the host and the slave.
[0052] In a possible implementation, the transceiver module is further used to receive a second unicast frame sent by the host, where the second unicast frame is used to set the slave to adopt the target protocol;
[0053] The transceiver module is further used to send a setting response to the second unicast frame to the host.
[0054] In a fifth aspect, the present application provides an electronic device, including:
[0055] Memory;
[0056] processor;
[0057] Wherein, the memory stores computer-executable instructions;
[0058] The processor executes the computer-executable instructions stored in the memory to implement the communication control method as described in the first aspect and various possible implementations of the first aspect or the second aspect and various possible implementations of the second aspect.
[0059] In a sixth aspect, the present application provides a computer storage medium having computer execution instructions stored thereon, wherein the computer execution instructions are executed by a processor to implement the communication control method as described in the first aspect and various possible implementations of the first aspect or the second aspect and various possible implementations of the second aspect.
[0060] The communication control method provided by the present application is to send a first unicast frame to multiple slaves respectively through the host, and the first unicast frame is used to query whether the slave is online. If no query response to the first unicast frame is received from any slave, the first unicast frame is repeatedly sent to the multiple slaves until query responses from some slaves are received. The host determines the slaves that have not responded, and sends the first unicast frame to the non-responding slaves again, adds all slaves corresponding to the received query responses to an online slave library, and determines the target protocol for the host to communicate with the slaves in the online slave library based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host. The method improves the communication efficiency of the communication system by establishing an online slave library, and the host can select the target protocol according to the communication protocols supported by the slaves in the online slave library, thereby improving the compatibility of the communication system. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0062] Figure 1 It is a schematic diagram of the architecture of the communication system provided by this application;
[0063] Figure 2This is the process of the communication control method provided by this application Figure 1 ;
[0064] Figure 3 This is the process of the communication control method provided by this application Figure 2 ;
[0065] Figure 4 This is the process of the communication control method provided by this application Figure 3 ;
[0066] Figure 5 This is the process of the communication control method provided by this application Figure 4 ;
[0067] Figure 6 This is the process of the communication control method provided by this application Figure 5 ;
[0068] Figure 7 This is a schematic diagram of the structure of the communication control device provided by this application. Figure 1 ;
[0069] Figure 8 This is a schematic diagram of the structure of the communication control device provided by this application. Figure 2 ;
[0070] Fig. 9 It is a structural schematic diagram of the electronic device provided by this application.
[0071] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0073] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein.
[0074] In the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0075] In a communication system based on a master-slave architecture, a one-master-multiple-slave network architecture is usually adopted. The host MCU can be connected to the RS-485 converter through its internal UART interface, and then communicate with other devices (slaves) on the RS-485 bus. However, as the functions of smart home appliances continue to increase and the level of intelligence continues to improve, the number of UART interfaces of the MCU itself is difficult to meet the communication needs between all internal modules or external devices of smart home appliances.
[0076] In order to alleviate the problem of insufficient UART interface resources, the prior art proposes a multiplexed communication control method, in which a unique address is assigned to each device, and the host communicates with each slave one by one in a polling manner based on the address, and a timer is used to manage the communication time between the host and each slave, so that a single serial interface can switch between multiple devices, thereby realizing multi-device communication.
[0077] However, during the host polling period, the existing communication control method cannot skip the slave that is offline due to disconnection or communication error, resulting in reduced communication efficiency of the communication system; and the communication protocol of both the host and the slave needs to be pre-defined before polling, resulting in poor compatibility of the communication system.
[0078] In view of this, the present application provides a communication control method, which adds an online slave query process before the host polls, establishes an online slave library for this communication through the query results replied by the slave, and in the subsequent polling process, only the slaves in the online slave library are polled. In addition, in order to be able to manage the online slave library in real time, the slaves that have not responded for a long time in the online slave library will be deleted; at the same time, the online slave query process will be re-performed after a period of time, and the slaves that have been added online in the middle of the process will be skipped during the subsequent host polling. The slaves that are offline due to disconnection or communication errors can be skipped to improve the communication efficiency of the communication system; and after the slave library is established, according to the recorded slave information, the host executes according to the lowest protocol version supported by all internal machines within the protocol version range supported by itself, so that the communication protocol running on the bus can be selected within a certain version range, thereby improving the compatibility of the communication system.
[0079] Figure 1 This is a schematic diagram of the architecture of the communication system provided in this application. It should be noted that: Figure 1What is shown are merely examples of application scenarios to which the communication control method of the present application can be applied, in order to help those skilled in the art understand the technical content of the present application, but it does not mean that the embodiments of the present application cannot be used in other devices, systems, environments or scenarios.
[0080] like Figure 1 As shown, the communication system includes a host and multiple slaves such as slave 1, slave 2...slave n, and the host and multiple slaves are connected to the bus, that is, bus A and bus B. Bus A and bus B are a pair of differential signal lines. Data is sent and received by transmitting differential signals through bus A and bus B, which can realize communication between the host and multiple slaves. The bus composed of bus A and bus B can be any one of RS-485 bus, RS-449 bus, RS-432 bus, RS-423 bus, and RS-422 bus, but not limited to. The above communication system can be applied to scenarios such as smart home systems, industrial sites, and security monitoring.
[0081] Taking RS-485 bus as an example, the master-slave architecture is adopted based on RS-485 bus communication. Figure 1 In the communication, the host is responsible for initiating communication and making requests, and other slaves respond to the requests sent by the host and perform corresponding operations. The communication between the host and any slave is mainly carried out in a "request-response" mode. For example, the host sends a request to the slave, and the request contains a function code indicating the specific operation that the slave should perform. After receiving the request, the slave performs the corresponding operation and returns the result to the host.
[0082] At the same time, in order to distinguish different slaves, each slave is usually assigned a unique address, and the host communicates with the corresponding slave through the address. For example, if the host address is set to 0x00, the slave addresses can be set starting from slave 1 to slave 1 (0x01), slave 2 (address 0x02)...slave n (0x0n).
[0083] After the communication system is initialized, the host enters the bus monitoring mode. If the host continuously detects that the bus remains idle for a preset time, the host will automatically switch to the idle state. When the host remains idle for longer than the preset time, the host can actively initiate the transmission of functional frames such as query or control.
[0084] The entire communication system has two communication modes: unicast and broadcast. When the host unicasts a slave, the host accesses the slave with the preset slave address. After the slave receives and processes the request, it returns a response to the host, and other slaves do not respond. When the host broadcasts all slaves, the host sends a request to bus A and bus B with an address of 0x00, and all slaves respond but do not return a response.
[0085] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be implemented independently or in combination with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0086] Figure 2 The process of the communication control method provided in the embodiment of the present application Figure 1 The execution subject of this embodiment can be, for example, Figure 1 The host in the communication system. Figure 2 As shown, the communication control method provided in this embodiment includes:
[0087] S101. The host sends a first unicast frame to multiple slaves respectively.
[0088] The first unicast frame is used to query whether the slave is online, and the first unicast frame may include: a slave address and a query instruction. The host sends the first unicast frame to each slave in sequence according to the address and order of each slave preset in the communication system.
[0089] For example, a smart home system has a host (e.g., a central controller) and multiple slaves (e.g., air conditioners, smart lights, water heaters, etc.), where the addresses of the air conditioner, smart light, and water heater are address 1, address 2, and address 3, respectively. The host needs to query the online status of these slaves, first sending the first unicast frame including address 1 to the air conditioner, then sending the first unicast frame including address 2 to the smart light, and then sending the first unicast frame including address 3 to the water heater, and so on until the first unicast frame is sent to the Nth slave with address N.
[0090] It can be understood that before the host sends the first unicast frame to each slave in turn, it can also use the host's own address to send a broadcast frame to all slaves to notify all slaves of the current status of the host to ensure that all slaves are ready to receive the subsequent first unicast frame, and after all slaves receive the broadcast frame, they do not need to respond to the broadcast frame.
[0091] S102, the host determines whether a query response to the first broadcast frame is received from any slave; if so, execute step S103; if not, execute step S101.
[0092] After the host sends the first unicast frame to all slaves in sequence, the online slaves need to send a query response to their own first unicast frame to the host after parsing the first unicast frame.
[0093] If the host does not receive a query response from any slave within the preset time, it means that all slaves may not be online, or there may be communication failure, slave failure, slave busy with other tasks, etc., causing the slave to be in a temporary non-responsive state. If only one query is performed, the host may misjudge the status of the slave. Therefore, in order to avoid misjudgment caused by a single polling failure, the host needs to repeatedly send the first unicast frame to multiple slaves and poll all slaves until query responses from some slaves are received.
[0094] If the host receives query responses from some slaves after first polling all slaves, and the query responses include the communication protocols supported by the slaves and the addresses of the slaves, the host can record the communication protocols and slave addresses of these slaves and perform the next round of polling.
[0095] S103: The host determines the unresponsive slaves and sends the first unicast frame to the unresponsive slaves again.
[0096] Among them, the host can determine the addresses of all responding slaves based on the query responses received in the previous round of polling, so as to filter out the unresponsive slaves, and poll the slaves that did not respond last time again according to the addresses of all unresponsive slaves, that is, send the first unicast frame to the unresponsive slaves again.
[0097] It is understandable that before the host re-sends the first unicast frame to each unresponsive slave, the host may also use its own address to send another broadcast frame to all slaves to synchronize the state of the host to all slaves.
[0098] Optionally, the master can set a retry count and retry interval to ensure that the correct slave status can be obtained again even if the first attempt fails. The master can also preset a timeout period to distinguish between the slave being temporarily unresponsive and the slave being truly offline. In addition, the master can also record the results of each query round to track the status changes of the slave.
[0099] By polling the slave status multiple times, the accuracy of the master's query of the slave's online status can be significantly improved, especially when the slave is occasionally in a non-responsive state, there is a chance that it will recover in subsequent queries. Sending the first broadcast frame multiple times helps ensure that the master can accurately obtain the status information of all slaves, thereby better controlling and managing the entire communication system.
[0100] S104. The host adds all slaves corresponding to the received query responses to the online slave library, and determines the target protocol for the host to communicate with the slaves in the online slave library based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host.
[0101] Among them, the host can summarize all slaves that have sent query responses according to the multiple slave addresses included in all query responses received through multiple polling to obtain multiple online slaves, and establish an online slave library based on the query responses of these online slaves, and determine the target protocol used by the host to communicate with all slaves based on the version of the communication protocol supported by each slave in the online slave library and the version of the communication protocol supported by the host.
[0102] For example, the host determines the lowest protocol version among the communication protocol versions supported by all slaves based on the communication protocol versions supported by all slaves in the online slave library. The host communicates with all slaves according to this lowest protocol version within the range of communication protocol versions supported by itself to ensure that all slaves can communicate with the host, thereby improving the compatibility of the communication system.
[0103] The communication control method provided in the present embodiment sends a first unicast frame to multiple slaves respectively through the host, the first unicast frame is used to query whether the slave is online, if no query response to the first unicast frame is received from any slave, the first unicast frame is repeatedly sent to the multiple slaves until query responses from some slaves are received, the query response includes the communication protocol supported by the slave, the host determines the slaves that have not responded, and sends the first unicast frame to the unresponsive slaves again, adds all slaves corresponding to the received query response to the online slave library, and determines the target protocol for the host to communicate with the slaves in the online slave library based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host; the method establishes an online slave library so that the host can avoid querying the offline slaves during the slave polling period, thereby improving the communication efficiency of the communication system, and the host can select the communication protocol used by the host according to the communication protocols of each slave in the online slave library, thereby improving the compatibility of the communication system.
[0104] Figure 3 The process of the communication control method provided in the embodiment of the present application Figure 2 This embodiment is in Figure 2 Based on the embodiment, a method for setting a target protocol for each slave in the online slave library after establishing the online slave library is described in detail. Figure 3 As shown, the communication control method provided in this embodiment includes:
[0105] S201. The host sends a second unicast frame to each of the slaves in the online slave library.
[0106] The second unicast frame is used to set the slave to adopt a target protocol.
[0107] It is understandable that after the host determines the target protocol according to the communication protocol version supported by all slaves in the online slave library, in order to ensure that all slaves can use the target protocol to communicate with the host, it is necessary to uniformly set the communication protocol used by the slaves in the online slave library. This is done because the target protocol is the lowest version of the communication protocol version supported by all slaves. Based on the principle of downward compatibility of the communication protocol, the communication protocol version used by all slaves can be set to the target protocol to ensure that the slave can communicate normally with the host.
[0108] S202, the host determines whether a setting response to the second unicast frame from the first slave in the online slave library is received; if so, execute step S205; if not, execute step S203.
[0109] Among them, since the host sends the second unicast frame to each slave in the online slave library in turn, the first slave can be any slave in the online slave library that the host polls according to the address of the online slave in the online slave library.
[0110] When the host receives a setting response to the second unicast frame sent by the first slave within the preset time, it indicates that the communication protocol of the first slave is set successfully, and it is also determined that the first slave is indeed online. At this time, the host needs to determine whether the communication protocols of all slaves in the online slave library have been set. If there are still slaves that have not been set in the online slave library, the host continues to send the second unicast frame to the next slave in the online slave library based on the address of the first slave to set the communication protocol of the next slave, until the communication protocols of all slaves in the online slave library are set to the target protocol.
[0111] When the host does not receive a setting response to the second unicast frame sent by the first slave within a preset time period, it indicates that the communication protocol setting of the first slave has failed, and it also indicates that the first slave may have been offline. When it is determined that the number of times the second unicast frame is sent does not exceed the preset number, the second unicast frame can be resent to set the communication protocol of the first slave again.
[0112] S203, the host determines whether the number of times the second unicast frame is sent to the first slave reaches the first number; if so, execute step S204; if not, execute step S201.
[0113] Among them, the first number is the preset maximum number of times the host sends the second unicast frame to the first slave. The first number can be a natural number greater than or equal to 2, for example, 3. By setting the first number, the host can avoid frequent retries and occupying communication resources.
[0114] When the host determines that the number of times the second unicast frame has been sent to the first slave has reached the first number, the host will delete the first slave from the online slave library. This is because in the communication system, the slave is set to respond to the unicast frame after receiving the unicast frame, and feed back the response information corresponding to the unicast frame to the host. Therefore, after the host sends the first number of second unicast frames to the first slave, if the host has not received the set response sent by the first slave, it can be determined that the first slave is no longer online.
[0115] S204: The host deletes the first slave from the online slave hangar.
[0116] The purpose of doing this is to be able to reconfirm the online status of each slave in the online slave library by setting the target protocol for each online slave after the online slave library is established, so as to achieve re-update of the newly established online slave library and improve the stability of the communication system.
[0117] It can be understood that when the host sends the second unicast frame to the slaves in the online slave library for the first time, it polls all slaves in the online slave library instead of sending the second unicast frame only to the slaves whose communication protocol is not the target protocol. This is to update the newly established online slave library again through the above steps.
[0118] S205, the host determines whether all slaves in the online slave library have been set up; if so, execute step S206; if not, execute step S201.
[0119] S206. Setting is completed.
[0120] The communication control method provided in this embodiment sends a second unicast frame to the slaves in the online slave library respectively through the host, and the second unicast frame is used to set the slave to adopt a target protocol. If a setting response to the second unicast frame from the first slave in the online slave library is not received, the second unicast frame is sent to the first slave again. If the setting response from the first slave is still not received after the number of times the second unicast frame is sent to the first slave reaches the first number, the first slave is deleted from the online slave library. This method realizes that after determining the target protocol used by the host, the communication protocol of all slaves in the online slave library is set to the target protocol, so as to ensure that the host can communicate normally with all slaves in the online slave library, thereby improving the compatibility of the communication system.
[0121] Figure 4 The process of the communication control method provided in the embodiment of the present application Figure 3 This embodiment is in Figure 2 Based on the embodiment, a method for processing a timeout of receiving a response sent by a slave in an online slave library after the host sends a unicast frame to the slave is described in detail. Figure 4As shown, the communication control method provided in this embodiment includes:
[0122] S301. The host sends a third unicast frame to the second slave in the online slave library.
[0123] The third unicast frame refers to a functional data frame used to query the slave state or control the slave to perform corresponding operations. The second slave may be any slave in the online slave library.
[0124] S302, the host enters a waiting state.
[0125] After sending the third unicast frame, the host enters the waiting state and starts the waiting timer. This is because the host needs to wait for the response of the second slave. In addition, in a master-slave communication system, only one device can send data at the same time. The host enters the waiting state to avoid conflicts with subsequent sending commands from other slaves or the host itself.
[0126] S303, the host determines whether a response from the second slave is received; if so, execute step S304; if not, execute step S305.
[0127] The response of the second slave includes the address of the second slave and other data. Therefore, if the host successfully receives the address information corresponding to the second slave during the waiting process, the host stops waiting timing, enters the receiving state and starts processing the received data.
[0128] On the contrary, if the host fails to identify the address corresponding to the second slave during the waiting process, the host needs to determine whether the duration of entering the waiting state exceeds the first duration, which refers to the host's waiting timing threshold, that is, the preset response timeout duration. The purpose of setting the first duration is to ensure that the second slave has enough time to process the third unicast frame and send a response to the host.
[0129] S304: The host enters a receiving state and processes the received data.
[0130] When the host enters the receive state and starts processing received data, the host also starts the receive timing.
[0131] S305, the host determines whether the duration of entering the waiting state exceeds the first duration; if so, execute step S307; if not, execute step S302.
[0132] The host needs to determine whether the duration of the waiting state exceeds the preset first time length, that is, the response timeout time. If it exceeds the first time length, the host will consider that the second slave has no response and enter the idle state; if it does not exceed the first time length, the host will continue to wait for the response of the second slave.
[0133] S306. The host determines whether the processing of the received data is completed; if so, execute step S307; if not, execute step S308.
[0134] If the host determines that the received data has been processed, it will return to the idle state again; if the host encounters an error during the receiving process or does not receive any data, it will further determine whether the host enters the receiving state for more than the second time period, which refers to the host's receiving timing threshold, that is, the preset receiving timeout period. The purpose of setting the second time period is to ensure that the response data sent by the second slave can be completely received by the host.
[0135] S307: The host enters an idle state.
[0136] S308, the host determines whether the duration of entering the receiving state exceeds the second duration; if so, execute step S307; if not, execute step S304.
[0137] If the host determines that the time it has been in the receiving state has exceeded the second time period during the process of receiving the response of the second slave to the third unicast frame, the host considers that the reception has timed out and returns to the idle state.
[0138] If the host determines that the time it has taken to enter the receiving state does not exceed the second time period during the process of receiving the response of the second slave to the third unicast frame, the host considers that the reception has not timed out and can continue to process the received data.
[0139] S309, the host determines whether any response from the second slave is received within the third continuous time period; if so, re-execute step S309; if not, execute step S310.
[0140] When the host re-enters the idle state, the host may determine whether any response from the second slave is received within a third continuous time period, such as receiving address information of the second slave or receiving response data sent by the second slave.
[0141] The third time length refers to the total response time length threshold of any slave in the online slave library preset by the host. The purpose of setting the third time length is that when the second slave in the online slave library fails to correctly respond to the host for multiple times within the accumulated response time length during the waiting process and / or the receiving process, and the accumulated response time length exceeds the third time length, the host can determine that the second slave is offline and delete the second slave from the online slave library.
[0142] S310: The host deletes the second slave from the online slave library.
[0143] In one possible implementation, if the number of slaves in the online slave library is zero, the first unicast frame is sent to multiple slaves respectively again, and the unresponsive slaves are determined and the first unicast frame is sent to the unresponsive slaves again to redetermine the online slave library based on the received query response.
[0144] When the number of slaves in the online slave library is zero, the host needs to re-establish the online slave library through polling to ensure that the host can rediscover and manage all slaves connected to the communication system. The polling process of re-establishing the online slave library is the same as above. Figure 2 Steps S101 to S104 described in the embodiment are similar and will not be described in detail here.
[0145] In another possible implementation, if the number of slaves in the online slave library is greater than zero and less than a first preset number, after each second preset number of rounds of polling, the first unicast frame is sent again to other slaves outside the online slave library to redetermine the online slave library based on the received query response.
[0146] The first preset number may be the number of all slaves in the communication system that can communicate with the host through the bus. When the number of online slaves in the library is less than the first preset number, the host may execute the above-mentioned operation again after completing the second preset number of rounds of polling. Figure 2 The specific process of step S103 and step S104 described in the embodiment will not be repeated here.
[0147] In this way, as offline slaves are deleted and new slaves are added to the online slave library, the host can dynamically adjust the version of the communication protocol to adapt to the communication requirements of each slave in the new online slave library, thereby improving the compatibility of the communication system.
[0148] The communication control method provided in this embodiment sets preset timeout periods such as a first period, a second period, and a third period, and determines whether the duration of each process in which the host receives the response of the second slave exceeds the corresponding preset timeout period, thereby ensuring that the host can completely receive and process the data sent by the second slave, and can avoid the host from waiting indefinitely for the response of the second slave, so that the host can retry as soon as possible, thereby improving the communication efficiency of the communication system, and the host can also promptly discover the offline slave and delete it from the online slave library, so as to ensure the stability of communication between the host and the slaves in the online slave library.
[0149] Figure 5 This is the process of the communication control method provided by this application Figure 4 , this embodiment is in Figure 2Based on the embodiment, a communication control method is described in detail when the host has a control demand for a slave in the online slave library within a polling cycle. Figure 4 As shown, the communication control method provided in this embodiment includes:
[0150] S401. The host sends polling requests to slaves in the online slave library in sequence according to a preset polling interval.
[0151] The host pre-sets a polling interval to control the frequency of polling. The host obtains the online slave library from the memory, which contains the addresses and related information of all online slaves. The host sends a polling request to each slave in turn according to the address of each slave in the order in the slave library.
[0152] S402, after sending a polling request to the third slave in the online slave library and receiving a polling response from the third slave, the host determines whether the third slave needs to be controlled; if so, execute step S403; if not, execute step S401.
[0153] When the host polls the third slave in the online slave library, after receiving the polling response of the third slave, the host determines whether the third slave needs to be controlled. If the third slave needs to be controlled, the host records the address of the third slave so as to send a control frame to the third slave; if the third slave does not need to be controlled, the host continues to poll other slaves in the online slave library, that is, the next slave of the third slave.
[0154] For example, the host is polling four slaves: smart lights, smart sockets, air conditioners, and smart curtains. The polling interval is set to 5 seconds. After the host starts the polling query process, it sends polling requests to the smart lights, smart sockets, air conditioners, and smart curtains in the order of the online slave library. During the polling process, the user triggers a control command through the user interface of the smart home system, such as "turn on the air conditioner". After receiving the user's control command, the host pauses the current polling process and constructs a control frame containing the address of the air conditioner and the control command (such as turning on the air conditioner). The host sends the control frame to the air conditioner.
[0155] S403: The host records the address of the third slave.
[0156] S404: The host sends a control frame to the third slave.
[0157] Among them, the control frame is used by the host to send control instructions to the third slave. The control frame includes: the address of the third slave, the function code and the actual data operation to be performed, such as setting values, control parameters, etc. The function code is used to indicate the specific operation type performed by the third slave.
[0158] Through this step, the host can respond to the user's control requirements in real time during the polling query process, and realize real-time control of the third slave.
[0159] S405, the host determines whether a control response from the third slave is received; if so, execute step S401; if not, execute step S406.
[0160] After sending the control frame to the third slave, the host enters a waiting state, waiting for the control response of the third slave. At this time, if the third slave receives the control frame and parses the control frame, after completing the corresponding operation, it generates a control response and sends it to the host. The host determines whether the control response of the third slave is received. After receiving the control response of the third slave and completing the parsing process, the host continues to poll the next slave in the online slave library to continue the paused polling cycle.
[0161] If the host does not receive a control response from the third slave within a preset time period or receives a control response but the control response contains an exception code, causing the host to fail to parse the control response, the host determines whether the number of control frames sent to the third slave has reached a second number, and if it has not reached the second number, the host re-sends a control frame to the third slave, where the second number is the preset maximum number of times the host sends control frames to the third slave, for example, it can be 3.
[0162] S406, determining whether the number of times of sending control frames to the third slave reaches the second number; if so, executing step S401; if not, executing step S404.
[0163] Among them, if the third slave fails to respond to the control frame correctly, the host will repeatedly send the control frame to the third slave and wait for a response. However, when the number of transmissions reaches the second number and the third slave fails to respond to the host correctly, it means that the control has failed, and the host continues to query from the address of the third slave when it was paused.
[0164] The communication control method provided in the present embodiment sends polling requests to the slaves in the online slave library in sequence according to a preset polling interval. After sending a polling request to the third slave in the online slave library and receiving a polling response from the third slave, if it is determined that the third slave needs to be controlled, the address of the third slave is recorded and a control frame is sent to the third slave. If the control response of the third slave is not received, the control frame is sent to the third slave again, and this step is repeated until the control response of the third slave is received, or until the number of control frames sent to the third slave reaches the second number, then the polling request is continued to be sent to the next slave of the third slave. The method realizes that when the host polls the online slave library, if there is a control demand, the current polling process can be interrupted, and the control frame can be sent to the slave before continuing the polling, thereby improving the control efficiency of the communication system so that the slave can respond quickly to the control demand.
[0165] Figure 6 The communication control method provided in the present application is as follows: Figure 5 The execution subject of this embodiment may be, for example, Figure 1 Any slave in the communication system. Figure 6 As shown, the communication control method provided in this embodiment includes:
[0166] S501: The slave receives a first unicast frame sent by the host.
[0167] After the slave is powered on, it enters a waiting-to-receive state until the slave receives a first unicast frame. The first unicast frame is used to query whether the slave is online, and the first unicast frame includes the address of the slave.
[0168] S502, the slave determines whether the address of the first unicast frame is the address of the slave; if so, execute step S503; if not, execute step S501.
[0169] The slave first determines whether the address is the address of the local machine based on the slave address in the first unicast frame, and when it is determined that the slave address in the first unicast frame is the address of the local machine, it parses the first unicast frame. When it is determined that the slave address in the first unicast frame is not the address of the local machine, it ignores the first unicast frame and returns to the waiting state to receive the next unicast frame sent by the host.
[0170] This is because the slave needs to confirm that the first unicast frame received is for itself so that the slave can correctly process subsequent data and instructions. If the first unicast frame received by the slave is not for itself, then it should not process the first unicast frame to avoid wasting resources and time. Therefore, by judging the address of the first unicast frame, the slave can avoid unnecessary data processing, thereby improving the efficiency of the entire communication system.
[0171] For example, slave A receives a first unicast frame whose address field is 1 and the address of slave A is 2. Slave A first checks the address field in the unicast frame and finds that the address 1 of the unicast frame does not match its own address 2. Slave A ignores the first unicast frame and does not process it further.
[0172] S503: The slave device parses the first unicast frame.
[0173] Among them, the slave needs to parse the first unicast frame to determine the command or request sent by the host in order to execute the response action. Specifically, the slave can extract necessary data from the first unicast frame, such as function code, data field, etc., by parsing the first unicast frame. The slave confirms that this is a status query command based on the function code in the first unicast frame, and the slave can generate a response frame to indicate that it is online so as to feedback to the host.
[0174] It can be understood that if a parsing exception occurs during the parsing of the first unicast frame by the slave machine, the slave machine determines the exception code corresponding to the current parsing exception according to the preset exception code judgment rule, and generates a response frame based on the exception code. The response frame is used to indicate the abnormal situation and then feedback to the host.
[0175] Optionally, the slave can also receive a broadcast frame sent by the host. Since the nature of the broadcast frame is directed to all slaves, after receiving the broadcast frame, the slave first determines whether the broadcast frame includes the address of the host. If so, the broadcast frame is parsed. When the parsing is completed and the data is correct, the slave will execute the instructions or operations indicated in the broadcast frame, but the slave will not send a response to the host during this process.
[0176] S504: The slave sends a query response to the first unicast frame to the master.
[0177] Among them, after the slave completes parsing of the first unicast frame, the slave will enter an idle state, and when the duration in the idle state is greater than a preset duration, the slave will send a query response to the first unicast frame to the host. The data frame of the query response includes a status code indicating that the slave is online and a communication protocol supported by the slave. This query response is used to determine that the slave is online, and to determine the target protocol for communication between the host and the slave.
[0178] It is understandable that after the slave completes processing the first unicast frame and enters the idle state, it needs to wait for a preset time before sending the first unicast frame to the host in order to ensure that the slave has enough time to generate a query response to the first unicast frame.
[0179] In a possible implementation, the slave may also receive a second unicast frame sent by the host, wherein the second unicast frame is used to set the slave to adopt the target protocol and send a setting response to the second unicast frame to the host. The specific setting process of the target protocol can be referred to above. Figure 3 The various steps described in the embodiments will not be repeated here.
[0180] The communication control method provided in the present embodiment receives the first unicast frame sent by the host by the slave. If the address of the first unicast frame is the address of the slave, the first unicast frame is parsed, and a query response for the first unicast frame is sent to the host. The query response includes the communication protocol supported by the slave. The query response is used to determine whether the slave is online and to determine the target protocol for communication between the host and the slave. The method realizes that the slave receives the first unicast frame sent by the host for querying the slave status, and generates a query response including the slave online code and the communication protocol information supported by the slave after the parsing is completed, and feeds it back to the host, so that the host can determine that the slave is online according to the query response, add the online slave to the online slave library and determine the target protocol for communication with the slave, so as to avoid the host from polling the offline slave again in subsequent polling, thereby improving the communication efficiency and the compatibility of the communication protocol.
[0181] Figure 7 The structure of the communication control device provided in this application is shown as follows: Figure 1 , used in the host in the communication system. Figure 7 As shown, the present application provides a communication control device, and the control device 600 of the thermostat device includes:
[0182] The transceiver module 601 is used to send a first unicast frame to each of the multiple slaves, where the first unicast frame is used to query whether the slave is online. When no query response to the first unicast frame is received from any slave, this step is repeated until a query response from some slaves is received, where the query response includes a communication protocol supported by the slave.
[0183] The processing module 602 is used to determine the slave that did not respond;
[0184] The transceiver module 601 is further configured to resend the first unicast frame to the non-responding slave;
[0185] The processing module 602 is also used to add all slaves corresponding to the received query responses to the online slave library, and determine the target protocol for the host to communicate with the slaves in the online slave library based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host.
[0186] In a possible implementation, the transceiver module 601 is further used to send a second unicast frame to each slave in the online slave library, where the second unicast frame is used to set the slave to adopt the target protocol;
[0187] The transceiver module 601 is further configured to send the second unicast frame to the first slave again when a setting response to the second unicast frame from the first slave in the online slave library is not received;
[0188] The processing module 602 is further configured to delete the first slave from the online slave library if no set response from the first slave is received after the number of times the second unicast frame is sent to the first slave reaches a first number.
[0189] In a possible implementation, the transceiver module 601 is further configured to send a third unicast frame to the second slave in the online slave library and enter a waiting state;
[0190] The processing module 602 is configured to cause the host to enter an idle state when the host does not receive a response from the second slave and the duration of entering the waiting state exceeds a first duration;
[0191] The processing module 602 is configured to, when the host receives a response from the second slave, cause the host to enter a receiving state and process the received data, and when the processing of the received data is completed, or when an error occurs in processing the received data and the duration of entering the receiving state exceeds a second duration, cause the host to enter an idle state;
[0192] The processing module 602 is further configured to delete the second slave from the online slave library when the host does not receive any response from the second slave within a third continuous time period.
[0193] In a possible implementation, the transceiver module 601 is further configured to sequentially send polling requests to the slaves in the online slave library according to a preset polling interval;
[0194] The processing module 602 is further configured to, after sending a polling request to a third slave in the online slave library and receiving a polling response from the third slave, record the address of the third slave if it is determined that the third slave needs to be controlled;
[0195] The transceiver module 601 is further configured to send a control frame to the third slave;
[0196] The transceiver module 601 is also used to send the control frame to the third slave again when the control response of the third slave is not received, and repeat this step until the control response of the third slave is received, or until the number of times the control frame is sent to the third slave reaches a second number, and then continue to send a polling request to the next slave of the third slave.
[0197] In a possible implementation, the transceiver module 601 is also used to, when the number of slaves in the online slave library is zero, again execute the sending of the first unicast frame to the multiple slaves respectively, and to determine the unresponsive slaves and again send the first unicast frame to the unresponsive slaves. The processing module 602 is also used to redetermine the online slave library based on the received query response.
[0198] Figure 8 The structure of the communication control device provided in this application is shown as follows: Figure 2 , used in slave devices in communication systems. Figure 8 As shown, the present application provides a communication control device, and the control device 700 of the thermostat device includes:
[0199] The transceiver module 701 is used to receive a first unicast frame sent by the host, where the first unicast frame is used to query whether the slave is online;
[0200] The processing module 702 is used to parse the first unicast frame when the address of the first unicast frame is the address of the slave;
[0201] The transceiver module 701 is also used to send a query response to the first unicast frame to the host, the query response includes the communication protocol supported by the slave, and the query response is used to determine whether the slave is online, and to determine the target protocol for communication between the host and the slave.
[0202] In a possible implementation, the transceiver module 701 is further used to receive a second unicast frame sent by the host, where the second unicast frame is used to set the slave to adopt the target protocol;
[0203] The transceiver module 701 is further configured to send a setting response to the second unicast frame to the host.
[0204] Fig. 9 This is a schematic diagram of the structure of the electronic device provided in this application. Fig. 9 As shown, the present application provides an electronic device, the electronic device 800 includes: a receiver 801, a transmitter 802, a processor 803 and a memory 804.
[0205] Receiver 801, used for receiving instructions and data;
[0206] A transmitter 802, used for sending instructions and data;
[0207] Memory 804, used to store computer-executable instructions;
[0208] The processor 803 is used to execute the computer-executable instructions stored in the memory 804 to implement the various steps performed by the communication control method in the above embodiment. For details, please refer to the relevant description in the above communication control method embodiment.
[0209] Optionally, the memory 804 may be independent or integrated with the processor 803 .
[0210] When the memory 804 is independently provided, the electronic device further includes a bus for connecting the memory 804 and the processor 803 .
[0211] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, a communication control method executed by the host and the slave in the above-mentioned communication system is implemented.
[0212] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0213] So far, the technical solution of the present application has been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present application is obviously not limited to these specific embodiments, and the above embodiments are only used to illustrate the technical solution of the present application rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A communication control method, characterized in that: A host computer used in a communication system, wherein the communication system includes the host computer and a plurality of slave computers, and the method includes: Sending a first unicast frame to each of the plurality of slaves, wherein the first unicast frame is used to query whether the slave is online, and if no query response to the first unicast frame is received from any slave, repeating this step until a query response from some slaves is received, wherein the query response includes a communication protocol supported by the slave; Determine the unresponsive slave and resend the first unicast frame to the unresponsive slave; All slaves corresponding to the received query responses are added to the online slave library, and based on the communication protocols supported by the slaves in the online slave library and the communication protocols supported by the host, a target protocol for the host to communicate with the slaves in the online slave library is determined.
2. The method according to claim 1, characterized in that Also includes: Sending a second unicast frame to each slave in the online slave library, wherein the second unicast frame is used to set the slave to adopt the target protocol; If a setting response to the second unicast frame is not received from the first slave in the online slave library, the second unicast frame is sent to the first slave again. If a setting response from the first slave is still not received after the second unicast frame is sent to the first slave for the first number of times, the first slave is deleted from the online slave library.
3. The method according to claim 1, characterized in that Also includes: Sending a third unicast frame to the second slave in the online slave library and entering a waiting state; If the host does not receive a response from the second slave and the duration of entering the waiting state exceeds a first duration, the host enters an idle state; If the host receives a response from the second slave, the host enters a receiving state and processes the received data, and if the processing of the received data is completed, or if an error occurs in processing the received data and the duration of entering the receiving state exceeds a second duration, the host enters an idle state; If the host does not receive any response from the second slave within a third continuous time period, the second slave is deleted from the online slave library.
4. The method according to any one of claims 1 to 3, characterized in that Also includes: Sending polling requests to the slaves in the online slave library in sequence according to a preset polling interval; After sending a polling request to a third slave in the online slave library and receiving a polling response from the third slave, if it is determined that the third slave needs to be controlled, recording the address of the third slave and sending a control frame to the third slave; If the control response of the third slave is not received, the control frame is sent to the third slave again, and this step is repeated until the control response of the third slave is received, or until the number of times the control frame is sent to the third slave reaches the second number, then the polling request is continued to be sent to the next slave of the third slave.
5. The method according to any one of claims 2 to 3, characterized in that: Also includes: If the number of slaves in the online slave library is zero, the step of sending the first unicast frame to the multiple slaves is performed again, and the unresponsive slaves are determined, and the first unicast frame is sent to the unresponsive slaves again to redetermine the online slave library based on the received query response.
6. The method according to any one of claims 2 to 3, characterized in that: Also includes: If the number of slaves in the online slave library is greater than zero and less than a first preset number, then after each second preset number of rounds of polling, the first unicast frame is sent again to other slaves outside the online slave library to redetermine the online slave library based on the received query response.
7. A communication control method, characterized in that: The method is applied to a slave in a communication system, wherein the communication system includes a master and a plurality of slaves, and comprises: receiving a first unicast frame sent by the host, where the first unicast frame is used to query whether the slave is online; If the address of the first unicast frame is the address of the slave, the first unicast frame is parsed and a query response for the first unicast frame is sent to the host, the query response including the communication protocol supported by the slave, the query response being used to determine whether the slave is online, and for determining a target protocol for communication between the host and the slave.
8. The method according to claim 7, characterized in that Also includes: receiving a second unicast frame sent by the host, where the second unicast frame is used to set the slave to adopt the target protocol; A setup response to the second unicast frame is sent to the host.
9. An electronic device, characterized in that: include: Memory; processor; Wherein, the memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the communication control method according to any one of claims 1 to 6 or any one of claims 7 to 8.
10. A computer storage medium, characterized in that: The computer storage medium stores computer execution instructions, which are used to implement the communication control method according to any one of claims 1 to 6 or any one of claims 7 to 8 when executed by a processor.
Citation Information
Patent Citations
Device for dynamically allocating slave addresses in pair of multistandard serial communications and use method
CN101834912A
Self-healing networking method for half-duplex asynchronous communication
CN102684923A
2.4G-based networking communication system and communication method
CN105578383A
Verification method of software communication protocol
CN110995686A
Low-load communication method based on RS485 bus
CN112565038A