Communication method, communication system, electronic device, storage medium and program product
By establishing an Internet protocol connection between the Hongmeng device and the programmable logic controller and transmitting data packets based on the soft bus protocol, the problem of poor communication effect and high cost in the prior art is solved, and a stable and low-cost communication effect is achieved.
Patent Information
- Application Number
- CN202411706931.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, the communication effect between the Hongmeng device and the programmable logic controller is poor and has high cost, and has poor interoperability and compatibility.
Network connection is established with the programmable logic controller through the Internet protocol, initial configuration information is sent to set up a communication interface within the programmable logic controller, and packet transmission and communication are carried out based on the soft bus protocol.
It realizes stable communication between Hongmeng equipment and programmable logic controller, reduces communication costs, improves communication effects, and solves the problem of poor communication effects and high cost.
Smart Images

Figure CN119766646A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and in particular to a communication method, a communication system, an electronic device, a storage medium and a program product. Background Art
[0002] With the rise of smart manufacturing, the demand for industrial automation and intelligence is growing. As a new type of operating system, Hongmeng devices equipped with Hongmeng system have the characteristics of distribution and interconnection, which can better meet the equipment connection and communication needs in industrial scenarios. As the core control device in the field of industrial control, programmable logic controllers also need to communicate effectively with various systems to achieve more efficient and intelligent control. Therefore, Hongmeng devices and programmable logic controllers can be interconnected and intelligently collaborated to give full play to the advantages of both and achieve more efficient and intelligent industrial control.
[0003] However, traditional communication solutions often use hard bus connections, which require the use of specific hardware interfaces and cables, are costly, and difficult to expand and maintain. At the same time, since the protocols and standards between Hongmeng devices and programmable logic controllers may not be unified, resulting in poor interoperability and compatibility, the existing communication solutions have the defects of poor communication effects and high costs.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a communication method, a communication system, an electronic device, a storage medium and a program product, so as to at least solve the technical problems of poor communication effect and high cost in the related art.
[0006] According to one aspect of an embodiment of the present invention, there is provided a communication method, which is applied to Hongmeng devices, including: establishing a network connection with a programmable logic controller via an Internet protocol; sending initialization configuration information to the programmable logic controller, and receiving confirmation information sent by the programmable logic controller, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to characterize that the configuration of the communication interface is complete; sending a data packet to the programmable logic controller based on a soft bus protocol, and receiving response information sent by the programmable logic controller based on the soft bus protocol, wherein the response information is used to characterize the processing result of the programmable logic controller on the data packet.
[0007] Optionally, a network connection is established with a programmable logic controller via an Internet protocol, including: obtaining device information of the programmable logic controller; creating a socket client instance and setting connection parameters of the socket client based on the device information; and calling a connection method in the socket client instance to establish a network connection with the programmable logic controller.
[0008] Optionally, before sending the data packet to the programmable logic controller based on the soft bus protocol, it also includes: packing the target data based on the soft bus protocol to obtain an initial data packet; generating a check code of the initial data packet through a cyclic redundancy check algorithm; splicing the check code with the initial data packet to obtain a data packet, wherein the check code is used to check the data packet through the programmable logic controller.
[0009] Optionally, the method further includes at least one of the following: in response to monitoring an abnormality in communication with a programmable logic controller, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an abnormality in communication with a programmable logic controller, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the programmable logic controller within a preset heartbeat time, or in response to monitoring an abnormality in the heartbeat packet sent by the programmable logic controller, confirming that an abnormality has occurred in communication with the programmable logic controller, and triggering abnormality processing; in response to monitoring an abnormality in communication with the programmable logic controller, identifying a faulty node, and isolating the faulty node; in response to monitoring an abnormality in communication with the programmable logic controller, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0010] According to another aspect of an embodiment of the present invention, a communication method is also provided, which is applied to a programmable logic controller, including: establishing a network connection with a Hongmeng device through an Internet protocol; in response to receiving initialization configuration information sent by the Hongmeng device, setting a communication interface in the programmable logic controller based on the initialization configuration information; sending a confirmation message to the Hongmeng device, wherein the confirmation message is used to characterize that the configuration of the communication interface is complete; in response to receiving a data packet sent by the Hongmeng device based on a soft bus protocol, processing the data packet to obtain a processing result, and sending a response message to the Hongmeng device based on the soft bus protocol, wherein the response message is used to characterize the processing result.
[0011] Optionally, based on the initialization configuration information, a communication interface is set in the programmable logic controller, including: decoding the initialization configuration information to obtain configuration data; extracting communication parameters from the configuration data, wherein the communication parameters are used to define the communication rules between the programmable logic controller and the Hongmeng device; setting the communication interface according to the communication parameters; and generating confirmation information in response to the completion of the communication interface configuration.
[0012] Optionally, the data packet is processed to obtain a processing result, including: parsing a check code from the data packet based on a soft bus protocol; verifying the data packet based on the check code to obtain a verification result; in response to the verification result being that the data packet verification is successful, parsing target data from the data packet based on the soft bus protocol; processing the target data to obtain a processing result.
[0013] Optionally, the above method also includes one of the following: in response to monitoring an abnormality in communication with a Hongmeng device, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an abnormality in communication with a Hongmeng device, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the Hongmeng device at a preset heartbeat time, or in response to monitoring an abnormality in the heartbeat packet sent by the Hongmeng device, confirming that an abnormality has occurred in communication with the Hongmeng device, and triggering exception processing; in response to monitoring an abnormality in communication with the Hongmeng device, identifying the faulty node, and isolating the faulty node; in response to monitoring an abnormality in communication with the Hongmeng device, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0014] According to another aspect of an embodiment of the present invention, a communication system is also provided, including: a Hongmeng device, which is used to send initialization configuration information after establishing a network connection with a programmable logic controller, and send a data packet based on a soft bus protocol after receiving a confirmation message, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to characterize that the communication interface configuration is complete; a programmable logic controller, which is used to configure and set the communication interface in the programmable logic controller based on the initialization configuration information, send a confirmation message when the communication interface configuration is complete, and process the data packet to generate a response message, and send the response message to the Hongmeng device based on the soft bus protocol, wherein the response information is used to characterize the processing result of the data packet.
[0015] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0018] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0019] According to another aspect of the embodiments of the present invention, a computer program is further provided. When the computer program is executed by a processor, the methods in the embodiments of the present invention are implemented.
[0020] In the embodiment of the present invention, it is applied to Hongmeng devices, and a network connection is established with a programmable logic controller through an Internet protocol; initialization configuration information is sent to the programmable logic controller, and confirmation information sent by the programmable logic controller is received, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is complete; a data packet is sent to the programmable logic controller based on a soft bus protocol, and a response information sent by the programmable logic controller based on the soft bus protocol is received, wherein the response information is used to indicate the processing result of the programmable logic controller on the data packet. It is easy to notice that, by adopting the soft bus communication method, after the Hongmeng device and the programmable logic controller are connected to a network, the initialization configuration information is sent to the programmable logic controller, so that the programmable logic controller can use the initialization configuration information to establish a communication interface, so that data transmission and communication can be performed based on the soft bus protocol, and a unified communication interface and soft bus protocol are negotiated between the two, without relying on the hardware interface, the communication cost is reduced, the communication effect is guaranteed, and the purpose of effective communication is achieved, thereby achieving the technical effect of stable communication between the Hongmeng device and the programmable logic controller, and thus solving the technical problems of poor communication effect and high cost in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 is a flow chart of a communication method according to an embodiment of the present invention;
[0023] Figure 2 is a flow chart of a communication method according to an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of a communication system architecture according to an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of a communication system according to an embodiment of the present invention;
[0026] Figure 5 is a schematic diagram of a communication device according to an embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of a communication device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] According to an embodiment of the present invention, a communication method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0031] Figure 1 is a flow chart of a communication method according to an embodiment of the present invention. Figure 1 As shown, the method is applied to Hongmeng devices, and the method includes the following steps:
[0032] Step S102, establishing a network connection with a programmable logic controller via an Internet protocol.
[0033] The above-mentioned Hongmeng devices may refer to smart devices running the Hongmeng system. The Hongmeng system is an operating system designed for all scenarios, distributed, and microkernel. It can provide a unified, smooth, and secure device interconnection and application development environment to achieve cross-device collaboration, such as resource sharing, data transmission, and control operations between devices. Hongmeng devices can be smart devices, such as industrial equipment, IoT devices, mobile phones, tablets, smart watches, smart home appliances, etc., which are not limited here and can be determined as needed. Hongmeng devices are equipped with the Hongmeng system. Therefore, Hongmeng devices have the characteristics of distribution, interconnection, microkernel design, high customizability, security and controllability, which can well meet the needs of industrial automation and intelligence. Hongmeng devices can communicate with programmable logic controllers through soft bus to achieve efficient, stable, and secure data transmission and control operations between the two.
[0034] The above-mentioned Internet Protocol (IP) can be used for data communication and network communication on the Internet. The Internet Protocol is the basis of communication. The Internet Protocol can be used for routing and transmission of data packets on the Internet, providing stable and efficient network support for data communication between Hongmeng devices and programmable logic controllers. Through the Internet Protocol, Hongmeng devices and programmable logic controllers can cross different networks and devices to achieve data interconnection and intelligent collaboration, and jointly promote the development of industrial automation and intelligence.
[0035] The above-mentioned programmable logic controller (PLC) can be a digital electronic system for industrial automation and process control. The programmable logic controller can be composed of two parts: hardware and software. The hardware can include a processor, memory, input / output interface, power module, network interface, etc., and the software can be used for programming and running control systems. Programmable logic controllers are often used in the field of industrial automation control, and can be applied to production line control, equipment monitoring, data acquisition, fault detection, etc. The programmable logic controller can be programmed to perform a variety of control tasks, and has the characteristics of programming flexibility. The programmable logic controller can also have a network communication function, and can communicate data with a host computer, intelligent devices, etc. through a communication protocol to achieve information sharing and collaborative work between devices. The programmable logic controller can communicate data and control operations with Hongmeng devices to achieve interconnection and intelligent collaboration between devices. The programmable logic controller has a high degree of stability and reliability and can achieve precise control. The distributed and interconnected characteristics of the programmable logic controller and the Hongmeng device complement each other, and are often used together in the development of industrial automation and intelligence.
[0036] In an optional embodiment, the Hongmeng device sends a connection request to the PLC via the Internet Protocol, and the connection request carries a first Transmission Control Protocol (TCP) data packet, and the first Transmission Control Protocol data packet carries a synchronization flag and the initial sequence number of the Hongmeng device. Then, after receiving the second TCP data packet sent by the PLC, the first transmission control protocol includes a synchronization flag, a first confirmation flag, and the initial sequence number of the PLC to confirm that the PLC has received the connection request. Further, the Hongmeng device sends a third TCP data packet with a second confirmation flag to confirm the sequence number of the PLC. After receiving a response confirming the sequence number of the PLC, the connection with the PLC is established.
[0037] In another optional embodiment, a connection relationship can be established with a programmable logic controller through the device information of the programmable logic controller. Specifically, the device information of the programmable logic controller can be obtained, and then a socket client instance can be created, and the connection parameters of the socket client can be set based on the device information, and then the connection method in the socket client instance can be called to connect the Hongmeng device to the programmable logic controller.
[0038] Step S104, sending the initialization configuration information to the programmable logic controller, and receiving confirmation information sent by the programmable logic controller.
[0039] The initialization configuration information is used to set the communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is complete.
[0040] The above-mentioned initialization configuration information can be used to set the communication interface in the programmable logic controller. The initialization configuration information may include communication parameter information, such as baud rate, data bit, stop bit, parity check, etc. The communication parameter information is not limited here and can be determined as needed. Through the initialization configuration information, the programmable logic controller can set the communication interface.
[0041] The above confirmation information can be used to indicate that the configuration of the communication interface is complete. The confirmation information can be a confirmation signal, or a configuration status report. Through the confirmation information, it can be confirmed that the communication interface of the programmable logic controller has been configured, and data transmission and communication can be further performed with the programmable logic controller.
[0042] In an optional embodiment, the initialization configuration information can be sent to the programmable logic controller via the Internet protocol. Further, a confirmation message sent by the programmable logic controller is received to prompt whether the communication interface of the programmable logic controller is configured, so as to perform subsequent data transmission.
[0043] Step S106: sending the data packet to the programmable logic controller based on the soft bus protocol, and receiving response information sent by the programmable logic controller based on the soft bus protocol.
[0044] The response information is used to represent the processing result of the programmable logic controller on the data packet.
[0045] The above-mentioned soft bus protocol may be a communication protocol based on software implementation. The soft bus protocol can be used to set up data exchange and communication, realize the interconnection between Hongmeng devices and programmable logic controllers, and improve the efficiency and capabilities of industrial automation and intelligence. The soft bus protocol includes the definition of the data structure. Specifically, the data structure may include but is not limited to: a start identifier, a length field, a command byte, a data field, a check code, and an end identifier, etc. The data structure is not limited here and can be determined as needed. Specifically, the start identifier may be a fixed start character used to identify the beginning of a data packet. The length field may indicate the total length of a data packet. The command byte may characterize the operation type of a data packet. The data field may be actual data. The check code may be used to detect the integrity of a data packet. The end identifier may be a fixed end character used to identify the end of a data packet.
[0046] The above response information can be used to represent the processing result of the programmable logic controller on the data packet.
[0047] In an optional embodiment, a data packet may be sent to a programmable logic controller based on a soft bus protocol. The data packet may include, but is not limited to, a start identifier, a length field, a command byte, a data field, a check code, and an end identifier, etc. The data packet is not limited here and may be determined as needed. Further, response information sent by the programmable logic controller based on the soft bus protocol is received.
[0048] In the embodiment of the present invention, it is applied to Hongmeng devices, and a network connection is established with a programmable logic controller through an Internet protocol; initialization configuration information is sent to the programmable logic controller, and confirmation information sent by the programmable logic controller is received, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is complete; a data packet is sent to the programmable logic controller based on a soft bus protocol, and a response information sent by the programmable logic controller based on the soft bus protocol is received, wherein the response information is used to indicate the processing result of the programmable logic controller on the data packet. It is easy to notice that, by adopting the soft bus communication method, after the Hongmeng device and the programmable logic controller are connected to a network, the initialization configuration information is sent to the programmable logic controller, so that the programmable logic controller can use the initialization configuration information to establish a communication interface, so that data transmission and communication can be performed based on the soft bus protocol, and a unified communication interface and soft bus protocol are negotiated between the two, without relying on the hardware interface, the communication cost is reduced, the communication effect is guaranteed, and the purpose of effective communication is achieved, thereby achieving the technical effect of stable communication between the Hongmeng device and the programmable logic controller, and thus solving the technical problems of poor communication effect and high cost in the related technology.
[0049] Optionally, a network connection is established with a programmable logic controller via an Internet protocol, including: obtaining device information of the programmable logic controller; creating a socket client instance and setting connection parameters of the socket client based on the device information; and calling a connection method in the socket client instance to establish a network connection with the programmable logic controller.
[0050] The device information of the programmable logic controller may include but is not limited to: an Internet protocol address and a port number, and the device information is not limited here and can be determined as needed. Providing the device information can bind with the programmable logic controller to establish a connection between the two.
[0051] In an optional embodiment, the Hongmeng device can be connected to the programmable logic controller through a socket client instance. Specifically, the connection method in the socket client instance can be called to establish a network connection with the programmable logic controller. This way of establishing a network connection simplifies the connection process and improves the flexibility and stability of the connection.
[0052] Optionally, before sending the data packet to the programmable logic controller based on the soft bus protocol, it also includes: packing the target data based on the soft bus protocol to obtain an initial data packet; generating a check code of the initial data packet through a cyclic redundancy check algorithm; splicing the check code with the initial data packet to obtain a data packet, wherein the check code is used to check the data packet through the programmable logic controller.
[0053] In an optional embodiment, the target data can be packaged based on the soft bus protocol to obtain an initial data packet. Then, a check code of the initial data packet is generated through a cyclic redundancy check algorithm, and the check code can be used to check the integrity of data transmission. Further, the check code is spliced with the initial data packet to obtain a data packet. The check code can enhance the reliability of data packet transmission and effectively prevent the loss or damage of the data packet during transmission.
[0054] Optionally, the method further includes at least one of the following: in response to monitoring an abnormality in communication with a programmable logic controller, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an abnormality in communication with a programmable logic controller, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the programmable logic controller within a preset heartbeat time, or in response to monitoring an abnormality in the heartbeat packet sent by the programmable logic controller, confirming that an abnormality has occurred in communication with the programmable logic controller, and triggering abnormality processing; in response to monitoring an abnormality in communication with the programmable logic controller, identifying a faulty node, and isolating the faulty node; in response to monitoring an abnormality in communication with the programmable logic controller, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0055] In an optional embodiment, the continuity and security of the communication between the Hongmeng device and the programmable logic controller can be ensured through an exception handling mechanism, which is crucial for the stable operation of the industrial automation system. Specifically, it is possible to monitor whether the communication with the programmable logic controller is abnormal. When an exception occurs, an error code is generated, and the error cause corresponding to the error code is queried through a preset error code list, and the error cause is processed based on the error cause. Alternatively, it is also possible to monitor whether the communication with the programmable logic controller is abnormal. When an exception occurs, the communication with the programmable logic controller is re-communicated based on the preset retry parameters. Alternatively, it is also possible to monitor whether the heartbeat packet is transmitted abnormally. When the heartbeat packet sent by the programmable logic controller is not received at the preset heartbeat time, or when the heartbeat packet sent by the programmable logic controller is detected to be abnormal, it is confirmed that the communication with the programmable logic controller is abnormal and the exception handling is triggered. Alternatively, it is also possible to monitor whether the communication with the programmable logic controller is abnormal. When an exception occurs, the faulty node is identified and the faulty node is isolated. Alternatively, it is also possible to monitor whether the communication with the programmable logic controller is abnormal. When an exception occurs, an alarm message is generated, the problem is located based on the communication log, the specific problem is determined, and the specific problem is processed. Alternatively, the authority of the preset operation instruction may be set, the preset operation instruction may be monitored, the authority verification may be performed on the preset operation instruction, and in response to the preset operation instruction passing the authority verification, the preset operation instruction may be executed.
[0056] Figure 2 is a flow chart of a communication method according to an embodiment of the present invention. Figure 2 As shown, applied to a programmable logic controller, the method comprises the following steps:
[0057] Step S202, establish a network connection with the Hongmeng device through the Internet protocol.
[0058] The above Internet protocols can be used for data communication and network communication in the Internet. The Internet protocol provides stable and efficient network support for data communication between Hongmeng devices and programmable logic controllers. Through the Internet protocol, Hongmeng devices and programmable logic controllers can cross different networks and devices to achieve data interconnection and intelligent collaboration, and jointly promote the development of industrial automation and intelligence.
[0059] The above-mentioned programmable logic controller can be a digital electronic system for industrial automation and process control. The programmable logic controller may also have a network communication function, and can communicate data with a host computer, intelligent devices, etc. through a communication protocol to achieve information sharing and collaborative work between devices. The programmable logic controller can communicate data and control operations with Hongmeng devices to achieve interconnection and intelligent collaboration between devices. The programmable logic controller has a high degree of stability and reliability and can achieve precise control. The distributed and interconnected characteristics of the programmable logic controller and the Hongmeng device complement each other, and are therefore often used together in the development of industrial automation and intelligence.
[0060] The above-mentioned Hongmeng devices may refer to smart devices running the Hongmeng system. Hongmeng devices have the characteristics of distribution, interconnection, microkernel design, high customizability, security and controllability, and can well meet the needs of industrial automation and intelligence. Hongmeng devices can communicate with programmable logic controllers through soft bus to achieve efficient, stable and secure data transmission and control operations between the two.
[0061] In an optional embodiment, after receiving a connection request sent by the Hongmeng device via the Internet Protocol, a second TCP data packet is generated to confirm that the PLC has received the connection request through the second TCP data packet. Further, after receiving a third TCP data packet sent by the Hongmeng device, after confirming that the sequence number in the third TCP data packet is correct, a response is sent to indicate that a connection can be established, thereby completing the connection establishment with the Hongmeng device.
[0062] In an optional embodiment, a connection relationship can be established with a Hongmeng device through the device information of the programmable logic controller. Specifically, the device information can be sent to the Hongmeng device so that the Hongmeng device is bound to the programmable logic controller based on the device information, thereby connecting the Hongmeng device to the programmable logic controller.
[0063] Step S204, in response to receiving the initialization configuration information sent by the Hongmeng device, setting a communication interface in the programmable logic controller based on the initialization configuration information.
[0064] The above-mentioned communication interface can be an interface for data communication between Hongmeng devices and programmable logic controllers. The communication interface can define the rules, methods and conditions for data transmission. The communication interface can be a hardware interface, a software interface, or a combination of the two. Preferably, the communication interface can be a communication interface implemented by a soft bus. The communication interface can be set by the following communication parameters: baud rate, data bit, stop bit and parity check, etc. The communication parameters are not limited here and can be determined as needed.
[0065] In an optional embodiment, after receiving the initialization configuration information sent by the Hongmeng device, a communication interface can be set in the programmable logic controller based on the initialization configuration information. Specifically, the initialization configuration information can be decoded to obtain configuration data for conversion into communication parameters. The communication parameters are then extracted from the configuration data, and the communication parameters can be used to define the communication rules between the programmable logic controller and the Hongmeng device. Furthermore, the communication interface can be set according to the communication parameters.
[0066] Step S206, send confirmation information to the Hongmeng device.
[0067] The confirmation information is used to indicate that the communication interface configuration is complete.
[0068] The above confirmation information can be used to indicate that the communication interface configuration is complete. The confirmation information can be a confirmation signal, or a configuration status report. Through the confirmation information, it can be confirmed that the communication interface of the programmable logic controller has been configured and can further transmit and communicate data with the Hongmeng device.
[0069] In an optional embodiment, a confirmation message can be sent via the Internet protocol to confirm that the communication interface of the programmable logic controller has been configured and can further transmit and communicate data with the Hongmeng device.
[0070] Step S208, in response to receiving a data packet sent by the Hongmeng device based on the soft bus protocol, the data packet is processed to obtain a processing result, and a response message is sent to the Hongmeng device based on the soft bus protocol. The response message is used to represent the processing result.
[0071] In an optional embodiment, after receiving a data packet sent by the Hongmeng device based on the soft bus protocol, the data packet is processed to obtain a processing result, and a response message is sent to the Hongmeng device based on the soft bus protocol, and the processing result is represented by the response message. This communication method can enable the programmable logic controller to better adapt to the communication needs of the Hongmeng device, and is suitable for real-time data exchange and control scenarios, such as smart factories, smart buildings, etc., and can improve the response speed and processing power of the industrial automation system.
[0072] Optionally, based on the initialization configuration information, a communication interface is set in the programmable logic controller, including: decoding the initialization configuration information to obtain configuration data; extracting communication parameters from the configuration data, wherein the communication parameters are used to define the communication rules between the programmable logic controller and the Hongmeng device; setting the communication interface according to the communication parameters; and generating confirmation information in response to the completion of the communication interface configuration.
[0073] In an optional embodiment, first, the initialization configuration information needs to be decoded to obtain configuration data for conversion into communication parameters. Then the communication parameters are extracted from the configuration data, and the communication parameters can be used to define the communication rules between the programmable logic controller and the Hongmeng device. Furthermore, the communication interface can be set according to the communication parameters. Thus, after the communication interface configuration is completed, a confirmation message is generated and sent to the Hongmeng device, so that the Hongmeng device confirms that the communication interface configuration is complete and data transmission between the two can be carried out. This process ensures the accurate application of communication parameters and improves the efficiency and accuracy of communication.
[0074] Optionally, the data packet is processed to obtain a processing result, including: parsing a check code from the data packet based on a soft bus protocol; verifying the data packet based on the check code to obtain a verification result; in response to the verification result being that the data packet verification is successful, parsing target data from the data packet based on the soft bus protocol; processing the target data to obtain a processing result.
[0075] In an optional embodiment, before processing the data packet, a check is required to ensure data security and integrity. Specifically, a check code can be parsed from the data packet based on the soft bus protocol, and then the data packet is checked based on the check code to obtain a check result. When the check result is that the data packet check is successful, after confirming that the check is successful, the target data is parsed from the data packet based on the soft bus protocol to process the target data and obtain a processing result. Through the check mechanism, the programmable logic controller can ensure the integrity of the received data packet, and provide data security protection for data-driven decision systems such as industrial production control and environmental monitoring systems.
[0076] Optionally, the above method also includes one of the following: in response to monitoring an abnormality in communication with a Hongmeng device, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an abnormality in communication with a Hongmeng device, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the Hongmeng device at a preset heartbeat time, or in response to monitoring an abnormality in the heartbeat packet sent by the Hongmeng device, confirming that an abnormality has occurred in communication with the Hongmeng device, and triggering exception processing; in response to monitoring an abnormality in communication with the Hongmeng device, identifying the faulty node, and isolating the faulty node; in response to monitoring an abnormality in communication with the Hongmeng device, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0077] In an optional embodiment, the continuity and security of the communication between the Hongmeng device and the programmable logic controller can be ensured through an exception handling mechanism, which is crucial for the stable operation of the industrial automation system. Specifically, it is possible to monitor whether the communication with the Hongmeng device is abnormal. When an exception occurs, an error code is generated, the error cause corresponding to the error code is queried through a preset error code list, and the error cause is processed based on the error cause. Alternatively, it is also possible to monitor whether the communication with the Hongmeng device is abnormal. When an exception occurs, re-communicate with the Hongmeng device based on preset retry parameters. Alternatively, it is also possible to monitor whether the heartbeat packet is transmitted abnormally. When the heartbeat packet sent by the Hongmeng device is not received at the preset heartbeat time, or when the heartbeat packet sent by the Hongmeng device is detected to be abnormal, it is confirmed that the communication with the Hongmeng device is abnormal and the exception handling is triggered. Alternatively, it is also possible to monitor whether the communication with the Hongmeng device is abnormal. When an exception occurs, the faulty node is identified and the faulty node is isolated. Alternatively, it is also possible to monitor whether the communication with the Hongmeng device is abnormal. When an exception occurs, an alarm message is generated, the problem is located based on the communication log, the specific problem is determined, and the specific problem is processed. Alternatively, the authority of the preset operation instruction may be set, the preset operation instruction may be monitored, the authority verification may be performed on the preset operation instruction, and in response to the preset operation instruction passing the authority verification, the preset operation instruction may be executed.
[0078] Figure 3 is a schematic diagram of a communication system architecture according to an embodiment of the present invention, such as Figure 3 As shown, the system architecture includes: Hongmeng devices, network layer and programmable logic controller.
[0079] Among them, Hongmeng devices include client applications, Internet protocol clients and application layer protocol modules.
[0080] Among them, the network layer includes a network module, a network routing module, a connection management module and a data transmission module.
[0081] Among them, the programmable logic controller includes an Internet protocol server, an application layer protocol module, a data processing module and a control module.
[0082] Through optimized communication strategies, the system achieves efficient, stable and secure communication between devices. It is suitable for various scenarios that require real-time data exchange and control, such as smart factories, smart homes, telemedicine, etc., providing strong support for modern technological life.
[0083] According to an embodiment of the present invention, a communication system embodiment is provided. It should be noted that the system can be used to execute the above-mentioned communication method. The specific implementation scheme and application scenario of this embodiment are the same as those of the above-mentioned embodiment and will not be repeated here.
[0084] Figure 4 is a schematic diagram of a communication system according to an embodiment of the present application, such as Figure 4 As shown, the system includes: Hongmeng device and a programmable logic controller.
[0085] Among them, the Hongmeng device is used to send initialization configuration information after establishing a network connection with the programmable logic controller, and send a data packet based on the soft bus protocol after receiving the confirmation information, wherein the initialization configuration information is used to set the communication interface in the programmable logic controller, and the confirmation information is used to indicate that the communication interface configuration is complete.
[0086] Among them, the programmable logic controller is used to configure and set up the communication interface in the programmable logic controller based on the initialization configuration information, send a confirmation message when the communication interface configuration is completed, and process the data packet, generate response information, and send the response information to the Hongmeng device based on the soft bus protocol, wherein the response information is used to represent the processing result of the data packet.
[0087] According to an embodiment of the present invention, a communication device embodiment is provided. It should be noted that the device can be used to execute the above-mentioned communication method and be applied to Hongmeng devices. The specific implementation scheme and application scenario in this embodiment are the same as those in the above-mentioned embodiment and will not be repeated here.
[0088] Figure 5 is a schematic diagram of a communication device according to an embodiment of the present application, such as Figure 5 As shown, the device includes: a connection module 50, which is used to establish a network connection with a programmable logic controller through an Internet protocol; a confirmation module 52, which is used to send initialization configuration information to the programmable logic controller and receive confirmation information sent by the programmable logic controller, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is complete; a transmission module 54, which is used to send a data packet to the programmable logic controller based on a soft bus protocol, and receive response information sent by the programmable logic controller based on the soft bus protocol, wherein the response information is used to indicate the processing result of the programmable logic controller on the data packet.
[0089] Optionally, the connection module is also used to obtain device information of the programmable logic controller; create a socket client instance and set connection parameters of the socket client based on the device information; call the connection method in the socket client instance to establish a network connection with the programmable logic controller.
[0090] Optionally, the above device also includes a packaging module.
[0091] Optionally, a packing module is used to pack the target data based on the soft bus protocol to obtain an initial data packet; generate a check code for the initial data packet through a cyclic redundancy check algorithm; and concatenate the check code with the initial data packet to obtain a data packet, wherein the check code is used to check the data packet through a programmable logic controller.
[0092] Optionally, the above device also includes an anomaly detection module.
[0093] Optionally, the exception detection module is used for one of the following: in response to monitoring an abnormality in communication with a programmable logic controller, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an abnormality in communication with a programmable logic controller, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the programmable logic controller within a preset heartbeat time, or in response to monitoring an abnormality in the heartbeat packet sent by the programmable logic controller, confirming that an abnormality has occurred in communication with the programmable logic controller and triggering exception processing; in response to monitoring an abnormality in communication with the programmable logic controller, identifying a faulty node and isolating the faulty node; in response to monitoring an abnormality in communication with the programmable logic controller, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0094] According to an embodiment of the present invention, a communication device embodiment is provided. It should be noted that the device can be used to execute the above-mentioned communication method and be applied to a programmable logic controller. The specific implementation scheme and application scenario in this embodiment are the same as those in the above-mentioned embodiment and will not be repeated here.
[0095] Figure 6 is a schematic diagram of a communication device according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:
[0096] A connection module 60 is used to establish a network connection with a Hongmeng device through the Internet protocol; a setting module 62 is used to set a communication interface in a programmable logic controller based on the initialization configuration information received from the Hongmeng device; a confirmation module 64 is used to send a confirmation message to the Hongmeng device, wherein the confirmation message is used to indicate that the configuration of the communication interface is complete; a processing module 66 is used to process the data packet in response to receiving a data packet sent by the Hongmeng device based on the soft bus protocol, obtain a processing result, and send a response message to the Hongmeng device based on the soft bus protocol, wherein the response message is used to indicate the processing result.
[0097] Optionally, the setting module is also used to decode the initialization configuration information to obtain configuration data; extract communication parameters from the configuration data, wherein the communication parameters are used to define the communication rules between the programmable logic controller and the Hongmeng device; set the communication interface according to the communication parameters; and generate confirmation information in response to the completion of the communication interface configuration.
[0098] Optionally, the processing module is also used to parse a check code from the data packet based on the soft bus protocol; verify the data packet based on the check code to obtain a check result; in response to the check result being that the data packet verification is successful, parse target data from the data packet based on the soft bus protocol; and process the target data to obtain a processing result.
[0099] Optionally, the above device also includes an anomaly detection module.
[0100] Optionally, the anomaly detection module is used for one of the following: in response to monitoring an anomaly in communication with a Hongmeng device, generating an error code, querying the error cause corresponding to the error code through a preset error code list, and processing based on the error cause; in response to monitoring an anomaly in communication with a Hongmeng device, re-communicating with the programmable logic controller based on preset retry parameters; in response to not receiving a heartbeat packet sent by the Hongmeng device at a preset heartbeat time, or in response to monitoring an anomaly in the heartbeat packet sent by the Hongmeng device, confirming that an anomaly has occurred in communication with the Hongmeng device, and triggering exception processing; in response to monitoring an anomaly in communication with the Hongmeng device, identifying the faulty node, and isolating the faulty node; in response to monitoring an anomaly in communication with the Hongmeng device, generating an alarm message, locating the problem based on the communication log, determining the specific problem that has occurred, and processing the specific problem that has occurred; in response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to passing the authority verification of the preset operation instruction, executing the preset operation instruction.
[0101] An embodiment of the present application further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of the present invention when running.
[0102] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0103] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in various embodiments of the present invention when executed by a processor.
[0104] An embodiment of the present application further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0105] The embodiments of the present application further provide a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.
[0106] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0107] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0108] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0109] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0110] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0111] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A communication method, characterized in that: Applied to Hongmeng devices, including: Establishing a network connection with a programmable logic controller via Internet protocol; Sending initialization configuration information to the programmable logic controller, and receiving confirmation information sent by the programmable logic controller, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is completed; A data packet is sent to the programmable logic controller based on a soft bus protocol, and response information sent by the programmable logic controller based on the soft bus protocol is received, wherein the response information is used to represent a processing result of the programmable logic controller on the data packet.
2. The method according to claim 1, characterized in that The method of establishing a network connection with the programmable logic controller through the Internet protocol includes: Obtaining device information of the programmable logic controller; Creating a socket client instance, and setting connection parameters of the socket client based on the device information; The connection method in the socket client instance is called to establish a network connection with the programmable logic controller.
3. The method according to claim 2, characterized in that Before sending the data packet to the programmable logic controller based on the soft bus protocol, the method further includes: Packing the target data based on the soft bus protocol to obtain an initial data packet; Generate a check code for the initial data packet through a cyclic redundancy check algorithm; The check code is concatenated with the initial data packet to obtain the data packet, wherein the check code is used to check the data packet through the programmable logic controller.
4. The method according to any one of claims 1 to 3, characterized in that Also includes at least one of the following: In response to monitoring an abnormality in communication with the programmable logic controller, an error code is generated, an error cause corresponding to the error code is searched through a preset error code list, and processing is performed based on the error cause; In response to monitoring that an abnormality occurs in communication with the programmable logic controller, re-communicating with the programmable logic controller based on preset retry parameters; In response to not receiving a heartbeat packet sent by the programmable logic controller at a preset heartbeat time, or in response to monitoring that an abnormality exists in the heartbeat packet sent by the programmable logic controller, confirming that an abnormality occurs in communication with the programmable logic controller, and triggering abnormality processing; In response to monitoring an abnormality in communication with the programmable logic controller, identifying a faulty node and isolating the faulty node; In response to monitoring an abnormality in communication with the programmable logic controller, an alarm message is generated, the problem is located based on the communication log, a specific problem is determined, and the specific problem is processed; In response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to the preset operation instruction passing the authority verification, executing the preset operation instruction.
5. A communication method, characterized in that: Applications in programmable logic controllers, including: Establish a network connection with Hongmeng devices through Internet protocol; In response to receiving the initialization configuration information sent by the Hongmeng device, setting a communication interface in the programmable logic controller based on the initialization configuration information; Sending a confirmation message to the Hongmeng device, wherein the confirmation message is used to indicate that the configuration of the communication interface is complete; In response to receiving a data packet sent by the Hongmeng device based on the soft bus protocol, the data packet is processed to obtain a processing result, and a response message is sent to the Hongmeng device based on the soft bus protocol, wherein the response information is used to characterize the processing result.
6. The method according to claim 5, characterized in that The step of setting a communication interface in the programmable logic controller based on the initialization configuration information includes: Decoding the initialization configuration information to obtain configuration data; Extracting communication parameters from the configuration data, wherein the communication parameters are used to define communication rules between the programmable logic controller and the Hongmeng device; According to the communication parameters, setting the communication interface; In response to the communication interface configuration being completed, the confirmation information is generated.
7. The method according to claim 5, characterized in that The processing of the data packet to obtain a processing result includes: Parsing a check code from the data packet based on the soft bus protocol; Verify the data packet based on the verification code to obtain a verification result; In response to the verification result indicating that the data packet is successfully verified, parsing the target data from the data packet based on the soft bus protocol; The target data is processed to obtain the processing result.
8. The method according to any one of claims 5 to 7, characterized in that Also includes one of the following; In response to monitoring an abnormality in communication with the Hongmeng device, an error code is generated, an error cause corresponding to the error code is searched through a preset error code list, and processing is performed based on the error cause; In response to monitoring an abnormality in communication with the Hongmeng device, re-communicating with the programmable logic controller based on preset retry parameters; In response to not receiving a heartbeat packet sent by the Hongmeng device at a preset heartbeat time, or in response to detecting an abnormality in the heartbeat packet sent by the Hongmeng device, confirming that an abnormality has occurred in communication with the Hongmeng device, and triggering exception handling; In response to monitoring an abnormality in communication with the Hongmeng device, identifying a faulty node and isolating the faulty node; In response to monitoring an abnormality in communication with the Hongmeng device, an alarm message is generated, the problem is located based on the communication log, a specific problem is determined, and the specific problem is processed; In response to monitoring a preset operation instruction, performing authority verification on the preset operation instruction, and in response to the preset operation instruction passing the authority verification, executing the preset operation instruction.
9. A communication system, characterized in that: include: A Hongmeng device is used to send initialization configuration information after establishing a network connection with a programmable logic controller, and send a data packet based on a soft bus protocol after receiving a confirmation message, wherein the initialization configuration information is used to set a communication interface in the programmable logic controller, and the confirmation information is used to indicate that the configuration of the communication interface is complete; A programmable logic controller is used to configure and set up a communication interface in the programmable logic controller based on the initialization configuration information, send the confirmation information when the communication interface configuration is completed, and process the data packet to generate response information, and send the response information to the Hongmeng device based on the soft bus protocol, wherein the response information is used to represent the processing result of the data packet.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 4 when running.