WO2018113432A1 - Broadcast realisation method, apparatus and device - Google Patents

Broadcast realisation method, apparatus and device Download PDF

Info

Publication number
WO2018113432A1
WO2018113432A1 PCT/CN2017/109754 CN2017109754W WO2018113432A1 WO 2018113432 A1 WO2018113432 A1 WO 2018113432A1 CN 2017109754 W CN2017109754 W CN 2017109754W WO 2018113432 A1 WO2018113432 A1 WO 2018113432A1
Authority
WO
WIPO (PCT)
Prior art keywords
response
slave
information
order
slave device
Prior art date
Application number
PCT/CN2017/109754
Other languages
French (fr)
Chinese (zh)
Inventor
苏本胜
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2018113432A1 publication Critical patent/WO2018113432A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • H04L12/1813Arrangements for providing special services to substations for broadcast or conference, e.g. multicast for computer conferences, e.g. chat rooms
    • H04L12/1827Network arrangements for conference optimisation or adaptation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/06Selective distribution of broadcast services, e.g. multimedia broadcast multicast service [MBMS]; Services to user groups; One-way selective calling services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus

Definitions

  • the present invention relates to the field of communications, and in particular, to a broadcast implementation method, apparatus, and device.
  • the Recommended Standard (RS)-485 specifies the electrical characteristics of the driver (driver/generator/transmitter) and receiver (receiver) in a serial communication system.
  • RS-485 is jointly released by the Telecommunications Industry Association and Electronic Industries Alliance (TIA/EIA) and is therefore also known as EIA-485 or TIA-485.
  • TIA/EIA Telecommunications Industry Association and Electronic Industries Alliance
  • RS-485 only specifies the electrical characteristics of the driver and receiver. No communication protocol is specified or recommended. That is, RS-485 only specifies the physical layer.
  • the Modbus protocol is a communication protocol for the master/slave architecture. In the Modbus-based network, one node is the master node, and other nodes that use the Modbus protocol to participate in communication are slave nodes. Each slave has a unique address.
  • the bus type network based on RS-485 deployment (hereinafter referred to as RS-485 bus network) adopts master-slave communication mode, so Modbus devices often communicate through the RS-485 physical layer. According to the Modbus protocol, addresses 0x01 to 0xF7 are slave addresses, and 0x00 is a broadcast address.
  • the traditional method may be to separately send a unicast frame to the multiple slave devices, or send a broadcast frame to the entire network.
  • the method of transmitting a unicast frame multiple times consumes a large amount of resources of the master device and takes a long time.
  • all slave devices will respond to the broadcast frame after receiving the broadcast frame. There is a response conflict between the slave devices. It is necessary to continuously try to answer and backoff conflicts, wasting the processing resources of the slave device and causing the RS-485 bus to be long. Occupied.
  • Embodiments of the present invention provide a broadcast implementation method and apparatus, where a master device transmits a broadcast frame including a response slave information, and instructs multiple devices on the RS-485 bus network to respond in order to avoid a response broadcast between multiple devices. Time conflicts improve the efficiency of broadcast communication, thereby improving the performance of the RS-485 bus network.
  • a broadcast implementation method for use in an RS-485 bus network. The method includes:
  • the first slave device acquires a response start time according to the response slave information, and responds when the response start time is reached.
  • the slave device determines that the response needs to be answered according to the response slave information in the broadcast frame, determines the response sequence and calculates the response start time, and then responds when the response start time is reached, thereby avoiding the broadcast response conflict between the slave devices, and improving the slave device.
  • Resource utilization and communication success rate When the slave device determines that the response needs to be answered according to the response slave information in the broadcast frame, determines the response sequence and calculates the response start time, and then responds when the response start time is reached, thereby avoiding the broadcast response conflict between the slave devices, and improving the slave device.
  • the first slave device acquires a response start time according to the responding slave information, and includes:
  • the first slave device calculates a response start time of the first slave device according to a single point timeout duration and a response order of the first slave device.
  • the response order of the first slave device is N, N ⁇ 1
  • the response start time Tsn of the first slave device is T0+(N-1)*D, where T0 is The moment when the first slave device receives the broadcast frame.
  • the first slave device listens to the RS-485 bus before reaching the response start time Tsn of the first slave device; according to the response order
  • the response start time Tek of the second slave device updates the response start time Tsn of the first slave device, and the updated Tsn is Tek+(NK-1)*D, where K is the response order of the second slave device.
  • the first slave device may obtain the response order K of the second slave device according to the address of the second slave device and the broadcast frame.
  • the first slave device can adjust the response start time of the slave device in the response sequence, and adjust the response start time in real time according to the response end time of the previous slave device in the response sequence, thereby avoiding the backoff conflict according to the fixed single point timeout duration.
  • the resulting delay increases the efficiency of the broadcast response.
  • the response slave information is a type-length-value (TLV) format.
  • the response slave information of type 0 indicates that all slave devices in the RS-485 bus network need to respond in order.
  • each slave device can determine its own response order according to the difference between its own address and the start address;
  • the response slave information of type 1 indicates that multiple slave devices in the value field from the start address to the end address range need to respond in order.
  • each slave device can determine its own response order according to the difference between its own address and the starting address;
  • the response slave information of type 2 indicates that the slave devices corresponding to the respective addresses in the value field need to respond in order.
  • each slave device that needs to respond can use its own address in the value field as its own response order;
  • the response slave information of type 3 indicates that the response indication bit in the value field indicates that the slave devices that need to answer are responsive in order.
  • the slave device that needs to respond can use its own response indication bit in the sequence of all response indication bits with a value of 1 as its own response sequence.
  • the first slave device determines, according to the response slave information, that the broadcast frame does not need to be acknowledged The information in the broadcast frame can be recorded and then discarded.
  • a second aspect provides a broadcast implementation method for use in an RS-485 bus network, comprising:
  • the master device generates and transmits a broadcast frame, the broadcast frame includes response slave information, and the response slave information is used to indicate that the plurality of slave devices in the RS-485 bus network respond in response order, the response
  • the order is an order in which the response frame is returned by the plurality of slave devices indicated by the response slave information;
  • the master device receives the response frame returned by the plurality of slave devices in response sequence.
  • a broadcast frame including the response slave information is generated and transmitted by the master device, indicating that multiple slave devices in the RS-485 bus network respond in response order, which can avoid broadcast response conflict between multiple slave devices, and improve broadcast communication success rate. To improve the performance of the RS-485 bus network.
  • the generating, by the master device, the broadcast frame includes:
  • the master device determines an address of the plurality of slave devices
  • the response slave information is a TLV format;
  • the preset condition includes:
  • a response slave information of type 0 is used.
  • the value of the length field in the response slave information is 0, and the value field is empty;
  • a response slave information of type 1 is used.
  • the value field in the response slave information includes a start address and a termination address, and the length field value is 2;
  • the type of the responding slave information may be determined according to the number of slave devices that need to be answered. When the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the response slave information is 2. Accordingly, the value field includes the addresses of multiple slave devices that need to be answered. When the number of slave devices that need to be answered is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3. Correspondingly, the response indication bit corresponding to the slave device in the value field that needs to be acknowledged is set to 1.
  • the preset threshold may be Where n is the number of bits of the address of the slave device.
  • the master device determines the response slave information according to the condition (number, address) of the slave device that needs to be answered, and specifies the response sequence to avoid the collision between the devices, and can shorten the length of the broadcast frame and improve the bandwidth utilization.
  • the method further includes: returning, by the master device, the multiple slave devices
  • the response frame records status information of each slave device; the status information includes a device version, a transmit power, a sleep time, and the like.
  • the master device receives the response frame returned by the multiple slave devices in the response order, The method includes: determining, by the master device, a response waiting period according to a single point timeout duration and the number of the multiple slave devices, and receiving, in the response waiting period, a response frame sequentially returned by the multiple slave devices.
  • a broadcast implementation apparatus which has the first slave device in the first aspect described above
  • the function may be implemented by hardware or by corresponding software implemented by hardware.
  • the hardware or software includes one or more modules corresponding to the functions described above.
  • a slave device for implementing the broadcast implementation method of the first aspect described above.
  • the slave device includes a processor and a communication interface, the processor and the communication interface being connected to each other.
  • the apparatus can also include a memory for storing a computer program, the computer program including program instructions, and the processor executing the program instructions to perform the broadcast implementation method of the first aspect described above.
  • a computer storage medium for storing computer software instructions for use in the first slave device described above, comprising a program designed to perform any of the first aspect described above and its possible implementations.
  • a master device having the function of implementing the master device in the second aspect described above.
  • the functions may be implemented by hardware or by corresponding software implemented by hardware.
  • the hardware or software includes one or more modules corresponding to the functions described above.
  • a master device for implementing the broadcast implementation method of the second aspect above.
  • the master device includes a processor and a communication interface, and the processor and the communication interface are connected to each other.
  • the apparatus can also include a memory for storing a computer program, the computer program comprising program instructions, the processor executing the program instructions, and performing the broadcast implementation method of the second aspect described above.
  • a computer storage medium for storing computer software instructions for use in the above-described host device, comprising a program designed to perform any of the above-described second aspects and possible implementations thereof.
  • an RS-485 bus network comprising: a master device and a plurality of slave devices; the master device, as described in the sixth aspect or the seventh aspect, each of the plurality of slave devices As described in the third aspect or the fourth aspect above.
  • FIG. 1 is a schematic flowchart of a broadcast implementation method according to an embodiment of the present invention.
  • 2A is a schematic structural diagram of a type of response slave information according to an embodiment of the present invention.
  • 2B is a schematic structural diagram of another type of response slave information according to an embodiment of the present invention.
  • 2C is a schematic structural diagram of still another type of response slave information according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart diagram of another broadcast implementation method according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a broadcast implementation apparatus according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a slave device according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a master device according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of another main device according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic diagram of an RS-485 bus network according to an embodiment of the present invention.
  • Embodiments of the present invention provide a broadcast implementation method for an RS-485 bus network, where a master device sends The sent broadcast frame includes response slave information, and the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond to the broadcast frame in order, thereby avoiding conflicts when the multiple slave devices respond, and improving Communication efficiency and network performance. Moreover, each slave device can recalculate the response waiting time according to the response of the prior slave device, and shorten the response waiting time, thereby further improving communication efficiency.
  • FIG. 1 is a schematic flowchart of a broadcast implementation method according to an embodiment of the present invention.
  • the method is used in an RS-485 bus network, and the method includes:
  • the first slave device receives a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network are in the order of Responding to the broadcast frame;
  • the slave device in the RS-485 bus network receives the broadcast frame.
  • the master device may specify that the plurality of slave devices that need to communicate respond in order.
  • the response slave information after receiving the broadcast frame from the slave device that does not need to communicate, there is no need to respond, avoiding the occupation of the RS-485 bus, and not consuming the resource to listen to whether the bus is idle, thereby improving the entire RS- Communication efficiency and performance of the 485 bus network.
  • the response slave information is a type-length-value (TLV) format.
  • TLV type-length-value
  • a Type field value of 0 means that all slave devices in the network need to respond in order (ie, in the order of the slave devices).
  • the value of the Length field is 0 (byte), indicating that the length of the data contained in the Value field is 0 bytes, that is, the Value field is empty.
  • Each slave device determines its own response order based on its own address.
  • a Type field value of 1 means that multiple slave devices within the address range contained in the Value field need to answer.
  • the value of the Length field is 2 (bytes).
  • the Value field includes a start address (1 byte) and a termination address (1 byte). For example, as shown in FIG. 2A, the start address is 0x02, and the end address is 0x1F, and the slave devices whose addresses are between 0x02 and 0x1F need to respond. Each slave device can determine its own response order based on the difference between its own address and the start address.
  • a Type field value of 2 means that the slave device of the specified address in the Value field needs to answer.
  • the Value field includes all the addresses of the slaves that need to be answered.
  • the value of the Length field is variable. If the number of slave devices to be answered is n, the value of the Length field is n (byte), indicating that the length of the data contained in the Value field is n. byte. For example, if the master device specifies four broadcast devices with addresses 0x11, 0x15, 0x43, and 0x78 to answer the broadcast frame, the above four addresses (0x11, 0x15, 0x43) are included in the value field of the response slave information. And 0x78), as shown in Figure 2B. Each slave device that needs to answer can use its own address in the value field as its own response order.
  • a Type field value of 3 indicates that the Answer Indicator bit in the Value field indicates that the slave device that needs to answer has replied.
  • the first to the 247th bits correspond to the address: 0x01 to 0xF7, that is, the first bit corresponding address: 0x01, the second bit corresponding address: 0x02, ..., the 247th bit corresponding address: 0x F7.
  • a value of 1 for the response indication bit may indicate that a response is required, and a value of 0 indicates that no response is required. For example, if the 5th bit is set to 1, the slave device with the address 0x05 needs to answer the broadcast frame. The slave device that needs to respond can use its own response indication bit in the sequence of all response indication bits with a value of 1 as its own response sequence.
  • the master device can determine the type of the response slave information according to the number of slave devices that need to respond.
  • the response slave information can be implemented with a Type field value of one.
  • the response slave information can be implemented with a Type field value of 2; if the number is greater than 31, the response slave information can be of type
  • the (Type) field value is an implementation of 3.
  • the first slave device determines, according to the response slave information, that the broadcast frame needs to be acknowledged, the first slave device determines a response start time according to the response slave information, and at the response start time. Respond.
  • the first slave device determines, according to the answering slave information in the broadcast frame, whether the broadcast frame needs to be answered. If it is determined according to the response slave information that the broadcast frame does not need to be acknowledged, the information in the broadcast frame may be recorded, and then the broadcast frame is discarded. If it is determined that the broadcast frame needs to be answered according to the response slave information, the first slave device determines a response start time according to the response slave information, and responds at the response start time, the first slave The device is one of the plurality of slave devices.
  • the determining, by the first slave device, the response time according to the response slave information specifically includes:
  • the first slave device calculates a response start time of the first slave device according to a single point timeout duration and a response order of the first slave device.
  • the first slave device has a response order of N, N ⁇ 1.
  • D represents the single point timeout duration, and the unit is usually microseconds ( ⁇ s) or milliseconds (ms).
  • the response start time Tsn T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame.
  • T0 is the time at which the first slave device receives the broadcast frame.
  • the time difference between the received broadcast frame of each slave device and the broadcast frame sent by the master device may be ignored.
  • T0 is also the time when the master device completes the transmission of the broadcast frame, and each slave device in the network starts to calculate the response start time from T0.
  • the broadcast frame further includes a single point timeout duration.
  • the single point timeout duration is the maximum duration required for each slave device designated by the master device to answer the broadcast frame for the broadcast frame.
  • the master device may determine the single point timeout duration according to factors in the broadcast frame, slave processing speed, bus communication rate, and the like.
  • the single-point delay duration can also be pre-configured on the master device and each slave device. In this way, When receiving any broadcast frame including the response slave information, the slave device calculates the response start time according to the preset single-point timeout period.
  • the single point timeout duration is generally not less than the actual length of time required for the slave device to respond, and may be an empirical value. In the embodiment of the present invention, the single-point timeout period must be longer than the response time of the slave device with the slowest response in the network. For example, there are 200 slave devices in the RS-485 bus network, and the response duration may be 10ms, 20ms, 25ms, 50ms, 80ms, 95ms, and the longest response time is 95ms. In order to ensure that each slave device has enough time to complete the response, the single point timeout should be no less than 95ms.
  • the slave device waits sequentially in accordance with the response order and the single-point timeout duration, it is possible to avoid a response collision between the slave devices.
  • the actual length of time required for different slave devices to respond in the network is different.
  • Many slave devices usually have a response time that is less than the single-point timeout period. Therefore, the slave device in the response sequence can adjust its own response start time in real time according to the response order of the previous slave device, and avoid the delay caused by the fixed single-point timeout waiting time.
  • the first slave device may update its own according to the response end time of the second slave device in the response sequence (ie, the time when the response is completed and the response frame is sent) The start time of the response. Specifically, before reaching the response start time (Tsn) of the first slave device, the first slave device listens for communication on the RS-485 bus to determine whether there is a response from the prior slave device. . If the first slave device does not hear the response frame of the other slave device in the response order, the first slave device responds when the response start time Tsn is reached.
  • the first slave device detects the response frame of the second slave device in the response order before reaching the intermediate time before Tsn, the first slave device updates its response start time (Tsn) according to the intermediate time. .
  • Tsn response start time
  • the time difference between the response frame of the second slave device and the response frame of the second slave device may be ignored.
  • the intermediate time is equal to the time at which the second slave device completes the response frame transmission, that is, equal to the response end time of the second slave device.
  • the broadcast implementation method provided by the embodiment of the present invention is described below in conjunction with a specific example.
  • the master device completes the transmission of the broadcast frame at time T0
  • the single-point timeout period is 100 ms
  • the type (Type) field value of the response slave information of the broadcast frame is 2
  • the specified address in the Value field is 0x03, 0x06.
  • the four slaves of 0x0A and 0x13 acknowledge the broadcast frame.
  • each slave device in the network determines whether its own address is in the response slave information of the broadcast frame to determine whether it wants to answer the broadcast frame.
  • the four slave devices 0x03, 0x06, 0x0A, and 0x13 determine that they want to answer the broadcast frame, respectively acquire respective response sequences, and calculate respective response start times. Specific The process is as follows:
  • the slave device 6 is the second slave device that needs to be answered. In this example, it is assumed that the slave device 6 has a failure and cannot respond. Therefore, the slave device 6 occupies a single point timeout of 100 ms.
  • the slave device 18 continues to listen to the slave devices (slave device 6 and slave device 10) that have responded in the prior order. Since the slave device 6 fails, the slave device 18 does not hear the response frame of the slave device 6.
  • the response order of the slave device 18 is 4, the response order of the slave device 10 is 3, so no other slave device needs to respond between the slave device 18 and the slave device 10. Therefore, the response start time of the slave device 18 is the response of the slave device 10. End time. That is, the slave device 18 responds immediately after hearing the response frame of the slave device 10.
  • the slave device 6 has no response due to a fault, and the response duration is equal to the single-point delay duration. If the slave device 6 has no fault, the total response duration can be further shortened.
  • the first slave device may first detect whether the RS-485 bus is occupied when the response start time is reached, and then send the response frame again if it is confirmed that the bus is idle.
  • the response start time is calculated according to the single point timeout duration and the response order, and the response is reached.
  • the response is answered at the beginning, which avoids the response conflict between the slave devices, and improves the resource utilization and communication efficiency of the slave device.
  • the first slave device adjusts its own response start time in real time according to the response end time of the other slave devices in the response order, avoids the delay caused by the backoff collision according to the fixed single point timeout period, and improves the broadcast response efficiency. Thereby improving the performance of the entire RS-485 bus network.
  • FIG. 3 is a schematic flowchart diagram of another method for implementing a broadcast according to an embodiment of the present invention, where the method includes:
  • the master device generates and sends a broadcast frame, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in response order.
  • the slave device in the RS-485 bus network receives the broadcast frame sent by the master device.
  • the master device specifies, by using the response slave information in the broadcast frame, that the multiple slave devices answer the broadcast frame according to the response order.
  • the response order is an order in which the response frames are returned by the plurality of devices indicated by the response slave information.
  • the response slave information is in the TLV format. For details, refer to the description in step 101.
  • the broadcast frame further includes a single point timeout duration.
  • the master device may specify, for the broadcast frame, a maximum duration required for each slave device to answer the broadcast frame according to factors in the broadcast frame, a slave processing speed, a bus communication rate, and the like, ie, the Single point timeout period.
  • the single-point delay duration can also be pre-configured on the master device and each slave device. In this way, when receiving any broadcast frame including the response slave information, the slave device calculates the response start time according to the preset single-point timeout duration.
  • the master device may determine a response waiting period according to a single point timeout period and a quantity of the plurality of slave devices (the slave device that specifies the broadcast frame to be answered), and in the response waiting period Receiving a response frame sequentially returned by the plurality of slave devices.
  • the master device may send the updated to the unacknowledged slave device of the multiple slave devices. Broadcast frame.
  • the master device may also send a unicast frame to the slave devices that are not answered in the plurality of slave devices.
  • the method may further include: the master device records status information of each slave device according to the response frame returned by the multiple slave devices, such as a device version, a transmit power, a sleep time, and the like.
  • Generating, by the master device, a broadcast frame including: determining, by the master device, an address of the multiple slave devices; determining, according to an address and a preset condition of the multiple slave devices, the response slave information;
  • the broadcast information is generated from the slave information.
  • Determining, by the master device, the answering slave information according to an address and a preset condition of the multiple slave devices including:
  • each slave device can determine its own response order based on its own address.
  • the master device is to specify a plurality of slave devices (a plurality of slave devices consecutive to each other) in a range of addresses to respond in order
  • the response slave information of type 1 and in the value field of the response slave information Includes start address and end address. Accordingly, each slave device can determine its own response order based on the difference between its own address and the start address. It is also possible to use the response slave information of type 1 to designate all slave devices to respond in order, and the start address in the value field of the response slave information is the minimum address of the slave device, and the termination address is the maximum address of the slave device.
  • the responder slave information may be of type 2 or 3. Specifically, the master device may determine the type of the responding slave information according to the number of slave devices that need to be answered. When the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the response slave information is 2 (ie, the response slave information includes addresses of multiple slave devices that need to be answered), and each of the responders needs to be answered. Slave devices can use their own address in the value field as their response order.
  • the type of the response slave information is 3 (ie, the response slave information includes a response indication bit corresponding to each slave device), and needs to be answered.
  • the slave device can set its own response indication bit in the order of all response indication bits with a value of 1 as its own response order.
  • the preset threshold may be Where n is the number of bits of the address of the slave device. For example, when the number of bits of the address of the slave device in the RS-485 bus network is 8, the preset threshold is set to 32. When the number of slave devices to be answered is greater than or equal to 32, the type of the response slave information is 3. When the preset threshold is set to less than 32, the type of the response slave information is 2. In this way, when the number of slave devices to be answered is small, the address of the slave device that needs to be answered is directly carried in order, the length of the broadcast frame can be reduced, and the processing efficiency of the device can be improved, of course, except that the preset threshold is set to It can also be set to a larger or smaller value.
  • the response slave information of type 3 can be used.
  • the master device generates and transmits a broadcast frame including the response slave information
  • the slave device information indicates that the plurality of slave devices in the RS-485 bus network respond in response order to broadcast Realizing a multicast-like communication mechanism, compared with the traditional unicast or broadcast mode, can improve the resource utilization and communication efficiency of the master device, and also avoid broadcast response conflicts between multiple slave devices, thereby improving RS-485.
  • the performance of the bus network can improve the resource utilization and communication efficiency of the master device, and also avoid broadcast response conflicts between multiple slave devices, thereby improving RS-485.
  • FIG. 4 is a schematic structural diagram of a broadcast implementation apparatus according to an embodiment of the present invention, which is used to implement the broadcast implementation method shown in FIG. 1 according to an embodiment of the present invention.
  • the broadcast implementation device 40 includes a receiving module 401 and a processing module 402;
  • the receiving module 401 is configured to receive a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order Broadcast frame
  • the processing module 402 is configured to determine, according to the response slave information, that the broadcast frame needs to be answered, determine a response start time according to the response slave information, and respond at the response start time.
  • the broadcast implementation device 40 is deployed on a first of the plurality of devices.
  • the processing module 402 is specifically configured to determine, according to the response slave information in the broadcast frame, whether the broadcast frame needs to be acknowledged; if it is determined according to the response slave information that the broadcast frame does not need to be acknowledged, the recording station Decoding the information in the broadcast frame, and then discarding the broadcast frame; if it is determined that the broadcast frame needs to be answered according to the response slave information, determining a response start time according to the response slave information, and at the response start time Send an answer frame.
  • the processing module 402 is specifically configured to acquire, according to the response slave information, a response sequence of the first slave device, where the response sequence is that the first slave device indicates the multiple of the response slave information.
  • the order in which the slave devices respond; the answer start time of the first slave device is calculated according to the single point timeout duration and the response order of the first slave device.
  • the first slave device has a response order of N, N ⁇ 1.
  • D represents the single point timeout duration.
  • the response start time Tsn T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame.
  • the response start time Tsn T0, that is, the first slave The device starts responding immediately after receiving the broadcast frame.
  • the first slave device may update its response start time according to the response end time of the second slave device (ie, the time when the response frame is sent) according to the response order. .
  • the processing module 402 is further configured to adjust the response start time of the first slave device in real time according to the response end time of the second slave device in the response sequence. Specifically, the processing module 402 listens for communication on the RS-485 bus before determining the response start time (Tsn) of the first slave device to determine whether there is a response from the prior slave device. If the response frame of the other slave device whose response order is prior is not detected, the response is reached when the response start time Tsn is reached. If the response frame of the second slave device in the response order is detected at an intermediate time before the arrival of Tsn, the response start time (Tsn) of the first slave device is updated according to the intermediate time.
  • Tsn response start time
  • the intermediate time Tek before the response start time Tsn of the first slave device is reached, the response frame of the second slave device having the response order K (K ⁇ N) is detected, and the first slave device is updated.
  • the broadcast implementation apparatus provided by the embodiment of the present invention may determine, according to the response slave information included in the broadcast frame, whether the broadcast frame needs to be acknowledged, and when determining that the broadcast frame needs to be answered, calculate according to the single point timeout duration and the response order. At the start of the response, the response is acknowledged at the start of the response, and the response conflict of the slave device is avoided.
  • the broadcast implementing apparatus provided by the embodiment of the present invention adjusts its own response start time in real time according to the response end time of the other slave devices in the response order, thereby avoiding the delay caused by the fixed single-point timeout period backoff conflict, and improving The response efficiency improves the performance of the entire RS-485 bus network.
  • FIG. 5 is a schematic structural diagram of a slave device according to an embodiment of the present invention, which is applied to an RS-485 bus network, and is used to implement the broadcast implementation method shown in FIG. 1 according to an embodiment of the present invention.
  • the slave device 50 includes a processor 501 and a communication interface 502.
  • the slave device 50 is configured to implement the first slave device in the method shown in FIG. 1 of the embodiment of the present invention.
  • the processor 501 and the communication interface 502 are connected to each other.
  • the communication interface 503 includes an RS-485 chip for communicating with other devices in the RS-485 bus network.
  • the processor 501 is configured to receive, by using the communication interface 502, a broadcast frame sent by a master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate the RS-485 bus network.
  • the plurality of slave devices respond to the broadcast frame in order.
  • the processor 501 is further configured to determine, according to the responding slave information in the broadcast frame, whether the broadcast frame needs to be answered; when determining, according to the responding slave information, that the broadcast frame needs to be answered, according to the The response slave information determines the response start time and responds at the response start time.
  • the processor 501 is typically a microcontroller unit (MCU); it may also include a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device. .
  • MCU microcontroller unit
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • the processor 501 is further configured to: when determining, according to the responding slave information, that the broadcast frame does not need to be acknowledged, record information in the broadcast frame, and discard the broadcast frame.
  • the processor 501 may specifically acquire, according to the response slave information, a response sequence of the slave device 50 (ie, the first slave device), where the response sequence is that the first slave device is in the response slave
  • the order in which the plurality of slave devices indicate the response is indicated by the information; and the response start time of the first slave device is further calculated according to the single point timeout duration and the response order of the first slave device.
  • the first slave device has a response order of N, N ⁇ 1.
  • D represents the single point timeout duration, and the unit is usually microseconds ( ⁇ s) or milliseconds (ms).
  • the response start time Tsn T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame.
  • the processor 501 is further configured to adjust the slave device 50 in real time according to the response end time of the second slave device in the response sequence (ie, the first From the device) The start of the response.
  • the processor 501 further includes a memory for storing the single point timeout duration.
  • the communication interface 502 is further configured to send a response frame to the broadcast frame.
  • FIG. 6 is a schematic structural diagram of a master device according to an embodiment of the present invention, which is used to implement the broadcast implementation method shown in FIG. 3 according to an embodiment of the present invention.
  • the master device 60 includes a generating module 601, a sending module 602, and a receiving module 603.
  • the generating module 601 is configured to generate a broadcast frame, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order;
  • the sending module 602 is configured to send the broadcast frame.
  • the slave device in the RS-485 bus network will receive the broadcast frame.
  • the broadcast implementing apparatus 60 specifies, by using the response slave information in the broadcast frame, that the multiple slave devices answer the broadcast frame in order.
  • the receiving module 603 is configured to receive a response frame returned by the multiple slave devices.
  • the response slave information is in the TLV format. For details, refer to the description in step 101.
  • the broadcast frame further includes a single point timeout duration.
  • the generating module 601 is configured to determine an address of the multiple slave devices, determine the responding slave information according to addresses and preset conditions of the multiple slave devices, and generate the broadcast frame according to the responding slave information .
  • the master device 60 can employ any type of response slave information to designate the plurality of slave devices to respond in order.
  • the preset conditions include:
  • master device 60 If the master device 60 is to designate all slave devices to respond in order, it is preferred to use answer slave information of type 0.
  • the master device wants to specify multiple consecutive slave addresses to respond in order, it is preferable to use the responder slave information of type 1.
  • the broadcast implementing device 60 may determine the type of the response slave information according to a preset condition.
  • the preset condition includes: when the number of slave devices that need to be answered is less than a preset threshold, determining that the type of the response slave information is 2, and each slave device that needs to respond The device can use its own address in the value field as its own response order.
  • the slave device that needs to respond may set its own response indicator to all the response indicator bits with a value of 1.
  • the order is as its own response order.
  • the preset threshold may be Where n is the number of bits of the address of the slave device. Of course, except that the preset threshold is set to It can also be set to a larger or smaller value.
  • the response slave information of type 3 can be used.
  • the receiving module 603 may determine a response waiting period according to a single point timeout duration and the number of the plurality of slave devices (specifying slave devices that need to answer the broadcast frame), and receive the multiple during the response waiting period.
  • the response frame returned from the device.
  • the master device 60 may further include: a recording module, configured to record, according to the response frame returned by the multiple devices, status information corresponding to each device, such as a device version, a transmit power, a sleep time, and the like.
  • a recording module configured to record, according to the response frame returned by the multiple devices, status information corresponding to each device, such as a device version, a transmit power, a sleep time, and the like.
  • the master device provided by the embodiment of the present invention generates and sends a broadcast frame including the response slave information, by which the slave device information indicates that multiple devices respond in response order, and broadcasts a multicast-like communication mechanism.
  • the traditional unicast or broadcast mode can improve the communication efficiency while avoiding the broadcast response conflict between multiple slave devices, thereby improving the performance of the entire RS-485 bus network.
  • FIG. 7 is a schematic structural diagram of another main device according to an embodiment of the present invention.
  • the master device 70 includes a processor 701 and a communication interface 702.
  • the master device 70 is configured to implement the broadcast implementation method shown in FIG. 3 of the embodiment of the present invention.
  • the processor 701 and the communication interface 702 are connected to each other.
  • the communication interface 702 includes an RS-485 chip for communicating with slave devices in the RS-485 bus network.
  • the processor 701 is configured to generate a broadcast frame and send the broadcast frame by using the communication interface 702.
  • the broadcast frame includes response slave information, and the response slave information is used to indicate the RS-485 bus. Multiple slave devices in the network respond in order.
  • the processor 701 is further configured to receive, by using the communication interface 702, a response frame returned by the multiple slave devices.
  • the processor 701 is typically an MCU and may also include a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • the response slave information is in the TLV format. For details, refer to the description in step 101.
  • the processor 701 is specifically configured to determine an address of the multiple slave devices, determine the response slave information according to an address and a preset condition of the multiple slave devices, and generate a location information according to the response slave information. Said broadcast frame.
  • the processor 701 further includes a memory for storing an address of the slave device in the RS-485 bus network.
  • the master device 70 may employ any type of response slave information to designate the plurality of slave devices to press Answer in order.
  • the preset condition may be specifically referred to in the method step 302 shown in FIG.
  • the broadcast frame further includes a single point timeout duration.
  • the processor 701 is further configured to determine the single point timeout duration according to factors in the broadcast frame, a slave processing speed, a bus communication rate, and the like.
  • the single point timeout duration is the maximum length of time required for the slave device to answer the broadcast frame.
  • the single-point delay duration can also be pre-configured on the master device and each slave device.
  • the memory can also be used to store the single point timeout duration.
  • the processor 701 may determine a response waiting period according to the single-point timeout duration and the number of the plurality of slave devices (specifying slave devices that need to answer the broadcast frame), and receive the receiving period during the response waiting period. A response frame returned by multiple slave devices.
  • the processor 701 is further configured to record, according to the response frame returned by the multiple devices, status information corresponding to each device, such as a device version, a transmit power, a sleep time, and the like.
  • FIG. 8 is a schematic diagram of an RS-485 bus network according to an embodiment of the present invention, including a master device 801 and a plurality of slave devices 802.
  • a master device 801 for details of the working principle, structure, and function of the main device 801, refer to FIG. 6 or 7 of the embodiment of the present invention, and details are not described herein again.
  • the working principle, structure, and function of the device 802 refer to FIG. 4 or 5 of the embodiment of the present invention, and details are not described herein again.
  • the broadcast implementation method provided by the embodiment of the present invention can also be applied to a low-rate wireless personal area network (LR-WPAN) in a star networking mode.
  • the coordinator in the LR-WPAN is equivalent to the master device in the embodiment of the present invention.
  • the non-coordinator device a full-function device (FFD) and a reduced-function device (RFD) are equivalent.
  • the embodiments of the present invention are described based on the RS-485 bus network and are not intended to limit the present invention.

Landscapes

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

Abstract

Disclosed are a broadcast realisation method, wherein a slave device receives a broadcast frame sent by a master device, the broadcast frame comprising response slave machine information for instructing a plurality of slave devices in an RS-485 bus network to respond in order; and when determining that a response is required according to the response slave machine information, a first slave device calculates a response starting moment according to the response slave machine information, and responds when the response starting moment is reached. By means of the broadcast realisation method, a plurality of slave devices in an RS-485 bus network respond to a broadcast frame in order, and response collision between the slave devices can be avoided, thus improving the communication efficiency of the RS-485 bus network.

Description

广播实现方法、装置和设备Broadcast implementation method, device and device 技术领域Technical field
本发明涉及通信领域,尤其涉及一种广播实现方法、装置和设备。The present invention relates to the field of communications, and in particular, to a broadcast implementation method, apparatus, and device.
背景技术Background technique
推荐标准(Recommended Standard,RS)-485规定了串行通信系统中驱动器(driver/generator/transmitter)和接收器(receiver)的电气特性。RS-485由电信行业协会和电子工业联盟(Telecommunications Industry Association and Electronic Industries Alliance,TIA/EIA)联合发布,因此也称为EIA-485或TIA-485。The Recommended Standard (RS)-485 specifies the electrical characteristics of the driver (driver/generator/transmitter) and receiver (receiver) in a serial communication system. RS-485 is jointly released by the Telecommunications Industry Association and Electronic Industries Alliance (TIA/EIA) and is therefore also known as EIA-485 or TIA-485.
RS-485仅规定了驱动器和接收器的电气特性,没有规定或推荐任何通信协议,也就是说,RS-485仅规定了物理层。Modbus协议是一种主(master)/从(slave)架构的通信协议。基于Modbus协议的网络中,有一个节点是主节点,其他使用Modbus协议参与通信的节点是从节点。每一个从节点都有一个唯一的地址。基于RS-485部署的总线型网络(以下称为RS-485总线网络)采用主从通信方式,因此Modbus设备常常通过RS-485物理层进行通信。Modbus协议约定,地址0x01至0xF7为从机地址,0x00表示广播地址。RS-485 only specifies the electrical characteristics of the driver and receiver. No communication protocol is specified or recommended. That is, RS-485 only specifies the physical layer. The Modbus protocol is a communication protocol for the master/slave architecture. In the Modbus-based network, one node is the master node, and other nodes that use the Modbus protocol to participate in communication are slave nodes. Each slave has a unique address. The bus type network based on RS-485 deployment (hereinafter referred to as RS-485 bus network) adopts master-slave communication mode, so Modbus devices often communicate through the RS-485 physical layer. According to the Modbus protocol, addresses 0x01 to 0xF7 are slave addresses, and 0x00 is a broadcast address.
RS-485总线网络中的主设备需要与多个从设备通信时,传统方式可以是向该多个从设备分别发送单播帧,也可以是向全网发送广播帧。但是,多次发送单播帧的方式,消耗主设备的大量资源且耗时较长。而发送广播帧的方式,所有从设备收到广播帧后都会应答广播帧,从设备之间存在应答冲突,需要不断尝试应答和退避冲突,浪费从设备的处理资源并造成RS-485总线长时间被占用。When the master device in the RS-485 bus network needs to communicate with multiple slave devices, the traditional method may be to separately send a unicast frame to the multiple slave devices, or send a broadcast frame to the entire network. However, the method of transmitting a unicast frame multiple times consumes a large amount of resources of the master device and takes a long time. In the manner of sending broadcast frames, all slave devices will respond to the broadcast frame after receiving the broadcast frame. There is a response conflict between the slave devices. It is necessary to continuously try to answer and backoff conflicts, wasting the processing resources of the slave device and causing the RS-485 bus to be long. Occupied.
发明内容Summary of the invention
本发明实施例提供了一种广播实现方法和装置,主设备发送包括应答从机信息的广播帧,指示RS-485总线网络上的多个设备按照次序作出应答,以避免多个设备间应答广播时冲突,提高了广播通信效率,从而提高所述RS-485总线网络的性能。Embodiments of the present invention provide a broadcast implementation method and apparatus, where a master device transmits a broadcast frame including a response slave information, and instructs multiple devices on the RS-485 bus network to respond in order to avoid a response broadcast between multiple devices. Time conflicts improve the efficiency of broadcast communication, thereby improving the performance of the RS-485 bus network.
第一方面,提供一种广播实现方法,用于RS-485总线网络中。该方法包括:In a first aspect, a broadcast implementation method is provided for use in an RS-485 bus network. The method includes:
第一从设备接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照次序作出应答;Receiving, by the first slave device, a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order;
当根据所述应答从机信息确定需要应答所述广播帧时,所述第一从设备根据所述应答从机信息获取应答开始时刻,并在到达所述应答开始时刻时作出应答。When it is determined that the broadcast frame needs to be answered according to the response slave information, the first slave device acquires a response start time according to the response slave information, and responds when the response start time is reached.
从设备根据广播帧中的应答从机信息确定需要应答时,确定应答次序并计算应答开始时刻,并在达到应答开始时刻再作出应答,避免了从设备间的广播应答冲突,提高了从设备的资源利用率和通信成功率。When the slave device determines that the response needs to be answered according to the response slave information in the broadcast frame, determines the response sequence and calculates the response start time, and then responds when the response start time is reached, thereby avoiding the broadcast response conflict between the slave devices, and improving the slave device. Resource utilization and communication success rate.
在第一方面的第一种可能的实现中,所述第一从设备根据所述应答从机信息获取应答开始时刻,包括: In a first possible implementation of the first aspect, the first slave device acquires a response start time according to the responding slave information, and includes:
所述第一从设备根据所述应答从机信息获取所述第一从设备的应答次序N,所述应答次序为所述第一从设备在所述多个从设备中应答所述广播帧的次序;Obtaining, by the first slave device, the response sequence N of the first slave device according to the response slave information, where the response sequence is that the first slave device answers the broadcast frame in the multiple slave devices order;
所述第一从设备根据单点超时时长和所述第一从设备的应答次序,计算所述第一从设备的应答开始时刻。当单点超时时长为D,所述第一从设备的应答次序为N,N≥1,所述第一从设备的应答开始时刻Tsn为T0+(N-1)*D,其中,T0是所述第一从设备收到所述广播帧的时刻。The first slave device calculates a response start time of the first slave device according to a single point timeout duration and a response order of the first slave device. When the single-point timeout is long, the response order of the first slave device is N, N≥1, and the response start time Tsn of the first slave device is T0+(N-1)*D, where T0 is The moment when the first slave device receives the broadcast frame.
结合第一方面或第一方面的第一种可能的实现,在第一方面的第二种可能的实现中,In conjunction with the first aspect or the first possible implementation of the first aspect, in a second possible implementation of the first aspect,
当所述第一从设备的应答次序N为1,即,所述第一从设备为第一个要作出应答的从设备时,所述第一从设备的应答开始时刻Tsn=T0,即,所述第一从设备收到所述广播帧后立即开始应答。When the response order N of the first slave device is 1, that is, the first slave device is the first slave device to be replied, the response start time of the first slave device is Tsn=T0, that is, The first slave device starts to respond immediately after receiving the broadcast frame.
当所述第一从设备的应答次序N≥2时,所述第一从设备在到达所述第一从设备的应答开始时刻Tsn前,侦听RS-485总线;根据应答次序在先的第二从设备的应答结束时刻Tek,更新所述第一从设备的应答开始时刻Tsn,更新后的Tsn为Tek+(N-K-1)*D,其中,K为所述第二从设备的应答次序,N>K≥1。所述第一从设备可以根据所述第二从设备的地址和所述广播帧获得所述第二从设备的应答次序K。When the response order of the first slave device is N≥2, the first slave device listens to the RS-485 bus before reaching the response start time Tsn of the first slave device; according to the response order The response start time Tek of the second slave device updates the response start time Tsn of the first slave device, and the updated Tsn is Tek+(NK-1)*D, where K is the response order of the second slave device. N>K≥1. The first slave device may obtain the response order K of the second slave device according to the address of the second slave device and the broadcast frame.
第一从设备通过侦听应答次序在线的从设备的应答帧,并根据应答次序在先的从设备的应答结束时刻,实时调整自己的应答开始时刻,可以避免按照固定的单点超时时长退避冲突所造成的延时,提高广播应答效率。The first slave device can adjust the response start time of the slave device in the response sequence, and adjust the response start time in real time according to the response end time of the previous slave device in the response sequence, thereby avoiding the backoff conflict according to the fixed single point timeout duration. The resulting delay increases the efficiency of the broadcast response.
结合第一方面及其上述可能的实现中的任一种,在第一方面的第三种可能的实现中,所述应答从机信息为类型长度值(type-length-value,简称TLV)格式;In combination with the first aspect and any of the foregoing possible implementations, in a third possible implementation of the first aspect, the response slave information is a type-length-value (TLV) format. ;
类型为0的应答从机信息,指示所述RS-485总线网络中的所有从设备需要按照次序应答。相应地,各个从设备可以根据自己的地址与该起始地址的差值确定自己的应答次序;The response slave information of type 0 indicates that all slave devices in the RS-485 bus network need to respond in order. Correspondingly, each slave device can determine its own response order according to the difference between its own address and the start address;
类型为1的应答从机信息,指示值字段中起始地址到终止地址范围内的多个从设备需要按照次序应答。相应地,各个从设备可以根据自己的地址与所述起始地址的差值确定自己的应答次序;The response slave information of type 1 indicates that multiple slave devices in the value field from the start address to the end address range need to respond in order. Correspondingly, each slave device can determine its own response order according to the difference between its own address and the starting address;
类型为2的应答从机信息,指示值字段中各个地址对应的从设备需要按照次序应答。相应地,需要应答的各个从设备可以将自己的地址在值字段中的顺序作为自己的应答次序;The response slave information of type 2 indicates that the slave devices corresponding to the respective addresses in the value field need to respond in order. Correspondingly, each slave device that needs to respond can use its own address in the value field as its own response order;
类型为3的应答从机信息,指示值字段中应答指示位指示需要应答的从设备按照次序应答。相应地,需要应答的从设备可以将自己对应的应答指示位在所有值为1的应答指示位中的顺序作为自己的应答次序。The response slave information of type 3 indicates that the response indication bit in the value field indicates that the slave devices that need to answer are responsive in order. Correspondingly, the slave device that needs to respond can use its own response indication bit in the sequence of all response indication bits with a value of 1 as its own response sequence.
结合第一方面及其上述可能实现中的任一种,在第一方面的第四种可能的实现中,若所述第一从设备根据所述应答从机信息确定不需要应答所述广播帧,可以记录所述广播帧中的信息,然后丢弃所述广播帧。 In conjunction with the first aspect and any of the foregoing possible implementations, in a fourth possible implementation of the first aspect, the first slave device determines, according to the response slave information, that the broadcast frame does not need to be acknowledged The information in the broadcast frame can be recorded and then discarded.
第二方面提供了一种用于RS-485总线网络中的广播实现方法,包括:A second aspect provides a broadcast implementation method for use in an RS-485 bus network, comprising:
主设备生成并发送广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照应答次序作出应答,所述应答次序为所述应答从机信息所指示的所述多个从设备返回应答帧的次序;The master device generates and transmits a broadcast frame, the broadcast frame includes response slave information, and the response slave information is used to indicate that the plurality of slave devices in the RS-485 bus network respond in response order, the response The order is an order in which the response frame is returned by the plurality of slave devices indicated by the response slave information;
所述主设备接收所述多个从设备按照应答次序返回的应答帧。The master device receives the response frame returned by the plurality of slave devices in response sequence.
通过主设备生成并发送包括应答从机信息的广播帧,指示RS-485总线网络中的多个从设备按照应答次序作出应答,可以避免多个从设备间的广播应答冲突,提高广播通信成功率,从而提高RS-485总线网络的性能。A broadcast frame including the response slave information is generated and transmitted by the master device, indicating that multiple slave devices in the RS-485 bus network respond in response order, which can avoid broadcast response conflict between multiple slave devices, and improve broadcast communication success rate. To improve the performance of the RS-485 bus network.
在第二方面的第一种可能的实现中,所述主设备生成所述广播帧,包括:In a first possible implementation of the second aspect, the generating, by the master device, the broadcast frame includes:
所述主设备确定所述多个从设备的地址;The master device determines an address of the plurality of slave devices;
根据所述多个从设备的地址和预设条件,确定所述应答从机信息;Determining the response slave information according to an address of the plurality of slave devices and a preset condition;
根据所述应答从机信息生成所述广播帧。Generating the broadcast frame based on the response slave information.
结合第二方面的第一种可能的实现,在第二方面的第二种可能的实现中,所述应答从机信息为TLV格式;所述预设条件包括:With reference to the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the response slave information is a TLV format; the preset condition includes:
若要指定所述RS-485总线网络中所有从设备按照次序应答,采用类型为0的应答从机信息。相应地,应答从机信息中的长度字段值为0,值字段为空;To specify that all slave devices in the RS-485 bus network respond in order, a response slave information of type 0 is used. Correspondingly, the value of the length field in the response slave information is 0, and the value field is empty;
若要指定地址连续的多个从设备按照次序应答,采用类型为1的应答从机信息。相应地,应答从机信息中的值字段中包括起始地址和终止地址,长度字段值为2;To specify that multiple slaves with consecutive addresses respond in order, a response slave information of type 1 is used. Correspondingly, the value field in the response slave information includes a start address and a termination address, and the length field value is 2;
若所述主设备要指定地址不连续的多个从设备按照次序应答,可以根据需要应答的从设备的数量,确定所述应答从机信息的类型。当需要应答的从设备的数量小于预设阈值时,确定所述应答从机信息的类型为2。相应地,值字段中包括需要应答的多个从设备的地址。当需要应答的从设备的数量大于等于预设阈值时,确定所述应答从机信息的类型为3。相应地,值字段中需要应答的从设备对应的应答指示位均置为1。If the master device wants to specify that multiple slave devices whose addresses are not consecutive are answered in order, the type of the responding slave information may be determined according to the number of slave devices that need to be answered. When the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the response slave information is 2. Accordingly, the value field includes the addresses of multiple slave devices that need to be answered. When the number of slave devices that need to be answered is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3. Correspondingly, the response indication bit corresponding to the slave device in the value field that needs to be acknowledged is set to 1.
所述预设阈值可以为
Figure PCTCN2017109754-appb-000001
其中n为从设备的地址的位数。
The preset threshold may be
Figure PCTCN2017109754-appb-000001
Where n is the number of bits of the address of the slave device.
主设备根据需要应答的从设备的情况(数量,地址)确定应答从机信息,在指定应答次序,避免从设备间应答冲突的同时,可以尽量缩短广播帧的长度,提高带宽利用率。The master device determines the response slave information according to the condition (number, address) of the slave device that needs to be answered, and specifies the response sequence to avoid the collision between the devices, and can shorten the length of the broadcast frame and improve the bandwidth utilization.
结合第二方面及第二方面上述可能的实现中的任一种,在第二方面的第三种可能的实现中,所述方法还包括:所述主设备根据所述多个从设备返回的应答帧,记录各个从设备的状态信息;所述状态信息包括设备版本,发射功率,休眠时间等。With reference to the second aspect, and any one of the foregoing possible implementations of the second aspect, in a third possible implementation of the second aspect, the method further includes: returning, by the master device, the multiple slave devices The response frame records status information of each slave device; the status information includes a device version, a transmit power, a sleep time, and the like.
结合第二方面及第二方面上述可能的实现中的任一种,在第二方面的第四种可能的实现中,所述主设备接收所述多个从设备按照应答次序返回的应答帧,包括:所述主设备根据单点超时时长和所述多个从设备的数量确定应答等待周期,并在所述应答等待周期内,接收所述多个从设备依次返回的应答帧。With reference to the second aspect, and any one of the foregoing possible implementations of the second aspect, in a fourth possible implementation of the second aspect, the master device receives the response frame returned by the multiple slave devices in the response order, The method includes: determining, by the master device, a response waiting period according to a single point timeout duration and the number of the multiple slave devices, and receiving, in the response waiting period, a response frame sequentially returned by the multiple slave devices.
第三方面,提供了一种广播实现装置,具有实现上述第一方面中第一从设备 的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。In a third aspect, a broadcast implementation apparatus is provided, which has the first slave device in the first aspect described above The function. The functions may be implemented by hardware or by corresponding software implemented by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
第四方面,提供了一种从设备,用于实现上述第一方面的广播实现方法。所述从设备包括处理器和通信接口,所述处理器和通信接口相互连接。所述设备还可以包括存储器,用于存储计算机程序,该计算机程序包括程序指令;所述处理器执行所述程序指令,执行如上述第一方面所述广播实现方法。In a fourth aspect, a slave device is provided for implementing the broadcast implementation method of the first aspect described above. The slave device includes a processor and a communication interface, the processor and the communication interface being connected to each other. The apparatus can also include a memory for storing a computer program, the computer program including program instructions, and the processor executing the program instructions to perform the broadcast implementation method of the first aspect described above.
第五方面,提供了一种计算机存储介质,用于储存为上述第一从设备所用的计算机软件指令,其包含用于执行上述第一方面及其可能实现中任一种所设计的程序。In a fifth aspect, a computer storage medium is provided for storing computer software instructions for use in the first slave device described above, comprising a program designed to perform any of the first aspect described above and its possible implementations.
第六方面,提供了一种主设备,具有实现上述第二方面中主设备的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。In a sixth aspect, a master device is provided, having the function of implementing the master device in the second aspect described above. The functions may be implemented by hardware or by corresponding software implemented by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
第七方面,提供了一种主设备,用于实现上述第二方面的广播实现方法。所述主设备包括处理器和通信接口,所述处理器和通信接口相互连接。所述设备还可以包括存储器,用于存储计算机程序,该计算机程序包括程序指令;所述处理器执行所述程序指令,执行如上述第二方面所述广播实现方法。In a seventh aspect, a master device is provided for implementing the broadcast implementation method of the second aspect above. The master device includes a processor and a communication interface, and the processor and the communication interface are connected to each other. The apparatus can also include a memory for storing a computer program, the computer program comprising program instructions, the processor executing the program instructions, and performing the broadcast implementation method of the second aspect described above.
第八方面,提供了一种计算机存储介质,用于储存为上述主设备所用的计算机软件指令,其包含用于执行上述第二方面及其可能实现中任一种所设计的程序。In an eighth aspect, a computer storage medium is provided for storing computer software instructions for use in the above-described host device, comprising a program designed to perform any of the above-described second aspects and possible implementations thereof.
第九方面,提供了一种RS-485总线网络,包括主设备和多个从设备;所述主设备如上述第六方面或第七方面所述,所述多个从设备中每个从设备如上述第三方面或第四方面所述。According to a ninth aspect, there is provided an RS-485 bus network, comprising: a master device and a plurality of slave devices; the master device, as described in the sixth aspect or the seventh aspect, each of the plurality of slave devices As described in the third aspect or the fourth aspect above.
附图说明DRAWINGS
图1是本发明实施例提供的一种广播实现方法的流程示意图;1 is a schematic flowchart of a broadcast implementation method according to an embodiment of the present invention;
图2A是本发明实施例提供的一种类型的应答从机信息的结构示意图;2A is a schematic structural diagram of a type of response slave information according to an embodiment of the present invention;
图2B是本发明实施例提供的另一种类型的应答从机信息的结构示意图;2B is a schematic structural diagram of another type of response slave information according to an embodiment of the present invention;
图2C是本发明实施例提供的又一种类型的应答从机信息的结构示意图;2C is a schematic structural diagram of still another type of response slave information according to an embodiment of the present invention;
图3是本发明实施例提供的另一种广播实现方法的流程示意图;FIG. 3 is a schematic flowchart diagram of another broadcast implementation method according to an embodiment of the present invention;
图4是本发明实施例提供的一种广播实现装置的结构示意图;4 is a schematic structural diagram of a broadcast implementation apparatus according to an embodiment of the present invention;
图5是本发明实施例提供的一种从设备的结构示意图;FIG. 5 is a schematic structural diagram of a slave device according to an embodiment of the present disclosure;
图6是本发明实施例提供的一种主设备的结构示意图;FIG. 6 is a schematic structural diagram of a master device according to an embodiment of the present disclosure;
图7是本发明实施例提供的另一种主设备的结构示意图;FIG. 7 is a schematic structural diagram of another main device according to an embodiment of the present disclosure;
图8是本发明实施例提供的RS-485总线网络的示意图。FIG. 8 is a schematic diagram of an RS-485 bus network according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明实施例作进一步详细的说明。The above described objects, features, and advantages of the embodiments of the present invention will become more apparent and understood.
本发明实施例提供一种用于RS-485总线网络中的广播实现方法,主设备发 送的广播帧中包括应答从机信息,该应答从机信息用于指示RS-485总线网络中多个从设备按照次序对该广播帧作出应答,可以避免该多个从设备应答时冲突,提高了通信效率和网络性能。且各个从设备可以根据在先从设备的应答,重新计算应答等待时间,缩短应答等待时长,从而进一步提高通信效率。Embodiments of the present invention provide a broadcast implementation method for an RS-485 bus network, where a master device sends The sent broadcast frame includes response slave information, and the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond to the broadcast frame in order, thereby avoiding conflicts when the multiple slave devices respond, and improving Communication efficiency and network performance. Moreover, each slave device can recalculate the response waiting time according to the response of the prior slave device, and shorten the response waiting time, thereby further improving communication efficiency.
参见图1,为本发明实施例提供的一种广播实现方法的流程示意图,用于RS-485总线网络中,该方法包括:FIG. 1 is a schematic flowchart of a broadcast implementation method according to an embodiment of the present invention. The method is used in an RS-485 bus network, and the method includes:
101、第一从设备接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中多个从设备按照次序对所述广播帧作出应答;101. The first slave device receives a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network are in the order of Responding to the broadcast frame;
所述主设备发送广播帧时,所述RS-485总线网络中从设备都会收到该广播帧。本发明实施例中,通过扩展该广播帧,携带应答从机信息,主设备可以指定需要通信的多个从设备按照次序作出应答。When the master device sends a broadcast frame, the slave device in the RS-485 bus network receives the broadcast frame. In the embodiment of the present invention, by extending the broadcast frame and carrying the response slave information, the master device may specify that the plurality of slave devices that need to communicate respond in order.
根据该应答从机信息,不需要通信的从设备收到该广播帧后,无需作出应答,避免了对RS-485总线的占用,也无需消耗资源侦听总线是否空闲,从而提高了整个RS-485总线网络的通信效率和性能。According to the response slave information, after receiving the broadcast frame from the slave device that does not need to communicate, there is no need to respond, avoiding the occupation of the RS-485 bus, and not consuming the resource to listen to whether the bus is idle, thereby improving the entire RS- Communication efficiency and performance of the 485 bus network.
所述应答从机信息为类型长度值(type-length-value,简称TLV)格式。参见图2A,2B和2C所示的应答从机信息示意图,本发明实施例中的应答从机信息说明如下。The response slave information is a type-length-value (TLV) format. Referring to the schematic diagram of the response slave information shown in Figs. 2A, 2B and 2C, the response slave information in the embodiment of the present invention is explained as follows.
类型(Type)字段值为0表示:网络中的所有从设备需要按照次序(即按照从设备的地址顺序)应答。此时长度(Length)字段的值为0(字节),表示值(Value)字段所包含数据的长度为0字节,也即,值(Value)字段为空。各个从设备根据自己的地址确定自己的应答次序。A Type field value of 0 means that all slave devices in the network need to respond in order (ie, in the order of the slave devices). At this time, the value of the Length field is 0 (byte), indicating that the length of the data contained in the Value field is 0 bytes, that is, the Value field is empty. Each slave device determines its own response order based on its own address.
类型(Type)字段值为1表示:值(Value)字段所包含的地址范围内的多个从设备需要应答。此时长度(Length)字段的值为2(字节)。值(Value)字段中包括起始地址(1个字节)和终止地址(1个字节)。例如图2A所示,起始地址为0x02,终止地址为0x1F,则地址在0x02~0x1F之间的从设备均需要作出应答。各个从设备可以根据自己的地址与该起始地址的差值确定自己的应答次序。A Type field value of 1 means that multiple slave devices within the address range contained in the Value field need to answer. At this time, the value of the Length field is 2 (bytes). The Value field includes a start address (1 byte) and a termination address (1 byte). For example, as shown in FIG. 2A, the start address is 0x02, and the end address is 0x1F, and the slave devices whose addresses are between 0x02 and 0x1F need to respond. Each slave device can determine its own response order based on the difference between its own address and the start address.
类型(Type)字段值为2表示:值(Value)字段中指定地址的从设备需要应答。值(Value)字段中包括所有需要应答的从设备的地址。此时长度(Length)字段的值可变,若需要应答的从设备为n个,则长度(Length)字段的值为n(字节),表示值(Value)字段所包含数据的长度为n字节。例如,主设备指定地址为0x11,0x15,0x43和0x78的四个从设备应答该广播帧,则在所述应答从机信息的值(Value)字段中包括上述四个地址(0x11,0x15,0x43和0x78),如图2B所示。需要应答的各个从设备可以将自己的地址在值字段中的顺序作为自己的应答次序。A Type field value of 2 means that the slave device of the specified address in the Value field needs to answer. The Value field includes all the addresses of the slaves that need to be answered. At this time, the value of the Length field is variable. If the number of slave devices to be answered is n, the value of the Length field is n (byte), indicating that the length of the data contained in the Value field is n. byte. For example, if the master device specifies four broadcast devices with addresses 0x11, 0x15, 0x43, and 0x78 to answer the broadcast frame, the above four addresses (0x11, 0x15, 0x43) are included in the value field of the response slave information. And 0x78), as shown in Figure 2B. Each slave device that needs to answer can use its own address in the value field as its own response order.
类型(Type)字段值为3表示:值(Value)字段中应答指示位指示需要应答的从设备作出应答。RS-485总线网络中可分配给从设备的地址有247个,即 0x01~0xF7,因此值(Value)字段中包括247个应答指示位,长度(Length)字段的值为31(字节),如图2C所示。值(Value)字段中第1~247位(bit)分别对应地址:0x01~0xF7,即,第1bit对应地址:0x01,第2bit对应地址:0x02,……,第247bit对应地址:0x F7。可以用应答指示位的值为1指示需要应答,值为0指示不需要应答。例如,第5bit置为1,则地址为0x05的从设备需要应答该广播帧。需要应答的从设备可以将自己对应的应答指示位在所有值为1的应答指示位中的顺序作为自己的应答次序。A Type field value of 3 indicates that the Answer Indicator bit in the Value field indicates that the slave device that needs to answer has replied. There are 247 addresses that can be assigned to slave devices in the RS-485 bus network. 0x01~0xF7, so the value field includes 247 response indication bits, and the length field has a value of 31 (bytes), as shown in FIG. 2C. In the Value field, the first to the 247th bits correspond to the address: 0x01 to 0xF7, that is, the first bit corresponding address: 0x01, the second bit corresponding address: 0x02, ..., the 247th bit corresponding address: 0x F7. A value of 1 for the response indication bit may indicate that a response is required, and a value of 0 indicates that no response is required. For example, if the 5th bit is set to 1, the slave device with the address 0x05 needs to answer the broadcast frame. The slave device that needs to respond can use its own response indication bit in the sequence of all response indication bits with a value of 1 as its own response sequence.
具体实现中,主设备可以根据需要作出应答的从设备的数量,来确定应答从机信息的类型。当需要作出应答的多个从设备的地址是连续的,应答从机信息可以用类型(Type)字段值为1的实现方式。当需要作出应答的多个从设备的地址不连续时,如果数量小于31,应答从机信息可以用类型(Type)字段值为2的实现方式;如果数量大于31,应答从机信息可以用类型(Type)字段值为3的实现方式。In a specific implementation, the master device can determine the type of the response slave information according to the number of slave devices that need to respond. When the addresses of multiple slave devices that need to respond are contiguous, the response slave information can be implemented with a Type field value of one. When the addresses of multiple slave devices that need to respond are not continuous, if the number is less than 31, the response slave information can be implemented with a Type field value of 2; if the number is greater than 31, the response slave information can be of type The (Type) field value is an implementation of 3.
102、若所述第一从设备根据所述应答从机信息确定需要应答所述广播帧,则所述第一从设备根据所述应答从机信息确定应答开始时刻,并在所述应答开始时刻作出应答。102. If the first slave device determines, according to the response slave information, that the broadcast frame needs to be acknowledged, the first slave device determines a response start time according to the response slave information, and at the response start time. Respond.
具体地,所述第一从设备根据所述广播帧中的所述应答从机信息判断是否需要应答所述广播帧。若根据所述应答从机信息确定不需要应答所述广播帧,可以记录所述广播帧中的信息,然后丢弃所述广播帧。若根据所述应答从机信息确定需要应答所述广播帧,则所述第一从设备根据所述应答从机信息确定应答开始时刻,并在所述应答开始时刻作出应答,所述第一从设备是所述多个从设备中的一个。Specifically, the first slave device determines, according to the answering slave information in the broadcast frame, whether the broadcast frame needs to be answered. If it is determined according to the response slave information that the broadcast frame does not need to be acknowledged, the information in the broadcast frame may be recorded, and then the broadcast frame is discarded. If it is determined that the broadcast frame needs to be answered according to the response slave information, the first slave device determines a response start time according to the response slave information, and responds at the response start time, the first slave The device is one of the plurality of slave devices.
所述第一从设备根据所述应答从机信息确定应答时刻,具体包括:The determining, by the first slave device, the response time according to the response slave information, specifically includes:
所述第一从设备根据所述应答从机信息获取所述第一从设备的应答次序,所述应答次序为所述第一从设备在所述应答从机信息所指示的所述多个从设备中作出应答的次序;Obtaining, by the first slave device, a response order of the first slave device according to the response slave information, where the response sequence is the multiple slaves indicated by the first slave device in the response slave information The order in which the devices respond;
所述第一从设备根据单点超时时长和所述第一从设备的应答次序,计算所述第一从设备的应答开始时刻。The first slave device calculates a response start time of the first slave device according to a single point timeout duration and a response order of the first slave device.
例如,所述第一从设备的应答次序为N,N≥1。D表示单点超时时长,单位通常为微秒(μs)或毫秒(ms)。所述第一从设备的应答开始时刻Tsn=T0+(N-1)*D,其中T0是所述第一从设备收到所述广播帧的时刻。本发明实施例中,可以忽略各个从设备收到广播帧与主设备发送广播帧之间的时差。换言之,T0也是主设备完成该广播帧发送的时刻,网络中各个从设备均从T0开始计算应答开始时刻。For example, the first slave device has a response order of N, N≥1. D represents the single point timeout duration, and the unit is usually microseconds (μs) or milliseconds (ms). The response start time Tsn=T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame. In the embodiment of the present invention, the time difference between the received broadcast frame of each slave device and the broadcast frame sent by the master device may be ignored. In other words, T0 is also the time when the master device completes the transmission of the broadcast frame, and each slave device in the network starts to calculate the response start time from T0.
可选的,所述广播帧中还包括单点超时时长。所述单点超时时长是由主设备为所述广播帧指定的每个从设备应答所述广播帧所需的最大时长。所述主设备可以根据所述广播帧中的数据、从设备处理速度、总线通信速率等因素确定所述单点超时时长。Optionally, the broadcast frame further includes a single point timeout duration. The single point timeout duration is the maximum duration required for each slave device designated by the master device to answer the broadcast frame for the broadcast frame. The master device may determine the single point timeout duration according to factors in the broadcast frame, slave processing speed, bus communication rate, and the like.
当然,所述单点延时时长也可以预先配置在主设备和各个从设备上。这样, 从设备收到任一包括应答从机信息的广播帧时,按照该预设配置的单点超时时长计算应答开始时刻。Of course, the single-point delay duration can also be pre-configured on the master device and each slave device. In this way, When receiving any broadcast frame including the response slave information, the slave device calculates the response start time according to the preset single-point timeout period.
所述单点超时时长一般不小于从设备作出应答实际所需的时长,可以是经验值。本发明实施例中,所述单点超时时长须大于网络中应答最慢的从设备的应答时长。例如,RS-485总线网络中有200个从设备,应答时长可能有10ms、20ms、25ms、50ms、80ms、95ms不等,其中最长的应答时长为95ms。为了保证每个从设备都有足够时间完成应答,所述单点超时时长应不低于95ms。The single point timeout duration is generally not less than the actual length of time required for the slave device to respond, and may be an empirical value. In the embodiment of the present invention, the single-point timeout period must be longer than the response time of the slave device with the slowest response in the network. For example, there are 200 slave devices in the RS-485 bus network, and the response duration may be 10ms, 20ms, 25ms, 50ms, 80ms, 95ms, and the longest response time is 95ms. In order to ensure that each slave device has enough time to complete the response, the single point timeout should be no less than 95ms.
虽然从设备按照应答次序和单点超时时长依次等待可以避免从设备之间的应答冲突。但是网络中不同的从设备作出应答实际所需的时长是不同的,很多从设备的应答时长通常都小于该单点超时时长。因此应答次序在后的从设备可以根据应答次序在先的从设备作出应答的时刻,实时调整自己的应答开始时刻,避免按照固定的单点超时时长等待所造成的时延。Although the slave device waits sequentially in accordance with the response order and the single-point timeout duration, it is possible to avoid a response collision between the slave devices. However, the actual length of time required for different slave devices to respond in the network is different. Many slave devices usually have a response time that is less than the single-point timeout period. Therefore, the slave device in the response sequence can adjust its own response start time in real time according to the response order of the previous slave device, and avoid the delay caused by the fixed single-point timeout waiting time.
若所述第一从设备的应答次序N为1,即,所述第一从设备为第一个要作出应答的从设备,则所述第一从设备的应答开始时刻Tsn=T0,即,所述第一从设备收到所述广播帧后立即开始应答。If the response sequence N of the first slave device is 1, that is, the first slave device is the first slave device to be replied, the response start time of the first slave device is Tsn=T0, ie, The first slave device starts to respond immediately after receiving the broadcast frame.
若所述第一从设备的应答次序N≥2,所述第一从设备可以根据应答次序在先的第二从设备的应答结束时刻(即完成应答,发出应答帧的时刻),更新自己的应答开始时刻。具体地,在到达所述第一从设备的应答开始时刻(Tsn)前,所述第一从设备侦听RS-485总线上的通信,以确定是否有应答次序在先的从设备做出应答。若所述第一从设备没有侦听到应答次序在先的其他从设备的应答帧,则所述第一从设备在到达应答开始时刻Tsn时作出应答。若到达Tsn前的中间时刻,所述第一从设备侦听到应答次序在先的第二从设备的应答帧,则所述第一从设备根据该中间时刻更新自己的应答开始时刻(Tsn)。本发明实施例中,可以忽略所述第一从设备侦听到所述第二从设备的应答帧,与所述第二从设备发出应答帧的时差。换言之,上述中间时刻等于第二从设备完成应答帧发送的时刻,即等于第二从设备的应答结束时刻。If the response order of the first slave device is N≥2, the first slave device may update its own according to the response end time of the second slave device in the response sequence (ie, the time when the response is completed and the response frame is sent) The start time of the response. Specifically, before reaching the response start time (Tsn) of the first slave device, the first slave device listens for communication on the RS-485 bus to determine whether there is a response from the prior slave device. . If the first slave device does not hear the response frame of the other slave device in the response order, the first slave device responds when the response start time Tsn is reached. If the first slave device detects the response frame of the second slave device in the response order before reaching the intermediate time before Tsn, the first slave device updates its response start time (Tsn) according to the intermediate time. . In this embodiment of the present invention, the time difference between the response frame of the second slave device and the response frame of the second slave device may be ignored. In other words, the intermediate time is equal to the time at which the second slave device completes the response frame transmission, that is, equal to the response end time of the second slave device.
例如,所述第一从设备在到达Tsn之前的中间时刻Tek侦听到应答次序为K(K<N)的第二从设备的应答帧,所述第一从设备更新应答开始时刻Tsn=Tek+(N-K-1)*D。在到达更新后的应答开始时刻Tsn前,所述第一从设备继续侦听应答次序在先的从设备的应答帧,如果侦听到,继续更新Tsn,如果没有侦听到,则在到达Tsn时,发出应答帧。For example, the first slave device listens to the response frame of the second slave device having the response order K (K<N) at the intermediate time Tek before reaching Tsn, and the first slave device updates the response start time Tsn=Tek+ (NK-1)*D. Before reaching the updated response start time Tsn, the first slave device continues to listen to the response frame of the prior slave device in the response order, and if it hears, continues to update Tsn, if not heard, then arrives at Tsn When an answer frame is sent.
下面结合一个具体的例子来说明本发明实施例提供的广播实现方法。假定主设备在T0时刻完成广播帧的发送,单点超时时长为100ms,所述广播帧的应答从机信息中类型(Type)字段值为2,值(Value)字段中指定地址为0x03,0x06,0x0A和0x13的四个从设备应答该广播帧。网络中每个从设备收到所述广播帧后,判断自己的地址是否在所述广播帧的应答从机信息中,以确定自己是否要应答该广播帧。所述四个从设备0x03,0x06,0x0A和0x13收到该广播帧后,确定自己要应答该广播帧,分别获取各自的应答次序,计算各自的应答开始时刻。具体 过程如下:The broadcast implementation method provided by the embodiment of the present invention is described below in conjunction with a specific example. Assume that the master device completes the transmission of the broadcast frame at time T0, the single-point timeout period is 100 ms, the type (Type) field value of the response slave information of the broadcast frame is 2, and the specified address in the Value field is 0x03, 0x06. The four slaves of 0x0A and 0x13 acknowledge the broadcast frame. After receiving the broadcast frame, each slave device in the network determines whether its own address is in the response slave information of the broadcast frame to determine whether it wants to answer the broadcast frame. After receiving the broadcast frame, the four slave devices 0x03, 0x06, 0x0A, and 0x13 determine that they want to answer the broadcast frame, respectively acquire respective response sequences, and calculate respective response start times. Specific The process is as follows:
(1)从设备3收到该广播帧后,确定自己要应答该广播帧,获取应答次序N=1,获取单点超时时长(从所述广播帧中或从本地),计算得到自己的应答开始时刻:(1) After receiving the broadcast frame from the device 3, it is determined that it wants to answer the broadcast frame, obtain the response sequence N=1, acquire the single-point timeout duration (from the broadcast frame or from the local), and calculate its own response. Start time:
Tr1=T0+(1-1)*100ms=T0Tr1=T0+(1-1)*100ms=T0
从设备3收到广播帧后立即作出应答。假定应答用了10ms,即应答时长为10ms,则从设备3在其应答结束时刻:Te1=Tr1+10ms=T0+10ms,完成应答。A response is received immediately after the device 3 receives the broadcast frame. Assuming that the response takes 10 ms, that is, the response duration is 10 ms, the slave device 3 completes the response at the end of its response: Te1 = Tr1 + 10 ms = T0 + 10 ms.
(2)从设备6为第2个需要应答的从设备,此例中,假定从设备6出现了故障,不能作出应答,因此从设备6占用单点超时时长100ms。(2) The slave device 6 is the second slave device that needs to be answered. In this example, it is assumed that the slave device 6 has a failure and cannot respond. Therefore, the slave device 6 occupies a single point timeout of 100 ms.
(3)从设备10收到该广播帧后,确定自己要应答该广播帧,获取应答次序N=3,获取单点超时时长,并计算得到自己的应答开始时刻:(3) After receiving the broadcast frame from the device 10, it determines that it wants to answer the broadcast frame, obtains the response sequence N=3, acquires the single-point timeout duration, and calculates its own response start time:
Tr3=T0+(3-1)*100ms=T0+2*100msTr3=T0+(3-1)*100ms=T0+2*100ms
在到达Tr3=T0+2*100ms之前,从设备10侦听应答次序在先的从设备(从设备3和从设备6)的应答帧;从设备10在中间时刻Te1=T0+10ms侦听到从设备3的应答帧,因此从设备10将自己的应答开始时刻调整为:Tr3=Te1+(3-1-1)*100ms=T0+110ms。Before reaching Tr3=T0+2*100ms, the slave device 10 listens to the response frame of the prior slave device (slave device 3 and slave device 6); the slave device 10 listens at the intermediate time Te1=T0+10ms From the response frame of the device 3, the slave device 10 adjusts its own response start time to: Tr3 = Te1 + (3-1 - 1) * 100 ms = T0 + 110 ms.
然后,从设备10接着继续侦听应答次序在先的从设备(从设备6)。由于从设备6故障,因此从设备10在到达Tr3=T0+110ms之前,侦听不到从设备6的应答帧,无法根据从设备6的应答进一步调整应答开始时刻。当达到Tr3=T0+110ms时刻,从设备10进行应答。假定从设备10应答用了20ms,则从设备10在其应答结束时刻:Te3=Tr3+20ms=T0+110ms+20ms=T0+130ms,完成应答。The slave device 10 then continues to listen to the slave device (slave device 6) that responds in the prior order. Since the slave device 6 fails, the slave device 10 does not hear the response frame of the slave device 6 until it reaches Tr3=T0+110 ms, and cannot further adjust the response start time according to the response of the slave device 6. When the Tr3 = T0 + 110 ms is reached, the slave device 10 responds. Assuming that the slave device 10 responds with 20 ms, the slave device 10 completes the response at its response end time: Te3 = Tr3 + 20 ms = T0 + 110 ms + 20 ms = T0 + 130 ms.
(4)从设备18收到该广播帧后,确定自己要应答该广播帧,获取应答次序N=4,获取单点超时时长,并计算得到自己的应答开始时刻:(4) After receiving the broadcast frame from the device 18, it determines that it wants to answer the broadcast frame, obtains the response sequence N=4, acquires the single-point timeout duration, and calculates its own response start time:
Tr4=T0+(4-1)*100ms=T0+3*100msTr4=T0+(4-1)*100ms=T0+3*100ms
在到达Tr4=T0+3*100ms之前,从设备18侦听应答次序在先的从设备(从设备3,从设备6和从设备10)。从设备18在中间时刻Te1=T0+10ms侦听到从设备3的应答帧,因此从设备18将自己的应答开始时刻调整为:Tr4=Te1+(4-1-1)*100ms=T0+210ms。The slave device 18 listens to the slave devices (slave device 3, slave device 6 and slave device 10) that have responded in order before reaching Tr4 = T0 + 3 * 100 ms. The slave device 18 listens to the response frame of the slave device 3 at the intermediate time Te1 = T0 + 10 ms, so the slave device 18 adjusts its own response start time to: Tr4 = Te1 + (4-1-1) * 100 ms = T0 + 210 ms .
然后,从设备18继续侦听应答次序在先的从设备(从设备6和从设备10)。由于从设备6故障,因此从设备18侦听不到从设备6的应答帧。从设备18在中间时刻Te3=T0+130ms侦听到从设备10的应答帧,因此从设备18将自己的应答开始时刻调整为:Tr4=Te3+(4-3-1)*100ms=Te3=T0+130ms。Then, the slave device 18 continues to listen to the slave devices (slave device 6 and slave device 10) that have responded in the prior order. Since the slave device 6 fails, the slave device 18 does not hear the response frame of the slave device 6. The slave device 18 listens to the response frame of the slave device 10 at the intermediate time Te3 = T0 + 130 ms, so the slave device 18 adjusts its own response start time to: Tr4 = Te3 + (4-3-1) * 100 ms = Te3 = T0 +130ms.
由于从设备18应答次序为4,从设备10的应答次序为3,因此从设备18与从设备10之间没有其它从设备需要应答,因此,从设备18的应答开始时刻就是从设备10的应答结束时刻。也就是,从设备18在侦听到从设备10的应答帧后,立即作出应答。Since the response order of the slave device 18 is 4, the response order of the slave device 10 is 3, so no other slave device needs to respond between the slave device 18 and the slave device 10. Therefore, the response start time of the slave device 18 is the response of the slave device 10. End time. That is, the slave device 18 responds immediately after hearing the response frame of the slave device 10.
假定从设备18应答用了30ms,则从设备18应答结束时间为Te4=Tr4+30ms=T0+130ms+30ms=T0+160ms。Assuming that the slave device 18 responds for 30 ms, the slave device 18 response end time is Te4 = Tr4 + 30 ms = T0 + 130 ms + 30 ms = T0 + 160 ms.
至此,本发明实施例提供的广播应答流程结束。 So far, the broadcast response process provided by the embodiment of the present invention ends.
从上述过程可以看出,在Te4时刻(T0+160ms),主设备指定的四个从设备完成该广播帧的应答。如果按照单点超时时长不做调整的方式作出应答,从设备18在T0+(4-1)*100ms+30ms=T0+330ms时刻完成应答。因此,动态调整应答开始时刻的方式,所述四个从设备完成该广播帧的应答可以缩短170ms。从设备6由于故障,没有应答,应答时长等于单点延时时长。如果从设备6没有故障,总的应答时长还可以进一步缩短。It can be seen from the above process that at the time Te4 (T0+160ms), the four slave devices designated by the master device complete the response of the broadcast frame. If the response is made in such a way that the single point timeout period is not adjusted, the slave device 18 completes the response at time T0 + (4-1) * 100 ms + 30 ms = T0 + 330 ms. Therefore, in a manner of dynamically adjusting the start time of the response, the response of the four slave devices to complete the broadcast frame can be shortened by 170 ms. The slave device 6 has no response due to a fault, and the response duration is equal to the single-point delay duration. If the slave device 6 has no fault, the total response duration can be further shortened.
进一步地,所述第一从设备在到达所述应答开始时刻,可以先侦听RS-485总线是否被占用,并在确认总线空闲的情况下再发送应答帧。Further, the first slave device may first detect whether the RS-485 bus is occupied when the response start time is reached, and then send the response frame again if it is confirmed that the bus is idle.
本发明实施例提供的广播实现方法,第一从设备根据广播帧中的应答从机信息,确定需要对该广播帧作出应答时,根据单点超时时长和应答次序计算应答开始时刻,在达到应答开始时刻再作出应答,避免了从设备间的应答冲突,提高了从设备的资源利用率和通信效率。此外,第一从设备根据应答次序在先的其他从设备的应答结束时刻,实时调整自己的应答开始时刻,避免按照固定的单点超时时长退避冲突所造成的延时,提高了广播应答效率,从而提高整个RS-485总线网络的性能。According to the broadcast implementation method provided by the embodiment of the present invention, when the first slave device determines that the broadcast frame needs to be responded according to the response slave information in the broadcast frame, the response start time is calculated according to the single point timeout duration and the response order, and the response is reached. The response is answered at the beginning, which avoids the response conflict between the slave devices, and improves the resource utilization and communication efficiency of the slave device. In addition, the first slave device adjusts its own response start time in real time according to the response end time of the other slave devices in the response order, avoids the delay caused by the backoff collision according to the fixed single point timeout period, and improves the broadcast response efficiency. Thereby improving the performance of the entire RS-485 bus network.
参见图3,为本发明实施例提供的另一种广播实现方法的流程示意图图,该方法包括:FIG. 3 is a schematic flowchart diagram of another method for implementing a broadcast according to an embodiment of the present invention, where the method includes:
301、主设备生成并发送广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照应答次序作出应答;301. The master device generates and sends a broadcast frame, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in response order.
所述RS-485总线网络中的从设备都会收到所述主设备发送的所述广播帧。本发明实施例,所述主设备通过所述广播帧中的应答从机信息,指定所述多个从设备按照应答次序应答所述广播帧。所述应答次序为所述应答从机信息所指示的所述多个设备返回应答帧的次序。The slave device in the RS-485 bus network receives the broadcast frame sent by the master device. In the embodiment of the present invention, the master device specifies, by using the response slave information in the broadcast frame, that the multiple slave devices answer the broadcast frame according to the response order. The response order is an order in which the response frames are returned by the plurality of devices indicated by the response slave information.
所述应答从机信息为TLV格式,具体可参见步骤101中描述。The response slave information is in the TLV format. For details, refer to the description in step 101.
可选地,所述广播帧中还包括单点超时时长。所述主设备可以根据所述广播帧中的数据、从设备处理速度、总线通信速率等因素,为所述广播帧指定每个从设备应答所述广播帧所需的最大时长,即,所述单点超时时长。Optionally, the broadcast frame further includes a single point timeout duration. The master device may specify, for the broadcast frame, a maximum duration required for each slave device to answer the broadcast frame according to factors in the broadcast frame, a slave processing speed, a bus communication rate, and the like, ie, the Single point timeout period.
当然,所述单点延时时长也可以预先配置在主设备和各个从设备上。这样,从设备收到任一包括应答从机信息的广播帧时,都按照该预设配置的单点超时时长计算应答开始时刻。Of course, the single-point delay duration can also be pre-configured on the master device and each slave device. In this way, when receiving any broadcast frame including the response slave information, the slave device calculates the response start time according to the preset single-point timeout duration.
302、接收所述多个从设备按照应答次序返回的应答帧。302. Receive a response frame that is returned by the multiple slave devices in response sequence.
所述主设备可以根据单点超时时长和所述多个从设备(所述应答从机信息中指定需应答所述广播帧的从设备)的数量确定应答等待周期,并在所述应答等待周期内,接收所述多个从设备依次返回的应答帧。The master device may determine a response waiting period according to a single point timeout period and a quantity of the plurality of slave devices (the slave device that specifies the broadcast frame to be answered), and in the response waiting period Receiving a response frame sequentially returned by the plurality of slave devices.
可选地,当所述应答等待周期结束,如果所述多个从设备中仍有从设备未返回应答帧,所述主设备可以向所述多个从设备中未应答的从设备发送更新的广播 帧。当然,所述主设备也可以向所述多个从设备中未应答的从设备发送单播帧。Optionally, when the response waiting period ends, if the slave device does not return the response frame, the master device may send the updated to the unacknowledged slave device of the multiple slave devices. Broadcast frame. Of course, the master device may also send a unicast frame to the slave devices that are not answered in the plurality of slave devices.
进一步地,所述方法还可以包括:所述主设备根据所述多个从设备返回的应答帧,记录各个从设备的状态信息,例如设备版本,发射功率,休眠时间等。Further, the method may further include: the master device records status information of each slave device according to the response frame returned by the multiple slave devices, such as a device version, a transmit power, a sleep time, and the like.
所述主设备生成广播帧,包括:所述主设备确定所述多个从设备的地址;根据所述多个从设备的地址和预设条件,确定所述应答从机信息;根据所述应答从机信息生成所述广播帧。Generating, by the master device, a broadcast frame, including: determining, by the master device, an address of the multiple slave devices; determining, according to an address and a preset condition of the multiple slave devices, the response slave information; The broadcast information is generated from the slave information.
所述主设备根据所述多个从设备的地址和预设条件,确定所述应答从机信息,包括:Determining, by the master device, the answering slave information according to an address and a preset condition of the multiple slave devices, including:
若所述主设备要指定所有从设备按照次序应答,优选采用类型为0的应答从机信息。相应地,各个从设备可以根据自己的地址确定自己的应答次序。If the master device wants to designate all slave devices to respond in order, it is preferred to use the responder slave information of type 0. Accordingly, each slave device can determine its own response order based on its own address.
若所述主设备要指定一段地址范围内的多个从设备(地址连续的多个从设备)按照次序应答,优选采用类型为1的应答从机信息,并且在应答从机信息的值字段中包括起始地址和终止地址。相应地,各个从设备可以根据自己的地址与该起始地址的差值确定自己的应答次序。也可以采用类型为1的应答从机信息指定所有从设备按照次序应答,则应答从机信息的值字段中的起始地址为从设备的最小地址,终止地址为从设备的最大地址。If the master device is to specify a plurality of slave devices (a plurality of slave devices consecutive to each other) in a range of addresses to respond in order, it is preferable to use the response slave information of type 1 and in the value field of the response slave information. Includes start address and end address. Accordingly, each slave device can determine its own response order based on the difference between its own address and the start address. It is also possible to use the response slave information of type 1 to designate all slave devices to respond in order, and the start address in the value field of the response slave information is the minimum address of the slave device, and the termination address is the maximum address of the slave device.
若所述主设备要指定地址不连续的多个从设备按照次序应答,可以采用类型为2或3的应答从机信息。具体地,所述主设备可以根据需要应答的从设备的数量,确定所述应答从机信息的类型。当需要应答的从设备的数量小于预设阈值时,确定所述应答从机信息的类型为2(即,所述应答从机信息包括需要应答的多个从设备的地址),需要应答的各个从设备可以将自己的地址在值字段中的顺序作为自己的应答次序。当需要应答的从设备的数量大于等于预设阈值时,确定所述应答从机信息的类型为3(即,所述应答从机信息包括与每个从设备对应的应答指示位),需要应答的从设备可以将自己对应的应答指示位在所有值为1的应答指示位中的顺序作为自己的应答次序。If the master device wants to specify multiple slave devices whose addresses are not consecutive, the responder slave information may be of type 2 or 3. Specifically, the master device may determine the type of the responding slave information according to the number of slave devices that need to be answered. When the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the response slave information is 2 (ie, the response slave information includes addresses of multiple slave devices that need to be answered), and each of the responders needs to be answered. Slave devices can use their own address in the value field as their response order. When the number of slave devices that need to be answered is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3 (ie, the response slave information includes a response indication bit corresponding to each slave device), and needs to be answered. The slave device can set its own response indication bit in the order of all response indication bits with a value of 1 as its own response order.
所述预设阈值可以为
Figure PCTCN2017109754-appb-000002
其中n为从设备的地址的位数。例如,RS-485总线网络中从设备的地址的位数为8时,所述预设阈值设为32。当需应答的从设备数量大于等于32时,应答从机信息的类型为3。当预设阈值设小于32时,应答从机信息的类型为2。这样,当需应答的从设备数量较少时,直接按序携带需要应答的从设备的地址,可以减小广播帧的长度,还可以提高设备的处理效率当然,除了将预设阈值设置为
Figure PCTCN2017109754-appb-000003
也可以设置为更大或更小的数值。
The preset threshold may be
Figure PCTCN2017109754-appb-000002
Where n is the number of bits of the address of the slave device. For example, when the number of bits of the address of the slave device in the RS-485 bus network is 8, the preset threshold is set to 32. When the number of slave devices to be answered is greater than or equal to 32, the type of the response slave information is 3. When the preset threshold is set to less than 32, the type of the response slave information is 2. In this way, when the number of slave devices to be answered is small, the address of the slave device that needs to be answered is directly carried in order, the length of the broadcast frame can be reduced, and the processing efficiency of the device can be improved, of course, except that the preset threshold is set to
Figure PCTCN2017109754-appb-000003
It can also be set to a larger or smaller value.
显然,无论上述何种情况,都可以采用类型为3的应答从机信息来实现。Obviously, regardless of the above situation, the response slave information of type 3 can be used.
本实施例中其他未尽细节可参考本发明实施例图1所示方法中描述。Other details in this embodiment may be described in the method shown in FIG. 1 of the embodiment of the present invention.
本发明实施例提供的广播实现方法,主设备生成并发送包括应答从机信息的广播帧,通过该应答从机信息指示RS-485总线网络中的多个从设备按照应答次序作出应答,以广播实现类似组播的通信机制,相比于传统的单播或广播方式,可以提高主设备的资源利用率和通信效率,同时还可以避免多个从设备间的广播应答冲突,从而提高RS-485总线网络的性能。 According to the broadcast implementation method provided by the embodiment of the present invention, the master device generates and transmits a broadcast frame including the response slave information, and the slave device information indicates that the plurality of slave devices in the RS-485 bus network respond in response order to broadcast Realizing a multicast-like communication mechanism, compared with the traditional unicast or broadcast mode, can improve the resource utilization and communication efficiency of the master device, and also avoid broadcast response conflicts between multiple slave devices, thereby improving RS-485. The performance of the bus network.
参见图4,为本发明实施例提供的一种广播实现装置的结构示意图,用于实现本发明实施例图1所示的广播实现方法。所述广播实现装置40包括接收模块401和处理模块402;FIG. 4 is a schematic structural diagram of a broadcast implementation apparatus according to an embodiment of the present invention, which is used to implement the broadcast implementation method shown in FIG. 1 according to an embodiment of the present invention. The broadcast implementation device 40 includes a receiving module 401 and a processing module 402;
所述接收模块401,用于接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示RS-485总线网络中多个从设备按照次序应答所述广播帧;The receiving module 401 is configured to receive a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order Broadcast frame
所述处理模块402,用于根据所述应答从机信息确定需要应答所述广播帧时,根据所述应答从机信息确定应答开始时刻,并在所述应答开始时刻作出应答。The processing module 402 is configured to determine, according to the response slave information, that the broadcast frame needs to be answered, determine a response start time according to the response slave information, and respond at the response start time.
所述广播实现装置40部署在所述多个设备中的第一从设备上。The broadcast implementation device 40 is deployed on a first of the plurality of devices.
所述处理模块402具体用于根据所述广播帧中的所述应答从机信息判断是否需要应答所述广播帧;若根据所述应答从机信息确定不需要应答所述广播帧,则记录所述广播帧中的信息,然后丢弃所述广播帧;若根据所述应答从机信息确定需要应答所述广播帧,则根据所述应答从机信息确定应答开始时刻,并在所述应答开始时刻发送应答帧。The processing module 402 is specifically configured to determine, according to the response slave information in the broadcast frame, whether the broadcast frame needs to be acknowledged; if it is determined according to the response slave information that the broadcast frame does not need to be acknowledged, the recording station Decoding the information in the broadcast frame, and then discarding the broadcast frame; if it is determined that the broadcast frame needs to be answered according to the response slave information, determining a response start time according to the response slave information, and at the response start time Send an answer frame.
所述处理模块402具体用于根据所述应答从机信息获取所述第一从设备的应答次序,所述应答次序为所述第一从设备在所述应答从机信息所指示的所述多个从设备中作出应答的次序;根据单点超时时长和所述第一从设备的应答次序,计算所述第一从设备的应答开始时刻。例如,所述第一从设备的应答次序为N,N≥1。D表示单点超时时长。所述第一从设备的应答开始时刻Tsn=T0+(N-1)*D,其中T0是所述第一从设备收到所述广播帧的时刻。The processing module 402 is specifically configured to acquire, according to the response slave information, a response sequence of the first slave device, where the response sequence is that the first slave device indicates the multiple of the response slave information. The order in which the slave devices respond; the answer start time of the first slave device is calculated according to the single point timeout duration and the response order of the first slave device. For example, the first slave device has a response order of N, N≥1. D represents the single point timeout duration. The response start time Tsn=T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame.
若所述第一从设备的应答次序N为1,即,所述第一从设备为第一个要作出应答的从设备,则所述应答开始时刻Tsn=T0,即,所述第一从设备收到所述广播帧后立即开始应答。If the response sequence N of the first slave device is 1, that is, the first slave device is the first slave device to be replied, the response start time Tsn=T0, that is, the first slave The device starts responding immediately after receiving the broadcast frame.
若所述第一从设备的应答次序N≥2,所述第一从设备可以根据应答次序在先的第二从设备的应答结束时刻(即发出应答帧的时刻),更新自己的应答开始时刻。If the response order of the first slave device is N≥2, the first slave device may update its response start time according to the response end time of the second slave device (ie, the time when the response frame is sent) according to the response order. .
所述处理模块402还用于根据应答次序在先的第二从设备的应答结束时刻,实时调整所述第一从设备的应答开始时刻。具体地,所述处理模块402在到达所述第一从设备的应答开始时刻(Tsn)前,侦听RS-485总线上的通信,以确定是否有应答次序在先的从设备做出应答。若没有侦听到应答次序在先的其他从设备的应答帧,则在到达应答开始时刻Tsn时作出应答。若在到达Tsn之前的中间时刻,侦听到应答次序在先的第二从设备的应答帧,则根据该中间时刻更新所述第一从设备的应答开始时刻(Tsn)。例如,在到达所述第一从设备的应答开始时刻Tsn之前的中间时刻Tek,侦听到应答次序为K(K<N)的第二从设备的应答帧,则更新所述第一从设备的应答开始时刻为Tsn=Tek+(N-K-1)*D。The processing module 402 is further configured to adjust the response start time of the first slave device in real time according to the response end time of the second slave device in the response sequence. Specifically, the processing module 402 listens for communication on the RS-485 bus before determining the response start time (Tsn) of the first slave device to determine whether there is a response from the prior slave device. If the response frame of the other slave device whose response order is prior is not detected, the response is reached when the response start time Tsn is reached. If the response frame of the second slave device in the response order is detected at an intermediate time before the arrival of Tsn, the response start time (Tsn) of the first slave device is updated according to the intermediate time. For example, when the intermediate time Tek before the response start time Tsn of the first slave device is reached, the response frame of the second slave device having the response order K (K<N) is detected, and the first slave device is updated. The response start time is Tsn=Tek+(NK-1)*D.
本实施例中其他未尽细节可参考本发明实施例图1所示的广播实现方法中所述。 Other details in this embodiment may be referred to in the broadcast implementation method shown in FIG. 1 of the embodiment of the present invention.
本发明实施例提供的广播实现装置,可以根据广播帧中包含的应答从机信息,确定是否需要对该广播帧作出应答,在确定需要应答该广播帧时,根据单点超时时长和应答次序计算应答开始时刻,在达到应答开始时刻再作出应答,避免了从设备件的应答冲突。此外,本发明实施例提供的广播实现装置根据应答次序在先的其他从设备的应答结束时刻,实时调整自己的应答开始时刻,避免按照固定的单点超时时长退避冲突所造成的延时,提高了应答效率,从而提高整个RS-485总线网络的性能。The broadcast implementation apparatus provided by the embodiment of the present invention may determine, according to the response slave information included in the broadcast frame, whether the broadcast frame needs to be acknowledged, and when determining that the broadcast frame needs to be answered, calculate according to the single point timeout duration and the response order. At the start of the response, the response is acknowledged at the start of the response, and the response conflict of the slave device is avoided. In addition, the broadcast implementing apparatus provided by the embodiment of the present invention adjusts its own response start time in real time according to the response end time of the other slave devices in the response order, thereby avoiding the delay caused by the fixed single-point timeout period backoff conflict, and improving The response efficiency improves the performance of the entire RS-485 bus network.
参见图5,为本发明实施例提供的一种从设备的结构示意图,应用于RS-485总线网络中,用于实现本发明实施例图1所示的广播实现方法。所述从设备50包括:处理器501和通信接口502。FIG. 5 is a schematic structural diagram of a slave device according to an embodiment of the present invention, which is applied to an RS-485 bus network, and is used to implement the broadcast implementation method shown in FIG. 1 according to an embodiment of the present invention. The slave device 50 includes a processor 501 and a communication interface 502.
所述从设备50用于实现本发明实施例图1所示方法中的第一从设备。The slave device 50 is configured to implement the first slave device in the method shown in FIG. 1 of the embodiment of the present invention.
所述处理器501和所述通信接口502相互连接。The processor 501 and the communication interface 502 are connected to each other.
所述通信接口503包括RS-485芯片,用于与所述RS-485总线网络中其他设备通信。The communication interface 503 includes an RS-485 chip for communicating with other devices in the RS-485 bus network.
所述处理器501,用于通过所述通信接口502接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中多个从设备按照次序对所述广播帧作出应答。所述处理器501,还用于根据所述广播帧中的所述应答从机信息判断是否需要应答所述广播帧;在根据所述应答从机信息确定需要应答所述广播帧时,根据所述应答从机信息确定应答开始时刻,并在所述应答开始时刻作出应答。The processor 501 is configured to receive, by using the communication interface 502, a broadcast frame sent by a master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate the RS-485 bus network. The plurality of slave devices respond to the broadcast frame in order. The processor 501 is further configured to determine, according to the responding slave information in the broadcast frame, whether the broadcast frame needs to be answered; when determining, according to the responding slave information, that the broadcast frame needs to be answered, according to the The response slave information determines the response start time and responds at the response start time.
所述处理器501通常为微控制器(microcontroller unit,简称MCU);还可以包括数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件。The processor 501 is typically a microcontroller unit (MCU); it may also include a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device. .
可选地,所述处理器501,还用于在根据所述应答从机信息确定不需要应答所述广播帧时,记录所述广播帧中的信息,并丢弃所述广播帧。Optionally, the processor 501 is further configured to: when determining, according to the responding slave information, that the broadcast frame does not need to be acknowledged, record information in the broadcast frame, and discard the broadcast frame.
所述处理器501具体可以根据所述应答从机信息获取所述从设备50(即所述第一从设备)的应答次序,所述应答次序为所述第一从设备在所述应答从机信息所指示的所述多个从设备中作出应答的次序;再根据单点超时时长和所述第一从设备的应答次序,计算所述第一从设备的应答开始时刻。例如,所述第一从设备的应答次序为N,N≥1。D表示单点超时时长,单位通常为微秒(μs)或毫秒(ms)。所述第一从设备的应答开始时刻Tsn=T0+(N-1)*D,其中T0是所述第一从设备收到所述广播帧的时刻。The processor 501 may specifically acquire, according to the response slave information, a response sequence of the slave device 50 (ie, the first slave device), where the response sequence is that the first slave device is in the response slave The order in which the plurality of slave devices indicate the response is indicated by the information; and the response start time of the first slave device is further calculated according to the single point timeout duration and the response order of the first slave device. For example, the first slave device has a response order of N, N≥1. D represents the single point timeout duration, and the unit is usually microseconds (μs) or milliseconds (ms). The response start time Tsn=T0+(N-1)*D of the first slave device, where T0 is the time at which the first slave device receives the broadcast frame.
若所述第一从设备的应答次序N为1,即,所述第一从设备为第一个要作出应答的从设备,则所述第一从设备的应答开始时刻Tsn=T0,即,所述第一从设备收到所述广播帧后立即开始应答。If the response sequence N of the first slave device is 1, that is, the first slave device is the first slave device to be replied, the response start time of the first slave device is Tsn=T0, ie, The first slave device starts to respond immediately after receiving the broadcast frame.
若所述第一从设备的应答次序N≥2,所述处理器501还用于根据应答次序在先的第二从设备的应答结束时刻,实时调整所述从设备50(即所述第一从设备) 的应答开始时刻。If the response order of the first slave device is N≥2, the processor 501 is further configured to adjust the slave device 50 in real time according to the response end time of the second slave device in the response sequence (ie, the first From the device) The start of the response.
所述处理器501具体用于:在到达所述第一从设备的应答开始时刻(Tsn)前,侦听RS-485总线上的通信,以确定是否有应答次序在先的从设备做出应答。若在到达Tsn之前的中间时刻,侦听到应答次序在先的第二从设备的应答帧,则根据该中间时刻更新所述第一从设备的应答开始时刻(Tsn)。例如,在到达所述第一从设备的应答开始时刻Tsn之前的中间时刻Tek,侦听到应答次序为K(K<N)的第二从设备的应答帧,则更新所述第一从设备的应答开始时刻为Tsn=Tek+(N-K-1)*D。若没有侦听到应答次序在先的其他从设备的应答帧,则在到达应答开始时刻Tsn时作出应答。The processor 501 is specifically configured to: after receiving the response start time (Tsn) of the first slave device, listen for communication on the RS-485 bus to determine whether there is a response from the prior slave device. . If the response frame of the second slave device in the response order is detected at an intermediate time before the arrival of Tsn, the response start time (Tsn) of the first slave device is updated according to the intermediate time. For example, when the intermediate time Tek before the response start time Tsn of the first slave device is reached, the response frame of the second slave device having the response order K (K<N) is detected, and the first slave device is updated. The response start time is Tsn=Tek+(NK-1)*D. If the response frame of the other slave device whose response order is prior is not detected, the response is reached when the response start time Tsn is reached.
所述处理器501中还包括存储器,用于存储所述单点超时时长。The processor 501 further includes a memory for storing the single point timeout duration.
所述通信接口502还用于发送对所述广播帧的应答帧。The communication interface 502 is further configured to send a response frame to the broadcast frame.
本领域技术人员可以理解的是,本发明实施例中仅示出了从设备与本发明相关的部分结构,还可以包括比图示更多的部件,或者不同的部件布置。It will be understood by those skilled in the art that only a part of the structure related to the present invention from the device is shown in the embodiment of the present invention, and more components than those illustrated, or different component arrangements may be included.
参见图6,为本发明实施例提供的一种主设备的结构示意图,用于实现本发明实施例图3所示的广播实现方法。所述主设备60包括:生成模块601,发送模块602和接收模块603。FIG. 6 is a schematic structural diagram of a master device according to an embodiment of the present invention, which is used to implement the broadcast implementation method shown in FIG. 3 according to an embodiment of the present invention. The master device 60 includes a generating module 601, a sending module 602, and a receiving module 603.
所述生成模块601,用于生成广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照次序作出应答;The generating module 601 is configured to generate a broadcast frame, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order;
所述发送模块602,用于发送所述广播帧。所述RS-485总线网络中的从设备都会收到所述广播帧。本发明实施例,所述广播实现装置60通过所述广播帧中的应答从机信息,指定所述多个从设备按照次序应答所述广播帧。The sending module 602 is configured to send the broadcast frame. The slave device in the RS-485 bus network will receive the broadcast frame. In the embodiment of the present invention, the broadcast implementing apparatus 60 specifies, by using the response slave information in the broadcast frame, that the multiple slave devices answer the broadcast frame in order.
所述接收模块603,用于接收所述多个从设备返回的应答帧。The receiving module 603 is configured to receive a response frame returned by the multiple slave devices.
所述应答从机信息为TLV格式,具体可参见步骤101中描述。The response slave information is in the TLV format. For details, refer to the description in step 101.
可选地,所述广播帧中还包括单点超时时长。Optionally, the broadcast frame further includes a single point timeout duration.
所述生成模块601,确定所述多个从设备的地址;根据所述多个从设备的地址和预设条件,确定所述应答从机信息;根据所述应答从机信息生成所述广播帧。The generating module 601 is configured to determine an address of the multiple slave devices, determine the responding slave information according to addresses and preset conditions of the multiple slave devices, and generate the broadcast frame according to the responding slave information .
所述主设备60可以采用任一类型的应答从机信息来指定所述多个从设备按照次序应答。所述预设条件包括:The master device 60 can employ any type of response slave information to designate the plurality of slave devices to respond in order. The preset conditions include:
若所述主设备60要指定所有从设备按照次序应答,优选采用类型为0的应答从机信息。If the master device 60 is to designate all slave devices to respond in order, it is preferred to use answer slave information of type 0.
若主设备要指定地址连续的多个从设备按照次序应答,优选采用类型为1的应答从机信息。If the master device wants to specify multiple consecutive slave addresses to respond in order, it is preferable to use the responder slave information of type 1.
若所述主设备60要指定地址不连续的多个从设备按照次序应答,可以采用类型为2或3的应答从机信息。具体地,所述广播实现装置60可以按照预设条件,确定所述应答从机信息的类型。所述预设条件包括:当需要应答的从设备的数量小于预设阈值时,确定所述应答从机信息的类型为2,需要应答的各个从设 备可以将自己的地址在值字段中的顺序作为自己的应答次序。当需要应答的从设备的数量大于等于预设阈值时,确定所述应答从机信息的类型为3,需要应答的从设备可以将自己对应的应答指示位在所有值为1的应答指示位中的顺序作为自己的应答次序。If the master device 60 wants to specify multiple slave devices whose addresses are not consecutive, the responder slave information of type 2 or 3 can be used. Specifically, the broadcast implementing device 60 may determine the type of the response slave information according to a preset condition. The preset condition includes: when the number of slave devices that need to be answered is less than a preset threshold, determining that the type of the response slave information is 2, and each slave device that needs to respond The device can use its own address in the value field as its own response order. When the number of slave devices that need to be answered is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3, and the slave device that needs to respond may set its own response indicator to all the response indicator bits with a value of 1. The order is as its own response order.
所述预设阈值可以为
Figure PCTCN2017109754-appb-000004
其中n为从设备的地址的位数。当然,除了将预设阈值设置为
Figure PCTCN2017109754-appb-000005
也可以设置为更大或更小的数值。
The preset threshold may be
Figure PCTCN2017109754-appb-000004
Where n is the number of bits of the address of the slave device. Of course, except that the preset threshold is set to
Figure PCTCN2017109754-appb-000005
It can also be set to a larger or smaller value.
显然,无论上述何种情况,都可以采用类型为3的应答从机信息来实现。Obviously, regardless of the above situation, the response slave information of type 3 can be used.
所述接收模块603可以根据单点超时时长和所述多个从设备(指定需应答所述广播帧的从设备)的数量确定应答等待周期,并在所述应答等待周期内,接收所述多个从设备返回的应答帧。The receiving module 603 may determine a response waiting period according to a single point timeout duration and the number of the plurality of slave devices (specifying slave devices that need to answer the broadcast frame), and receive the multiple during the response waiting period. The response frame returned from the device.
所述主设备60还可以包括:记录模块,用于根据所述多个设备返回的应答帧,记录各个设备对应的状态信息,例如设备版本,发射功率,休眠时间等。The master device 60 may further include: a recording module, configured to record, according to the response frame returned by the multiple devices, status information corresponding to each device, such as a device version, a transmit power, a sleep time, and the like.
本实施例中其他未尽细节可参考本发明实施例图1和图3所示方法中描述。Other details in this embodiment may be described in the method shown in FIG. 1 and FIG. 3 of the embodiment of the present invention.
本发明实施例提供的主设备,生成并发送包括应答从机信息的广播帧,通过该应答从机信息指示多个设备按照应答次序作出应答,以广播实现类似组播的通信机制,相比于传统的单播或广播方式,在避免多个从设备间广播应答冲突的同时,可以提高通信效率,从而提高整个RS-485总线网络的性能。The master device provided by the embodiment of the present invention generates and sends a broadcast frame including the response slave information, by which the slave device information indicates that multiple devices respond in response order, and broadcasts a multicast-like communication mechanism. The traditional unicast or broadcast mode can improve the communication efficiency while avoiding the broadcast response conflict between multiple slave devices, thereby improving the performance of the entire RS-485 bus network.
参见图7,为本发明实施例提供的另一种主设备的结构示意图。所述主设备70包括:处理器701和通信接口702。所述主设备70用于实现本发明实施例图3所示的广播实现方法。FIG. 7 is a schematic structural diagram of another main device according to an embodiment of the present invention. The master device 70 includes a processor 701 and a communication interface 702. The master device 70 is configured to implement the broadcast implementation method shown in FIG. 3 of the embodiment of the present invention.
所述处理器701和所述通信接口702相互连接。The processor 701 and the communication interface 702 are connected to each other.
所述通信接口702包括RS-485芯片,用于与所述RS-485总线网络中的从设备通信。The communication interface 702 includes an RS-485 chip for communicating with slave devices in the RS-485 bus network.
所述处理器701,用于生成广播帧并通过所述通信接口702发送所述广播帧;所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照次序作出应答。The processor 701 is configured to generate a broadcast frame and send the broadcast frame by using the communication interface 702. The broadcast frame includes response slave information, and the response slave information is used to indicate the RS-485 bus. Multiple slave devices in the network respond in order.
所述处理器701还用于通过所述通信接口702接收所述多个从设备返回的应答帧。The processor 701 is further configured to receive, by using the communication interface 702, a response frame returned by the multiple slave devices.
所述处理器701通常为MCU,还可以包括数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件。The processor 701 is typically an MCU and may also include a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic device.
所述应答从机信息为TLV格式,具体可参见步骤101中描述。The response slave information is in the TLV format. For details, refer to the description in step 101.
所述处理器701,具体用于确定所述多个从设备的地址;根据所述多个从设备的地址和预设条件,确定所述应答从机信息;根据所述应答从机信息生成所述广播帧。The processor 701 is specifically configured to determine an address of the multiple slave devices, determine the response slave information according to an address and a preset condition of the multiple slave devices, and generate a location information according to the response slave information. Said broadcast frame.
所述处理器701中还包括存储器,用于存储所述RS-485总线网络中从设备的地址。The processor 701 further includes a memory for storing an address of the slave device in the RS-485 bus network.
所述主设备70可以采用任一类型的应答从机信息来指定所述多个从设备按 照次序应答。所述预设条件具体可参考图3所示方法步骤302中所述。The master device 70 may employ any type of response slave information to designate the plurality of slave devices to press Answer in order. The preset condition may be specifically referred to in the method step 302 shown in FIG.
可选地,所述广播帧中还包括单点超时时长。所述处理器701还用于根据所述广播帧中的数据、从设备处理速度、总线通信速率等因素确定所述单点超时时长。所述单点超时时长是从设备应答所述广播帧所需的最大时长。Optionally, the broadcast frame further includes a single point timeout duration. The processor 701 is further configured to determine the single point timeout duration according to factors in the broadcast frame, a slave processing speed, a bus communication rate, and the like. The single point timeout duration is the maximum length of time required for the slave device to answer the broadcast frame.
当然,所述单点延时时长也可以预先配置在主设备和各个从设备上。所述存储器还可以用于存储所述单点超时时长。Of course, the single-point delay duration can also be pre-configured on the master device and each slave device. The memory can also be used to store the single point timeout duration.
所述处理器701可以根据所述单点超时时长和所述多个从设备(指定需应答所述广播帧的从设备)的数量确定应答等待周期,并在所述应答等待周期内,接收所述多个从设备返回的应答帧。The processor 701 may determine a response waiting period according to the single-point timeout duration and the number of the plurality of slave devices (specifying slave devices that need to answer the broadcast frame), and receive the receiving period during the response waiting period. A response frame returned by multiple slave devices.
所述处理器701,还用于根据所述多个设备返回的应答帧,记录各个设备对应的状态信息,例如设备版本,发射功率,休眠时间等。The processor 701 is further configured to record, according to the response frame returned by the multiple devices, status information corresponding to each device, such as a device version, a transmit power, a sleep time, and the like.
本领域技术人员可以理解的是,本发明实施例中仅示出了主设备与本发明相关的部分结构,还可以包括比图示更多的部件,或者不同的部件布置。It will be understood by those skilled in the art that only a part of the structure of the main device related to the present invention is shown in the embodiment of the present invention, and more components than those illustrated, or different component arrangements may be included.
参见图8所示,为本发明实施例提供的RS-485总线网络的示意图,其中包括主设备801和多个从设备802。所述主设备801的工作原理、结构和功能的具体细节可参见本发明实施例图6或7所示,在此不再赘述。从设备802的工作原理、结构和功能的具体细节可参见本发明实施例图4或5所示,在此不再赘述。FIG. 8 is a schematic diagram of an RS-485 bus network according to an embodiment of the present invention, including a master device 801 and a plurality of slave devices 802. For details of the working principle, structure, and function of the main device 801, refer to FIG. 6 or 7 of the embodiment of the present invention, and details are not described herein again. For details of the working principle, structure, and function of the device 802, refer to FIG. 4 or 5 of the embodiment of the present invention, and details are not described herein again.
本发明实施例提供的广播实现方法也可用于星型组网方式的低速率无线个人区域网(low-rate wireless personal area network,简称LR-WPAN)。LR-WPAN中的协调器等同于本发明实施例中的主设备,非协调器设备:全功能设备(full-function device,简称FFD)和精简功能设备(reduced-function device,简称RFD),等同于本发明实施例中的从设备。本发明实施例基于RS-485总线网络来说明,并不作为对本发明的限制。The broadcast implementation method provided by the embodiment of the present invention can also be applied to a low-rate wireless personal area network (LR-WPAN) in a star networking mode. The coordinator in the LR-WPAN is equivalent to the master device in the embodiment of the present invention. The non-coordinator device: a full-function device (FFD) and a reduced-function device (RFD) are equivalent. A slave device in an embodiment of the present invention. The embodiments of the present invention are described based on the RS-485 bus network and are not intended to limit the present invention.
本领域普通技术人员可以理解,实现上述各方法实施例中的全部或部分步骤是可以通过程序来指令相关的硬件完成,相应的程序可以存储于计算机可读存储介质中,上述存储介质可以是随机存取存储器,只读存储器,快闪存储器,硬盘,固态硬盘或光盘等。A person skilled in the art can understand that all or part of the steps in implementing the foregoing method embodiments may be performed by a program to instruct related hardware, and the corresponding program may be stored in a computer readable storage medium, and the storage medium may be random. Access memory, read-only memory, flash memory, hard disk, solid state hard disk or optical disk.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。 The above is only a preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or within the technical scope disclosed by the present invention. Alternatives are intended to be covered by the scope of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims (13)

  1. 一种广播实现方法,用于推荐标准RS-485总线网络中,其特征在于,包括:A broadcast implementation method for recommending a standard RS-485 bus network, characterized in that it comprises:
    第一从设备接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照次序作出应答;Receiving, by the first slave device, a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order;
    当根据所述应答从机信息确定需要应答所述广播帧时,所述第一从设备根据所述应答从机信息获取应答开始时刻,并在到达所述应答开始时刻时作出应答。When it is determined that the broadcast frame needs to be answered according to the response slave information, the first slave device acquires a response start time according to the response slave information, and responds when the response start time is reached.
  2. 根据权利要求1所述的方法,其特征在于,所述第一从设备根据所述应答从机信息获取应答开始时刻,包括:The method according to claim 1, wherein the first slave device acquires a response start time according to the response slave information, and includes:
    所述第一从设备根据所述应答从机信息获取所述第一从设备的应答次序N,所述应答次序N为所述第一从设备在所述多个从设备中应答所述广播帧的次序;Obtaining, by the first slave device, the response sequence N of the first slave device according to the response slave information, where the response sequence N is that the first slave device answers the broadcast frame in the multiple slave devices Order
    所述第一从设备根据单点超时时长D和所述第一从设备的应答次序N,计算所述第一从设备的应答开始时刻Tsn=T0+(N-1)*D,其中,T0是所述第一从设备收到所述广播帧的时刻。The first slave device calculates a response start time Tsn=T0+(N-1)*D of the first slave device according to a single point timeout duration D and a response sequence N of the first slave device, where T0 is The moment when the first slave device receives the broadcast frame.
  3. 根据权利要求1或2所述的方法,其特征在于,N≥2,所述方法还包括:The method according to claim 1 or 2, wherein N ≥ 2, the method further comprises:
    所述第一从设备在到达所述第一从设备的应答开始时刻Tsn前,侦听RS-485总线;The first slave device listens to the RS-485 bus before reaching the response start time Tsn of the first slave device;
    根据应答次序在先的第二从设备的应答结束时刻Tek,更新所述第一从设备的应答开始时刻Tsn=Tek+(N-K-1)*D,其中,K为所述第二从设备的应答次序,N>K≥1。Updating the response start time Tsn=Tek+(NK-1)*D of the first slave device according to the response end time Tek of the second slave device in the response order, where K is the response of the second slave device Order, N>K≥1.
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述应答从机信息为类型长度值(type-length-value,简称TLV)格式;所述应答从机信息的类型为如下任意一种:The method according to any one of claims 1 to 3, wherein the response slave information is a type-length-value (TLV) format; the type of the response slave information is as follows Any one:
    类型为0,指示所述RS-485总线网络中的所有从设备需要按照次序应答;Type 0, indicating that all slave devices in the RS-485 bus network need to respond in order;
    类型为1,指示值字段中起始地址到终止地址范围内的多个从设备需要按照次序应答;Type 1 indicates that multiple slave devices in the range of the start address to the end address in the value field need to respond in order;
    类型为2,指示值字段中各个地址对应的从设备需要按照次序应答;The type is 2, indicating that the slave devices corresponding to each address in the value field need to respond in order;
    类型为3,指示值字段中应答指示位指示需要应答的从设备按照次序应答。The type is 3, and the response indication bit in the indication value field indicates that the slaves that need to answer are responsive in order.
  5. 一种广播实现方法,用于推荐标准RS-485总线网络中,其特征在于,包括:A broadcast implementation method for recommending a standard RS-485 bus network, characterized in that it comprises:
    主设备生成并发送广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照应答次序作出应答;The master device generates and transmits a broadcast frame, the broadcast frame includes response slave information, and the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in response order;
    所述主设备接收所述多个从设备按照应答次序返回的应答帧;Receiving, by the master device, a response frame returned by the multiple slave devices in response sequence;
    所述应答次序为所述应答从机信息所指示的所述多个从设备返回应答帧的次序。The response order is an order in which the response frame is returned by the plurality of slave devices indicated by the response slave information.
  6. 根据权利要求5所述的方法,其特征在于,所述主设备生成所述广播帧, 包括:The method according to claim 5, wherein said master device generates said broadcast frame, include:
    所述主设备确定所述多个从设备的地址;The master device determines an address of the plurality of slave devices;
    根据所述多个从设备的地址和预设条件,确定所述应答从机信息;Determining the response slave information according to an address of the plurality of slave devices and a preset condition;
    根据所述应答从机信息生成所述广播帧。Generating the broadcast frame based on the response slave information.
  7. 根据权利要求5或6所述的方法,其特征在于,所述应答从机信息为类型长度值(type-length-value,简称TLV)格式;所述预设条件包括:The method according to claim 5 or 6, wherein the response slave information is a type-length-value (TLV) format; the preset condition includes:
    若要指定所述RS-485总线网络中所有从设备按照次序应答,采用类型为0的应答从机信息;To specify that all slave devices in the RS-485 bus network respond in order, using the responder slave information of type 0;
    若要指定地址连续的多个从设备按照次序应答,采用类型为1的应答从机信息;To specify that multiple slave devices with consecutive addresses respond in order, use response slave information of type 1;
    若所述主设备要指定地址不连续的多个从设备按照次序应答,当需要应答的从设备的数量小于预设阈值时,确定所述应答从机信息的类型为2;当需要应答的从设备的数量大于等于预设阈值时,确定所述应答从机信息的类型为3。If the master device wants to specify multiple slave devices whose addresses are not consecutively replied in order, when the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the responding slave information is 2; When the number of devices is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3.
  8. 一种广播实现装置,用于推荐标准RS-485总线网络中,其特征在于,包括:A broadcast implementation device for recommending a standard RS-485 bus network, comprising:
    接收模块,用于接收主设备发送的广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照次序作出应答;a receiving module, configured to receive a broadcast frame sent by the master device, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in order ;
    处理模块,用于当根据所述应答从机信息确定需要应答所述广播帧时,所述第一从设备根据所述应答从机信息获取应答开始时刻,并在到达所述应答开始时刻时作出应答;a processing module, configured to: when determining, according to the response slave information, that the broadcast frame needs to be answered, the first slave device acquires a response start time according to the response slave information, and when the response start time is reached Answer
    所述广播实现装置部署在所述多个从设备中的第一从设备上。The broadcast implementation device is deployed on a first of the plurality of slave devices.
  9. 根据权利要求8所述的装置,其特征在于,所述处理模块,具体用于根据所述应答从机信息获取所述第一从设备的应答次序N,所述应答次序N为所述第一从设备在所述多个从设备中应答所述广播帧的次序;根据单点超时时长D和所述第一从设备的应答次序N,计算所述第一从设备的应答开始时刻Tsn=T0+(N-1)*D,其中,T0是所述第一从设备收到所述广播帧的时刻。The apparatus according to claim 8, wherein the processing module is configured to acquire a response sequence N of the first slave device according to the response slave information, where the response sequence N is the first An order in which the slave device answers the broadcast frame in the plurality of slave devices; and calculates a response start time Tsn=T0+ of the first slave device according to the single-point timeout duration D and the response sequence N of the first slave device (N-1)*D, where T0 is the time at which the first slave device receives the broadcast frame.
  10. 根据权利要求8或9所述的装置,其特征在于,N≥2,所述处理模块,还用于所述第一从设备在到达所述第一从设备的应答开始时刻Tsn前,侦听RS-485总线;根据应答次序在先的第二从设备的应答结束时刻Tek,更新所述第一从设备的应答开始时刻Tsn=Tek+(N-K-1)*D,其中,K为所述第二从设备的应答次序,N>K≥1。The device according to claim 8 or 9, wherein N ≥ 2, the processing module is further configured to: the first slave device listens before reaching a response start time Tsn of the first slave device RS-485 bus; updating the response start time Tsn=Tek+(NK-1)*D of the first slave device according to the response end time Tek of the second slave device in the response sequence, where K is the number The order of response of the two slave devices, N>K≥1.
  11. 一种主设备,用于推荐标准RS-485总线网络中,其特征在于,包括:A master device for recommending a standard RS-485 bus network, characterized by comprising:
    生成模块,用于生成广播帧,所述广播帧中包括应答从机信息,所述应答从机信息用于指示所述RS-485总线网络中的多个从设备按照应答次序作出应答;a generating module, configured to generate a broadcast frame, where the broadcast frame includes response slave information, where the response slave information is used to indicate that multiple slave devices in the RS-485 bus network respond in response order;
    发送模块,用于发送所述广播帧,所述应答次序为所述应答从机信息所指示的所述多个从设备返回应答帧的次序;a sending module, configured to send the broadcast frame, where the response order is an order in which the response frame is returned by the multiple slave devices indicated by the response slave information;
    接收模块,用于接收所述多个从设备按照应答次序返回的应答帧。 And a receiving module, configured to receive the response frame returned by the multiple slave devices in the response sequence.
  12. 根据权利要求11所述的主设备,其特征在于,所述生成模块,具体用于确定所述多个从设备的地址;根据所述多个从设备的地址和预设条件,确定所述应答从机信息;根据所述应答从机信息生成所述广播帧。The master device according to claim 11, wherein the generating module is specifically configured to determine an address of the plurality of slave devices, and determine the response according to an address and a preset condition of the multiple slave devices The slave information; the broadcast frame is generated according to the response slave information.
  13. 根据权利要求11或12所述的主设备,其特征在于,所述应答从机信息为类型长度值(type-length-value,简称TLV)格式;所述预设条件包括:The master device according to claim 11 or 12, wherein the response slave information is a type-length-value (TLV) format; the preset condition includes:
    若要指定所述RS-485总线网络中所有从设备按照次序应答,采用类型为0的应答从机信息;To specify that all slave devices in the RS-485 bus network respond in order, using the responder slave information of type 0;
    若要指定地址连续的多个从设备按照次序应答,采用类型为1的应答从机信息;To specify that multiple slave devices with consecutive addresses respond in order, use response slave information of type 1;
    若所述主设备要指定地址不连续的多个从设备按照次序应答,当需要应答的从设备的数量小于预设阈值时,确定所述应答从机信息的类型为2;当需要应答的从设备的数量大于等于预设阈值时,确定所述应答从机信息的类型为3。 If the master device wants to specify multiple slave devices whose addresses are not consecutively replied in order, when the number of slave devices that need to be answered is less than a preset threshold, it is determined that the type of the responding slave information is 2; When the number of devices is greater than or equal to a preset threshold, it is determined that the type of the response slave information is 3.
PCT/CN2017/109754 2016-12-24 2017-11-07 Broadcast realisation method, apparatus and device WO2018113432A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611210210.9A CN108243017B (en) 2016-12-24 2016-12-24 Broadcast implementation method, device and equipment
CN201611210210.9 2016-12-24

Publications (1)

Publication Number Publication Date
WO2018113432A1 true WO2018113432A1 (en) 2018-06-28

Family

ID=62624696

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/109754 WO2018113432A1 (en) 2016-12-24 2017-11-07 Broadcast realisation method, apparatus and device

Country Status (2)

Country Link
CN (1) CN108243017B (en)
WO (1) WO2018113432A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130970A (en) * 2019-12-31 2020-05-08 深圳市无眼界科技有限公司 Communication method based on modbus communication protocol
CN112104487A (en) * 2020-08-31 2020-12-18 北京智芯微电子科技有限公司 Remote upgrading method for terminal of Internet of things, Internet of things master station and storage medium
CN112363479A (en) * 2020-12-09 2021-02-12 南昌航空大学 Digital communication transmission method and system between field devices
CN112653743A (en) * 2020-12-16 2021-04-13 广州鲁邦通物联网科技有限公司 Multi-sensor addressing method in RS485 bus, data acquisition equipment and system
CN115442333A (en) * 2022-08-19 2022-12-06 上海长江电气设备集团有限公司 Self-networking method and device based on RS485 communication, computer equipment and medium

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111008169B (en) * 2019-11-20 2022-08-12 南京南瑞水利水电科技有限公司 Low-cost high-speed communication bus and transmission control method thereof
CN113746647B (en) * 2020-05-27 2023-12-19 中国联合网络通信集团有限公司 Data transmission method, node, electronic device and readable storage medium
CN111756610A (en) * 2020-05-29 2020-10-09 宁波三星医疗电气股份有限公司 RS485 bus communication time sequence control method
CN112311641B (en) * 2020-12-30 2021-04-06 深圳市法拉第电驱动有限公司 CAN communication-based communication method and system for upper computer and lower computer
CN113726602A (en) * 2021-08-20 2021-11-30 浙江中产科技有限公司 Semi-active response polling method
CN114741349B (en) * 2021-12-31 2024-02-27 杭州拓深科技有限公司 Multi-platform data transparent transmission 485 bus interaction method, medium, equipment and system
CN116723176B (en) * 2023-08-11 2023-10-20 广东云驰时代技术有限公司 Continuous addressing communication method, system, computer device and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101032127A (en) * 2004-10-19 2007-09-05 英特尔公司 Response scheduling for multiple receivers
US20100254369A1 (en) * 2009-04-07 2010-10-07 Zhifeng Tao Cooperative Ultra-Reliable Wireless Communications
CN102265545A (en) * 2008-12-31 2011-11-30 三菱电机株式会社 Ofdma based medium access control and frame structure design for industrial applications
CN103826252A (en) * 2014-01-16 2014-05-28 京信通信系统(中国)有限公司 Method of acquiring and sending sequence numbers among main and slave devices and system
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN105813026A (en) * 2014-12-31 2016-07-27 华为技术有限公司 Broadcast realizing method, device and equipment
CN107181659A (en) * 2016-03-10 2017-09-19 深圳市祈飞科技有限公司 Intelligent cabinet communication means and system based on RS485 buses

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101032127A (en) * 2004-10-19 2007-09-05 英特尔公司 Response scheduling for multiple receivers
CN102265545A (en) * 2008-12-31 2011-11-30 三菱电机株式会社 Ofdma based medium access control and frame structure design for industrial applications
US20100254369A1 (en) * 2009-04-07 2010-10-07 Zhifeng Tao Cooperative Ultra-Reliable Wireless Communications
CN103826252A (en) * 2014-01-16 2014-05-28 京信通信系统(中国)有限公司 Method of acquiring and sending sequence numbers among main and slave devices and system
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN105813026A (en) * 2014-12-31 2016-07-27 华为技术有限公司 Broadcast realizing method, device and equipment
CN107181659A (en) * 2016-03-10 2017-09-19 深圳市祈飞科技有限公司 Intelligent cabinet communication means and system based on RS485 buses

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130970A (en) * 2019-12-31 2020-05-08 深圳市无眼界科技有限公司 Communication method based on modbus communication protocol
CN112104487A (en) * 2020-08-31 2020-12-18 北京智芯微电子科技有限公司 Remote upgrading method for terminal of Internet of things, Internet of things master station and storage medium
CN112104487B (en) * 2020-08-31 2023-06-20 北京智芯微电子科技有限公司 Remote upgrading method of Internet of things terminal, internet of things master station and storage medium
CN112363479A (en) * 2020-12-09 2021-02-12 南昌航空大学 Digital communication transmission method and system between field devices
CN112363479B (en) * 2020-12-09 2022-04-08 南昌航空大学 Digital communication transmission method and system between field devices
CN112653743A (en) * 2020-12-16 2021-04-13 广州鲁邦通物联网科技有限公司 Multi-sensor addressing method in RS485 bus, data acquisition equipment and system
CN112653743B (en) * 2020-12-16 2024-05-10 广州鲁邦通物联网科技股份有限公司 Multi-sensor addressing method, data acquisition equipment and system in RS485 bus
CN115442333A (en) * 2022-08-19 2022-12-06 上海长江电气设备集团有限公司 Self-networking method and device based on RS485 communication, computer equipment and medium

Also Published As

Publication number Publication date
CN108243017A (en) 2018-07-03
CN108243017B (en) 2020-10-23

Similar Documents

Publication Publication Date Title
WO2018113432A1 (en) Broadcast realisation method, apparatus and device
TWI779165B (en) Method for reserving resources and devices and terminals
RU2595886C2 (en) Device for short personal service call
US9094424B2 (en) Method, apparatus, and computer program product for digital stream swapping between signal sources
KR101644150B1 (en) Updating method and apparatus of sleep mode operation
US20170026777A1 (en) Bluetooth low energy interlaced advertising and scanning
US9288832B2 (en) Wireless apparatus, base station, and communication controlling method thereof
WO2018027591A1 (en) Method, device, and system for v2x message transmission
CN109923913A (en) Method and apparatus for managing the paging in cordless communication network
US20160286465A1 (en) Method and apparatus for transmitting d2d discovery signal and communication system
WO2016107129A1 (en) Broadcast implementation method, apparatus and device
CN110536382B (en) Method and device for processing packet wake-up signal, base station, terminal and storage medium
TWI663889B (en) Method and device for random access
JP2020523869A (en) Method, device and storage medium for transmitting paging messages
EP3419325B1 (en) Distance measurement method using wireless fidelity (wi-fi), related device, and system
WO2018107370A1 (en) Point to multi-point channel allocation method, apparatus, and system
WO2017041629A1 (en) Active scanning processing method and related device and communication system
JP6951458B2 (en) How to transmit system information, base stations and terminals
CN105406955A (en) Data output control method and system
JP2018186342A (en) Communication device, control method, and program
CN104854950A (en) Systems and methods for delay indication in a wireless message
US9986412B2 (en) Discovery in a wireless communications system
FI127550B (en) Slotted channel access in communications network
WO2021227917A9 (en) Time determination method and apparatus, terminal, and network device
WO2013071478A1 (en) A method and an apparatus for assisting operation of a wireless sensor network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17883401

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17883401

Country of ref document: EP

Kind code of ref document: A1