Search

CN-121333844-B - Communication bus control method and single-host communication system

CN121333844BCN 121333844 BCN121333844 BCN 121333844BCN-121333844-B

Abstract

The present disclosure provides a communication bus control method and a single host communication system, which belongs to the technical field of communication, wherein the single host communication system comprises a communication bus, a first host device, a second host device and at least one slave device, wherein the first host device, the second host device and the at least one slave device are connected through the communication bus; the system comprises a first master device, a second master device, a first slave device and a first host device, wherein the first master device is configured to monitor a bus idle period of a communication bus, the bus idle period is a period of time after a second master device and at least one slave device complete a round of inquiry frames and response frames, a preset bus preemption message is broadcast through the communication bus in the bus idle period, the second master device is configured to respond to the received bus preemption message sent by the first master device, switch the working mode to a slave working mode, and the first master device is further configured to switch the working mode to a host working mode. The new host is able to take over communication bus control securely and collision free over a single host communication bus.

Inventors

  • Jiang Jiongguang
  • CHEN ZIHAO
  • CHEN QIANG
  • SHEN YUEYU
  • LIANG JINLONG

Assignees

  • 杭州康钡电机有限公司

Dates

Publication Date
20260508
Application Date
20251215

Claims (8)

  1. 1. A communication bus control method applied to a first master device, the communication bus including a second master device and at least one slave device, the communication bus control method comprising: receiving all data frames on the communication bus; analyzing the data frame, and identifying an inquiry frame sent to a target slave device in the at least one slave device by the second master device; after a delay of t0 and t1, responding to the monitored target slave device to start sending a response frame corresponding to the inquiry frame, determining to enter a bus idle period after the last bit of the response frame is transmitted on the communication bus, wherein t0 represents the time length from the beginning of the transmission of the inquiry frame to the completion of the transmission of the last bit on the communication bus, t1 is the time length of the target slave device for preparing the response frame after completely receiving and analyzing the inquiry frame, and the bus idle period is the time length from the completion of the transmission of the last bit of the response frame on the communication bus to the time length before the preparation of the polling of the next slave device; broadcasting a preset bus preemption message through a communication bus in the bus idle period so as to enable the second master device to be switched from a host working mode to a slave working mode; Switching the working mode to a host working mode; The switching the working mode to the host working mode includes: and under the condition that a response message of the bus preemption message replied by the second main equipment is received, switching the working mode into a host working mode.
  2. 2. The method of claim 1, wherein the bus preemption message includes a priority function code and the response message indicates that the priority function code indicates a higher priority than the task priority of the second master device.
  3. 3. The method of claim 1, wherein the step of determining the position of the substrate comprises, The periodic broadcast is used to indicate that the current communication bus is being occupied by the bus occupancy message of the first master device.
  4. 4. A communication bus control method, applied to a second master device, comprising: Responding to a received bus preemption message sent by a first master device, switching a working mode to a slave working mode, and sending a response message to the first master device; The bus preemption message is broadcast by the first master device in a bus idle period through a communication bus, the bus idle period is a period from when the last bit of the response frame is transmitted on the communication bus to when the last bit is ready to initiate polling of the next slave device, and the determining of the bus idle period includes: the first master device receives all data frames on the communication bus; the first master device analyzes the data frame and identifies an inquiry frame which is sent to a target slave device in at least one slave device by the second master device; After a delay of t0 and t1, the first master device starts to send a response frame corresponding to the query frame in response to the monitored certain target slave device, after the last bit of the response frame is transmitted on the communication bus, a bus idle period is determined to enter, t0 represents a time period from the beginning of the transmission of the query frame to the completion of the transmission of the last bit on the communication bus, and t1 is a time period that the certain target slave device prepares the response frame after completely receiving and analyzing the query frame.
  5. 5. The method of claim 4, wherein the communication bus control method further comprises: Analyzing the bus preemption message to obtain a priority function code; The responding to the received bus preemption message sent by the first master device, sending a response message to the first master device, includes: And sending the response message to the first master device under the condition that the priority indicated by the priority function code is higher than the current task priority.
  6. 6. The method of claim 4, wherein the communication bus control method further comprises: Acquiring the state of the communication bus; and switching the slave working mode to the master working mode under the condition that the duration of the communication bus in the idle state is greater than a duration threshold value.
  7. 7. The method of claim 6, wherein the obtaining the status of the communication bus comprises: and determining that the communication bus is in an occupied state based on the received bus occupation message broadcasted by the first main equipment.
  8. 8. The single-host communication system is characterized by comprising a communication bus, a first master device, a second master device and at least one slave device, wherein the first master device, the second master device and the at least one slave device are connected through the communication bus; the first master device configured to receive all data frames on the communication bus; Analyzing the data frame, and identifying an inquiry frame sent to a target slave device in the at least one slave device by the second master device; After a delay of t0 and t1, responding to the monitored target slave device to start to send a response frame corresponding to the query frame, determining to enter a bus idle period after the last bit of the response frame is transmitted on the communication bus, wherein t0 represents the time length from the beginning of the transmission of the query frame to the completion of the transmission of the last bit on the communication bus, t1 is the time length of the target slave device for preparing the response frame after completely receiving and analyzing the query frame, and the bus idle period is the time length of the last bit of the response frame after the transmission of the last bit of the response frame on the communication bus is completed to the time length before the preparation of the transmission of the query to the next slave device; Broadcasting a preset bus preemption message through a communication bus in the bus idle period; The second master device is configured to respond to the received bus preemption message sent by the first master device, switch the working mode to the slave working mode and send a response message to the first master device; the first master device is further configured to switch the working mode to a host working mode under the condition that a response message of the bus preemption message replied by the second master device is received.

Description

Communication bus control method and single-host communication system Technical Field The disclosure relates to the field of communication technologies, and in particular, to a communication bus control method and a single-host communication system. Background The RS-485 bus has the advantages of high anti-interference performance, support of multi-node mounting, long transmission distance and the like due to differential signal transmission, and is widely applied to communication among devices in the fields of industrial automation, building automatic control, intelligent home and the like. In a typical RS-485 communication system, a Master-Slave (Master-Slave) communication architecture is generally employed. Under this architecture, there is only one Master (Master) on the bus, the remainder being Slave devices (Slave). The master is the initiator of the communication and it sends instructions or read status to the slave devices by periodically polling the slave devices, which passively respond to the master's requests. The single-host polling mechanism has a simple structure and clear communication time sequence, can effectively avoid data collision on a bus, and ensures the stability and reliability of communication. For example, in a temperature control system, a central temperature controller may be used as a master to control a plurality of fan driving boards, sensors and other slave devices in a polling manner. However, with the complexity and intelligence of the system functions, it is often necessary to introduce external monitoring devices, such as an upper computer for system diagnosis, data analysis, or parameter configuration. When the upper computer accesses the RS-485 bus, it also needs to actively send a query command to each slave device to obtain the required information, i.e. it also needs to play the role of a host. At this time, two hosts, an original central temperature controller and a newly connected upper computer are arranged on the RS-485 bus. Two hosts can respectively try to occupy the RS-485 bus to send data according to own logic and time sequence, which is very easy to cause that a plurality of hosts send signals to the RS-485 bus at the same time, so that signal collision of a physical layer is caused, namely data 'packet collision'. The packet is damaged due to data collision, the receiver cannot analyze correctly, and finally the whole RS-485 bus communication is broken down and cannot work normally. Disclosure of Invention The present disclosure provides a communication bus control method and a single-host communication system, which aims to solve the problems of bus data collision and communication abnormality caused by the occurrence of multiple hosts when a new master device needs to access to an operating single-host polling communication system. The technical scheme of the present disclosure is realized as follows: In a first aspect, the disclosure provides a communication bus control method applied to a first master device, wherein a communication bus comprises a second master device and at least one slave device, the communication bus control method comprises the steps of monitoring a bus idle period of the communication bus, wherein the bus idle period is a period of time after the second master device and the at least one slave device complete a round of inquiry frames and response frames, broadcasting a preset bus preemption message through the communication bus in the bus idle period to enable the second master device to switch from a host working mode to a slave working mode, and switching the working mode to the host working mode. In a second aspect, the present disclosure provides a communication bus control method applied to a second master device, where the communication bus control method includes switching an operation mode to a slave operation mode in response to a received bus preemption message sent by a first master device. In a third aspect, the present disclosure provides a single-host communication system including a communication bus, a first master device, a second master device, and at least one slave device, the first master device, the second master device, and the at least one slave device being connected by the communication bus, the first master device configured to monitor a bus idle period of the communication bus, the bus idle period being a period of time after the second master device and the at least one slave device complete a round of inquiry frames and response frames, and broadcast a preset bus preemption message over the communication bus during the bus idle period, the second master device configured to switch an operation mode to a slave operation mode in response to a received bus preemption message sent by the first master device, the first master device further configured to switch the operation mode to the master operation mode. In a fourth aspect, the present disclosure provides a communication bus control apparatus inc