[go: up one dir, main page]

CN119299509A - Communication control method, device and storage medium - Google Patents

Communication control method, device and storage medium Download PDF

Info

Publication number
CN119299509A
CN119299509A CN202411197786.0A CN202411197786A CN119299509A CN 119299509 A CN119299509 A CN 119299509A CN 202411197786 A CN202411197786 A CN 202411197786A CN 119299509 A CN119299509 A CN 119299509A
Authority
CN
China
Prior art keywords
slave
slaves
host
online
library
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411197786.0A
Other languages
Chinese (zh)
Inventor
蒯宇航
隋艺亮
管江勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Economic And Technology Development District Haier Water Heater Co ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Economic And Technology Development District Haier Water Heater Co ltd
Haier Smart Home Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Economic And Technology Development District Haier Water Heater Co ltd, Haier Smart Home Co Ltd filed Critical Qingdao Economic And Technology Development District Haier Water Heater Co ltd
Priority to CN202411197786.0A priority Critical patent/CN119299509A/en
Publication of CN119299509A publication Critical patent/CN119299509A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/1396Protocols specially adapted for monitoring users' activity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

本申请属于通信技术领域,具体涉及一种通信控制方法、设备及存储介质。该方法包括:主机向多个从机分别发送第一单播帧,第一单播帧用于查询从机是否在线,若未接收到任一从机针对第一单播帧的查询响应,则重复向多个从机发送第一单播帧,直至接收到部分从机的查询响应,主机确定未响应的从机,并向未响应的从机再次发送第一单播帧,将接收到的查询响应对应的所有从机加入在线从机库,并基于在线从机库中的从机支持的通信协议和主机支持的通信协议,确定主机与在线从机库中的从机进行通信的目标协议;该方法通过建立在线从机库,提高通信系统的通信效率,且主机可以根据在线从机库中的从机支持的通信协议选择目标协议,提高了通信系统的兼容性。

The present application belongs to the field of communication technology, and specifically relates to a communication control method, device and storage medium. The method includes: the host sends a first unicast frame to multiple slaves respectively, 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 multiple slaves until the query response of some slaves is received, the host determines the unresponsive slaves, 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 protocol supported by the slaves in the online slave library and the communication protocol 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 protocol supported by the slaves in the online slave library, thereby improving the compatibility of the communication system.

Description

Communication control method, device and storage medium
Technical Field
The application belongs to the technical field of communication, and particularly relates to a communication control method, a device and a storage medium.
Background
Communication systems based on a master-slave architecture are taken as important modes for communication between intelligent home appliances and internal modules and between intelligent home appliances and external devices, and are used for carrying out key tasks of data transmission and instruction exchange. Taking an RS-485 bus based communication system as an example, a host controls communication with a plurality of slaves, wherein a microcontroller unit (Microcontroller Unit, MCU) of the host may be connected to an RS-485 converter via its internal asynchronous transceiver (Universal Asynchronous Receiver/Transmitter, UART) interface, in turn communicating with other slaves on the RS-485 bus. However, as the functions of the intelligent home appliances are continuously increased and the level of intelligence is continuously improved, the number of the intelligent home appliances is difficult to meet the communication requirements between all the internal modules or the external devices of the intelligent home appliances only by virtue of UART interfaces of the MCU.
In order to alleviate the problem of insufficient UART interface resources, the prior art proposes a multiplexing communication control method, in which a host communicates with each slave one by one in a polling manner based on an address by allocating a unique address to each device, and a timer is used to manage the communication time between the host and each slave, so that a single serial interface can be switched between a plurality of devices, thereby realizing multi-device communication.
However, in the conventional communication control method, during the polling of the master, the slave which is disconnected due to the disconnection or communication error cannot be skipped, so that the communication efficiency of the communication system is reduced, and the communication protocols of both the master and the slave need to be predefined before the polling, so that the compatibility of the communication system is poor.
Disclosure of Invention
The application provides a communication control method, equipment and a storage medium, which are used for solving the problems of lower communication efficiency and poor compatibility of the existing communication control method.
In a first aspect, the present application provides a communication control method applied to a host in a communication system, the communication system including the host and a plurality of slaves, the method including:
Respectively sending a first unicast frame to the plurality of slaves, wherein the first unicast frame is used for inquiring whether the slaves are online, and if the inquiry response of any slave to the first unicast frame is not received, repeating the step until the inquiry response of part of the slaves is received, wherein the inquiry response comprises a communication protocol supported by the slaves;
determining an unresponsive slave and retransmitting the first unicast frame to the unresponsive slave;
And adding all the slaves corresponding to the received inquiry response into an online slave library, and determining a target protocol for the communication between the master and the slaves in the online slave library based on the communication protocol supported by the slaves in the online slave library and the communication protocol supported by the master.
In one possible implementation, the method further includes:
respectively sending second unicast frames to the slaves in the online slave library, wherein the second unicast frames are used for setting the slaves to adopt the target protocol;
And if the setting response of the first slave in the online slave library is not received, the second unicast frame is sent to the first slave again, and if the setting response of the first slave is not received after the number of times of sending the second unicast frame to the first slave reaches the first number, the first slave is deleted from the online slave library.
In one possible implementation, the method further includes:
transmitting a third unicast frame to a second slave in the online slave library, and entering a waiting state;
If the host does not receive the response of the second slave and the waiting time exceeds the first time, the host enters an idle state;
If the host receives the response of the second slave, the host enters a receiving state and processes the received data, if the processing of the received data is completed, or if the processing of the received data is wrong and the time for entering the receiving state exceeds a second time, the host enters an idle state;
and if the host does not receive any response of the second slave machine in a continuous third time period, deleting the second slave machine from the online slave machine library.
In one possible implementation, the method further includes:
sequentially sending polling requests to the slaves in the online slave library according to preset polling intervals;
after a polling request is sent to a third slave in the online slave library and a polling response of the third slave is received, if the third slave is judged to need to be controlled, the address of the third slave is recorded, and a control frame is sent to the third slave;
And if the control response of the third slave machine is not received, the control frame is sent to the third slave machine again, the step is repeatedly executed until the control response of the third slave machine is received, or until the number of times of sending the control frame to the third slave machine reaches the second number of times, and the polling request is continuously sent to the next slave machine of the third slave machine.
In one possible implementation, the method further includes:
and if the number of the slaves in the online slave machine library is zero, the step of respectively sending the first unicast frames to the slaves is executed again, the slaves which are not responded are determined, and the first unicast frames are sent to the slaves which are not responded again, so that the online slave machine library is determined again based on the received inquiry response.
In one possible implementation, the method further includes:
And if the number of the slaves in the online slave machine library is greater than zero and smaller than the first preset number, after polling of a second preset number of rounds is carried out, the first unicast frame is sent to other slaves outside the online slave machine library again, so that the online slave machine library is redetermined based on the received query response.
In a second aspect, the present application provides a communication control method applied to a slave in a communication system including a master and a plurality of slaves, the method comprising:
receiving a first unicast frame sent by the host, wherein the first unicast frame is used for inquiring whether the slave is online;
If the address of the first unicast frame is the address of the slave, the first unicast frame is analyzed, and a query response aiming at the first unicast frame is sent to the host, wherein the query response comprises a communication protocol supported by the slave, the query response is used for determining that the slave is online, and a target protocol used for communicating between the host and the slave is determined.
In one possible implementation manner, the method further comprises receiving a second unicast frame sent by the host, wherein the second unicast frame is used for setting the slave to adopt the target protocol;
and sending a setting response for the second unicast frame to the host.
In a third aspect, the present application provides a communication control apparatus for use with a host in a communication system, the apparatus comprising:
The receiving and transmitting module is used for respectively transmitting a first unicast frame to the plurality of slaves, the first unicast frame is used for inquiring whether the slaves are online, and when no inquiry response of any slave to the first unicast frame is received, the steps are repeatedly executed until inquiry responses of part of the slaves are received, and the inquiry responses comprise communication protocols supported by the slaves;
the processing module is used for determining an unresponsive slave;
The transceiver module is further configured to retransmit the first unicast frame to the non-responding slave;
The processing module is further configured to add all the slaves corresponding to the received query response to an online slave library, and determine a target protocol for the communication between the master and the slaves in the online slave library based on a communication protocol supported by the slaves in the online slave library and a communication protocol supported by the master.
In a possible implementation manner, the transceiver module is further configured to send a second unicast frame to the slaves in the online slave library, where the second unicast frame is used to set the slaves to adopt the target protocol;
the transceiver module is further configured to send the second unicast frame to the first slave again when a setting response of the first slave in the online slave library to the second unicast frame is not received;
And the processing module is further used for deleting the first slave from the online slave library after the number of times of sending the second unicast frame to the first slave reaches the first number and the setting response of the first slave is not received yet.
In one possible implementation manner, the transceiver module is further configured to send a third unicast frame to a second slave in the online slave library, and enter a waiting state;
The processing module is configured to enter an idle state when the host does not receive the response of the second slave and the duration of entering the waiting state exceeds a first duration;
the processing module is configured to, when the host receives the response of the second slave, enter a receiving state and process the received data, and when processing the received data is completed or when processing the received data is wrong and the duration of entering the receiving state exceeds a second duration, enter an idle state;
The processing module is further configured to delete the second slave from the online slave library when the master does not receive any response from the second slave within a continuous third duration.
In one possible implementation manner, the transceiver module is further configured to sequentially send a polling request to the slaves in the online slave library according to a preset polling interval;
the processing module is further used for recording the address of a third slave machine when judging that the third slave machine needs to be controlled after sending a polling request to the third slave machine in the online slave machine library and receiving a polling response of the third slave machine;
the transceiver module is further configured to send a control frame to the third slave;
And the transceiver module is further configured to, when the control response of the third slave is not received, send the control frame to the third slave again, and repeatedly perform this step until the control response of the third slave is received, or until the number of times of sending the control frame to the third slave reaches the second number of times, continue sending a polling request to the next slave of the third slave.
In a possible implementation manner, the transceiver module is further configured to re-execute the sending of the first unicast frame to the plurality of slaves when the number of slaves in the online slave pool is zero, and determine an unresponsive slave and re-send the first unicast frame to the unresponsive slave, and the processing module is further configured to re-determine the online slave pool based on the received query response.
In a fourth aspect, the present application provides a communication control apparatus for use in a slave in a communication system, the apparatus comprising:
The receiving and transmitting module is used for receiving a first unicast frame sent by the host, and the first unicast frame is used for inquiring whether the slave is online or not;
the processing module is used for analyzing the first unicast frame when the address of the first unicast frame is the address of the slave;
the transceiver module is further configured to send a query response to the host for the first unicast frame, where the query response includes a communication protocol supported by the slave, and the query response is used to determine that the slave is online, and is used to determine a target protocol for the host and the slave to communicate.
In a possible implementation manner, the transceiver module is further configured to receive a second unicast frame sent by the host, where the second unicast frame is used to set the slave to use the target protocol;
The transceiver module is further configured to send a setting response for the second unicast frame to the host.
In a fifth aspect, the present application provides an electronic device, comprising:
A memory;
A processor;
Wherein the memory stores computer-executable instructions;
The processor executes computer-executable instructions stored by the memory to implement the communication control method as described above in the first aspect and the various possible implementations of the first aspect or in the second aspect and the various possible implementations of the second aspect.
In a sixth aspect, the present application provides a computer storage medium having stored thereon computer-executable instructions that are executed by a processor to implement the communication control method as described above in the first aspect and the various possible implementations of the first aspect or the various possible implementations of the second aspect and the second aspect.
The method comprises the steps that a first unicast frame is sent to a plurality of slaves through a host, the first unicast frame is used for inquiring whether the slaves are online or not, if the inquiry response of any slave to the first unicast frame is not received, the first unicast frame is repeatedly sent to the slaves until the inquiry response of part of the slaves is received, the host determines the slaves which do not respond, sends the first unicast frame again to the slaves which do not respond, all the slaves corresponding to the received inquiry response are added into an online slave library, and a target protocol for communication between the host and the slaves in the online slave library is determined based on a communication protocol supported by the slaves in the online slave library and a communication protocol supported by the host.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic diagram of a communication system according to the present application;
FIG. 2 is a flow chart of a communication control method provided by the present application;
FIG. 3 is a second flowchart of the communication control method provided by the present application;
fig. 4 is a flowchart III of a communication control method provided by the present application;
fig. 5 is a flowchart of a communication control method provided by the present application;
fig. 6 is a flowchart fifth of the communication control method provided by the present application;
fig. 7 is a schematic structural diagram of a communication control device provided by the present application;
Fig. 8 is a schematic diagram of a second configuration of the communication control device according to the present application;
fig. 9 is a schematic structural diagram of an electronic device provided by the present application.
Specific embodiments of the present application have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the specific embodiments.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein.
In embodiments of the application, words such as "exemplary" or "such as" are used to mean examples, illustrations, or descriptions. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In a communication system based on a master-slave architecture, a network architecture of one master and multiple slaves is generally adopted, and an MCU of a host can be connected with an RS-485 converter through an internal UART interface thereof, so as to communicate with other devices (slaves) on an RS-485 bus. However, as the functions of the intelligent home appliances are continuously increased and the level of intelligence is continuously improved, the number of the intelligent home appliances is difficult to meet the communication requirements between all the internal modules or the external devices of the intelligent home appliances only by virtue of UART interfaces of the MCU.
In order to alleviate the problem of insufficient UART interface resources, the prior art proposes a multiplexing communication control method, in which a host communicates with each slave one by one in a polling manner based on an address by allocating a unique address to each device, and a timer is used to manage the communication time between the host and each slave, so that a single serial interface can be switched between a plurality of devices, thereby realizing multi-device communication.
However, in the conventional communication control method, during the polling of the master, the slave which is disconnected due to the disconnection or communication error cannot be skipped, so that the communication efficiency of the communication system is reduced, and the communication protocols of both the master and the slave need to be predefined before the polling, so that the compatibility of the communication system is poor.
In view of this, the present application provides a communication control method, which increases an online slave inquiry flow before a master poll, establishes an online slave library of the present communication according to an inquiry result returned by the slave, and polls only the slave in the online slave library in a subsequent polling process. In order to manage the online slave machine library in real time, the slaves which do not answer in the online slave machine library for a long time are deleted, meanwhile, the online slave machine inquiry process is carried out again at intervals, and the slaves which are added in the middle of the online process can be skipped over the slaves which are disconnected or have a communication error in the follow-up host machine polling period, so that the communication efficiency of the communication system is improved, after the slave machine library is built, the host machine executes according to the lowest protocol version supported by all the internal machines in the protocol version range supported by the host machine according to the recorded slave machine information, so that the communication protocol running on the bus can be selected in a certain version range, and the compatibility of the communication system is improved.
Fig. 1 is a schematic diagram of a communication system according to the present application. It should be noted that fig. 1 is only an example of an application scenario where the communication control method of the present application may be applied, so as to help those skilled in the art understand the technical content of the present application, but it does not mean that the embodiment of the present application may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the communication system includes a master and a slave 1, a slave 2, and a plurality of slaves n, and the master and the plurality of slaves are connected to a bus, that is, a bus a and a bus B, which are a pair of differential signal lines, and transmit and receive data by transmitting differential signals through the bus a and the bus B, so that communication between the master and the plurality of slaves can be realized. The bus comprising bus A and bus B may be, but is not limited to, any of the RS-485 bus, the RS-449 bus, the RS-432 bus, the RS-423 bus, and the RS-422 bus. The communication system can be applied to scenes such as intelligent home systems, industrial sites, security monitoring and the like.
Taking an RS-485 bus as an example, a master-slave architecture is adopted based on the communication of the RS-485 bus, in fig. 1, a host is responsible for initiating the communication and making a request, and other slaves respond to the request sent by the host and execute corresponding operations. Communication between the master and any slave is mainly performed in a "request-response" mode. For example, the master sends a request to the slave, the request including a function code indicating a specific operation that the slave should perform. After receiving the request, the slave machine executes the corresponding operation and returns the result to the host machine.
Meanwhile, in order to distinguish between different slaves, each slave is typically assigned a unique address, and the host communicates with the corresponding slave through the address. For example, the master address is set to 0x00, and the slave address may be set to slave 1 (0 x 01), slave 2 (address 0x 02), slave n (0 x0 n) in this order from slave 1.
After the communication system is initialized, the host computer enters a bus monitoring mode. If the host continuously monitors that the bus keeps in an idle state within a preset time period, the host automatically switches to the idle state. When the host keeps idle state for more than a preset duration, the host can actively initiate transmission of functional frames such as inquiry or control.
The whole communication system has two communication modes of unicast and broadcast. When the host computer unicasts the slave computer, the host computer accesses the slave computer by a preset slave computer address, and after the slave computer receives and processes the request, the slave computer returns a response to the host computer, and other slave computers do not respond. When the master broadcasts all slaves, the master sends a request to bus a and bus B with an address of 0x00, and all slaves respond, but do not return a reply.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems in detail with specific embodiments. The following embodiments may be implemented independently or combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a communication control method according to an embodiment of the present application, and an execution body of the embodiment may be, for example, a host in the communication system in fig. 1. As shown in fig. 2, the communication control method provided in this embodiment includes:
S101, the master transmits a first unicast frame to each of the plurality of slaves.
The first unicast frame is used for inquiring whether the slave is online, and the first unicast frame can comprise a slave address and an inquiry instruction. And the host sequentially sends the first unicast frame to each slave according to the address and the sequence of each slave preset in the communication system.
For example, an intelligent home system has a host (e.g., a central controller) and a plurality of slaves (e.g., an air conditioner, an intelligent lamp, a water heater, etc.), wherein addresses of the air conditioner, the intelligent lamp, and the water heater are respectively address 1, address 2, address 3, and the host needs to query on-line status of the slaves, first sends a first unicast frame including address 1 to the air conditioner, then sends a first unicast frame including address 2 to the intelligent lamp, then sends a first unicast frame including address 3 to the water heater, and so on until the first unicast frame is sent to an nth slave having address N.
It will be appreciated that the host may also use the address of the host itself to send a broadcast frame to all slaves before sending the first unicast frame to each slave in turn, to inform all slaves of the current state of the host, to ensure that all slaves are ready to receive the subsequent first unicast frame, and that all slaves need not respond to the broadcast frame after receiving the broadcast frame.
S102, the host computer judges whether any slave computer receives the query response to the first broadcast frame, if yes, the step S103 is executed, and if not, the step S101 is executed.
After the host sequentially sends the first unicast frames to all the slaves, the online slaves need to send query responses for the own first unicast frames to the host after the analysis of the first unicast frames is completed.
If the host does not receive the query response of any slave within the preset duration, it is indicated that all the slaves may not be online at present, or there are problems such as communication failure, slave busy with other tasks, etc., so that the slaves are in a temporary non-response state, if only one query is performed, the host may misjudge the state of the slaves, so in order to avoid misjudgment caused by single polling failure, the host needs to repeatedly send a first unicast frame to a plurality of slaves, and poll all the slaves until receiving the query response of part of the slaves.
If the master machine receives a query response of a part of the slaves after polling all the slaves for the first time, the query response comprises the communication protocol supported by the slaves and also comprises the address of the slaves, and the master machine can record the communication protocol of the part of the slaves, the address of the slaves and other information and carry out the next polling.
S103, the host determines an unresponsive slave and sends the first unicast frame to the unresponsive slave again.
The host can determine the addresses of all the responding slaves according to the query response received by the last polling, so that the non-responding slaves can be screened out, and the slaves which are not responded last time are polled again according to the addresses of all the non-responding slaves, namely, the first unicast frame is sent to the non-responding slaves again.
It will be appreciated that the host may also use the address of the host itself to resend a broadcast frame to all slaves before resending the first unicast frame to each of the non-responding slaves to synchronize the state of the host to all slaves.
Alternatively, the host may set a number of retries and retry interval time to ensure that the correct slave state is again obtained even in the event of a first attempt failure. The host can also preset a timeout period to distinguish between the situation that the slave is temporarily unable to respond and the situation that the slave is actually offline. And, the host computer can also record the result of each round of inquiry so as to track the state change of the slave computer.
By polling the slave state for multiple times, the accuracy of the master to inquire the slave on-line state can be remarkably improved, and especially under the condition that the slave is in a non-response state occasionally, the slave has the opportunity to recover to normal in the subsequent inquiry. Transmitting the first broadcast frame multiple times helps to ensure that the host can accurately obtain state information for all slaves, thereby better controlling and managing the overall communication system.
And S104, the host joins all the slaves corresponding to the received inquiry response into the online slave library, and determines a target protocol for the host to communicate with the slaves in the online slave library based on the communication protocol supported by the slaves in the online slave library and the communication protocol supported by the host.
The method comprises the steps that a host collects all slaves which send query responses according to a plurality of slave addresses included in all query responses received through multiple times of polling, a plurality of online slaves are obtained, an online slave library is built based on the query responses of the online slaves, and a target protocol used by the host for communicating with all the slaves is determined based on the version of a communication protocol supported by each slave in the online slave library and the version of the communication protocol supported by the host.
For example, the host determines the lowest protocol version in the communication protocol versions supported by all the slaves according to the communication protocol versions supported by all the slaves in the online slave library, and the host communicates with all the slaves according to the lowest protocol version in the communication protocol version range supported by the host so as to ensure that all the slaves can communicate with the host, thereby improving the compatibility of the communication system.
According to the communication control method, a first unicast frame is sent to a plurality of slaves through a host, the first unicast frame is used for inquiring whether the slaves are online or not, if the inquiry response of any slave for the first unicast frame is not received, the first unicast frame is repeatedly sent to the plurality of slaves until the inquiry response of part of the slaves is received, the inquiry response comprises communication protocols supported by the slaves, the host determines the slaves which do not respond and sends the first unicast frame to the slaves which do not respond again, all the slaves corresponding to the received inquiry response are added into an online slave library, and a target protocol for communication between the host and the slaves in the online slave library is determined based on the communication protocols supported by the slaves in the online slave library.
Fig. 3 is a flowchart of a communication control method according to an embodiment of the present application. The present embodiment is a detailed description of a method for setting a target protocol for each slave in an online slave library after the online slave library is established based on the embodiment of fig. 2. As shown in fig. 3, the communication control method provided in this embodiment includes:
S201, the master sends second unicast frames to the slaves in the online slave library respectively.
The second unicast frame is used for setting the slave to adopt a target protocol.
It will be appreciated that after the host determines the target protocol according to the communication protocol versions supported by all the slaves in the online slave library, in order to ensure that all the slaves can use the target protocol to communicate with the host, a unified setting of the communication protocol used by the slaves in the online slave library is required. This is done because the target protocol is the lowest version protocol among all communication protocol versions supported by the slave, and based on the principle that the communication protocols are downward compatible, the communication protocol version used by all the slave can be set as the target protocol, so that the slave can normally communicate with the host.
S202, the host judges whether a setting response of the first slave in the online slave library to the second unicast frame is received, if yes, the step S205 is executed, and if not, the step S203 is executed.
The first slave can be any slave in the online slave library, which is polled by the master according to the address of the online slave in the online slave library, because the master is a second unicast frame which is sequentially sent to each slave in the online slave library.
When the host receives a setting response sent by the first slave machine for the second unicast frame within a preset time period, the setting of the communication protocol of the first slave machine is successful, and it is also determined that the first slave machine is truly in an online state, at this time, the host needs to judge whether all the communication protocols of the slave machines in the online slave machine library are set completely, if the slave machines which are not set completely remain in the online slave machine library, based on the address of the first slave machine, the second unicast frame is continuously sent to the next slave machine in the online slave machine library, so as to set the communication protocol of the next slave machine until all the communication protocols of the slave machines in the online slave machine library are set to be target protocols.
When the host does not receive the setting response of the second unicast frame sent by the first slave within the preset duration, the failure of setting the communication protocol of the first slave is indicated, and the first slave may not be online, and the second unicast frame may be retransmitted once to set the communication protocol of the first slave again if the number of times of sending the second unicast frame is determined not to exceed the preset number of times.
S203, the host computer judges whether the number of times of sending the second unicast frame to the first slave computer reaches the first number, if so, the step S204 is executed, and if not, the step S201 is executed.
The first number of times is a preset maximum number of times that the host transmits the second unicast frame to the first slave, and the first number of times may be a natural number greater than or equal to 2, for example, 3, so as to avoid that the host frequency retries again and occupies communication resources.
In the case that the host determines that the number of times of transmitting the second unicast frame to the first slave has reached the first number, the host may delete the first slave from the online slave library, because in the communication system, the slave is set to have to respond to the unicast frame after receiving the unicast frame and feeds back response information corresponding to the unicast frame to the host, and therefore, after the host transmits the first number of second unicast frames to the first slave, it may be determined that the first slave has not been in an online state, after having received the set response transmitted by the first slave.
S204, the master deletes the first slave from the online slave library.
The purpose of this is to be able to confirm the online state of each slave in the online slave library again by setting a target protocol for each online slave after the online slave library is established, so as to update the newly established online slave library again and improve the stability of the communication system.
It will be appreciated that when the host first transmits a second unicast frame to a slave in the online slave library, it polls all slaves in the online slave library, rather than transmitting the second unicast frame only to slaves whose communication protocol is not the target protocol, just to update the online slave library once again through the above steps.
S205, the host judges whether all the slaves in the online slave library are set, if yes, the step S206 is executed, and if no, the step S201 is executed.
S206, setting is finished.
According to the communication control method, the second unicast frames are respectively sent to the slaves in the online slave library through the master, the second unicast frames are used for setting the slaves to adopt the target protocol, if the setting response of the first slaves in the online slave library to the second unicast frames is not received, the second unicast frames are sent to the first slaves again, if the number of times of sending the second unicast frames to the first slaves reaches the first number, the setting response of the first slaves is not received yet, the first slaves are deleted from the online slave library, and after the target protocol used by the master is determined, all the communication protocols of all the slaves in the online slave library are set to be the target protocol, so that the master can normally communicate with all the slaves in the online slave library, and the compatibility of the communication system is improved.
Fig. 4 is a flowchart of a communication control method according to an embodiment of the present application. In this embodiment, a method of timeout processing for receiving a response transmitted from a slave in an online slave library after a host transmits a unicast frame to the slave will be described in detail based on the embodiment of fig. 2. As shown in fig. 4, the communication control method provided in this embodiment includes:
S301, the master sends a third unicast frame to a second slave in the online slave library.
Wherein, the third unicast frame refers to a data frame for querying the state of the slave or controlling the slave to perform the functionality of the corresponding operation. The second slave may be any slave in the online slave library.
S302, the host enters a waiting state.
The host enters the waiting state after sending the third unicast frame, and starts the waiting timer, because the host needs to wait for the response of the second slave, and in the master-slave communication system, only one device can send data at the same time, and the host enters the waiting state, so that the collision with other slaves or subsequent sending commands of the host can be avoided.
S303, the host computer judges whether a response of the second slave computer is received, if yes, the step S304 is executed, and if not, the step S305 is executed.
The response of the second slave includes the address of the second slave and other data, so that the master stops the waiting time when the address information corresponding to the second slave is successfully received in the waiting process, and enters the receiving state and starts to process the received data.
In contrast, if the host fails to identify the address corresponding to the second slave in the waiting process, the host needs to determine whether the duration of entering the waiting state exceeds a first duration, where the first duration is a waiting timing threshold of the host, that is, a preset response timeout duration. The purpose of 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 master.
S304, the host enters a receiving state and processes the received data.
The host also initiates a receive timer when the host enters a receive state and begins processing the received data.
S305, the host judges whether the time length of entering the waiting state exceeds the first time length, if so, the step S307 is executed, and if not, the step S302 is executed.
The host needs to determine whether the duration of the waiting state exceeds a preset first duration, i.e. the response timeout. If the first time length is exceeded, the host considers that the second slave does not answer, and enters an idle state, and if the first time length is not exceeded, the host continues to wait for the response of the second slave.
S306, the host computer judges whether the processing of the received data is completed, if yes, the step S307 is executed, and if not, the step S308 is executed.
If the host encounters an error in the receiving process or does not receive any data, whether the time length of the host entering the receiving state exceeds a second time length is further judged, wherein the second time length is the receiving timing threshold of the host, namely the preset receiving timeout time length. The second time period is set to ensure that the response data sent by the second slave can be received completely by the master.
S307, the host enters an idle state.
S308, the host judges whether the time length of entering the receiving state exceeds the second time length, if so, the step S307 is executed, and if not, the step S304 is executed.
If the host judges that the time length of the host entering the receiving state exceeds the second time length in the process of receiving the response of the second slave to the third unicast frame, the host considers that the receiving time is overtime, and then returns to the idle state;
if the host judges that the time length of the host entering the receiving state does not exceed the second time length in the process of receiving the response of the second slave to the third unicast frame, the host considers that the receiving is not overtime, and can continue to process the received data.
S309, the host computer judges whether any response of the second slave computer is received in the continuous third time period, if yes, the step S309 is executed again, and if not, the step S310 is executed.
Wherein, after the host reenters the idle state, the host may determine whether any response of the second slave is received in a third continuous period of time, for example, receiving address information of the second slave or receiving response data sent by the second slave.
The third duration refers to a total response duration threshold of any slave in the online slave library preset by the master, and the purpose of setting the third duration is to ensure that the second slave is disconnected and deleted from the online slave library when the second slave in the online slave library fails to respond to the master correctly for a plurality of times in the accumulated response duration in a waiting process and/or a receiving process and the accumulated response duration exceeds the third duration.
S310, the master machine deletes the second slave machine from the online slave machine library.
In one possible implementation, if the number of slaves in the online slave pool is zero, then sending the first unicast frame to the plurality of slaves, respectively, is performed again, and the non-responding slaves are determined, and the first unicast frame is sent again to the non-responding slaves to re-determine the online slave pool based on the received query response.
When the number of slaves in the online slave library is zero, the master needs to reestablish the online slave library by polling, so as to ensure that the master can rediscover and manage all slaves connected to the communication system, and the polling process for reestablishing the online slave library is similar to the steps S101 to S104 described in the embodiment of fig. 2, which are not repeated here.
In another possible implementation, if the number of slaves in the online slave library is greater than zero and less than the first preset number, after each polling of the second preset number of rounds, 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.
The first preset number may be the number of all slaves in the communication system that can communicate with the master via the bus. When the number of online slaves in the online slave pool is smaller than the first preset number, the step S103 and the step S104 described in the embodiment of fig. 2 may be executed again after the second preset number of rounds of polling is completed by the master, and the specific process is not repeated here.
Thus, with the deletion of the slave machine which is already off-line in the online slave machine library and the addition of the new slave machine, the host machine can dynamically adjust the version of the communication protocol so as to adapt to the communication requirement of each slave machine in the new online slave machine library, thereby improving the compatibility of the communication system.
According to the communication control method provided by the embodiment, by setting the preset timeout durations such as the first duration, the second duration and the third duration, and judging whether the duration of the host in each process of receiving the response of the second slave exceeds the corresponding preset timeout duration, the host can be ensured to completely receive and process the data sent by the second slave, and the host can be prevented from waiting for the response of the second slave indefinitely, so that the host can retry as soon as possible, the communication efficiency of the communication system is improved, the host can timely find the slave which is off line, delete the slave from the online slave library, and ensure the stability of communication between the host and the slave in the online slave library.
Fig. 5 is a flowchart of a communication control method provided in the present application, and this embodiment is based on the embodiment of fig. 2, and describes in detail a communication control method when a certain slave in an online slave library has a control requirement in a polling period of a master. As shown in fig. 4, the communication control method provided in this embodiment includes:
S401, the host sequentially sends polling requests to the slaves in the online slave library according to preset polling intervals.
The host sets a polling interval time in advance for controlling the polling frequency, the host acquires an online slave library from the memory, the library contains the addresses and related information of all online slaves, and the host sequentially sends a polling request to each slave according to the addresses of each slave according to the sequence in the slave library.
S402, after the host computer sends a polling request to a third slave computer in the online slave computer library and receives a polling response of the third slave computer, judging whether the third slave computer needs to be controlled, if so, executing step S403, and if not, executing step S401.
When the host polls a third slave in the online slave library, after receiving a polling response of the third slave, the host judges 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, and if the third slave does not need to be controlled, the host continues to poll other slaves in the online slave library, namely the next slave of the third slave in sequence.
For example, the host is polling four slaves, namely a smart light, a smart socket, an air conditioner and a smart curtain, the polling interval is set to 5 seconds, and after the host starts the polling process, the host sequentially sends polling requests to the smart light, the smart socket, the air conditioner and the smart curtain in the order of the on-line slaves. In the polling process, a user triggers a control command, such as "turn on an air conditioner", through a user interface of the smart home system, and after receiving the control command from the user, the host pauses the current polling process and constructs a control frame including the address of the air conditioner and the control command (such as turn on the air conditioner), and the host sends the control frame to the air conditioner.
S403, the host records the address of the third slave.
S404, the master sends a control frame to the third slave.
The control frame is used for sending a control instruction to the third slave machine, and the control frame comprises an address of the third slave machine, a function code and data operation to be actually executed, for example, a set value, a control parameter and the like, wherein the function code is used for indicating the specific operation type executed by the third slave machine.
Through the step, the host can immediately respond to the control requirement of the user in the polling and inquiring process, and the real-time control of the third slave is realized.
S405, the host computer judges whether a control response of the third slave computer is received, if yes, the step S401 is executed, and if no, the step S406 is executed.
After the control frame is sent to the third slave, the host enters a waiting state and waits for the control response of the third slave, at this time, if the third slave receives the control frame and analyzes the control frame, after the corresponding operation is completed, the control response is generated and sent to the host, the host judges whether the control response of the third slave is received, and after the control response of the third slave is received and the analysis processing is completed, the host continues to poll the next slave in the online slave library so as to continue the suspended polling period.
If the host does not receive the control response of the third slave within the preset duration or receives the control response, but the control response contains an abnormal code, so that the analysis of the control response by the host fails, the host judges whether the number of times of sending the control frame to the third slave reaches a second number of times, and when the number of times of sending the control frame to the third slave does not reach the second number of times, the second number of times is the preset maximum number of times of sending the control frame to the third slave by the host, for example, the number of times can be 3.
S406, judging whether the number of times of sending the control frame to the third slave machine reaches the second number of times, if so, executing the step S401, and if not, executing the step S404.
When the third slave fails to respond to the control frame correctly, the master repeatedly sends the control frame to the third slave and waits for response, but when the sending times reach the second times and the third slave fails to respond to the master correctly, the control failure is indicated, and the master continues to inquire from the address of the third slave in a pause state.
According to the communication control method, the polling request is sequentially sent to the slaves in the online slave library according to the preset polling interval, after the polling request is sent to the third slaves in the online slave library and the polling response of the third slaves is received, if the third slaves are judged to need to be controlled, the address of the third slaves is recorded, the control frame is sent to the third slaves, if the control response of the third slaves is not received, the control frame is sent to the third slaves again, the steps are repeatedly executed until the control response of the third slaves is received or until the number of times of sending the control frame to the third slaves reaches the second number, the polling request is continuously sent to the next slave of the third slaves.
Fig. 6 is a flowchart fifth of a communication control method according to an embodiment of the present application, and an execution body of the embodiment may be, for example, any slave in the communication system in fig. 1. As shown in fig. 6, the communication control method provided in this embodiment includes:
s501, the slave receives a first unicast frame sent by the host.
And the slave machine enters a waiting receiving state after being electrified until the slave machine receives a first unicast frame, wherein the first unicast frame is used for inquiring whether the slave machine is online or not, and the first unicast frame comprises the address of the slave machine.
S502, the slave determines whether the address of the first unicast frame is the address of the slave, if so, step S503 is executed, and if not, step S501 is executed.
The slave firstly judges whether the address is the address of the slave according to the address of the slave in the first unicast frame, when the address of the slave in the first unicast frame is determined to be the local address, the first unicast frame is analyzed, when the address of the slave in the first unicast frame is determined not to be the local address, the first unicast frame is ignored, and a waiting receiving state is returned to receive the unicast frame sent by the host next time.
This is because the slave needs to confirm that the received first unicast frame is directed to itself, the slave can correctly process the subsequent data and instructions, and if the received first unicast frame is not directed to itself, it should not process the first unicast frame to avoid wasting resources and time, so that the slave can avoid unnecessary data processing by judging the address of the first unicast frame, thereby improving the efficiency of the whole communication system.
For example, slave a receives a first unicast frame with address field 1 and slave a with address 2, and first checks the address field in the unicast frame and finds that address 1 of the unicast frame does not match address 2 of itself. The slave a ignores the first unicast frame and does not perform further processing.
S503, the slave analyzes the first unicast frame.
The slave needs to parse the first unicast frame to determine a command or a request sent by the host so as to execute a response action, specifically, the slave can extract necessary data, such as a function code, a data field and the like, from the first unicast frame through parsing the first unicast frame, and the slave confirms that the data is a state query command according to the function code in the first unicast frame, and can generate a response frame indicating that the slave is online so as to feed back to the host.
It can be understood that if the slave machine has an abnormal analysis condition in the process of analyzing the first unicast frame, the slave machine determines an abnormal code corresponding to the current abnormal analysis condition according to a preset abnormal code judging rule, and generates a response frame according to the abnormal code, wherein the response frame is used for indicating the abnormal condition and is fed back to the host machine.
Optionally, the slave may also receive a broadcast frame sent by the host, and since the nature of the broadcast frame is for all the slaves, after the slave receives the broadcast frame, it first determines whether the broadcast frame includes the address of the host, if yes, parses the broadcast frame, and when the parsing is completed and the data is error-free, the slave will execute the instruction or operation indicated in the broadcast frame, but in this process, the slave will not send a response to the host.
S504, the slave machine sends a query response for the first unicast frame to the host machine.
After the analysis of the first unicast frame by the slave machine is completed, the slave machine enters an idle state, and when the duration in the idle state is longer than a preset duration, the slave machine sends a query response aiming at the first unicast frame to the host machine, wherein a data frame of the query response comprises a state code for indicating that the slave machine is online and a communication protocol supported by the slave machine, and the query response is used for determining that the slave machine is online and determining a target protocol for communication between the host machine and the slave machine.
It will be appreciated that the objective of the slave machine, after completing processing the first unicast frame and entering the idle state, also needs to wait for a preset period of time to send the first unicast frame to the host machine, is to ensure that the slave machine has enough time to generate a query response for the first unicast frame.
In one possible implementation manner, the slave may further receive a second unicast frame sent by the host, where the second unicast frame is used to set the slave to use the above-mentioned target protocol, and send a setting response for the second unicast frame to the host. The specific setting procedure of the target protocol may refer to each step described in the embodiment of fig. 3, and will not be described herein.
According to the communication control method, the first unicast frame sent by the host is received by the slave, if the address of the first unicast frame is the address of the slave, the first unicast frame is analyzed, the query response for the first unicast frame is sent to the host, the query response comprises a communication protocol supported by the slave, the query response is used for determining that the slave is online, and a target protocol used for determining that the host and the slave communicate, the method is used for receiving the first unicast frame sent by the host and used for querying the state of the slave, and after the analysis is completed, the query response comprising the online code of the slave and the communication protocol information supported by the slave is generated and fed back to the host, so that the host can determine that the slave is online according to the query response, the online slave is added into an online slave library, the target protocol for communicating with the slave is determined, the fact that the host polls the slave which is not online again when the host is in a subsequent round is avoided, the communication efficiency is improved, and the compatibility of the communication protocols is improved.
Fig. 7 is a schematic structural diagram of a communication control device according to the present application, which is applied to a host in a communication system. As shown in fig. 7, the present application provides a communication control device, a control device 600 of which includes:
A transceiver module 601, configured to send a first unicast frame to the plurality of slaves, where the first unicast frame is used to query whether the slaves are online, and repeatedly execute the step when no query response of any slave to the first unicast frame is received, until a query response of a part of the slaves is received, where the query response includes a communication protocol supported by the slaves;
a processing module 602, configured to determine an unresponsive slave;
the transceiver module 601 is further configured to send the first unicast frame to the non-responding slave again;
The processing module 602 is further configured to add all slaves corresponding to the received query response to an online slave library, and determine a target protocol for the host to communicate with the slaves in the online slave library based on a communication protocol supported by the slaves in the online slave library and a communication protocol supported by the host.
In a possible implementation manner, the transceiver module 601 is further configured 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 use the target protocol;
the transceiver module 601 is further configured to send the second unicast frame to the first slave again when a setting response of the first slave in the online slave pool to the second unicast frame is not received;
The processing module 602 is further configured to delete the first slave from the online slave library after the number of times of sending the second unicast frame to the first slave reaches a first number, and the setting response of the first slave has not been received yet.
In a possible implementation manner, the transceiver module 601 is further configured to send a third unicast frame to a second slave in the online slave library, and enter a waiting state;
The processing module 602 is configured to enter an idle state when the host does not receive the response of the second slave and the duration of entering the waiting state exceeds a first duration;
The processing module 602 is configured to enter a receiving state and process the received data when the host receives the response of the second slave, and enter an idle state when processing the received data is completed or when processing the received data is wrong and the duration of entering the receiving state exceeds a second duration;
The processing module 602 is further configured to delete the second slave from the online slave library when the master does not receive any response of the second slave within a continuous third duration.
In a possible implementation manner, the transceiver module 601 is further configured to sequentially send a polling request to the slaves in the online slave library according to a preset polling interval;
The processing module 602 is further configured to record an address of a third slave in the online slave library when it is determined that the third slave needs to be controlled after sending a polling request to the third slave and receiving a polling response of the third slave;
The transceiver module 601 is further configured to send a control frame to the third slave;
The transceiver module 601 is further configured to, when the control response of the third slave is not received, send the control frame to the third slave again, and repeatedly perform this step until the control response of the third slave is received, or until the number of times of sending the control frame to the third slave reaches the second number of times, continue sending a polling request to the next slave of the third slave.
In a possible implementation manner, the transceiver module 601 is further configured to re-perform the sending of the first unicast frame to the plurality of slaves when the number of slaves in the online slave pool is zero, and determine an unresponsive slave and re-send the first unicast frame to the unresponsive slave, and the processing module 602 is further configured to re-determine the online slave pool based on the received query response.
Fig. 8 is a schematic diagram of a second configuration of the communication control device provided by the present application, which is applied to a slave in a communication system. As shown in fig. 8, the present application provides a communication control device, a control device 700 of which includes:
A transceiver module 701, configured to receive a first unicast frame sent by the host, where the first unicast frame is used to query whether the slave is online;
a processing module 702, configured to parse the first unicast frame when the address of the first unicast frame is the address of the slave;
The transceiver module 701 is further configured to send a query response to the host for the first unicast frame, where the query response includes a communication protocol supported by the slave, and the query response is used to determine that the slave is online, and is used to determine a target protocol for the host and the slave to communicate.
In a possible implementation manner, the transceiver module 701 is further configured to receive a second unicast frame sent by the host, where the second unicast frame is used to set the slave to use the target protocol;
the transceiver module 701 is further configured to send a setup response for the second unicast frame to the host.
Fig. 9 is a schematic structural diagram of an electronic device provided by the present application. As shown in fig. 9, the present application provides an electronic device 800 comprising a receiver 801, a transmitter 802, a processor 803, and a memory 804.
A receiver 801 for receiving instructions and data;
a transmitter 802 for transmitting instructions and data;
A memory 804 for storing computer-executable instructions;
A processor 803 for executing computer-executable instructions stored in a memory 804 to implement the steps executed by the communication control method in the above-described embodiment. Reference may be made in particular to the description of the embodiments of the communication control method described above.
Alternatively, the memory 804 may be separate or integrated with the processor 803.
When the memory 804 is provided separately, the electronic device further comprises a bus for connecting the memory 804 and the processor 803.
The present application also provides a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement a communication control method as performed by a master and a slave in the above-described communication system.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components, for example, one physical component may have a plurality of functions, or one function or step may be cooperatively performed by several physical components. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is 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 tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies 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 includes any information delivery media.
While the present application has been described with reference to the preferred embodiments shown in the drawings, it will be readily understood by those skilled in the art that the scope of the present application is not limited to such specific embodiments, and that the above embodiments are merely illustrative of the technical solutions of the present application, rather than limiting, and that, although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art will appreciate that modifications may be made to the technical solutions described in the foregoing embodiments, or that equivalents may be substituted for some or all of the technical features thereof, without departing from the spirit of the technical solutions of the embodiments.

Claims (10)

1. A communication control method applied to a master in a communication system including the master and a plurality of slaves, the method comprising:
Respectively sending a first unicast frame to the plurality of slaves, wherein the first unicast frame is used for inquiring whether the slaves are online, and if the inquiry response of any slave to the first unicast frame is not received, repeating the step until the inquiry response of part of the slaves is received, wherein the inquiry response comprises a communication protocol supported by the slaves;
determining an unresponsive slave and retransmitting the first unicast frame to the unresponsive slave;
And adding all the slaves corresponding to the received inquiry response into an online slave library, and determining a target protocol for the communication between the master and the slaves in the online slave library based on the communication protocol supported by the slaves in the online slave library and the communication protocol supported by the master.
2. The method as recited in claim 1, further comprising:
respectively sending second unicast frames to the slaves in the online slave library, wherein the second unicast frames are used for setting the slaves to adopt the target protocol;
And if the setting response of the first slave in the online slave library is not received, the second unicast frame is sent to the first slave again, and if the setting response of the first slave is not received after the number of times of sending the second unicast frame to the first slave reaches the first number, the first slave is deleted from the online slave library.
3. The method as recited in claim 1, further comprising:
transmitting a third unicast frame to a second slave in the online slave library, and entering a waiting state;
If the host does not receive the response of the second slave and the waiting time exceeds the first time, the host enters an idle state;
If the host receives the response of the second slave, the host enters a receiving state and processes the received data, if the processing of the received data is completed, or if the processing of the received data is wrong and the time for entering the receiving state exceeds a second time, the host enters an idle state;
and if the host does not receive any response of the second slave machine in a continuous third time period, deleting the second slave machine from the online slave machine library.
4. A method according to any one of claims 1-3, further comprising:
sequentially sending polling requests to the slaves in the online slave library according to preset polling intervals;
after a polling request is sent to a third slave in the online slave library and a polling response of the third slave is received, if the third slave is judged to need to be controlled, the address of the third slave is recorded, and a control frame is sent to the third slave;
And if the control response of the third slave machine is not received, the control frame is sent to the third slave machine again, the step is repeatedly executed until the control response of the third slave machine is received, or until the number of times of sending the control frame to the third slave machine reaches the second number of times, and the polling request is continuously sent to the next slave machine of the third slave machine.
5. A method according to any one of claims 2-3, further comprising:
and if the number of the slaves in the online slave machine library is zero, the step of respectively sending the first unicast frames to the slaves is executed again, the slaves which are not responded are determined, and the first unicast frames are sent to the slaves which are not responded again, so that the online slave machine library is determined again based on the received inquiry response.
6. A method according to any one of claims 2-3, further comprising:
And if the number of the slaves in the online slave machine library is greater than zero and smaller than the first preset number, after polling of a second preset number of rounds is carried out, the first unicast frame is sent to other slaves outside the online slave machine library again, so that the online slave machine library is redetermined based on the received query response.
7. A communication control method applied to a slave in a communication system including a master and a plurality of slaves, the method comprising:
receiving a first unicast frame sent by the host, wherein the first unicast frame is used for inquiring whether the slave is online;
If the address of the first unicast frame is the address of the slave, the first unicast frame is analyzed, and a query response aiming at the first unicast frame is sent to the host, wherein the query response comprises a communication protocol supported by the slave, the query response is used for determining that the slave is online, and a target protocol used for communicating between the host and the slave is determined.
8. The method as recited in claim 7, further comprising:
Receiving a second unicast frame sent by the host, wherein the second unicast frame is used for setting the slave to adopt the target protocol;
and sending a setting response for the second unicast frame to the host.
9. An electronic device, comprising:
A memory;
A processor;
Wherein the memory stores computer-executable instructions;
The processor executes computer-executable instructions stored in the memory to implement the communication control method as claimed in any one of claims 1 to 6 or any one of claims 7 to 8.
10. A computer storage medium having stored therein computer executable instructions which when executed by a processor are for implementing the communication control method of any one of claims 1 to 6 or any one of claims 7 to 8.
CN202411197786.0A 2024-08-28 2024-08-28 Communication control method, device and storage medium Pending CN119299509A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411197786.0A CN119299509A (en) 2024-08-28 2024-08-28 Communication control method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411197786.0A CN119299509A (en) 2024-08-28 2024-08-28 Communication control method, device and storage medium

Publications (1)

Publication Number Publication Date
CN119299509A true CN119299509A (en) 2025-01-10

Family

ID=94155091

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411197786.0A Pending CN119299509A (en) 2024-08-28 2024-08-28 Communication control method, device and storage medium

Country Status (1)

Country Link
CN (1) CN119299509A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101834912A (en) * 2010-04-20 2010-09-15 南京航空航天大学 Device for dynamically allocating slave addresses in pair of multistandard serial communications and use method
CN102684923A (en) * 2012-05-24 2012-09-19 江苏华德电力科技有限公司 Self-healing networking method for half-duplex asynchronous communication
CN105578383A (en) * 2015-05-25 2016-05-11 上海归墟电子科技有限公司 2.4G-based networking communication system and communication method
CN110995686A (en) * 2019-11-26 2020-04-10 珠海泰芯半导体有限公司 Software communication protocol checking method
CN112565038A (en) * 2020-12-04 2021-03-26 广州擎天实业有限公司 RS485 bus-based low-load communication method
CN114422288A (en) * 2021-12-29 2022-04-29 厦门诚通达智能科技有限公司 Communication System Based on Modbus Protocol
CN115442182A (en) * 2022-08-31 2022-12-06 厦门熵基科技有限公司 Polling method, device, equipment and storage medium
CN117290269A (en) * 2023-10-12 2023-12-26 深圳市欧瑞博科技股份有限公司 Communication method, communication system and electronic equipment
CN118331796A (en) * 2024-04-10 2024-07-12 成都工业学院 Polling communication method, system, equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101834912A (en) * 2010-04-20 2010-09-15 南京航空航天大学 Device for dynamically allocating slave addresses in pair of multistandard serial communications and use method
CN102684923A (en) * 2012-05-24 2012-09-19 江苏华德电力科技有限公司 Self-healing networking method for half-duplex asynchronous communication
CN105578383A (en) * 2015-05-25 2016-05-11 上海归墟电子科技有限公司 2.4G-based networking communication system and communication method
CN110995686A (en) * 2019-11-26 2020-04-10 珠海泰芯半导体有限公司 Software communication protocol checking method
CN112565038A (en) * 2020-12-04 2021-03-26 广州擎天实业有限公司 RS485 bus-based low-load communication method
CN114422288A (en) * 2021-12-29 2022-04-29 厦门诚通达智能科技有限公司 Communication System Based on Modbus Protocol
CN115442182A (en) * 2022-08-31 2022-12-06 厦门熵基科技有限公司 Polling method, device, equipment and storage medium
CN117290269A (en) * 2023-10-12 2023-12-26 深圳市欧瑞博科技股份有限公司 Communication method, communication system and electronic equipment
CN118331796A (en) * 2024-04-10 2024-07-12 成都工业学院 Polling communication method, system, equipment and storage medium

Similar Documents

Publication Publication Date Title
JP3725165B2 (en) Method for initializing a wireless packet hopping network
US7693934B2 (en) Network device, system and method for providing list of controlled devices
CN106385661B (en) Pairing request, pairing response method and pairing request, pairing response terminal
KR101355308B1 (en) Method for transmitting and receiving data in wireless sensor network
JPH0620203B2 (en) Data communication method and communication system
JP2010514319A (en) Method and system for selecting each device of a wireless network, in particular a network of wireless lighting devices
JP2009088750A (en) Management device, wireless terminal, ad hoc network system, management device setting change program, management device setting change method, wireless terminal setting change program, and wireless terminal setting change method
US20070066338A1 (en) Method and apparatus for operating network application in communication devices in power save mode
US20080126492A1 (en) Pinging for the Presence of a Server in a Peer to Peer Monitoring System
JP3115451B2 (en) Communication network
CN113905050B (en) Method, device and system for detecting internet access information
JP3359094B2 (en) Communication system, method in which parent node recognizes states of multiple child nodes, and method of recognizing new terminal in communication system having multiple terminals
CN115113901A (en) Remote upgrade method, device and medium for electronic control software of smart home appliances
CN115687226A (en) I2c bus communication method, device and readable storage medium
EP2168311B1 (en) Upnp control point and method of handling upnp control request
CN101909007A (en) Production method, device and network equipment of binding table
CN119299509A (en) Communication control method, device and storage medium
CN116938712A (en) Device upgrade method, device upgrade apparatus, and computer-readable storage medium
US10111051B2 (en) Communication apparatus, control method therefor, program, and storage medium
JP2005346175A (en) Command communication apparatus and command communication method
CN103765791A (en) Near field communication radio frequency discovery control method, device and terminal device
CN115208794B (en) Timer adjustment method, device, equipment and medium of Profibus-DP protocol
CN116232556B (en) Channel usage methods, electronic devices, and computer storage media
CN118138386B (en) Device communication method, system, device, storage medium and product
US20050262224A1 (en) Method for modifying one or more parameters for the operation of a network and subscribers for carrying out this method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination