A device communication method, apparatus, device, and storage medium

CN117376056BActive Publication Date: 2026-08-11HANGZHOU HOLLYSYS AUTOMATION
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-13
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

但是对串行总线冗余主站与交叉故障从站的通信及诊断缺乏有效的解决手段

Benefits of technology

[0059]本申请在进行设备通信时,主用主站首先判断从站设备是否能与主用主站进行数据通信;若能与所述主用主站进行数据通信,将所述从站设备确定为当前第一从站设备,由所述主用主站向所述当前第一从站设备发送数据采集请求以采集数据;若不能与所述主用主站进行数据通信,由所述备用主站向所述从站设备转发所述主用主站生成的数据采集请求,并由所述备用主站将所述从站设备返回应答数据对应的通信信息发送至所述主用主站;然后基于所述通信信息判断所述从站设备是否符合预设离线条件;若符合所述预设离线条件,则确定所述从站设备为当前离线设备;若不符合所述预设离线条件,则确定所述从站设备为当前第二从站设备;最后基于预设诊断周期对各所述当前离线设备、所述当前第一从站设备以及所述当前第二从站设备进行诊断,将相应的离线诊断报文发送至本地总线设备。可见,本申请能够根据主用主站与从站设备的通信情况完成各工况下,串行总线冗余主站与交叉故障从站的通信及诊断。同时无需依赖高性能的软硬件,可以适用于任何软件或硬件平台。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117376056B_ABST
    Figure CN117376056B_ABST
Patent Text Reader

Abstract

This application discloses a device communication method, apparatus, device, and storage medium, applied to a master station and relating to the field of industrial communication. The method includes: determining whether a slave device can communicate with the master station via data; if so, identifying the slave device as the current first slave device and sending a data acquisition request to the current first slave device; if not, having a backup master station forward the data acquisition request to the slave device and sending the communication information corresponding to the returned response data to the master station; determining whether the slave device meets preset offline conditions based on the communication information; if so, identifying the slave device as the current offline device; if not, identifying the slave device as the current second slave device; and performing diagnostics on each currently offline device, the current first slave device, and the current second slave device based on a preset diagnostic cycle, sending an offline diagnostic message to the local bus device. Thus, this application completes communication between the master station and a cross-faulted slave device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial communication, and in particular to a device communication method, apparatus, device, and storage medium. Background Technology

[0002] SCADA (Supervisory Control and Data Acquisition) systems often employ redundant FEPs (Front-End Processors, referred to as master units in this paper) to communicate with slave devices. However, many slave devices, both domestically and internationally, only support serial single-channel communication, such as... Figure 1 As shown, the device can only connect to the COMA (Component Object Mode A) and COMB (Component Object Mode B) serial ports of the redundant FEP master station through one serial port.

[0003] The communication protocol between slave devices and master FEPs largely adopts a master-slave response method. The physical layer typically uses a two-wire RS485 half-duplex mode, meaning that only one communication node (the communication node refers to all master FEPs and slave devices participating in the communication on the serial bus) can be in transmit mode at any given time. This is the link collision mode. In link collision mode, the master station needs to control the communication to ensure stable, reliable, and real-time communication. For a SCADA monitoring station, in actual project implementation, a pair of FEPs usually handles the access of all external devices to the station. However, the number of serial ports on a single FEP is often no more than 20, while the number of external devices in a SCADA monitoring station often reaches hundreds. Therefore, one serial port on an FEP usually needs to connect to multiple devices (such as...). Figure 1 (As shown). The communication channel between any serial port in an FEP and all its slave devices is called a link; that is, an FEP usually has multiple links. In a redundant FEP, FEP-A and FEP-B each have a link connected to the same device. These two links are called serial bus redundant master links (or redundant links for short). The master station where the default primary link for communicating with the device is located is called the default master or default host, and the master station where the default backup link for communicating with the device is located is called the default backup or default standby machine.

[0004] Firstly, write operations on the serial link must be managed. This means the two FEPs must not simultaneously send data requests or other commands to the device; otherwise, link data corruption will occur, leading to communication failure—a phenomenon known as link conflict. Current technology ensures that when the slave device is single-channel in the master-slave response protocol, the redundant master will not perform operations on the device simultaneously. The standby device first identifies the request message sent by the hot-running master, then identifies the response message sent by the slave, and then performs self-diagnosis based on the request and response messages. This self-diagnosis can be achieved without the standby device itself sending request messages to the slave. In most cases, this technology ensures the real-time nature of communication status diagnosis between the standby and slave devices without affecting the smoothness of hot-running communication. However, there is a lack of effective solutions for communication and diagnosis between redundant serial bus masters and cross-faulted slave devices. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a device communication method, apparatus, device, and storage medium that can effectively solve the communication and diagnosis problems between redundant master stations and cross-faulted slave stations on a serial bus. The specific solution is as follows:

[0006] In a first aspect, this application discloses a device communication method applied to a primary master station, comprising:

[0007] Determine whether the slave device can communicate with the master station via data.

[0008] If data communication can be established with the master station, the slave device is identified as the current first slave device, and the master station sends a data acquisition request to the current first slave device to collect data;

[0009] If data communication with the primary master station is not possible, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station.

[0010] Based on the communication information, it is determined whether the slave device meets the preset offline conditions; if it meets the preset offline conditions, the slave device is determined to be the current offline device; if it does not meet the preset offline conditions, the slave device is determined to be the current second slave device.

[0011] Based on a preset diagnostic cycle, diagnose each of the currently offline devices, the currently first slave device, and the currently second slave device, and send the corresponding offline diagnostic messages to the local bus device.

[0012] Optionally, the step of forwarding the data acquisition request generated by the primary master station to the slave device from the backup master station, and the backup master station sending the communication information corresponding to the response data returned by the slave device to the primary master station, includes:

[0013] A data acquisition request is generated and sent to the backup master station based on a pre-configured heartbeat line between master stations. The backup master station then sends the data acquisition request to the slave device and sends the communication information corresponding to the response data returned by the slave device to the primary master station via the heartbeat line.

[0014] Optionally, the method further includes:

[0015] The data acquisition request is generated according to the preset acquisition parameters;

[0016] The preset acquisition parameters include any one or a combination of acquisition period, timeout time, and transmission delay.

[0017] Optionally, determining whether the slave device meets preset offline conditions based on the communication information; if it meets the preset offline conditions, then determining the slave device as the current offline device; if it does not meet the preset offline conditions, then determining the slave device as the current second slave device includes:

[0018] If the backup master station does not receive the response data returned by the slave device and fails to send the response status of the slave device to the master station within the preset timeout period, the communication with the slave device is deemed to have failed.

[0019] If the number of communication failures with the slave device exceeds a preset number of failures, the slave device is determined to meet the preset offline conditions, and the slave device is identified as the currently offline device.

[0020] If the backup master station receives the response data returned by the slave device and sends the response status of the slave device to the primary master station within the preset timeout period, it is determined that the slave device does not meet the preset offline conditions, and the slave device is identified as the current second slave device.

[0021] Optionally, the step of performing diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and sending the corresponding offline diagnostic messages to the local bus device, includes:

[0022] Determine whether the primary master station receives a heartbeat packet sent by the current second slave device and / or the current offline device within a preset diagnostic period;

[0023] If so, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding first offline diagnostic message is obtained. The slave device that is not in an offline state among the current second slave device and / or the current offline device is re-marked as online, so as to determine the current offline device and the current second slave device.

[0024] If not, the current offline device corresponding to the heartbeat packet is determined to be in an offline state, and a corresponding second offline diagnostic message is obtained;

[0025] Send the first offline diagnostic message and the second offline diagnostic message corresponding to the target number of the current second slave devices and / or the current offline devices obtained within the current preset diagnostic cycle to the local bus device;

[0026] In the next preset diagnostic cycle, the primary master station will send a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received the heartbeat packet sent by the current first slave device based on the diagnostic notification.

[0027] If so, it is determined that the current first slave device corresponding to the heartbeat packet is not offline, and the corresponding third offline diagnostic message is obtained. The slave devices that are not offline in the current first slave device are re-marked as online to determine the current first slave device.

[0028] If not, it is determined that the first slave device corresponding to the heartbeat packet is still offline, and the corresponding fourth offline diagnostic message is obtained;

[0029] Send the third and fourth offline diagnostic messages corresponding to the target number of the current first slave devices to the local bus device.

[0030] Optionally, after sending the target number of the third offline diagnostic messages and the fourth offline diagnostic messages corresponding to the current first slave devices to the local bus device, the method further includes:

[0031] Determine whether the primary master station receives a heartbeat packet sent by the current second slave device within a preset diagnostic period;

[0032] If so, it is determined that the current second slave device corresponding to the heartbeat packet is not offline, and the corresponding fifth offline diagnostic message is obtained. The slave device that is not offline in the current second slave device is re-marked as online to determine the current second slave device.

[0033] If not, it is determined that the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding sixth offline diagnostic message is obtained;

[0034] Send the fifth offline diagnostic message and the sixth offline diagnostic message corresponding to the target number of the current second slave devices obtained within the current preset diagnostic cycle to the local bus device;

[0035] In the next preset diagnostic cycle, the primary master station will send a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the current offline device based on the diagnostic notification.

[0036] If so, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding seventh offline diagnostic message is obtained. The slave device that is not in an offline state among the current first slave device and / or the current offline device is re-marked as online, so as to determine the current first slave device and the current offline device.

[0037] If not, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is still in an offline state, and the corresponding eighth offline diagnostic message is obtained;

[0038] The target number of the current first slave devices and / or the current offline devices corresponding to the seventh and eighth offline diagnostic messages are sent to the local bus device, and the process jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or the current offline device has been received within the preset diagnostic period, until the diagnosis of all slave devices is completed.

[0039] Optionally, the target number is the number of current offline devices in each part after dividing all current offline devices into several parts based on the total number of current offline devices. If it is not possible to divide them equally, the excess number of current offline devices is collected into a single part.

[0040] Optionally, the step of performing diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and sending the corresponding offline diagnostic messages to the local bus device, includes:

[0041] Determine whether the primary master station receives a heartbeat packet sent by the current second slave device and / or the current offline device within a preset diagnostic period;

[0042] If so, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding ninth offline diagnostic message is obtained. The slave device that is not in an offline state among the current second slave device and / or the current offline device is re-marked as online to determine the current offline device and the current second slave device.

[0043] If not, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding tenth offline diagnostic message is obtained;

[0044] The target number of current second slave devices and / or current offline devices obtained within the current preset diagnostic period are sent to the local bus device along with the ninth and tenth offline diagnostic messages. The process then jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or current offline device has been received based on the preset diagnostic period, until all current second slave devices and / or current offline devices have completed the diagnostic process.

[0045] Based on the preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the current offline device based on the diagnostic notification.

[0046] If so, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding eleventh offline diagnostic message is obtained. The slave device that is not in an offline state among the current first slave device and / or the current offline device is re-marked as online, so as to determine the current first slave device and the current offline device.

[0047] If not, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding twelve offline diagnostic messages are obtained;

[0048] The target number of the eleventh and twelfth offline diagnostic messages are sent to the local bus device, and the process jumps back to the step of the primary master station sending a diagnostic notification to the backup master station based on the preset diagnostic cycle, until all the current first slave devices and / or the current offline devices have completed the diagnosis.

[0049] Secondly, this application discloses a device communication apparatus applied to a primary master station, comprising:

[0050] The first judgment module is used to determine whether the slave device can communicate with the master station.

[0051] The request sending module is used to determine the slave device as the current first slave device if data communication with the master station is possible, and then the master station sends a data acquisition request to the current first slave device to collect data.

[0052] The response data sending module is used to forward the data acquisition request generated by the primary master station to the slave device if data communication with the primary master station is not possible, and to send the communication information corresponding to the response data returned by the slave device to the primary master station.

[0053] The second judgment module is used to determine whether the slave device meets the preset offline conditions based on the communication information; if it meets the preset offline conditions, the slave device is determined to be the current offline device; if it does not meet the preset offline conditions, the slave device is determined to be the current second slave device.

[0054] The diagnostic module is used to perform diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and send the corresponding offline diagnostic messages to the local bus device.

[0055] Thirdly, this application discloses an electronic device, including:

[0056] Memory, used to store computer programs;

[0057] A processor for executing the computer program to implement the steps of the aforementioned disclosed device communication method.

[0058] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed device communication method.

[0059] In this application, during device communication, the primary master station first determines whether the slave device can communicate with the primary master station via data. If it can, the slave device is designated as the current first slave device, and the primary master station sends a data acquisition request to the current first slave device to collect data. If it cannot communicate with the primary master station, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and sends the communication information corresponding to the response data returned by the slave device to the primary master station. Then, based on the communication information, it is determined whether the slave device meets the preset offline conditions. If it meets the preset offline conditions, the slave device is determined as the current offline device. If it does not meet the preset offline conditions, the slave device is determined as the current second slave device. Finally, based on a preset diagnostic cycle, diagnoses are performed on each of the current offline devices, the current first slave device, and the current second slave device, and the corresponding offline diagnostic messages are sent to the local bus device. As can be seen, this application can complete the communication and diagnosis between the serial bus redundant master station and the cross-faulted slave station under various operating conditions based on the communication status between the master station and the slave station devices. Furthermore, it does not rely on high-performance hardware or software and can be applied to any software or hardware platform. Attached Figure Description

[0060] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0061] Figure 1 This is a schematic diagram of a serial bus redundant master network;

[0062] Figure 2 This is a flowchart of a device communication method disclosed in this application;

[0063] Figure 3 This is a schematic diagram of a conventional communication method for a serial bus redundant master station FEP-A.

[0064] Figure 4 This is a schematic diagram of a serial bus redundant master station dual-machine data synchronization.

[0065] Figure 5 This is a flowchart of a specific device communication method disclosed in this application;

[0066] Figure 6 This is a flowchart of a specific device communication method disclosed in this application;

[0067] Figure 7This is a schematic diagram of the structure of a device communication apparatus disclosed in this application;

[0068] Figure 8 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0069] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0070] Current technology can only guarantee that when the slave device in the master-slave response protocol is a single-channel device, the redundant master station will not perform operations on the device simultaneously. The standby device first identifies the request message sent by the hot-running machine, then identifies the response message sent by the slave station, and then performs self-diagnosis of the standby device's inability to transmit data based on the request and response messages. This self-diagnosis can be achieved without the standby device itself sending a request message to the slave. In most cases, this technology ensures the real-time nature of communication status diagnosis between the standby device and the slave station, while not affecting the smoothness of hot-running machine communication. However, there is a lack of effective solutions for communication and diagnosis between a redundant master station and a cross-faulted slave station on a serial bus. To solve the above problems, this application discloses a device communication method that can effectively solve the communication and diagnosis between a redundant master station and a cross-faulted slave station on a serial bus.

[0071] See Figure 2 As shown, this embodiment of the invention discloses a device communication method applied to a primary master station, comprising:

[0072] Step S11: Determine whether the slave device can communicate with the master station via data.

[0073] In this embodiment, the application determines the request sending rules based on the values ​​of the device state machine. For the device state machine: 1 indicates that a master station is selected to lead the sending. 0 indicates that the master station sends autonomously, with an initial value of 1. Specifically, the state machine assignment rules are as follows:

[0074] A) When all slave devices are online on the default master, the device state machine is at state 1. In this case, the default master takes the lead in sending data. Specifically, the default master notifies the default standby machine to perform a diagnostic on the slave devices every 30 seconds (which can be pre-configured). After the diagnostic is completed, the default standby machine enters a silent state (only receiving bus data and not sending data to the bus). At other times, the default master polls all slave devices according to the data acquisition configuration parameters (acquisition period, timeout, transmission delay, etc.) through the default master's local communication link to collect data from all slave devices in sequence.

[0075] B) If all slave devices are online on the default standby machine but not all slave devices are online on the default master machine, then the device state machine is 1. In this case, the default standby machine takes the lead in sending. The specific operation process afterward is the same as the steps in A above, and will not be repeated here.

[0076] C) Some slave devices are offline on both the default master and default standby, while the remaining slave devices are online on both. In this case, the default master takes the lead in sending heartbeats to all online devices, following the steps described in A above. The default master also takes the lead in sending heartbeats to all currently offline devices. The heartbeat devices use a long-cycle diagnostic mode (default 1 minute). When the diagnostic cycle expires, the default master first sends a diagnostic message for the currently offline devices to the local bus, and then notifies the default standby to perform a diagnostic on the slave devices.

[0077] D) All slave devices are offline on the default master and standby. At this time, the default master takes the lead in sending all devices. Since all devices are offline, the default master first sends the currently offline device diagnostic message to the local bus, and then notifies the default standby to perform a diagnostic on the slave devices.

[0078] E) Some slave devices are only online on one of the master stations, while the remaining slave devices are offline on the default master and default standby stations. In this case, the master station that is online will take the lead in sending. The specific operation process afterward is the same as the steps in A above, and will not be repeated here.

[0079] However, if a crossover failure occurs at a slave station, meaning some slave devices are only online with one master station and others are only online with another master station, then the device state machine is set to 1. The default master then controls the transmission of all online devices, polling all online slave stations sequentially according to the data acquisition configuration parameters. Therefore, the primary master station (default master) first needs to iterate through all online devices to determine if a slave device is locally online (local online means the local communication link can communicate with the slave device), essentially determining if the slave device can communicate with the primary master station.

[0080] Step S12: If data communication with the master station is possible, the slave device is identified as the current first slave device, and the master station sends a data acquisition request to the current first slave device to collect data.

[0081] In this embodiment, if the slave device can communicate with the master station, the slave device is determined as the current first slave device, and a request is sent to the device via the default master local communication link, such as... Figure 3As shown, a data acquisition request is generated based on preset acquisition parameters and sent to the current first slave device to acquire data; wherein, the preset acquisition parameters include any one or a combination of several of the following: acquisition period, timeout time, and transmission delay.

[0082] Step S13: If data communication with the primary master station is not possible, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station.

[0083] In this embodiment, if the slave device cannot communicate with the primary master station (meaning the default backup device can communicate with it), and the backup master station can communicate with the slave device, then the default host first generates a data acquisition request for the device and sends it to the backup master station based on the pre-configured heartbeat line between master stations. The backup master station then sends the data acquisition request to the slave device and sends the communication information corresponding to the response data returned by the slave device to the primary master station via the heartbeat line. That is, after receiving the request, the default backup device sends the request to the slave device through its local communication link. After receiving the device's response, the default backup device notifies the default master station via the heartbeat line. Upon receiving this notification, the default master station can proceed to the next online device's transmission transaction. It should be noted that a heartbeat line is pre-configured between the redundant master stations, using networks A / B / C. Networks A / B are internal LAN segments of the switch for both primary and backup FEPs, while network C is a network segment directly connected between primary and backup FEPs (without going through a switch). Configuring three network segments in this way can make the system more stable. For example... Figure 4 As shown, the redundant master station synchronizes the status of the slave devices in real time via the heartbeat line (slave device link status, communication status between the slave device and each slave device, and default master / slave status of the slave device).

[0084] Step S14: Determine whether the slave device meets the preset offline conditions based on the communication information; if it meets the preset offline conditions, determine that the slave device is the current offline device; if it does not meet the preset offline conditions, determine that the slave device is the current second slave device.

[0085] In this embodiment, it is important to understand that if the primary host does not receive notification from the backup host within the timeout period, it determines that the communication with the slave device has failed (after a certain number of consecutive failures, the primary host will determine the device to be offline and move it to the current offline device group), and will proceed to the next online device's transmission transaction. Therefore, if the backup primary station does not receive the response data returned by the slave device and fails to send the slave device's response status to the primary primary station within the preset timeout period, the communication with the slave device is determined to be a failure. If the number of communication failures with the slave device exceeds the preset number of failures, the slave device is determined to meet the preset offline conditions and is identified as the current offline device. If the backup primary station receives the response data returned by the slave device and sends the slave device's response status to the primary primary station within the preset timeout period, the slave device is determined to not meet the preset offline conditions and is identified as the current second slave device.

[0086] Step S15: Perform diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and send the corresponding offline diagnostic messages to the local bus device.

[0087] In this embodiment, the default master station controls the heartbeat transmission of all currently offline devices. The heartbeat devices adopt a large-cycle diagnostic mode (default 1 minute). When the diagnostic cycle is over, the default master station first sends a diagnostic message for the currently offline devices to the local bus. Then, in the next large diagnostic cycle, it changes to notifying the default standby station to perform a diagnostic on the slave devices, and so on. This process is repeated until all currently offline devices and slave devices are diagnosed, and the diagnostic messages are sent to the local bus devices.

[0088] In one specific embodiment, a cross-connection failure occurs in a link. There are five devices A, B, C, D, and E on the link, and the status of each device is as follows:

[0089] Device A is online on both the primary and backup master station channels; device B is online only on the primary master station channel; device C is online only on the backup master station channel; devices D and E are offline on both the primary and backup master station channels. From the above steps, it can be seen that, based on the device communication method disclosed in this application, the communication strategy at this time is:

[0090] Device A communicates through the main station channel;

[0091] Device B communicates through the main station channel;

[0092] Device C initiates a request from the primary master station and sends the request to the backup master station, communicating with the device through the backup master station channel;

[0093] Device D initiates a request from the primary master station and sends the request to the backup master station. It communicates with the device through the backup master station channel, and the communication cycle is a large cycle diagnostic mode.

[0094] Device E initiates a request from the primary master station, which then sends the request to the backup master station. Communication with the device occurs through the backup master station channel, with the communication cycle being the next major cycle diagnostic mode. That is, device D is communicated and diagnosed first, and after the diagnosis is completed, device E is communicated and diagnosed in the next major cycle. A more general strategy is to complete the diagnosis of M currently offline devices sequentially within one major cycle, following step S21 as described below. In this example, the diagnostic strategy for devices D and E only refers to the special case where M=1.

[0095] As can be seen from the above, when performing device communication, the primary master station first determines whether the slave device can communicate with the primary master station. If it can communicate with the primary master station, the slave device is identified as the current first slave device, and the primary master station sends a data acquisition request to the current first slave device to collect data. If it cannot communicate with the primary master station, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station. Then, based on the communication information, it is determined whether the slave device meets the preset offline conditions. If it meets the preset offline conditions, the slave device is determined as the current offline device. If it does not meet the preset offline conditions, the slave device is determined as the current second slave device. Finally, based on a preset diagnostic cycle, each of the current offline devices, the current first slave device, and the current second slave device is diagnosed, and the corresponding offline diagnostic messages are sent to the local bus device. As can be seen, this application can complete the communication and diagnosis between the serial bus redundant master station and the cross-faulted slave station under various operating conditions based on the communication status between the master station and the slave station devices. Furthermore, it does not rely on high-performance hardware or software and can be applied to any software or hardware platform.

[0096] As can be seen from the above embodiments, this application can perform diagnoses on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle. Next, a method for diagnosing each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle will be described in detail. See [link to documentation]. Figure 5 As shown, this embodiment of the invention discloses a specific device communication method applied to a primary master station, including:

[0097] Step S21: Determine whether the master station has received a heartbeat packet sent by the current second slave device and / or the current offline device within the preset diagnostic period.

[0098] In this embodiment, the large-cycle diagnostic mode can adopt the following strategy: within a large diagnostic cycle, diagnostics are sent sequentially to only M (1≤M≤N, where N is the total number of offline devices) current second slave devices and / or current offline devices. That is, in the first large diagnostic cycle, diagnostics are sent to the current second slave devices and / or current offline devices 1, 2, ..., M; in the second large diagnostic cycle, diagnostics are sent to the current second slave devices and / or current offline devices M+1, M+2, ..., 2M; ..., in the X+1th large diagnostic cycle, diagnostics are sent to the current second slave devices and / or current offline devices XM+1, ..., N-1, N, and so on. Therefore, it is first determined whether the master station has received heartbeat packets sent by the current second slave devices and / or current offline devices within the preset diagnostic cycle.

[0099] Step S22: If yes, then determine that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, obtain the corresponding first offline diagnostic message, and re-mark the slave device that is not in an offline state among the current second slave device and / or the current offline device as online, so as to determine the current offline device and the current second slave device.

[0100] In this embodiment, if a heartbeat packet is received from the current second slave device and / or the current offline device, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not offline. At this time, the diagnostic message of the device corresponding to the non-offline state is obtained. Simultaneously, the slave devices that are not offline among the current second slave devices and / or the current offline devices need to be re-marked as online to clearly distinguish between the currently offline and online devices.

[0101] Step S23: If not, determine that the current offline device corresponding to the heartbeat packet is in an offline state, and obtain the corresponding second offline diagnostic message.

[0102] In this embodiment, if a heartbeat packet sent by the currently offline device cannot be received, it is determined that the currently offline device corresponding to the heartbeat packet is in an offline state, and a diagnostic message of the currently offline device corresponding to the offline state is obtained.

[0103] Step S24: Send the first offline diagnostic message and the second offline diagnostic message corresponding to the target number of the current second slave devices and / or the current offline devices obtained within the current preset diagnostic cycle to the local bus device.

[0104] In this embodiment, the diagnostic method for the large diagnostic cycle is divided into two types. The first type is described here: After the default host completes the diagnostics of M currently offline devices, it then completes the diagnostics of the same M slave devices on the default standby device, and so on. Therefore, the first offline diagnostic message and the second offline diagnostic message corresponding to the target number of currently second slave devices and / or the currently offline devices obtained within the current preset diagnostic cycle are sent to the local bus device. Then, the next diagnostic cycle assesses the M slave devices.

[0105] Step S25: In the next preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received the heartbeat packet sent by the current first slave device based on the diagnostic notification.

[0106] In this embodiment, the default master notifies the default standby master to perform a diagnostic on the slave device, so that the standby master can determine whether it has received a heartbeat packet from the current first slave device based on the diagnostic notification. The presence or absence of the heartbeat packet determines whether the device is offline.

[0107] Step S26: If yes, then determine that the current first slave device corresponding to the heartbeat packet is not in an offline state, obtain the corresponding third offline diagnostic message, and re-mark the slave device that is not in an offline state as online state to determine the current first slave device.

[0108] Step S27: If not, determine that the first slave device corresponding to the heartbeat packet is still offline, and obtain the corresponding fourth offline diagnostic message.

[0109] Step S28: Send the third offline diagnostic message and the fourth offline diagnostic message corresponding to the target number of the current first slave devices to the local bus device.

[0110] In this embodiment, after sending the target number of the third and fourth offline diagnostic messages corresponding to the current first slave devices to the local bus device, it is determined whether the primary master station receives a heartbeat packet sent by the current second slave device within a preset diagnostic period. If yes, it is determined that the current second slave device corresponding to the heartbeat packet is not offline, and a corresponding fifth offline diagnostic message is obtained. The slave devices that are not offline are re-marked as online to identify the current second slave device. If no, it is determined that the current offline device corresponding to the heartbeat packet is offline, and a corresponding sixth offline diagnostic message is obtained. The target number of the fifth and sixth offline diagnostic messages corresponding to the current second slave devices obtained within the current preset diagnostic period are sent to the local bus device. In the next preset diagnostic period, the primary master station sends a diagnostic notification to the backup master station so that the backup master station can determine whether the current second slave device is offline based on the diagnostic notification. If a heartbeat packet is received from the current first slave device and / or the current offline device, and if yes, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is not offline, and a corresponding seventh offline diagnostic message is obtained. The slave devices that are not offline among the current first slave devices and / or the current offline devices are re-marked as online to identify the current first slave device and the current offline device. If no, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is still offline, and a corresponding eighth offline diagnostic message is obtained. The seventh and eighth offline diagnostic messages corresponding to the target number of current first slave devices and / or the current offline devices are sent to the local bus device, and the process jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or the current offline device has been received within the preset diagnostic period, until the diagnosis of all slave devices is completed. This completes the entire diagnostic process.

[0111] Additionally, it should be noted that the target number of the third offline diagnostic messages corresponding to the current first slave device refers to, in the large-cycle diagnostic mode, sending diagnostics sequentially to only M offline devices within a large diagnostic cycle. Therefore, the target number of diagnostic messages refers to the M messages in step S21. Furthermore, the target number is the number of current offline devices in each of several equal parts after dividing all current offline devices based on the total number of current offline devices. If equal division is not possible, the excess current offline devices are grouped into a single group.

[0112] As can be seen from the above, this application can diagnose all slave devices and / or currently offline devices during communication, and the method is simple, easy to operate, and also ensures the accuracy of the diagnostic results.

[0113] Next, a specific description will be given of another method for diagnosing each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle. See [link to documentation]. Figure 6 As shown, this embodiment of the invention discloses a specific device communication method applied to a primary master station, including:

[0114] Step S31: Determine whether the master station has received a heartbeat packet sent by the current second slave device and / or the current offline device within the preset diagnostic period.

[0115] Step S32: If yes, then determine that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and obtain the corresponding ninth offline diagnostic message, and re-mark the slave device that is not in an offline state among the current second slave device and / or the current offline device as online, so as to determine the current offline device and the current second slave device.

[0116] Step S33: If not, determine that the current second slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and obtain the corresponding tenth offline diagnostic message.

[0117] Step S34: Send the ninth and tenth offline diagnostic messages corresponding to the target number of the current second slave devices and / or the current offline devices obtained within the current preset diagnostic period to the local bus device, and then jump back to the step of determining whether the heartbeat packets sent by the current second slave devices and / or the current offline devices are received based on the preset diagnostic period, until all the current second slave devices and / or the current offline devices have completed the diagnosis.

[0118] In this embodiment, diagnosis is performed according to another diagnostic method based on the large diagnostic cycle. This means that only after the default host completes a full round of diagnosis for all current second slave devices and / or the current offline devices, does the default host send a diagnostic notification to the default standby device, allowing the default standby device to diagnose all slave devices. Therefore, after sending the ninth and tenth offline diagnostic messages corresponding to the target number of current second slave devices and / or the current offline devices obtained within the current preset diagnostic cycle to the local bus device, to continue diagnosing M current second slave devices and / or the current offline devices, it is necessary to jump back to the step of determining whether a heartbeat packet sent by the current second slave device and / or the current offline device has been received based on the preset diagnostic cycle, until all current second slave devices and / or the current offline devices have completed their diagnosis.

[0119] Step S35: Based on the preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the current offline device based on the diagnostic notification.

[0120] Step S36: If yes, then determine that the current first slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and obtain the corresponding eleventh offline diagnostic message, and re-mark the slave device that is not in an offline state among the current first slave device and / or the current offline device as online, so as to determine the current first slave device and the current offline device.

[0121] Step S37: If not, determine that the current first slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and obtain the corresponding twelve offline diagnostic messages.

[0122] Step S38: Send the target number of the eleventh offline diagnostic messages and the twelfth offline diagnostic messages to the local bus device, and then jump back to the step of the primary master station sending the diagnostic notification to the backup master station based on the preset diagnostic cycle, until all the current first slave devices and / or the current offline devices have completed the diagnosis.

[0123] In this embodiment, as can be seen from the above embodiments, the current first slave device and / or the current offline device have all completed the diagnosis. Therefore, after sending the target number of the eleventh offline diagnosis message and the twelfth offline diagnosis message to the local bus device, to continue to diagnose the M current first slave devices and / or the current offline devices, it is necessary to jump back to the step of the primary master station sending the diagnosis notification to the backup master station based on the preset diagnosis period, until all the current first slave devices and / or the current offline devices have completed the diagnosis.

[0124] As can be seen from the above, this application can diagnose all slave devices and / or currently offline devices during communication, and the method is simple, easy to operate, and also ensures the accuracy of the diagnostic results.

[0125] See Figure 7 As shown, an embodiment of the present invention discloses a device communication apparatus applied to a primary master station, comprising:

[0126] The first judgment module 11 is used to determine whether the slave device can communicate with the master station via data.

[0127] The request sending module 12 is used to determine the slave device as the current first slave device if data communication with the master station is possible, and the master station sends a data acquisition request to the current first slave device to collect data;

[0128] The response data sending module 13 is used to forward the data acquisition request generated by the primary master station to the slave device if data communication with the primary master station is not possible, and to send the communication information corresponding to the response data returned by the slave device to the primary master station.

[0129] The second judgment module 14 is used to determine whether the slave device meets the preset offline conditions based on the communication information; if it meets the preset offline conditions, the slave device is determined to be the current offline device; if it does not meet the preset offline conditions, the slave device is determined to be the current second slave device.

[0130] The diagnostic module 15 is used to perform diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and send the corresponding offline diagnostic messages to the local bus device.

[0131] As can be seen from the above, when performing device communication, the primary master station first determines whether the slave device can communicate with the primary master station. If it can communicate with the primary master station, the slave device is identified as the current first slave device, and the primary master station sends a data acquisition request to the current first slave device to collect data. If it cannot communicate with the primary master station, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station. Then, based on the communication information, it is determined whether the slave device meets the preset offline conditions. If it meets the preset offline conditions, the slave device is determined as the current offline device. If it does not meet the preset offline conditions, the slave device is determined as the current second slave device. Finally, based on a preset diagnostic cycle, each of the current offline devices, the current first slave device, and the current second slave device is diagnosed, and the corresponding offline diagnostic messages are sent to the local bus device. As can be seen, this application can complete the communication and diagnosis between the serial bus redundant master station and the cross-faulted slave station under various operating conditions based on the communication status between the master station and the slave station devices. Furthermore, it does not rely on high-performance hardware or software and can be applied to any software or hardware platform.

[0132] In some specific embodiments, the response data sending module 13 may specifically include:

[0133] A communication information sending unit is used to generate a data acquisition request and send the data acquisition request to the backup master station based on a pre-configured heartbeat line between master stations, so that the backup master station can send the data acquisition request to the slave device and send the communication information corresponding to the response data returned by the slave device to the primary master station through the heartbeat line.

[0134] In some specific embodiments, the device can also be used to generate the data acquisition request according to preset acquisition parameters; wherein, the preset acquisition parameters include any one or a combination of acquisition period, timeout time and transmission delay.

[0135] In some specific embodiments, the second judgment module 14 can be used to determine that the current communication with the slave device is a failure if the backup master station does not receive the response data returned by the slave device and fails to send the response status of the slave device to the primary master station within a preset timeout period; if the number of communication failures with the slave device exceeds a preset number of failures, the slave device is determined to meet the preset offline conditions and is identified as the current offline device; if the backup master station receives the response data returned by the slave device and sends the response status of the slave device to the primary master station within a preset timeout period, the slave device is determined to not meet the preset offline conditions and is identified as the current second slave device.

[0136] In some specific embodiments, the diagnostic module 15 can be used to determine whether the primary master station receives a heartbeat packet sent by the current second slave device and / or the current offline device within a preset diagnostic period; if yes, it determines that the current second slave device and / or the current offline device corresponding to the heartbeat packet is not offline, obtains the corresponding first offline diagnostic message, and re-marks the slave devices that are not offline among the current second slave devices and / or the current offline devices as online to determine the current offline device and the current second slave device; if no, it determines that the current offline device corresponding to the heartbeat packet is offline, and obtains the corresponding second offline diagnostic message; and sets the target number of the first offline diagnostic messages corresponding to the current second slave devices and / or the current offline devices obtained within the current preset diagnostic period. The primary master station sends a diagnostic message and the second offline diagnostic message to the local bus device. Within the next preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet from the current first slave device based on the diagnostic notification. If yes, it determines that the current first slave device corresponding to the heartbeat packet is not offline, obtains the corresponding third offline diagnostic message, and re-marks the slave devices that are not offline as online to identify the current first slave device. If no, it determines that the first slave device corresponding to the heartbeat packet is still offline and obtains the corresponding fourth offline diagnostic message. The target number of the third and fourth offline diagnostic messages corresponding to the current first slave devices are sent to the local bus device.

[0137] In some specific embodiments, the device can also be used to determine whether the primary master station receives a heartbeat packet sent by the current second slave device within a preset diagnostic period; if yes, it determines that the current second slave device corresponding to the heartbeat packet is not offline, obtains the corresponding fifth offline diagnostic message, and re-marks the slave devices that are not offline as online to identify the current second slave device; if no, it determines that the current offline device corresponding to the heartbeat packet is offline and obtains the corresponding sixth offline diagnostic message; the fifth offline diagnostic message and the sixth offline diagnostic message corresponding to the target number of current second slave devices obtained within the current preset diagnostic period are sent to the local bus device; in the next preset diagnostic period, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it receives the heartbeat packet sent by the current first slave device and / or the current slave device based on the diagnostic notification. If a heartbeat packet is sent by the previously offline device, then it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is not offline, and a corresponding seventh offline diagnostic message is obtained. The slave devices that are not offline among the current first slave devices and / or the current offline devices are re-marked as online to determine the current first slave device and the current offline device. If not, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is still offline, and a corresponding eighth offline diagnostic message is obtained. The seventh and eighth offline diagnostic messages corresponding to the target number of current first slave devices and / or the current offline devices are sent to the local bus device, and the process jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or the current offline device has been received within the preset diagnostic period, until the diagnosis of all slave devices is completed.

[0138] In some specific embodiments, the diagnostic module 15 can be used to determine whether the master station has received a heartbeat packet from the current second slave device and / or the current offline device within a preset diagnostic period; if yes, it determines that the current second slave device and / or the current offline device corresponding to the heartbeat packet is not offline, and obtains the corresponding ninth offline diagnostic message, re-marking the slave devices that are not offline among the current second slave devices and / or the current offline devices as online, thereby identifying the current offline device and the current second slave device; if no, it determines that the current second slave device and / or the current offline device corresponding to the heartbeat packet is offline, and obtains the corresponding tenth offline diagnostic message; the target number of the ninth and tenth offline diagnostic messages corresponding to the current second slave devices and / or the current offline devices obtained within the current preset diagnostic period are sent to the local bus device, and the process jumps back to the step of determining whether a heartbeat packet from the current second slave device and / or the current offline device has been received based on the preset diagnostic period, until all the current second slave devices... The backup and / or the currently offline device completes the diagnosis; based on the preset diagnosis period, the primary master station sends a diagnosis notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the currently offline device based on the diagnosis notification; if so, it determines that the current first slave device and / or the currently offline device corresponding to the heartbeat packet is not offline, and obtains the corresponding eleventh offline diagnosis message, and re-marks the slave device that is not offline among the current first slave device and / or the currently offline device as... The system checks the online status to determine the current first slave device and the current offline device; if not, it determines that the current first slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and obtains the corresponding twelfth offline diagnostic message; it sends the target number of the eleventh offline diagnostic messages and the twelfth offline diagnostic messages to the local bus device, and then jumps back to the step of the primary master station sending the diagnostic notification to the backup master station based on the preset diagnostic cycle, until all the current first slave devices and / or the current offline devices have completed the diagnosis.

[0139] Furthermore, embodiments of this application also disclose an electronic device, Figure 8 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0140] Figure 8This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the device communication method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0141] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0142] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0143] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs capable of performing the device communication methods executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0144] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed device communication method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0146] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0147] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0148] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0149] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A device communication method, characterized in that, Applied to the primary main station, including: Determine whether the slave device can communicate with the master station via data. If data communication can be established with the master station, the slave device is identified as the current first slave device, and the master station sends a data acquisition request to the current first slave device to collect data; If data communication with the primary master station is not possible, the backup master station forwards the data acquisition request generated by the primary master station to the slave device, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station. Based on the communication information, it is determined whether the slave device meets the preset offline conditions; if it meets the preset offline conditions, the slave device is determined to be the current offline device; if it does not meet the preset offline conditions, the slave device is determined to be the current second slave device. Based on a preset diagnostic cycle, diagnose each of the currently offline devices, the currently first slave device, and the currently second slave device, and send the corresponding offline diagnostic messages to the local bus device; The step of diagnosing each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and sending the corresponding offline diagnostic messages to the local bus device, includes: Determine whether the primary master station receives a heartbeat packet sent by the current second slave device and / or the current offline device within a preset diagnostic period; If so, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding first offline diagnostic message is obtained. The slave device that is not in an offline state among the current second slave device and / or the current offline device is re-marked as online, so as to determine the current offline device and the current second slave device. If not, the current offline device corresponding to the heartbeat packet is determined to be in an offline state, and a corresponding second offline diagnostic message is obtained; Send the first offline diagnostic message and the second offline diagnostic message corresponding to the target number of the current second slave devices and / or the current offline devices obtained within the current preset diagnostic cycle to the local bus device; In the next preset diagnostic cycle, the primary master station will send a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received the heartbeat packet sent by the current first slave device based on the diagnostic notification. If so, it is determined that the current first slave device corresponding to the heartbeat packet is not offline, and the corresponding third offline diagnostic message is obtained. The slave devices that are not offline in the current first slave device are re-marked as online to determine the current first slave device. If not, it is determined that the first slave device corresponding to the heartbeat packet is still offline, and the corresponding fourth offline diagnostic message is obtained; Send the third and fourth offline diagnostic messages corresponding to the target number of the current first slave devices to the local bus device.

2. The device communication method according to claim 1, characterized in that, The step of forwarding the data acquisition request generated by the primary master station to the slave device from the backup master station, and the backup master station sending the communication information corresponding to the response data returned by the slave device to the primary master station, includes: A data acquisition request is generated and sent to the backup master station based on a pre-configured heartbeat line between master stations. The backup master station then sends the data acquisition request to the slave device and sends the communication information corresponding to the response data returned by the slave device to the primary master station via the heartbeat line.

3. The device communication method according to claim 1, characterized in that, Also includes: The data acquisition request is generated according to the preset acquisition parameters; The preset acquisition parameters include any one or a combination of acquisition period, timeout time, and transmission delay.

4. The device communication method according to claim 3, characterized in that, The system determines whether the slave device meets the preset offline conditions based on the communication information; if it meets the preset offline conditions, the slave device is determined to be a currently offline device. If the preset offline conditions are not met, then the slave device is determined to be the current second slave device, including: If the backup master station does not receive the response data returned by the slave device and fails to send the response status of the slave device to the master station within the preset timeout period, the communication with the slave device is deemed to have failed. If the number of communication failures with the slave device exceeds a preset number of failures, the slave device is determined to meet the preset offline conditions, and the slave device is identified as the currently offline device. If the backup master station receives the response data returned by the slave device and sends the response status of the slave device to the primary master station within the preset timeout period, it is determined that the slave device does not meet the preset offline conditions, and the slave device is identified as the current second slave device.

5. The device communication method according to claim 1, characterized in that, After sending the target number of the third offline diagnostic messages and the fourth offline diagnostic messages corresponding to the current first slave devices to the local bus device, the method further includes: Determine whether the primary master station receives a heartbeat packet sent by the current second slave device within a preset diagnostic period; If so, it is determined that the current second slave device corresponding to the heartbeat packet is not offline, and the corresponding fifth offline diagnostic message is obtained. The slave device that is not offline in the current second slave device is re-marked as online to determine the current second slave device. If not, it is determined that the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding sixth offline diagnostic message is obtained; Send the fifth offline diagnostic message and the sixth offline diagnostic message corresponding to the target number of the current second slave devices obtained within the current preset diagnostic cycle to the local bus device; In the next preset diagnostic cycle, the primary master station will send a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the current offline device based on the diagnostic notification. If so, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding seventh offline diagnostic message is obtained. The slave device that is not in an offline state among the current first slave device and / or the current offline device is re-marked as online, so as to determine the current first slave device and the current offline device. If not, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is still in an offline state, and the corresponding eighth offline diagnostic message is obtained; The target number of the current first slave devices and / or the current offline devices corresponding to the seventh and eighth offline diagnostic messages are sent to the local bus device, and the process jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or the current offline device has been received within the preset diagnostic period, until the diagnosis of all slave devices is completed.

6. The device communication method according to claim 1, characterized in that, The target number is the number of current offline devices in each part after dividing all current offline devices into several parts based on the total number of current offline devices. If it is not possible to divide them equally, the excess number of current offline devices will be collected into a single part.

7. The device communication method according to any one of claims 1 to 4, characterized in that, The step of diagnosing each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and sending the corresponding offline diagnostic messages to the local bus device, includes: Determine whether the primary master station receives a heartbeat packet sent by the current second slave device and / or the current offline device within a preset diagnostic period; If so, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding ninth offline diagnostic message is obtained. The slave device that is not in an offline state among the current second slave device and / or the current offline device is re-marked as online to determine the current offline device and the current second slave device. If not, it is determined that the current second slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding tenth offline diagnostic message is obtained; The target number of current second slave devices and / or current offline devices obtained within the current preset diagnostic period are sent to the local bus device along with the ninth and tenth offline diagnostic messages. The process then jumps back to the step of determining whether a heartbeat packet sent by the current second slave device and / or current offline device has been received based on the preset diagnostic period, until all current second slave devices and / or current offline devices have completed the diagnostic process. Based on the preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet sent by the current first slave device and / or the current offline device based on the diagnostic notification. If so, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet are not in an offline state, and the corresponding eleventh offline diagnostic message is obtained. The slave device that is not in an offline state among the current first slave device and / or the current offline device is re-marked as online, so as to determine the current first slave device and the current offline device. If not, it is determined that the current first slave device and / or the current offline device corresponding to the heartbeat packet is in an offline state, and the corresponding twelfth offline diagnostic message is obtained; The target number of the eleventh and twelfth offline diagnostic messages are sent to the local bus device, and the process jumps back to the step of the primary master station sending a diagnostic notification to the backup master station based on the preset diagnostic cycle, until all the current first slave devices and / or the current offline devices have completed the diagnosis.

8. A device communication apparatus, characterized in that, Applied to the primary main station, including: The first judgment module is used to determine whether the slave device can communicate with the master station. The request sending module is used to determine the slave device as the current first slave device if data communication with the master station is possible, and then the master station sends a data acquisition request to the current first slave device to collect data. The response data sending module is used to forward the data acquisition request generated by the primary master station to the slave device if data communication with the primary master station is not possible, and the backup master station sends the communication information corresponding to the response data returned by the slave device to the primary master station. The second judgment module is used to determine whether the slave device meets the preset offline conditions based on the communication information; if it meets the preset offline conditions, the slave device is determined to be the current offline device; if it does not meet the preset offline conditions, the slave device is determined to be the current second slave device. The diagnostic module is used to perform diagnostics on each of the currently offline devices, the currently first slave device, and the currently second slave device based on a preset diagnostic cycle, and send the corresponding offline diagnostic messages to the local bus device. The diagnostic module is used to determine whether the primary station receives a heartbeat packet from the current second slave device and / or the current offline device within a preset diagnostic period. If yes, it determines that the current second slave device and / or the current offline device corresponding to the heartbeat packet is not offline, obtains a corresponding first offline diagnostic message, and re-marks the slave devices that are not offline among the current second slave devices and / or the current offline devices as online to identify the current offline device and the current second slave device. If no, it determines that the current offline device corresponding to the heartbeat packet is offline and obtains a corresponding second offline diagnostic message. The module then uses the target number of first offline diagnostic messages and second offline diagnostic messages corresponding to the current second slave devices and / or the current offline devices obtained within the current preset diagnostic period to determine the current offline device and the current second slave device. The primary master station sends a diagnostic message to the local bus device. Within the next preset diagnostic cycle, the primary master station sends a diagnostic notification to the backup master station, so that the backup master station can determine whether it has received a heartbeat packet from the current first slave device based on the diagnostic notification. If yes, it determines that the current first slave device corresponding to the heartbeat packet is not offline, obtains the corresponding third offline diagnostic message, and re-marks the slave devices that are not offline as online to identify the current first slave device. If no, it determines that the first slave device corresponding to the heartbeat packet is still offline and obtains the corresponding fourth offline diagnostic message. The target number of the third and fourth offline diagnostic messages corresponding to the current first slave devices are sent to the local bus device.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the device communication method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the device communication method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Master station redundancy implementation system and method based on industrial Ethernet protocol

    CN111817939A