Serial port communication reconnection method

By monitoring the serial port communication status in real time and automatically triggering the reconnection process, the problem of manual intervention in traditional serial port communication interruption is solved, rapid recovery and high reliability are achieved, and user experience and system stability are improved.

CN120144346APending Publication Date: 2025-06-13SUZHOU SHENGTENG ZHILIAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510194746.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

When traditional serial communication encounters unexpected disconnection, manual intervention is often required to re-establish the connection, which is time-consuming and labor-intensive and may lead to data loss and service interruption.

Method used

Through the monitoring module, the serial communication status is monitored in real time, the interruption is detected automatically and the reconnection process is triggered, the reconnection environment is evaluated, the optimal reconnection parameters are selected, the reconnection is attempted and the result is recorded, the maximum number of retry times and time intervals are set to prevent excessive resource occupancy.

Benefits of technology

It realizes rapid recovery after serial communication interruption, improves system reliability and user experience, reduces the need for manual intervention, and provides troubleshooting and alarm functions through log and notification modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144346A_ABST
    Figure CN120144346A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of communication, and discloses a serial port communication reconnection method, which comprises the following steps: S1, detecting interruption, and monitoring a serial port communication state in real time through a monitoring module; s2, reconnection is started, and when communication interruption is detected, a reconnection process is automatically triggered; s3, environment evaluation: evaluating a current reconnection environment; s4, selecting parameters, and selecting optimal reconnection parameters according to a preset rule; s5, trying to reconnect and trying to reestablish connection, recording the result of each try, setting the maximum number of retry times and time interval when the connection is tried to reestablish, and increasing delay after each retry fails to prevent excessive occupation of resources; and S6, checking successfully, and verifying whether the connection is recovered or not. By introducing multiple technical innovations such as an automatic detection mechanism, an intelligent reconnection strategy and a multi-attempt mechanism, quick recovery after serial port communication interruption is realized, and the reliability of the system and the user experience are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, and particularly to a method for reconnecting serial port communication. Background Art

[0002] Serial port communication is a common way to transfer data between electronic devices and is widely used in fields such as embedded systems, industrial control, and medical devices.

[0003] However, in practical applications, due to various reasons (such as power fluctuations, cable loosening or damage, electromagnetic interference, etc.), serial port communication may be unexpectedly disconnected. Traditional solutions usually rely on manual intervention to re - establish the connection, which is not only time - consuming and laborious but also may lead to data loss and service interruption. Therefore, a method capable of automatically detecting and re - establishing serial port communication is needed to improve the reliability and stability of the system. Summary of the Invention

[0004] (1) Technical Problems to be Solved

[0005] Aiming at the deficiencies of the prior art, the present invention provides a method for reconnecting serial port communication, which solves the problem that traditional solutions for possible unexpected disconnection of serial port communication usually rely on manual intervention to re - establish the connection, which is not only time - consuming and laborious but also may lead to data loss and service interruption.

[0006] (2) Technical Solutions

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] A method for reconnecting serial port communication includes the following steps:

[0009] S1: Detect interruption, and monitor the serial port communication status in real - time through a monitoring module;

[0010] S2: Start reconnection. When a communication interruption is detected, automatically trigger the reconnection process;

[0011] S3: Evaluate the environment, and evaluate the current reconnection environment;

[0012] S4: Select parameters, and select the optimal reconnection parameters according to preset rules;

[0013] S5: Attempt reconnection, attempt to re - establish the connection, and record the result of each attempt. Set the maximum number of retries and the time interval when attempting to re - establish the connection. Increase the delay after each retry failure to prevent excessive resource occupation;

[0014] S6: Check success, verify whether the connection is restored, and send the verification result to the administrator.

[0015] As a further solution of the present invention, the S1 includes a monitoring module, which monitors the serial port communication status in real time. Once a connection interruption is detected, the reconnection process is immediately triggered.

[0016] Furthermore, the S1 includes a serial port module, which supports a variety of common serial port protocols and their variants to ensure wide applicability.

[0017] On the basis of the foregoing solution, the S3 includes a policy module, which contains predefined reconnection rules to guide specific reconnection operations.

[0018] Furthermore, when selecting the optimal reconnection parameters in the S4, it dynamically adapts to different serial port protocols and their variants and takes the historical reconnection success rate as a reference factor.

[0019] As a further solution of the present invention, the S5 includes an execution module, which is connected to the policy module. The execution module performs the reconnection action according to the instructions provided by the policy module.

[0020] On the basis of the foregoing solution, the S6 includes a log module and a notification module. The log module saves the reconnection information, and when an important event occurs, the notification module sends an alarm to the designated contact.

[0021] (III) Beneficial Effects

[0022] Compared with the prior art, the present invention provides a method for reconnection of serial port communication, which has the following

[0023] beneficial effects:

[0024] 1. In the present invention, the monitoring module monitors the serial port communication status in real time. Once a connection interruption is detected, the reconnection process is immediately triggered.

[0025] 2. In the present invention, through the multi-attempt mechanism that when the initial reconnection fails, the system will make multiple attempts according to the predetermined number of times and intervals until it succeeds, the success rate is improved.

[0026] 3. In the present invention, through the introduction of multiple technological innovations such as an automatic detection mechanism, an intelligent reconnection strategy, and a multi-attempt mechanism, the rapid recovery after the serial port communication interruption is realized, and the reliability of the system and the user experience are significantly improved.

[0027] 4. In the present invention, the log module saves the reconnection information for subsequent analysis and troubleshooting. When an important event occurs, the notification module sends an alarm to the designated contact. Description of the Drawings

[0028] Figure 1 It is a schematic diagram of the step flow of a method for reconnection of serial port communication proposed by the present invention.

[0029] Figure 2 Schematic diagram of the system framework of a serial communication reconnection method proposed by the present invention. Detailed implementation manners

[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0031] Embodiment 1

[0032] Referring to Figure 1-2 , a serial communication reconnection method includes the following steps:

[0033] S1: Detect interruption. The monitoring module monitors the serial communication status in real time. The monitoring module in S1 monitors the serial communication status in real time. Once a connection interruption is found, the reconnection process is immediately triggered.

[0034] S2: Start reconnection. When a communication interruption is detected, the reconnection process is automatically triggered. In S2, the reason for the communication interruption is judged, and the reconnection strategy is adjusted accordingly.

[0035] S3: Evaluate the environment. Evaluate the current reconnection environment. The strategy module in S3 contains predefined reconnection rules to guide specific reconnection operations.

[0036] S4: Select parameters. Select the optimal reconnection parameters according to preset rules (such as baud rate, data bits, stop bits, etc.).

[0037] S5: Attempt reconnection. Attempt to re - establish the connection and record the result of each attempt. In S5, when attempting to re - establish the connection, the maximum number of retries and the time interval are set. After each retry fails, the delay is increased to prevent excessive resource occupation. Through the multi - attempt mechanism that when the initial reconnection fails, the system will make multiple attempts according to the predetermined number and interval until successful, the success rate is improved. The execution module in S5 is connected to the strategy module. The execution module performs the reconnection action according to the instructions provided by the strategy module. By introducing a number of technical innovations such as an automatic detection mechanism, an intelligent reconnection strategy, and a multi - attempt mechanism, the rapid recovery after a serial communication interruption is realized, and the reliability of the system and the user experience are significantly improved.

[0038] S6: Check success. Verify whether the connection is restored and send the verification result to the administrator.

[0039] Embodiment 2

[0040] Reference Figure 1-2 , a serial port communication reconnection method, comprising the following steps:

[0041] S1: Detect interruptions. The serial port communication status is monitored in real time through a monitoring module. S1 includes a monitoring module that monitors the serial port communication status in real time. Once a connection interruption is detected, the reconnection process is immediately triggered. S1 includes a serial port module that supports a variety of common serial port protocols (such as RS-232, RS-485) and their variants to ensure wide applicability;

[0042] S2: Initiate reconnection. When a communication interruption is detected, the reconnection process is automatically triggered. S2 determines the cause of the communication interruption and adjusts the reconnection strategy accordingly;

[0043] S3: Evaluate the environment. The current reconnection environment is evaluated. S3 includes a policy module that contains predefined reconnection rules to guide specific reconnection operations;

[0044] S4: Select parameters. The optimal reconnection parameters (such as baud rate, data bits, stop bits, etc.) are selected according to preset rules. S4 dynamically adapts to different serial port protocols and their variants when selecting the optimal reconnection parameters and uses the historical reconnection success rate as a reference factor;

[0045] S5: Attempt reconnection. Attempt to re-establish the connection and record the results of each attempt. S5 sets the maximum number of retries and the time interval when attempting to re-establish the connection. The delay is increased after each retry failure to prevent excessive resource occupation. Through the multi-attempt mechanism where the system will make multiple attempts according to the predetermined number and interval until successful after the initial reconnection fails, the success rate is improved. S5 includes an execution module that is connected to the policy module. The execution module performs the reconnection action according to the instructions provided by the policy module. Through the introduction of multiple technological innovations such as an automatic detection mechanism, an intelligent reconnection strategy, and a multi-attempt mechanism, the rapid recovery after a serial port communication interruption is achieved, significantly improving the reliability of the system and the user experience;

[0046] S6: Check success. Verify whether the connection is restored and send the verification result to the administrator. S6 includes a log module and a notification module. The log module saves the reconnection information for subsequent analysis and troubleshooting. When an important event occurs, the notification module sends an alert to the specified contact.

[0047] In the description herein, it should be noted that relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising", or any other variation thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0048] Although embodiments of the present invention have been shown and described, those of ordinary skill in the art will appreciate that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the invention. The scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A serial communication reconnection method, characterized in that: The following steps are involved: S1: Detect interruption and monitor the serial port communication status in real time through the monitoring module; S2: Start reconnection. When communication interruption is detected, the reconnection process is automatically triggered; S3: Evaluate the environment, evaluate the current reconnection environment; S4: Select parameters, and select optimal reconnection parameters according to preset rules; S5: Attempt to reconnect, try to reestablish the connection, and record the results of each attempt. Set the maximum number of retries and time interval when trying to reestablish the connection. Add a delay after each failed retry to prevent excessive resource usage. S6: Check success, verify whether the connection is restored, and send the verification result to the administrator.

2. A serial communication reconnection method according to claim 1, characterized in that: The S1 includes a monitoring module, which monitors the serial port communication status in real time, and immediately triggers a reconnection process once a connection interruption is found.

3. A serial communication reconnection method according to claim 1, characterized in that: The S1 includes a serial port module, which supports a variety of common serial port protocols and their variants to ensure wide applicability.

4. A serial communication reconnection method according to claim 1, characterized in that: The S3 includes a policy module, which contains predefined reconnection rules for guiding specific reconnection operations.

5. A serial communication reconnection method according to claim 1, characterized in that: In S4, different serial port protocols and their variants are dynamically adapted when selecting the optimal reconnection parameters, and the historical reconnection success rate is used as a reference factor.

6. A serial communication reconnection method according to claim 1, characterized in that: The S5 includes an execution module, which is connected to the policy module. The execution module executes the reconnection action according to the instruction provided by the policy module.

7. A serial communication reconnection method according to claim 1, characterized in that: The S6 includes a log module and a notification module. The log module stores the reconnection information. When an important event occurs, the notification module sends an alarm to a designated contact.