A communication method, system, storage medium and program product of a serial network

By adopting a dual serial port structure and intelligent routing mechanism between industrial field devices, the problems of low efficiency and poor reliability of master-slave serial communication are solved, and efficient and reliable data transmission between devices is achieved.

CN120151410BActive Publication Date: 2025-12-26SIGAS MEASUREMENT ENG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510155101.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-12-26
Estimated Expiration
2045-02-12

AI Technical Summary

Technical Problem

The existing master-slave serial communication method in industrial sites is inefficient when exchanging data between multiple devices, and the failure of the host can paralyze the entire network, resulting in poor communication reliability.

Method used

It adopts a dual serial port structure and an intelligent routing mechanism based on address size relationship to realize direct data transmission between devices, and introduces data packet integrity verification, communication quality monitoring and anomaly handling mechanisms to optimize the transmission path.

Benefits of technology

It improves communication efficiency, enhances system reliability and flexibility, avoids redundant data transmission and paths, ensures communication stability and reliability, and reduces interruptions caused by anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120151410B_ABST
    Figure CN120151410B_ABST
Patent Text Reader

Abstract

A communication method and system of serial port network, a storage medium and a program product, relate to the technical field of communication, and the method comprises the following steps: receiving a serial port data packet through a first serial port or a second serial port, and analyzing the serial port data packet to obtain a source address, a destination address and request data; when the destination address is greater than the local address, forwarding the serial port data packet through the second serial port; when the destination address is less than the local address, forwarding the serial port data packet through the first serial port; when the destination address is equal to the local address, executing a corresponding task according to the request data to generate response data; taking the local address as a response source address, the source address as a response destination address, packing the response data to generate a response data packet; and returning the response data packet through the first serial port or the second serial port receiving the serial port data packet. The application can improve the communication efficiency of serial port communication between multiple devices.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, and particularly relates to a serial port network communication method and system, a storage medium and a program product. BACKGROUND

[0002] With the rapid development of industrial control systems, multi-device collaborative work has become an important demand in the field of industrial automation. Among many communication methods, serial port communication has become one of the main methods for communication between industrial field devices due to its simplicity, reliability, strong anti-interference ability and other characteristics.

[0003] In the related art, the master-slave serial port communication mode is generally used in the industrial field. In this mode, the host device sends data request instructions to each slave device through polling, and the slave device responds and returns data after receiving the request of the host device. This communication mode establishes a complete data interaction mechanism and realizes the basic communication demand between industrial field devices.

[0004] However, when data interaction between multiple devices needs to be realized, the host device often needs to be used as a transit node for data forwarding, resulting in low communication efficiency. SUMMARY

[0005] The present application provides a serial port network communication method and system, a storage medium and a program product, which are used to improve the communication efficiency of serial port communication between multiple devices.

[0006] In a first aspect, the present application provides a serial port network communication method, which is applied to multiple communication devices in a communication system, each communication device being provided with a first serial port and a second serial port. The method comprises the following steps: receiving a serial port data packet through the first serial port or the second serial port, and analyzing the serial port data packet to obtain a source address, a destination address and request data; when the destination address is greater than the local address, forwarding the serial port data packet through the second serial port; when the destination address is less than the local address, forwarding the serial port data packet through the first serial port; when the destination address is equal to the local address, executing a corresponding task according to the request data to generate response data; taking the local address as a response source address and the source address as a response destination address, packing the response data to generate a response data packet; and returning the response data packet through the first serial port or the second serial port that receives the serial port data packet.

[0007] In the above embodiment, the communication system sets a double serial port structure, and performs data packet forwarding routing based on the size relationship between the destination address and the local address, thereby realizing efficient transmission of data in the network. When a device receives a data packet, it can intelligently determine the forwarding direction according to the destination address, thereby avoiding repeated transmission and redundant paths of data in the network and improving the overall communication efficiency.

[0008] In some embodiments of the first aspect, in some embodiments, the step of receiving the serial port data packet through the first serial port or the second serial port and parsing the serial port data packet to obtain the source address, the destination address and the request data specifically comprises: receiving the serial port data packet through the first serial port or the second serial port and performing integrity verification of the serial port data packet; the integrity verification comprises checking a packet header identifier, verifying a packet length and calculating a cyclic redundancy check value; when the integrity verification passes, parsing the serial port data packet to obtain the source address, the destination address and the request data; when the integrity verification does not pass, returning data error information through the first serial port or the second serial port receiving the serial port data packet.

[0009] In the above embodiments, the communication system introduces a data packet integrity verification mechanism, including header identifier checking, length verification and CRC verification, which can timely find transmission errors and quickly feedback through error information, ensuring the reliability and accuracy of data transmission and reducing the retransmission overhead caused by data errors.

[0010] In some embodiments of the first aspect, in some embodiments, when the destination address is equal to the local address, the step of executing a corresponding task according to the request data and generating response data specifically comprises: when the destination address is equal to the local address, extracting a task type identifier in the request data; after determining that the local authority meets the task execution authority corresponding to the task type identifier, checking local resource occupation; when the local resource occupation meets the task execution condition corresponding to the task type identifier, adding a corresponding target execution task to a task queue and determining the execution order of the target execution task; after the task execution is completed, recording task execution results and related log information and generating response data.

[0011] In the above embodiments, the communication system implements a task type-based authority management and resource scheduling mechanism, which reasonably arranges the task execution order by checking the authority and resource occupation, avoids device resource conflicts and task congestion, and improves system operation efficiency.

[0012] In some embodiments of the first aspect, in some embodiments, before the step of returning the response data packet through the first serial port or the second serial port receiving the serial port data packet, the method further comprises: when it is determined that the target device is a direct connection device of the first serial port or the second serial port of the local device, obtaining historical communication quality of the serial port corresponding to the direct connection device; the historical communication quality comprises a recent communication success rate and an average response time; when the historical communication quality is lower than a preset quality threshold, forwarding the response data packet to an adjacent device connected by another serial port to forward the response data packet through the adjacent device as a relay node.

[0013] In the above embodiments, the communication system monitors the communication quality of the direct connection device and automatically switches to a better transmission path when the communication quality is poor, thereby realizing adaptive optimization of the network and improving the stability and reliability of the communication.

[0014] In some embodiments of the first aspect, in some embodiments, the destination address is multiple, after receiving the serial port data packet through the first serial port or the second serial port and parsing the serial port data packet to obtain the source address, the destination address and the request data, the method further comprises: when the local address belongs to the destination address, executing a corresponding task according to the request data to generate a response data unit; after determining that there is an additional address different from the local address in the destination address, packing the response data unit and the request data with the local address as the response source address unit and the additional address as the response destination address to generate a serial port processing packet; and forwarding the serial port processing packet through the other serial port of the first serial port or the second serial port receiving the serial port data packet.

[0015] In the above embodiments, the communication system implements a parallel processing mechanism for multiple destination addresses, so that a single data packet can trigger multiple devices to execute tasks at the same time, thereby improving the concurrent processing capability and overall efficiency of the network.

[0016] In some embodiments of the first aspect, in some embodiments, after the step of forwarding the serial port processing packet through the other serial port of the first serial port or the second serial port receiving the serial port data packet, the method further comprises: receiving an execution result packet returned by an additional device corresponding to the additional address, parsing the execution result packet to obtain task execution information; when it is determined according to the task execution information that there is a task execution exception, determining a corresponding exception handling scheme based on an exception handling strategy library to generate a correction instruction; packing the correction instruction into a correction data packet and returning it to the additional device.

[0017] In the above embodiments, the communication system establishes an exception handling mechanism, analyzes the execution result and sends a correction instruction in a timely manner according to an exception handling strategy, thereby improving the fault tolerance and reliability of the system.

[0018] In some embodiments of the first aspect, in some embodiments, before the step of packing the correction instruction into a correction data packet and returning it to the additional device, the method further comprises: generating a task waiting request containing a task suspension identifier and an estimated waiting time; and returning the task waiting request through the first serial port or the second serial port receiving the serial port data packet.

[0019] In the above embodiments, the communication system introduces a task suspension mechanism to timely inform the source device to wait during exception handling, thereby avoiding communication interruption and data loss and ensuring the continuity of task execution.

[0020] In a second aspect, an embodiment of the present application provides a communication system, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is configured to store computer program codes, the computer program codes comprising computer instructions, and the one or more processors are configured to invoke the computer instructions to cause the communication system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0021] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions which, when executed on a communication system, cause the communication system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium comprising instructions which, when executed on a communication system, cause the communication system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0023] It can be understood that the communication system provided in the second aspect, the computer program product provided in the third aspect and the computer storage medium provided in the fourth aspect are all used to execute the method provided by the embodiments of the present application. Therefore, the beneficial effects that can be achieved are referred to the beneficial effects in the corresponding method, which will not be described here.

[0024] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0025] 1. Since the double-serial port structure is adopted and intelligent routing is performed based on the size relationship of the addresses, each device can select the optimal forwarding path according to the comparison result of the destination address and the local address, so that the data packet can reach the target device along the shortest path, and the loop transmission of data in the network is avoided, thereby effectively solving the problems of long data transmission path and repeated forwarding in the related art, and further improving the network communication efficiency, reducing the network load and reducing the transmission delay.

[0026] 2. Since the adaptive routing mechanism based on the historical communication quality is adopted, the communication success rate and the response time of the directly connected devices are monitored in real time, and when the communication quality is detected to be lower than the threshold, the system automatically switches to the alternative path, so that the system can dynamically avoid the transmission link with poor performance, thereby effectively solving the problem of unstable transmission caused by the quality fluctuation of the communication link in the related art, and further improving the reliability and stability of the network transmission, and ensuring the continuity and real-time performance of the data transmission.

[0027] 3、Due to the adoption of the intelligent error correction mechanism based on the exception handling strategy library, the system can automatically analyze the exception causes according to the execution results and generate targeted correction instructions, and meanwhile, through the task suspension mechanism, the completeness of the exception handling process is ensured, so that the system can quickly respond and effectively correct when an exception occurs, effectively solving the problems of untimely exception handling and poor correction effect in the related art, thereby realizing high reliability and strong fault tolerance of the system and improving the success rate of task execution. BRIEF DESCRIPTION OF DRAWINGS

[0028] Figure 1 is a flowchart of a communication method of a serial port network in an embodiment of the present application;

[0029] Figure 2 is another flowchart of a communication method of a serial port network in an embodiment of the present application;

[0030] Figure 3 is a schematic diagram of an entity device structure of a communication system in an embodiment of the present application. DETAILED DESCRIPTION

[0031] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting on the present application. As used in the specification of the present application, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or" used in the present application, mean any or all possible combinations of one or more of the listed items.

[0032] Hereinafter, the terms "first" and "second" are only for the purpose of description, and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.

[0033] In order to facilitate understanding, the application scenarios of the embodiments of the present application are introduced as follows.

[0034] In modern industrial automation production lines, multiple numerical control machine tools need to work cooperatively to complete machining tasks. For example, there are 20 numerical control machine tools on an automobile part production line, and each machine tool is responsible for different machining processes. The machine tools need to exchange information such as workpiece states, machining parameters, and quality inspection data in real time. Due to strong electromagnetic interference in the industrial field and the relatively dispersed distribution of equipment, a reliable communication mode is needed to realize data interaction between devices.

[0035] In the related art, data interaction can be realized by polling each slave device by a host device through a master-slave serial communication architecture. In this way, the host needs to establish a connection with each slave, send a request and wait for a response in a fixed order, resulting in low communication efficiency. The following introduces a scenario of using the serial network communication method in the related art.

[0036] In the traditional master-slave serial communication scheme, one central controller acts as the master device, and the other 20 numerical control machines act as slave devices. When the No. 1 machine needs to deliver the workpiece state information after processing to the No. 15 machine, it must first report the data to the master controller, and then the master controller forwards it to the No. 15 machine. In this way, even if the adjacent machines exchange data, they must pass through the master controller, resulting in increased communication delay and low data transmission efficiency. At the same time, when the master controller fails, the entire communication network will be paralyzed, affecting the normal operation of the production line.

[0037] And by using the serial network communication method in the embodiments of the present application, direct data transmission between devices is realized through the setting of a double serial port structure and an intelligent forwarding mechanism based on addresses, which not only improves the communication efficiency, but also enhances the reliability and flexibility of the system. The following introduces a scenario of using the serial network communication method in the present application.

[0038] After using the serial network communication method of the present application, 20 numerical control machines are connected in series to form a network, and each machine has two serial ports and a unique address number. When the No. 1 machine needs to send data to the No. 15 machine, the data packet will be automatically forwarded through the intermediate machines one by one until it reaches the target machine. Each machine compares the target address in the data packet with its own address to decide whether to receive and process or forward the data. This way, the central controller is not needed, improving the communication efficiency, and any device failure will not affect the communication of the entire network.

[0039] As can be seen, by using the serial network communication method in the embodiments of the present application, efficient data exchange between devices is realized, and the problem of the entire network being paralyzed due to the failure of the host in the traditional master-slave architecture is effectively solved, thereby realizing a more reliable industrial field communication network.

[0040] For ease of understanding, the method provided by the present embodiment is described in the following flow. Please refer to Figure 1 , which is a flowchart of the serial network communication method in the embodiments of the present application.

[0041] S101, receive a serial data packet through a first serial port or a second serial port, and parse the serial data packet to obtain a source address, a destination address and request data.

[0042] Wherein, the serial port data packet represents a data unit transmitted through a serial communication mode, containing various types of information required for communication; the first serial port and the second serial port refer to two independent serial communication interfaces on the communication device, used for bidirectional data transmission with other devices; the source address represents the device address of the data packet sender; the destination address represents the address of the device expected to receive the data packet; and the request data represents the specific task content required to be executed by the target device.

[0043] This step is executed after the communication device is in a normal working state and a serial port communication link is established, and is used for receiving a data request sent by other devices. Specifically, after the communication device receives data through a serial port hardware interface, it first performs data frame synchronization to identify the start flag of the data packet; then performs analysis according to a preset data packet format, and sequentially extracts the source address, the destination address and the request data field contained; and finally performs validity verification on the parsed fields.

[0044] In some embodiments, the receiving and analysis of the data packet can be realized in the following manner: optionally, the device first detects whether there is data arriving at the serial port receiving buffer, and when detecting data, starts the receiving process, reads the data header according to the fixed data format, and verifies the correctness of the start flag; then calculates the total number of bytes to be received according to the data packet length field, and reads in a loop until the entire data packet is received; and finally performs CRC check to ensure the integrity of the data. Optionally, the device receives data in an interrupt mode, and when the serial port receives data, triggers an interrupt handling program, which completes the receiving of the data in the interrupt service program; after the data receiving is completed, the main program analyzes and processes the data in the receiving buffer to extract the information of each field. It can be understood that other data receiving and analysis methods can also be used as long as the various types of information contained in the data packet can be accurately obtained.

[0045] S102、In a case where the destination address is greater than the local address, forwarding the serial port data packet through the second serial port.

[0046] Wherein, the destination address represents the device address to which the data packet is expected to be delivered; the local address refers to the unique identification address of the current communication device; the second serial port refers to the serial communication interface on the device used to connect devices with larger address values; and forwarding refers to delivering the received data packet to the next device completely.

[0047] This step is executed after the data packet is parsed, and is used for realizing the directional forwarding of the data packet. Specifically, the device compares the parsed destination address with the preset address value of the local device, and when the destination address is greater than the local address, it indicates that the target device is located in the "upstream" direction of the local device, and at this time, the data packet needs to be forwarded through the second serial port so that the data packet can continue to be transmitted to the target device.

[0048] In some embodiments, the forwarding process of the data packet can be implemented in the following manner: optionally, the device first checks the working state of the second serial port, ensuring that the serial port is in a transmittable state; then writes the complete data packet in the original format into the sending buffer, and starts the serial port sending process; finally waits for the sending to be completed and performs timeout judgment. Optionally, the device temporarily caches the data packet before forwarding, and starts the response timeout timing at the same time; if no response from the target device is received within the preset time, the data packet is resent until the maximum number of retries is reached. It can be understood that other forwarding processing methods can also be used as long as the data packet can be reliably delivered to the next device.

[0049] S103, when the destination address is less than the local address, forwarding the serial port data packet through the first serial port.

[0050] Among them, the first serial port represents a serial communication interface on the device for connecting devices with smaller address values; the forwarding process is similar to the operation in S102, the difference being that the first serial port is used.

[0051] This step is also executed after the data packet is parsed, and is used to implement the reverse forwarding of the data packet. Specifically, when the destination address is less than the local address, it indicates that the target device is located in the "downstream" direction of the local device, and the data packet needs to be forwarded out through the first serial port to ensure that the data packet can be transmitted in the target direction along the device link.

[0052] S104, when the destination address is equal to the local address, executing the corresponding task according to the request data to generate response data.

[0053] Among them, the request data contains specific task type, parameter and execution requirement; the corresponding task refers to the specific operation that needs to be performed according to the instruction type in the request data; the response data is used to record the results and related state information of the task execution.

[0054] This step is executed when it is confirmed that the data packet is sent to the local device, and is used to process specific business requests. Specifically, the device first parses the task type in the request data, and then executes the corresponding operation according to the preset task processing flow; after the task is executed, the execution results and related state information are collected to generate response data in a standard format.

[0055] In some embodiments, the task processing can be implemented in the following manner: optionally, the device establishes a mapping relationship between the task type and the processing function, and directly calls the corresponding processing function according to the task type in the request; necessary parameter verification and resource inspection are performed during the processing to ensure that the task can be safely executed. Optionally, the device adopts a task queue management mechanism, and places the received request task into a queue for queuing processing, and determines the execution order according to the task priority. It can be understood that other task processing manners can also be adopted as long as the task of the request can be correctly completed and valid response data can be generated.

[0056] S105, the local address is taken as the response source address, the source address is taken as the response destination address, the response data is packaged, and a response data packet is generated.

[0057] The response source address refers to the address of the sender of the response data packet; the response destination address refers to the address of the receiver of the response data packet; and the response data packet refers to a complete data packet containing the task execution result.

[0058] This step is executed after the task processing is completed, and is used for generating a response data packet in a standard format. Specifically, the device takes the local address as the source address of the response data packet, takes the source address of the original request data packet as the response destination address, and then packages the response data generated by the task execution according to a predetermined format, and finally forms a complete response data packet.

[0059] In some embodiments, the generation of the response data packet can be implemented in the following manner: optionally, the device first constructs a packet header part according to a predefined data packet format, which contains start flag, length and other information; then fills the address information and the response data into the corresponding fields; and finally calculates and adds a check code to form a complete response data packet. Optionally, the device performs data compression and encryption processing during the packaging process to improve the efficiency and security of data transmission. It can be understood that other packaging manners can also be adopted as long as the generated response data packet meets the requirements of the communication protocol.

[0060] S106, the response data packet is returned through the first serial port or the second serial port receiving the serial port data packet.

[0061] The return refers to sending the response data packet back to the original requestor; and the serial port receiving the serial port data packet refers to the serial port that initially receives the request data packet.

[0062] This step is executed after the response data packet is generated, and is used for returning the execution result to the requestor. Specifically, the device sends the response data packet using the serial port (the first serial port or the second serial port) that initially receives the request data packet, so as to ensure that the response information can be returned to the requestor through the original communication link.

[0063] In some embodiments, the return of the response data packet can be achieved in the following ways: optionally, the device records the receiving port information of each request data packet, and directly uses the port for return when responding; a flow control mechanism is implemented during transmission to ensure reliable data transmission. Optionally, the device evaluates the communication link state before returning, and if the original receiving port communication quality deteriorates, it will find an alternative path to respond. It can be understood that other return methods can also be used as long as they can ensure that the response data packet reliably reaches the requester.

[0064] In the above embodiment, the processing method of the data is determined by comparing the target address in the data packet with the local address, realizing intelligent routing of the data. In actual application, this mechanism can dynamically adjust the forwarding path according to the communication quality to ensure the reliability of data transmission. The scenarios of this embodiment are supplemented as follows.

[0065] In actual application, this scheme can also automatically optimize the transmission path according to the communication quality. For example, when the success rate of communication with the target device through the direct connection serial port is detected to be reduced, the system will automatically select another path to forward the data. At the same time, for tasks that need to be completed by multiple machines in cooperation, multiple target addresses can be specified in the data packet to realize parallel processing of data. In addition, the system also has an exception handling mechanism, which can generate correction instructions in time to ensure the continuity of production when a machine executes a task abnormally.

[0066] After combining the above scenarios, the method provided by the present embodiment is further described in a more specific flow. Please refer to Figure 2 , another flowchart of the communication method of the serial port network in the embodiment of the present application.

[0067] S201, receiving a serial port data packet through a first serial port or a second serial port, and performing integrity verification of the serial port data packet.

[0068] The integrity verification includes checking the data packet header identifier, verifying the data packet length, and calculating the cyclic redundancy check value, which means checking the legality and correctness of the received data packet; the data packet header identifier indicates a specific byte sequence at the beginning of the data packet; the data packet length indicates the number of bytes of the entire data packet; the cyclic redundancy check value (CRC) is a check code used to detect data transmission errors.

[0069] This step is executed immediately after the serial port receives the data, and is used to ensure the accuracy of the received data. Specifically, the device first checks whether the header of the data packet contains a predefined identifier sequence, then verifies whether the actual received data length is consistent with the length declared in the data packet, and finally calculates the CRC value of the entire data packet and compares it with the check value carried in the data packet.

[0070] S202. When the integrity verification passes, parse the serial port data packet to obtain a source address, a destination address, and request data.

[0071] The integrity verification passing means that each check of the data packet meets the requirements, and the parsing process refers to extracting information of each field according to a predefined data packet format.

[0072] This step is performed after the data packet verification succeeds, and is configured to obtain key information in the data packet. Specifically, the device extracts a source address field, a destination address field, and a request data field from the data packet in sequence according to the format definition of the data packet, and stores these information in corresponding data structures, to prepare for subsequent processing.

[0073] In some embodiments, the data packet parsing can be implemented in the following manner: optionally, the device uses a state machine to parse, and extracts data gradually according to characteristics and boundary identifiers of different fields; meanwhile, the extracted data is subjected to type conversion and range check to ensure the validity of the data. Optionally, the device uses a cache mechanism to process large data packets, and caches the field information obtained by parsing in the memory, to avoid performance overhead caused by repeated parsing. It can be understood that other parsing manners can also be used, as long as each item of information in the data packet can be accurately extracted.

[0074] S203. When the integrity verification fails, return data error information through the first serial port or the second serial port that receives the serial port data packet.

[0075] The data error information refers to a standard format message describing the reason for the data packet verification failure, and the returning means sending the error information to the source device of the data packet through the original receiving port.

[0076] This step is performed when the integrity verification fails, and is configured to timely notify the sender of a data transmission problem. Specifically, the device generates corresponding error codes and description information according to the specific reason for the verification failure (such as header identifier error, length mismatch, or CRC check failure), and then sends these information to the source device through the original data receiving port.

[0077] In some embodiments, the error information returning can be implemented in the following manner: optionally, the device maintains a standard error code mapping table, and generates corresponding error descriptions according to different verification failure reasons; meanwhile, detailed error logs are recorded to facilitate subsequent problem analysis. Optionally, the device uses a simplified data packet format when sending the error information, to ensure that the error information can be quickly sent, and to start a retry counter to wait for retransmission of the source device after sending. It can be understood that other error handling manners can also be used, as long as the source device of the data transmission exception can be effectively notified.

[0078] S204, forwarding the serial port data packet through the second serial port when the destination address is greater than the local address.

[0079] Referring to step S102, the communication system can forward the serial port data packet through the second serial port.

[0080] S205, forwarding the serial port data packet through the first serial port when the destination address is less than the local address.

[0081] Referring to step S103, the communication system can forward the serial port data packet through the first serial port.

[0082] S206, generating a response data unit according to the request data when the local address belongs to the destination address.

[0083] Wherein, the local address belongs to the destination address means that the address of the current device is included in the target address list of the data packet; the response data unit means the execution result generated for the task that the local device needs to process.

[0084] This step is executed when it is found that the data packet needs to be processed by the local device, and is used to complete the specified task and generate the corresponding result. Specifically, the device first confirms that the local address is indeed in the destination address list, then performs the corresponding operation according to the task requirement in the request data, and finally encapsulates the execution result into a standard format response data unit.

[0085] In some embodiments, the task processing can be implemented in the following way: optionally, the device adopts a multi-task parallel processing mechanism to process multiple requests and generate corresponding response data units at the same time; the task execution state is monitored in real time during the processing process to ensure that all tasks can be responded in time. Optionally, the device establishes a task priority management mechanism to dynamically adjust the processing order according to the task type and urgency, and ensures that critical tasks are executed first. It can be understood that other task processing methods can also be used as long as they can efficiently complete the request task and generate effective responses.

[0086] S207, after determining that there is an additional address different from the local address in the destination address, packing the response data unit and the request data with the local address as the response source address unit and the additional address as the response destination address to generate a serial port processing packet.

[0087] Wherein, the additional address refers to the other address in the destination address list except the local address; the response source address unit represents the source device address of the current processing result; the serial port processing packet is a composite data packet containing the local processing result and the request to be forwarded.

[0088] The step is executed after the local task processing is completed, and is used for preparing subsequent forwarding of the data. Specifically, the device checks whether there is another target address in the destination address list, and if yes, repackages the local processing result and the original request data to construct a new serial port processing packet for subsequent forwarding.

[0089] In some embodiments, the construction of the processing packet can be implemented in the following manner: optionally, the device encapsulates the local response data unit and the original request respectively using a layered encapsulation manner, and then combines them into a complete processing packet; and meanwhile, the address mapping relationship is maintained to ensure that the data can be correctly sent to the next target. Optionally, the device performs data optimization during the packaging process to remove the processed address information and reduce the amount of transmission data. It can be understood that other packaging manners can also be used as long as all necessary information is ensured to be contained in the processing packet.

[0090] S208, forwarding the serial port processing packet through another serial port opposite to the serial port receiving the data packet.

[0091] In the formula, the other serial port refers to another serial port opposite to the serial port receiving the data packet; and the forwarding of the serial port processing packet means that the data packet containing multiple targets is delivered to the next device.

[0092] The step is executed after the serial port processing packet is generated, and is used for continuing the delivery process of the data packet. Specifically, the device selects another serial port opposite to the receiving port as a forwarding port to send out the serial port processing packet, so that the data packet can continue to be delivered to other target devices. It should be noted that in actual embodiments, according to the configuration of the transmission direction in the serial port data packet, the other serial port can be pointed, that is, 1 represents the next transmission of the other serial port, and -1 represents the need for backhaul; through the setting, the setting of the task starting point in the serial port data packet and the setting of the next task delivery direction can be realized, and a complete data processing chain can be generated, which greatly increases the flexibility of task processing and delivery.

[0093] In some embodiments, the forwarding of the processing packet can be implemented in the following manner: optionally, the device selects the optimal forwarding path according to the network topology information to ensure that the data packet can quickly reach the next target device; and meanwhile, flow control is implemented to avoid network congestion. Optionally, the device evaluates the link quality before forwarding, and performs packet fragmentation processing when necessary to ensure that large data packets can be reliably transmitted. It can be understood that other forwarding strategies can also be used as long as the processing packet can be reliably delivered to other target devices.

[0094] In some embodiments, the communication system receives an execution result package returned by the additional device corresponding to the additional address, parses the execution result package to obtain task execution information, determines that there is an abnormal task execution according to the task execution information, determines a corresponding abnormal processing scheme based on an abnormal processing strategy library, generates a correction instruction, packages the correction instruction into a correction data package, and returns the correction data package to the additional device.

[0095] The execution result package refers to a data package returned by the additional device after executing the task, and the task execution information refers to key information such as an execution state and result data extracted from the result package. The abnormal processing strategy library is a database for storing preset abnormal conditions and corresponding processing schemes. The correction instruction refers to a specific operation instruction for correcting the abnormal condition, and the correction data package refers to a standard format data package containing the correction instruction.

[0096] This step is performed after receiving the execution result of the additional device, and is used to process possible task abnormal conditions. Specifically, the system first receives and parses the execution result package returned by the additional device to obtain specific conditions of task execution. When an abnormal execution result is found, the system queries the abnormal processing strategy library, selects a suitable processing scheme according to the abnormal type, and generates a corresponding correction instruction. Finally, the correction instruction is packaged and sent to the additional device to guide it to correct errors.

[0097] In some embodiments, the abnormal processing can be implemented in the following ways: optionally, the device adopts a hierarchical abnormality detection mechanism, first performs formal verification to check parameter integrity and format specification, then performs logical verification to analyze the rationality and consistency of the execution result, and finally performs abnormal pattern matching combined with historical data to achieve comprehensive abnormality detection; optionally, the device implements an intelligent abnormal processing strategy, dynamically accumulates processing experience by establishing an abnormal feature library, uses a decision tree algorithm to classify abnormal types and select the optimal processing scheme, records the processing effect to optimize the strategy library, and finally generates a targeted correction instruction. It can be understood that other abnormal processing methods can also be used to detect and correct execution abnormalities, which are not limited here.

[0098] In some embodiments, the communication system generates a task waiting request containing a task suspension identifier and an estimated waiting time, and returns the task waiting request through the first serial port or the second serial port receiving the serial data package.

[0099] The task suspension identifier refers to a specific flag bit used to notify that the task execution needs to be temporarily suspended, and the estimated waiting time refers to the predicted suspension duration calculated by the system. The task waiting request refers to a standard format request data package containing suspension information.

[0100] The step is triggered when the system needs to temporarily suspend task execution, and is used to realize the orderly interruption and resumption of tasks. Specifically, the system first evaluates the necessity of suspension according to the current resource status and task priority, calculates the expected waiting time, and then generates a request in a standard format containing the suspension identifier and the waiting time. Finally, the request is sent to the relevant device through the original data receiving channel to ensure that the task can be suspended in an orderly manner.

[0101] In some embodiments, the task suspension processing can be realized in the following ways: optionally, the device implements a dynamic task management mechanism, first evaluates the current load status and resource occupation of the system, then calculates the priority of each task using a queue priority algorithm, estimates the waiting time in combination with the historical execution time, and finally generates accurate suspension control information; optionally, the device establishes an intelligent task scheduling system, establishes a load prediction model by monitoring the system resource usage rate in real time, dynamically adjusts the suspension strategy according to the task type and system state, and maintains the task dependency relationship to ensure the synchronous suspension of related tasks, thereby realizing the optimal utilization of system resources. It can be understood that other task management methods can also be used to realize the suspension control of the execution task, which is not limited here.

[0102] S209、In the case where the destination address is equal to the local address, the corresponding task is executed according to the request data, and response data is generated.

[0103] Referring to step S104, the communication system generates response data when the destination address is equal to the local address.

[0104] In some embodiments, the communication system extracts the task type identifier in the request data when the destination address is equal to the local address; after determining that the local authority meets the task execution authority corresponding to the task type identifier, the local resource occupation is checked; when the local resource occupation meets the task execution condition corresponding to the task type identifier, the corresponding target execution task is added to the task queue, and the execution order of the target execution task is determined; after the task execution is completed, the task execution result and related log information are recorded, and the response data is generated.

[0105] The task type identifier is a unique identifier used to distinguish different task categories; the task execution authority represents the system authorization level required to execute a specific type of task; the resource occupation refers to the current system resource usage status such as calculation and storage; the task execution condition represents the minimum requirement of a specific task type on system resources; the task queue is an ordered sequence that stores tasks to be executed; the execution order represents the priority ranking of the task in the queue.

[0106] The step is executed when it is confirmed that the target task is a local processing, and is used for implementing permission check and resource scheduling of the task. Specifically, the system first extracts task type information from the request data, verifies whether the local device has corresponding execution permission; then checks whether the current system resource state meets the task execution condition; when the condition is met, the task is added to the execution queue and the priority is determined; finally, after the task is executed, the relevant information is recorded, and the response data in the standard format is generated.

[0107] In some embodiments, the task processing flow can be implemented in the following ways: optionally, the device implements a multi-level permission management mechanism, first verifies the operation authorization through an access control list, then checks the resource quota limit to ensure system security, and finally makes a fine-grained permission judgment based on the task characteristics to realize strict task access control; optionally, the device establishes an adaptive resource scheduling system, constructs a system state model by monitoring the usage rate of various resources in real time, optimizes task scheduling and resource allocation using dynamic programming algorithm, and maintains detailed execution logs to support subsequent analysis and optimization, ensuring efficient use of system resources. It can be understood that other task management methods can also be used to realize safe and efficient task processing, which is not limited here.

[0108] S210, the local address is used as the response source address, the source address is used as the response destination address, the response data is packaged, and the response data packet is generated.

[0109] Referring to step S105, the communication system generates a response data packet.

[0110] S211, the response data packet is returned through the first serial port or the second serial port receiving the serial port data packet.

[0111] Referring to step S106, the communication system returns the response data packet.

[0112] In some embodiments, when the communication system determines that the target device is a direct connection device of the first serial port or the second serial port of the local device, the historical communication quality of the serial port corresponding to the direct connection device is obtained; the historical communication quality includes the recent communication success rate and the average response time; when the historical communication quality is lower than the preset quality threshold, the response data packet is forwarded to another serial port connected adjacent device, and the adjacent device is used as a relay node to forward the response data packet.

[0113] Wherein, the direct connection device refers to the adjacent communication node directly connected through the serial port; the historical communication quality represents the recorded past data transmission condition; the communication success rate refers to the percentage of successful data packet transmission; the average response time refers to the average delay of data transmission; the preset quality threshold refers to the minimum communication quality standard set by the system; the relay node is used to represent the intermediate device forwarding data in the communication path.

[0114] The step is performed when data needs to be sent to a direct connection device, for optimizing data transmission path. Specifically, the system first confirms whether the target device is a direct connection device, and then queries historical communication data of the connection, including success rate and response time, etc. When it is found that the communication quality is lower than the preset standard, the system selects another serially connected device as a relay node, and forwards data packets through an alternative path.

[0115] In some embodiments, the communication quality management can be achieved in the following ways: optionally, the device establishes a communication quality evaluation system, establishes a link state model by continuously collecting transmission delay, packet loss rate, etc., calculates the communication quality trend using a weighted moving average algorithm, dynamically updates the optimal transmission path combining network topology information, and ensures the reliability of data transmission; optionally, the device implements an adaptive routing mechanism, constructs a network traffic distribution map by real-time monitoring of the load status of each link, calculates alternative transmission paths using the shortest path algorithm, and maintains a link state database to support fast path switching, realizing efficient utilization of communication links. It can be understood that other link management methods can also be used to achieve reliable data transmission, which is not limited here.

[0116] In the embodiments of the present application, since the network topology structure of double serial port device cascade is adopted, and the intelligent forwarding mechanism based on address comparison is combined, direct point-to-point communication between devices is realized without the need for transfer through the central controller. At the same time, by introducing data packet integrity check, communication quality monitoring, multi-target parallel processing and other mechanisms, the problems of low data transmission efficiency and poor system reliability in traditional master-slave serial communication are effectively solved, and a more efficient and reliable communication network between industrial field devices is realized.

[0117] The communication system in the embodiments of the present application will be described from the perspective of hardware processing. Please refer to Figure 3 , which is a schematic diagram of an entity device structure of the communication system in the embodiments of the present application.

[0118] It should be noted that Figure 3 The structure of the communication system shown is only an example and should not bring any limitation to the function and use range of the embodiments of the present application.

[0119] As Figure 3As shown, the communication system includes a Central Processing Unit (CPU) 301 which can perform various appropriate actions and processes in accordance with a program stored in a Read-Only Memory (ROM) 302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303, for example, to execute the methods described in the above embodiments. In the RAM 303, various programs and data required for the operation of the system are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.

[0120] Connected to the I / O interface 305 are an input section 306 including an audio input device, a push button switch, and the like; an output section 307 including a Liquid Crystal Display (LCD) and an audio output device, an indicator, and the like; the storage section 308 including a hard disk and the like; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, and the like. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as necessary. A removable media 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is attached to the drive 310 as necessary, so that a computer program read therefrom is installed into the storage section 308 as necessary.

[0121] In particular, in accordance with embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing a computer program for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 309, and / or installed from the removable media 311. When the computer program is executed by the Central Processing Unit (CPU) 301, various functions defined in the present application are performed.

[0122] Note that specific examples of computer-readable storage media can include but are not limited to an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, computer-readable storage media can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.

[0123] The flow diagrams and the block diagrams in the drawings are illustrations of possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. It will be understood that each block of the flow diagrams and the block diagrams, and combinations of blocks in the flow diagrams and the block diagrams, can be implemented by computer program instructions. Such instructions can be implemented by one or more software programs or code segments. One or more of the blocks in the flow diagrams and the block diagrams can also be implemented using special-purpose logic, such as an FPGA or an ASIC. In some embodiments, one or more of the blocks in the flow diagrams and the block diagrams can be implemented using both program instructions and special-purpose logic.

[0124] In particular, the communication system of the embodiment includes a processor and a memory, and the memory stores a computer program. When the computer program is executed by the processor, the communication method of the serial port network provided by the above-mentioned embodiment is implemented.

[0125] As another aspect, the present disclosure also provides a computer-readable storage medium. The storage medium can be included in the communication system described in the above-mentioned embodiments, or can exist independently without being assembled into the communication system. The storage medium carries one or more computer programs. When the one or more computer programs are executed by a processor of the communication system, the communication system implements the communication method of the serial port network provided in the above-mentioned embodiments.

[0126] The above-mentioned embodiments are only used to illustrate the technical solutions of the present disclosure, rather than limit them. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still make modifications to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features. The modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present disclosure.

[0127] In the above embodiments, the term "when" can be interpreted to mean "if" or "after" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "on determining" or "if detecting (a stated condition or event)" can be interpreted to mean "if determining" or "in response to determining" or "on detecting (a stated condition or event)" or "in response to detecting (a stated condition or event)" depending on the context.

[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program instructing the relevant hardware to complete, and the program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments. The aforementioned storage medium includes ROM or random storage memory RAM, magnetic disk or optical disk and various storage program codes.

Claims

1. A communication method of a serial network, characterized by, The application relates to a method for applying multiple communication devices in a communication system, each of the communication devices being provided with a first serial port and a second serial port, the multiple communication devices being connected in series through the first serial port and the second serial port, and each of the communication devices being provided with a unique address number as a local address, the method comprising the following steps: receiving a serial port data packet through the first serial port or the second serial port, and analyzing the serial port data packet to obtain a source address, a destination address and request data; when the destination address is greater than the local address, forwarding the serial port data packet through the second serial port; when the destination address is smaller than the local address, forwarding the serial port data packet through the first serial port; when the destination address is equal to the local address, executing a corresponding task according to the request data to generate response data; packing the response data to generate a response data packet by taking the local address as a response source address and the source address as a response destination address; returning the response data packet through the first serial port or the second serial port receiving the serial port data packet.

2. The method of claim 1, wherein, The step of receiving a serial port data packet through the first serial port or the second serial port and analyzing the serial port data packet to obtain a source address, a destination address and request data specifically comprises the following steps: receiving a serial port data packet through the first serial port or the second serial port, and executing integrity verification of the serial port data packet; the integrity verification comprises checking a data packet header identifier, verifying a data packet length and calculating a cyclic redundancy check value; when the integrity verification is passed, analyzing the serial port data packet to obtain a source address, a destination address and request data; when the integrity verification is not passed, returning data error information through the first serial port or the second serial port receiving the serial port data packet.

3. The method of claim 1, wherein, The step of executing a corresponding task according to the request data to generate response data when the destination address is equal to the local address specifically comprises the following steps: when the destination address is equal to the local address, extracting a task type identifier in the request data; after determining that a local authority meets a task execution authority corresponding to the task type identifier, checking a local resource occupation; when the local resource occupation meets a task execution condition corresponding to the task type identifier, adding a corresponding target execution task to a task queue and determining an execution order of the target execution task; after task execution is completed, recording task execution results and related log information to generate response data.

4. The method of claim 1, wherein, The destination address is multiple, and after the step of receiving a serial port data packet through the first serial port or the second serial port and analyzing the serial port data packet to obtain a source address, a destination address and request data, the method further comprises the following steps: when the local address belongs to the destination address, executing a corresponding task according to the request data to generate a response data unit; after determining that there is an additional address different from the local address in the destination address, packing the response data unit and the request data to generate a serial port processing packet by taking the local address as a response source address unit and the additional address as a response destination address. forward the serial processing package through another serial port of the first serial port or the second serial port receiving the serial data package; the other serial port is another serial port opposite to the serial port receiving the data package, that is, when the first serial port receives the serial data package, the other serial port is the second serial port, and when the second serial port receives the serial data package, the other serial port is the first serial port.

5. The method of claim 4, wherein, After the step of forwarding the serial processing package through another serial port of the first serial port or the second serial port receiving the serial data package, the method further comprises: receiving an execution result package returned by the additional device corresponding to the additional address, and analyzing the execution result package to obtain task execution information; when it is determined according to the task execution information that there is an abnormal task execution, determining a corresponding abnormal processing scheme based on an abnormal processing strategy library, and generating a correction instruction; packaging the correction instruction into a correction data package and returning it to the additional device.

6. The method of claim 5, wherein, Before the step of packaging the correction instruction into a correction data package and returning it to the additional device, the method further comprises: generating a task waiting request containing a task suspension identifier and an estimated waiting time; returning the task waiting request through the first serial port or the second serial port receiving the serial data package.

7. A communication system, characterized by The communication system comprises one or more processors and a memory; the memory is coupled with the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to enable the communication system to perform the method according to any one of claims 1-6.

8. A computer-readable storage medium comprising instructions, characterized in that, When the instructions run on the communication system, the communication system performs the method according to any one of claims 1-6.

9. A computer program product, characterised in that, When the computer program product runs on the communication system, the communication system performs the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Unmanned helicopter relay data link system and control method thereof

    CN105007115A

  • Low-cost unidirectional network transmission device and method

    CN110445780A