Serial communication loop anti-loop method, equipment and medium

By using programmable logic devices to construct a physical closed-loop topology in a serial communication network, the problem of automatic recovery of loop detection function is solved, hardware loop prevention is achieved, the stability and flexibility of the system are improved, costs are reduced, and data loop forwarding is avoided.

CN121967111APending Publication Date: 2026-05-01SHENZHEN PRIMESTONE NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN PRIMESTONE NETWORK TECH CO LTD
Filing Date
2025-12-29
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In existing serial communication networks, once the automatic recovery time limit for loop detection expires, the port switching to forwarding mode can easily lead to the re-formation of loops, affecting communication quality and stability. Furthermore, existing loop prevention solutions rely on complex software protocols, have high hardware requirements, limited applications, or fixed master-slave modes, which restrict the flexibility and reliability of the system.

Method used

A ring network topology is constructed at the physical layer using programmable logic devices. Serial signals are converted into TTL level signals through signal drivers and transceivers, and data forwarding logic is executed based on flag bits to achieve flexible master-slave switching for each device, avoid data loop forwarding, and build a pure hardware anti-loop architecture.

Benefits of technology

It reduces system complexity and cost, improves the stability and reliability of communication networks, enhances networking flexibility, avoids data storms, and possesses high reliability and real-time performance, enabling rapid response to signal changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967111A_ABST
    Figure CN121967111A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of serial communication, discloses a serial communication loop anti-loop method, equipment and a medium, and aims to solve the problems that an existing serial communication loop anti-loop scheme depends on a complex software protocol, is high in hardware requirement, limited in application, low in reliability or fixed in master-slave mode. According to the invention, the serial signal input by the serial communication interface and the serial signal input by the ring network receiving interface are accessed to the programmable logic device, and then the programmable logic device carries out subsequent signal processing and forwarding logic control, and finally the ring network with a physical closed-loop topological structure is constructed. Dependence of a traditional scheme on a complex software protocol is eliminated, a switching chip supporting various looped network protocols does not need to be used, hardware cost is reduced, system complexity is reduced, and stability and reliability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

A method, device and medium for preventing loops in serial communication Technical Field

[0001] This invention relates to the field of serial communication technology, and more specifically, to a method, device, and medium for preventing serial communication loops. Background Technology

[0002] Loop detection is a crucial function in serial communication. Its main purpose is to automatically shut down the problematic port when a loop exists in the serial communication network, thus eliminating the loop's impact on the network. During the deployment or configuration of a serial communication network, incorrect wiring connections or improper network parameter configuration can easily lead to message forwarding loops in the serial communication lines. This causes problems such as circular message forwarding and repeated transmission, resulting in network congestion, communication interruptions, or even the paralysis of the entire serial communication system. The loop detection function is specifically designed to effectively suppress the generation and spread of such loop faults, and is key to ensuring the stable operation of the serial communication network and improving network communication security. Therefore, the operational stability of the loop detection function itself is of great significance to the overall reliability of the serial communication network.

[0003] Existing conventional loop detection functions typically have an automatic recovery timeout. When this timeout expires, the previously blocked faulty port will automatically switch to forwarding mode. However, during the period when the port switches to forwarding mode, the serial communication network may fall into a loop again. If this forwarding state persists for too long, it will severely negatively impact the communication quality and operational stability of the serial communication network. Therefore, in loop detection functions, the duration for which the blocked port switches to forwarding mode after the automatic recovery timeout expires is also a critical parameter affecting the stable operation of the serial communication network, and its rationality and controllability are of paramount importance.

[0004] Serial communication (including but not limited to RS232, RS485 (2-wire or 4-wire), RS422, etc.) does not itself constitute a logical loop network. However, in the cabling scenario of a multi-point serial communication system, based on actual application requirements, there is a need to connect the serial communication buses end to end to form a physical closed loop. However, the above-mentioned physical closed loop deployment method is very prone to causing serial communication network failures, communication interruptions, and other faults, which restricts the application of serial communication in multi-point networking scenarios.

[0005] Currently, existing technologies for preventing loops in serial communication networks and suppressing loop faults mainly fall into three categories, all of which have significant drawbacks: 1. Loop suppression based on general communication protocols, such as STP, RSTP, MSTP, ERPS, and MRP protocols; the drawback of this type of solution is that it relies on dedicated systems capable of running these protocols, placing high demands on the computing power and compatibility of the hardware, leading to increased system deployment costs and limited adaptability; 2. Some companies implement loop suppression through proprietary communication protocols, such as MOXA's Turbo Ring protocol and B&R's Redundant protocol. Ring protocol, etc.; The drawback of this type of solution is that its application scenarios are limited to specific fields and are protected by the patents of relevant companies, which makes it difficult to promote and apply widely and is not conducive to the standardized deployment of multi-point serial communication systems; 3. In multi-point communication systems built on serial communication, the network topology is ensured to be bus-type by manual configuration, thereby avoiding the formation of logical loops at the application layer; The drawback of this type of solution is that, on the one hand, manual configuration is prone to loop failures due to operational errors, resulting in low reliability; on the other hand, it requires a master device to be pre-set, and all other devices are slave devices, resulting in a fixed master-slave working mode of the devices, which cannot be flexibly switched, limiting the system's operational flexibility and scalability.

[0006] Therefore, there is an urgent need to design a technical solution that relies solely on hardware to achieve loop detection and suppression while ensuring the stability of system operation. Summary of the Invention

[0007] To overcome the problems of existing serial communication loop prevention schemes relying on complex software protocols, high hardware requirements, limited applications, low reliability, or fixed master-slave modes, this invention provides a serial communication loop prevention method, device, and medium. It enables serial communication devices to directly form a ring network topology at the physical layer, unaffected by physical loops. Furthermore, each serial communication device in the ring network can flexibly switch between master and slave working modes without the need for fixed master-slave device configurations, thereby improving the networking flexibility and operational adaptability of the serial communication system.

[0008] The technical solution of the present invention is as follows: In a first aspect, the present invention provides a serial communication loop prevention method, comprising the following steps: Step S1, converting the serial signal input from the serial communication interface into a unified TTL level signal, and performing gain processing on the converted TTL level signal through a signal driver; Step S2, connecting the gain-processed TTL level signal and the serial signal input from the ring network receiving interface to a programmable logic device (PLD); Step S3, the PLD samples the serial signals input from the local serial communication interface and the ring network receiving interface respectively, and detects the signal source based on the sampling results, generating corresponding flag bits; Step S4, the PLD executes data forwarding logic according to the mutual exclusion relationship of the flag bits; Step S5, each node device in the ring network executes steps S1 to S4, and when the signal completes the closed-loop transmission of the ring network and returns to the initial sending node device, the PLD of the initial sending node device detects and identifies the signal as a local signal returning from the ring network based on the flag bits, and prohibits it from entering the local serial communication interface again.

[0009] As a preferred embodiment of the present invention, in step S3, when the programmable logic device detects a valid signal input at the local serial communication interface, it sets the local side signal validity flag to 1; when the programmable logic device detects a valid signal input at the ring network receiving interface, it sets the ring network side signal validity flag to 1.

[0010] As a preferred embodiment of the present invention, in step S3, when the local side signal valid flag is set to 1, if the programmable logic device detects that the local serial communication interface has entered an idle state for a preset duration, or detects that the ring network side signal valid flag is set to 1, then the local side signal valid flag is set to 0; when the ring network side signal valid flag is set to 1, if the programmable logic device detects that the ring network receiving interface has entered an idle state for a preset duration, or detects that the local side signal valid flag is set to 1, then the ring network side signal valid flag is set to 0.

[0011] As a preferred embodiment of the present invention, in step S4, the data forwarding logic includes: when the valid flag bit of the ring network side signal is 1, the programmable logic device forwards the signal received from the ring network receiving interface to both the local serial communication interface and the ring network transmitting interface simultaneously; when the valid flag bit of the local side signal is 1, the programmable logic device forwards the signal received from the local serial communication interface only to the ring network transmitting interface.

[0012] As a preferred embodiment of the present invention, in step S4, the data forwarding logic further includes: when both the ring network side signal valid flag bit and the local side signal valid flag bit are 0, the programmable logic device shuts down the local serial communication interface and the ring network transmission interface.

[0013] As a preferred embodiment of the present invention, the ring network adopts a physical closed-loop topology and is composed of multiple serial communication devices interconnected.

[0014] As a preferred embodiment of the present invention, each of the serial communication devices is connected to a serial communication converter via its serial communication interface. The serial communication converter consists of a signal driver, a programmable logic unit, and a signal transceiver connected in sequence. The signal transceiver is provided with a ring network receiving interface and a ring network transmitting interface for accessing the ring network.

[0015] As a preferred embodiment of the present invention, the programmable logic device is a general-purpose EPLD.

[0016] In a second aspect, the present invention provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the above-described serial communication loop prevention method.

[0017] Thirdly, the present invention provides a computer-readable storage medium, including a data storage area and a program storage area, wherein the data storage area stores created data and the program storage area stores a computer program; wherein, when the computer program is executed by a processor, it implements the serial communication loop prevention method described above.

[0018] According to the above-described scheme, the beneficial effects of this invention are as follows: 1. By connecting the serial signal input from the serial communication interface and the serial signal input from the ring network receiving interface to the programmable logic device, and then having the programmable logic device perform subsequent signal processing and forwarding logic control, a ring network with a physical closed-loop topology is finally constructed. This eliminates the dependence on complex software protocols in traditional schemes, eliminates the need to use switching chips that support various ring network protocols, reduces hardware costs, reduces system complexity, and improves system stability and reliability.

[0019] 2. The programmable logic unit executes different data forwarding logic based on the status of the valid flag bits of the signals on the local side and the ring network side, which enables each serial communication device in the ring network to flexibly switch between master and slave working modes without the need for fixed master and slave device configuration, greatly improving the networking flexibility and operational adaptability of the serial communication system.

[0020] 3. Data forwarding logic built with hardware code using a programmable logic device (PLC) can effectively prevent data storms caused by physical loops, thus preventing communication network failures. The pure hardware loop prevention architecture eliminates the need for additional layers of switching equipment and software protocols for link loop prevention, significantly reducing system costs. Compared to software loop prevention solutions, hardware loop prevention offers higher reliability and real-time performance, enabling rapid response to signal changes and effectively avoiding loop failures caused by software processing delays or malfunctions. Attached Figure Description

[0021] Figure 1 is a flowchart illustrating a serial communication loop prevention method according to an embodiment of the present invention; Figure 2 is a device topology diagram of a ring network according to an embodiment of the present invention; Figure 3 is a structural schematic diagram of a serial communication converter according to an embodiment of the present invention; Figure 4 is a structural schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0022] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0023] It should be noted that the terms "comprising" and "having," and any variations thereof, in the specification and claims of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.

[0024] As shown in Figure 1, an embodiment of the present invention provides a serial communication loop prevention method, including the following steps: Step S0, constructing a ring network.

[0025] Specifically, as shown in Figures 2 and 3, the ring network adopts a physically closed-loop topology, consisting of multiple interconnected serial communication devices. Each serial communication device's serial communication interface is connected to a serial communication converter. The serial communication converter consists of a signal driver, a programmable logic unit (PLU), and a transceiver connected in sequence. The transceiver has a ring network receiving interface and a ring network transmitting interface. The signal driver is an AiP74LVC244TA20 model to bridge the signals of the serial communication interface. The PLU uses a general-purpose EPLD, such as the GW1N-UV1P5LQ100 model. Due to its minimal anti-ring resource requirements, a low-cost chip with less than 1K logic gates and less than 32 macrocells is sufficient to meet the requirements.

[0026] Figure 2 shows a physical closed-loop topology consisting of four serial communication devices as an example. In actual use, dozens or even hundreds of serial communication devices can be interconnected. In this invention, a pure hardware anti-loop architecture is adopted, eliminating the need for additional layers of switching equipment and relying on software protocols to implement link anti-loop. Multiple serial communication converters are directly connected end-to-end to form a physical closed-loop topology, reducing intermediate links and lowering system complexity and cost. Normal communication transmission can be achieved between nodes in the ring network, effectively avoiding data storms caused by data loops and thus preventing communication network failure.

[0027] Step S1: Convert the serial signal input from the serial communication interface into a unified TTL level signal, and perform gain processing on the converted TTL level signal through a signal driver.

[0028] Specifically, since different serial communication devices have different signal levels, different numbers of lines, and different modes for their serial signals, it is necessary to convert the serial signals input from the serial communication interface into common TTL level signals to adapt to the signal processing requirements of programmable logic devices. After level conversion, in order to maintain signal stability, signal gain is also required to compensate for signal attenuation during transmission and ensure the transmission quality of the signal in the ring network.

[0029] Step S2: Connect the gain-processed TTL level signal and the serial signal input from the ring network receiving interface to the programmable logic device. The serial signal is divided into TX and RX signals; the serial signal input from the serial communication interface is the TX signal, and the serial signal received by the ring network receiving interface is the RX signal.

[0030] Step S3: The programmable logic device samples the serial signals input from the local serial communication interface and the ring network receiving interface, respectively, and detects the signal source based on the sampling results to generate the corresponding flag bit.

[0031] Specifically, the logic for generating corresponding flag bits based on the signal source detected by the sampling results is as follows: When the programmable logic device (PLD) detects a valid signal input at the local serial communication interface, it sets the local signal validity flag to 1; when the PLD detects a valid signal input at the ring network receiving interface, it sets the ring network signal validity flag to 1; after the local signal validity flag is set to 1, if the PLD detects that the local serial communication interface has entered an idle state for a preset duration, or if it detects that the ring network signal validity flag is set to 1, it sets the local signal validity flag to 0; after the ring network signal validity flag is set to 1, if the PLD detects that the ring network receiving interface has entered an idle state for a preset duration, or if it detects that the local signal validity flag is set to 1, it sets the ring network signal validity flag to 0, ensuring the timeliness and mutual exclusivity of the flag bits, thereby preventing the signal from forming a loop and endlessly cycling.

[0032] Step S4: The programmable logic device (PLD) executes data forwarding logic based on the mutual exclusion relationship of the flag bits. Specifically, the data forwarding logic includes: when the ring network side signal validity flag bit is 1, it indicates that the signal source is the ring network. The PLD will forward the signal received from the ring network receiving interface to both the local serial communication interface and the ring network transmitting interface, realizing local reception and downward transmission of the ring network signal; when the local side signal validity flag bit is 1, it indicates that the signal source is the local serial communication interface. The PLD will forward the signal received from the local serial communication interface only to the ring network transmitting interface, prohibiting the signal from being transmitted back to the local serial communication interface; when both the ring network side signal validity flag bit and the local side signal validity flag bit are 0, it indicates that there is no valid signal input. The PLD will close the local serial communication interface and the ring network transmitting interface, that is, close the signal forwarding channel to avoid interference from invalid signals.

[0033] In step S5, each node device in the ring network executes steps S1 to S4. When the signal completes the closed-loop transmission of the ring network and returns to the initial sending node device, the programmable logic device of the initial sending node device identifies the signal as a local signal returning from the ring network based on the flag bit detection, and prohibits it from entering the local serial communication interface again to avoid forming a loop storm. This ensures that there will be no data loop forwarding in the entire ring network, guarantees normal communication between each node device, and improves the reliability and stability of the communication network.

[0034] For example, in a ring network, each node operates independently according to steps S1 to S4. When a signal is sent from the initial sending node (e.g., node A), forwarded sequentially by nodes B, C, D, etc., and finally returns to node A in the closed loop, the programmable logic device (PLD) of node A detects and identifies the signal as a local signal returning from the ring network by setting its local signal validity flag to 1. Following the data forwarding logic, it only forwards the signal to the ring network's sending interface, preventing the signal from originating locally and returning locally. If the PLD does not perform this judgment and restriction, a signal could originate locally, return locally, and then be forwarded again, ultimately triggering a network data storm and paralyzing the entire ring network.

[0035] In summary, the serial communication loop prevention method of this invention connects the serial signals input from the serial communication interface and the serial signals input from the ring network receiving interface to a programmable logic controller (PLC). The PLC then performs subsequent signal processing and forwarding logic control, ultimately constructing a ring network with a physically closed-loop topology. This eliminates the reliance on complex software protocols found in traditional solutions, eliminates the need for switching chips supporting various ring network protocols, reduces hardware costs and system complexity, and improves system stability and reliability. The PLC executes different data forwarding logic based on the valid flag bits of the signals on the local side and the ring network side, allowing each serial communication device in the ring network to flexibly switch between master and slave modes without requiring fixed master / slave configurations, greatly enhancing the networking flexibility and operational adaptability of the serial communication system. The data forwarding logic, constructed with hardware code by the PLC, effectively prevents data storms caused by physical loops during data forwarding, thereby preventing communication network failure. The pure hardware loop prevention architecture eliminates the need for additional layers of switching equipment and software protocols to prevent loops, significantly reducing system costs. Compared to software loop prevention solutions, hardware loop prevention offers higher reliability and real-time performance, enabling rapid response to signal changes and effectively preventing loop failures caused by software processing delays or malfunctions.

[0036] Figure 4 shows a schematic diagram of the electronic device that implements the serial communication loop prevention method of the present invention.

[0037] The electronic device may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and capable of running on the processor 10, such as a serial communication loop prevention program.

[0038] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., executing serial communication loop prevention programs) and calls data stored in the memory 11 to perform various functions of the electronic device and process data.

[0039] The memory 11 includes at least one type of readable storage medium, including flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device, such as a plug-in portable hard drive, SmartMediaCard (SMC), SecureDigital (SD) card, FlashCard, etc. Furthermore, the memory 11 can include both internal and external storage units of the electronic device. The memory 11 can be used not only to store application software and various types of data installed on the electronic device, such as code for serial communication loop prevention programs, but also to temporarily store data that has been output or will be output.

[0040] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable communication between the memory 11 and at least one processor 10, etc.

[0041] Communication interface 13 is used for communication between the aforementioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, Bluetooth interface, etc.), typically used to establish communication connections between the electronic device and other electronic devices. The user interface may be a display, an input unit (such as a keyboard), or optionally, a standard wired or wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device and to display a visual user interface.

[0042] Figure 4 only shows an electronic device with components. Those skilled in the art will understand that the structure shown in Figure 4 does not constitute a limitation on the electronic device and may include fewer or more components than shown, or combine certain components, or have different component arrangements.

[0043] For example, a power supply, although not shown, may also include a power source (such as a battery) to power various components. Preferably, the power supply can be logically connected to at least one processor 10 via a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power sources, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be elaborated further here.

[0044] It should be understood that the embodiments are for illustrative purposes only and are not limited to this structure in the scope of the patent application.

[0045] The serial communication loop prevention program stored in the memory 11 of the electronic device is a combination of multiple computer programs. The specific implementation method of the processor 10 for the above computer programs can be referred to the description of the relevant steps in the corresponding embodiment of Figure 1, which will not be repeated here.

[0046] Furthermore, if the modules / units integrated into an electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, a computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, and read-only memory (ROM).

[0047] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor of an electronic device, can implement the steps of the serial communication loop prevention method shown in Figure 1.

[0048] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0049] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0050] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0051] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0052] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.

[0053] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0054] Furthermore, although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0055] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

[0056] The present invention has been described above with reference to the accompanying drawings. Obviously, the implementation of the present invention is not limited to the above-described manner. Any improvements made using the inventive concept and technical solution of the present invention, or the direct application of the inventive concept and technical solution of the present invention to other situations without modification, are all within the protection scope of the present invention.

Claims

1. A method for preventing loops in serial communication, characterized in that, Includes the following steps: Step S1: Convert the serial signal input from the serial communication interface into a unified TTL level signal, and perform gain processing on the converted TTL level signal through a signal driver; Step S2: The TTL level signal after gain processing and the serial signal input from the ring network receiving interface are connected to the programmable logic device (PLD). Step S3: The PLD samples the serial signals input from the local serial communication interface and the ring network receiving interface, respectively, and detects the signal source based on the sampling results, generating corresponding flag bits. Step S4: The PLD executes data forwarding logic according to the mutual exclusion relationship of the flag bits. Step S5: Each node device in the ring network executes steps S1 to S4. When the signal completes the closed-loop transmission of the ring network and returns to the initial sending node device, the PLD of the initial sending node device detects and identifies the signal as a local signal returning from the ring network based on the flag bits, and prohibits it from entering the local serial communication interface again.

2. The serial communication loop prevention method according to claim 1, characterized in that, In step S3, when the programmable logic device detects a valid signal input at the local serial communication interface, it sets the local signal validity flag to 1; when the programmable logic device detects a valid signal input at the ring network receiving interface, it sets the ring network signal validity flag to 1.

3. The serial communication loop prevention method according to claim 2, characterized in that, In step S3, when the local side signal valid flag is set to 1, if the programmable logic device detects that the local serial communication interface has entered an idle state for a preset duration, or detects that the ring network side signal valid flag is set to 1, then the local side signal valid flag is set to 0; when the ring network side signal valid flag is set to 1, if the programmable logic device detects that the ring network receiving interface has entered an idle state for a preset duration, or detects that the local side signal valid flag is set to 1, then the ring network side signal valid flag is set to 0.

4. The serial communication loop prevention method according to claim 3, characterized in that, In step S4, the data forwarding logic includes: when the ring network side signal valid flag is 1, the programmable logic device forwards the signal received from the ring network receiving interface to both the local serial communication interface and the ring network transmitting interface simultaneously; when the local side signal valid flag is 1, the programmable logic device forwards the signal received from the local serial communication interface only to the ring network transmitting interface.

5. The serial communication loop prevention method according to claim 4, characterized in that, In step S4, the data forwarding logic further includes: when both the ring network side signal valid flag bit and the local side signal valid flag bit are 0, the programmable logic device shuts down the local serial communication interface and the ring network transmission interface.

6. The serial communication loop prevention method according to claim 1, characterized in that, The ring network adopts a physical closed-loop topology and consists of multiple serial communication devices interconnected.

7. The serial communication loop prevention method according to claim 6, characterized in that, Each of the serial communication devices is connected to a serial communication converter via its serial communication interface. The serial communication converter consists of a signal driver, a programmable logic unit, and a signal transceiver connected in sequence. The signal transceiver is provided with a ring network receiving interface and a ring network transmitting interface for accessing the ring network.

8. The serial communication loop prevention method according to claim 1, characterized in that, The programmable logic device is a general-purpose EPLD.

9. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the serial communication loop prevention method as described in any one of claims 1 to 8.

10. A computer-readable storage medium storing computer-executable instructions, characterized in that, It includes a data storage area and a program storage area. The data storage area stores the created data, and the program storage area stores the computer program. When the computer program is executed by the processor, it implements the serial communication loop prevention method as described in any one of claims 1 to 8.