Multipath serial communication system

By using a multi-channel serial communication system, data interaction between different types of devices is achieved through shared areas and shared mapping areas. This solves the problems of single mode and poor applicability in MODBUS communication, and realizes efficient data interaction and stable communication between multiple devices.

CN120602253BActive Publication Date: 2026-11-20CRRC QINGDAO SIFANG ROLLING STOCK RESEARCH INSTITUTE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510790357.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2026-11-20
Estimated Expiration
2045-06-13

AI Technical Summary

Technical Problem

In existing technologies, the master-slave communication mode is singular, the communication range is limited, and the applicability is poor. MODBUS communication equipment resources are scarce, data processing is complex, it cannot interact with multiple devices, has low adaptability, and non-standard programs lack abnormal data response and fault handling functions. The parameter configuration process is complex and cannot be used universally across different platforms.

Method used

It adopts a multi-channel serial communication system based on the Linux operating system, and performs MODBUS communication through serial port and Ethernet. It supports multiple communication modes, utilizes shared area and shared mapping area to realize data interaction between different types of devices, sets up a multi-threaded module for data transmission and fault detection, and switches device modes through configuration file to realize MODBUS communication between multiple devices.

Benefits of technology

It expands the communication range, improves communication compatibility and applicability, supports multiple communication protocols, simplifies equipment expansion and fault handling, optimizes data transmission stability and efficiency, and reduces cabling costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120602253B_ABST
    Figure CN120602253B_ABST
Patent Text Reader

Abstract

The application relates to a multi-path serial communication system, which comprises serial communication master stations of multiple types and serial communication slave stations of multiple types, any serial communication master station exchanges data with at least one serial communication master station of a type via a shared area and / or a common mapping area, sends data to serial communication slave stations of different types from the current serial communication master station type via another shared area, sends data to serial communication slave stations of the same type via Ethernet and / or a serial port, any serial communication slave station receives data sent by any serial communication master station, receives data transmitted by serial communication slave stations of the same type, obtains read data, increases the address of the read data by an offset, and transmits data to another serial communication slave station of the same type according to the offset address. The application solves the problems of single communication mode and small communication range in a serial communication protocol, one master station can be connected to multiple devices, multi-path communication has stronger applicability, and the communication range is wider.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and in particular to multi-channel serial communication systems. Background Technology

[0002] Serial communication protocols are a common standard for industrial fieldbuses, enabling data exchange and control between different devices, and have become one of the more popular communication protocols in the field of workstation automation.

[0003] Currently, industrial field devices communicate with embedded gateway middleware via a serial communication protocol. An industrial field device can act as a master or slave device and supports communication between the master and slave devices.

[0004] This master-slave communication model is simplistic, has a limited communication range, and poor applicability. Summary of the Invention

[0005] This application provides a multi-channel serial communication system to at least solve the problems of a single master-slave corresponding communication mode, small communication range, and poor applicability.

[0006] In a first aspect, embodiments of this application provide a multi-channel serial communication system, including: a serial communication master station and a serial communication slave station, wherein the master station and slave station are configured with various types, wherein... The current serial communication master station interacts with at least one type of serial communication master station via a shared area and / or a shared mapping area; sends data to a serial communication slave station of a different type than the current serial communication master station via another shared area; and sends data to a serial communication slave station of the same type via Ethernet and / or serial port. The current serial communication slave station receives data sent by at least one type of serial communication master station; receives data transmitted by a serial communication slave station of the same type; obtains the read data, increases the address of the read data by an offset, and transmits the data to another serial communication slave station of the same type according to the increased offset address.

[0007] In some embodiments, the multi-channel serial communication system further includes: a first transmission module and a second transmission module, with a shared area between the first transmission module and the second transmission module; the first transmission module has a first thread, which communicates with the current serial communication master station to obtain data from the current serial communication master station and save the data to the shared area; the second transmission module has a second thread, which communicates with a serial communication master station of a different type from the current serial communication master station or a serial communication slave station of a different type from the current serial communication master station, which obtains data from the shared area, updates internal data, and sends it to the serial communication master station of a different type from the current serial communication master station or a serial communication slave station of a different type from the current serial communication master station.

[0008] In some embodiments, the multi-channel serial communication system further includes: a third transmission module and a fourth transmission module, both of which are connected to a first shared mapping area; the third transmission module is configured with a third thread, which communicates with the current serial communication master station, enabling the current serial communication master station to upload or receive data in the first shared mapping area; the fourth transmission module is configured with a fourth thread, which communicates with another serial communication master station of the same type, enabling the other serial communication master station of the same type to upload or receive data in the first shared mapping area.

[0009] In some embodiments, the multi-channel serial communication system further includes: a fifth transmission module and a sixth transmission module, both of which are connected to a second shared mapping area; the fifth transmission module is configured with a fifth thread, which communicates with the current serial communication slave station to read data from the current serial communication slave station and upload it to the second shared mapping area; the sixth transmission module is configured with a sixth thread, which communicates with another serial communication slave station of the same type to receive data from the second shared mapping area, adds the offset address of the data, and sends it to another serial communication slave station of the same type.

[0010] In some embodiments, the multiplexed serial communication system further includes: The detection module detects all threads and determines whether any thread is in a dead state. If so, it controls the dead threads to restart automatically.

[0011] In some embodiments, the serial communication master station includes a transmission control master station, which is further configured to establish a communication channel with a serial communication slave station of the same type via Ethernet according to the IP information, port number and serial communication slave station ID in the configuration file, and periodically call the send function after connection to send data to the serial communication slave station of the same type.

[0012] In some embodiments, the serial communication slave station includes a transmission control slave station, which is further configured to establish a connection with the control transmission master station, receive data sent by the transmission control master station, and provide feedback based on the received data; determine whether the current connection is the first connection, and if so, start communication; if not, disconnect the previous connection and then reconnect the current connection.

[0013] In some embodiments, the serial communication master station includes a remote terminal master station, which is further configured to communicate via a serial port, send instruction data, receive corresponding feedback data, determine whether the feedback data is qualified, and if so, send another instruction data; if not, record the abnormal state and send another instruction data.

[0014] In some embodiments, the serial communication slave station includes a remote terminal slave station, which is further configured to communicate with the remote terminal master station via a serial port according to the port, baud rate and remote terminal slave station ID in the configuration file, receive and determine whether the instruction data sent by the remote terminal master station is qualified. If it is qualified, it replies with feedback data; if not, it waits for another instruction data.

[0015] In some embodiments, the multiplexed serial communication system further includes: The switching module is configured to switch between multiple serial communication master stations when the data sent by multiple serial communication master stations are from the same source, based on the life signal in the data sent by each serial communication master station. The life signal is used for data continuity detection. If the life signal is normal, the serial communication master station that sent the normal life signal is saved. If the life signal is abnormal, the serial communication master station that sent the abnormal life signal is disconnected.

[0016] Compared with related technologies, the multi-channel serial communication system provided in this application embodiment can communicate with multiple devices through multi-channel communication. It supports multiple communication modes, solves the problems of single mode, limited communication range, and poor applicability of master-slave corresponding communication, and achieves the effect of expanding the communication range and improving communication compatibility and applicability.

[0017] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application; Figure 2 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application; Figure 6 This is a flowchart of the transmission control master station in a multi-channel serial communication system according to an embodiment of this application; Figure 7This is a flowchart illustrating the transmission control slave station in a multi-channel serial communication system according to an embodiment of this application. Figure 8 This is a flowchart of the remote terminal master station in a multi-channel serial communication system according to an embodiment of this application; Figure 9 This is a flowchart illustrating the workflow of a remote terminal slave station in a multi-channel serial communication system according to an embodiment of this application. Figure 10 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0020] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.

[0021] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0022] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.

[0023] Modicon Bus (MODBUS) is a serial communication protocol and a universal standard for industrial fieldbuses. It enables data exchange and control between different devices and has become one of the most popular communication protocols in industrial automation. MODBUS uses a master-slave mode for communication. The MODBUS master sends requests to the MODBUS slave, and the slave executes the operation and responds to the master. The MODBUS master is typically a programmable logic controller (PLC), and field devices act as MODBUS slaves.

[0024] Currently, there are many field devices that support MODBUS, and their application scenarios are wide-ranging. However, most field devices only support one mode and can only act as MODBUS master or MODBUS slave devices. They do not support switching between master and slave modes, or require modification of complex underlying logic to achieve mode change.

[0025] It only supports single MODBUS communication via Ethernet or serial port, has limited device resources, complex data processing, cannot interact with multiple devices, and has low adaptability.

[0026] However, programs written for specific scenarios are not standard MODBUS. Although they meet the requirements for simple data communication, they lack functions such as abnormal data response and fault handling. The parameter configuration process is complex, and they are not universal across different platforms, resulting in poor portability.

[0027] To address the aforementioned problems, this embodiment provides a multi-channel serial communication system. For example... Figure 1 As shown, the multi-channel serial communication system is based on the Linux operating system and uses the serial port and Ethernet, which are commonly available in Linux, to communicate with external devices via MODBUS. Communication is achieved using serial port and Ethernet, and the master and slave modes of the devices are switched through configuration files, with different communication parameters configured as well.

[0028] Figures 2-5 This is a schematic diagram of the structure of a multi-channel serial communication system according to an embodiment of this application, such as... Figures 2-5 As shown, the multi-channel serial communication system uses the Linux operating system to connect multiple devices as multiple stations, which are divided into serial communication master stations and serial communication slave stations.

[0029] The serial communication master station and serial communication slave station are configured with various types.

[0030] From the perspective of communication protocol layer, serial communication master stations can be categorized into MOTBUS TCP master stations and MODBUS RTU master stations. Serial communication slave stations can be categorized into MOTBUS TCP slave stations and MODBUS RTU slave stations.

[0031] like Figure 2 As shown, the current serial communication master station interacts with at least one type of serial communication master station via a shared area and / or a shared mapping area.

[0032] like Figure 3 As shown, the current serial communication master station sends data to a serial communication slave station of a different type via another shared area.

[0033] like Figure 4 As shown, the current serial communication master station sends data to the same type of serial communication slave station via Ethernet and / or serial port.

[0034] The shared area, located within a multi-channel serial communication system, allows data exchange between two different stations. For example, it can facilitate data exchange between one serial communication master station and another, or between one serial communication master station and one serial communication slave station. A shared area is established between any two interconnected stations; multiple shared areas can be independently configured and not interconnected. The two interconnected stations can be of the same type or different types.

[0035] A shared mapping area is located within a multi-channel serial communication system and can be used for data exchange between two identical serial communication master stations or two identical serial communication slave stations. One shared mapping area is set up between any two interconnected master stations or between any two interconnected slave stations. Multiple shared mapping areas are set up independently and do not communicate with each other.

[0036] The current serial communication slave station receives data sent by at least one type of serial communication master station, and also receives data transmitted by the same type of serial communication slave station.

[0037] like Figure 5 As shown, the current serial communication slave station obtains the read data, adds an offset to the address of the read data, and transmits the data to another serial communication slave station of the same type according to the added offset address.

[0038] Through shared areas or shared mapping areas, the current serial communication master station can interact with other types of serial communication master stations and other types of serial communication slave stations, enabling the multi-channel serial communication system to simultaneously support the coexistence of devices with multiple serial communication protocols, support multiple communication modes, expand the communication range, and improve communication compatibility and applicability.

[0039] Serial communication slave stations can use a shared mapping area for data interaction and transmit data through address offset, which can better adapt to long-distance, multi-node industrial scenarios and reduce cabling costs.

[0040] When two serial communication master stations or two serial communication slave stations communicate, setting up independent shared areas and shared mapping areas will only affect the directly connected serial communication master station or serial communication slave station if a fault occurs, effectively preventing the fault from spreading.

[0041] In some embodiments, the multi-channel serial communication system further includes: a first transmission module and a second transmission module, with a shared area established between the first and second transmission modules. The first transmission module has a first thread that communicates with the current serial communication master station, retrieves data from the current serial communication master station, and saves the data to the shared area. The second transmission module has a second thread that communicates with a serial communication master station or a serial communication slave station of a different type than the current serial communication master station. The second transmission module retrieves data from the shared area, updates internal data, and sends it to the serial communication master station or the serial communication slave station of a different type than the current serial communication master station.

[0042] The first and second threads run separately, decoupling data acquisition and distribution and preventing mutual blocking. When adding different types of serial communication master or slave stations, only the configuration of the second thread needs to be modified, without restarting the entire system. This facilitates dynamic expansion of industrial field equipment and simplifies operation.

[0043] The first transmission module connects to one device, which acts as the transmission control master station. The second transmission module connects to another device, which acts as the remote terminal master station. The shared area serves as a data conversion hub for protocol conversion. Through the first thread, the second thread, and the shared area, the two different types of master stations can communicate in real time, enabling cross-protocol or cross-type communication.

[0044] Furthermore, adjusting the thread's running priority and execution frequency can adapt to different types of device communication loads, resulting in a more balanced resource allocation.

[0045] In some embodiments, the multi-channel serial communication system further includes a third transmission module and a fourth transmission module, both connected to a first shared mapping area. The third transmission module has a third thread that communicates with the current serial communication master station, enabling the current master station to upload or receive data from the first shared mapping area. The fourth transmission module has a fourth thread that communicates with another serial communication master station of the same type, enabling the other master station to upload or receive data from the first shared mapping area.

[0046] The third transmission module connects to one device, which acts as the current transmission control master station. The fourth transmission module connects to another device, which acts as another transmission control master station. Through the third thread, the fourth thread, and the shared mapping area, data sharing between two master stations of the same type is achieved, ensuring consistency in reading and writing the same data by multiple master stations, reducing data conflicts, and thus supporting parallel control of their respective slave stations.

[0047] Furthermore, a redundant architecture can be constructed so that if the current serial communication master station fails, another serial communication master station of the same type via the fourth thread can obtain real-time data from the mapping area, maintaining data transmission and control.

[0048] Furthermore, a data persistence function can be configured in the shared mapping area to record key interaction data of the serial communication master station and form an operation log to meet the needs of industrial systems.

[0049] In some embodiments, the multi-channel serial communication system further includes a fifth transmission module and a sixth transmission module. Both the fifth and sixth transmission modules are connected to a second shared mapping area. The fifth transmission module has a fifth thread, which communicates with the current serial communication slave station to read data from the current serial communication slave station and upload it to the second shared mapping area. The sixth transmission module has a sixth thread, which communicates with another serial communication slave station of the same type to receive data from the second shared mapping area, increments the data's offset address, and sends it to the other serial communication slave station of the same type.

[0050] By using address offset, a data interaction path is established between serial communication slave stations, enabling the transmission of read-only data, expanding the system communication mode, constructing slave station cascade communication, and improving data transmission efficiency.

[0051] In some embodiments, the multiplex serial communication system further includes: The detection module detects all threads and determines whether any thread is in a dead state. If so, it controls the dead threads to restart automatically.

[0052] Furthermore, a structure array is used to uniformly manage thread information, centrally initialize all thread control blocks, and use pthread_kill to detect thread status, automatically restart dead threads, and ensure smooth data transmission.

[0053] Furthermore, the detection module can be configured with multi-level monitoring, including thread-level, communication-level, and application-level. Thread-level monitoring tracks thread utilization and memory leaks. Communication-level monitoring tracks serial port packet loss rate and network latency. Application-level monitoring ensures data continuity. For example, when the Modbus communication packet loss rate exceeds 5%, the thread is automatically restarted.

[0054] Furthermore, during the restart process, various restart strategies can be set to reduce the impact of restarting on data transmission.

[0055] Furthermore, when the detection module detects an abnormal thread state, it can adjust the thread monitoring frequency and send an early warning.

[0056] In this application, as Figure 10 As shown, the system communicates with multiple external devices via Ethernet or serial port using the MODBUS protocol based on the Linux system. Using the standard MODBUS protocol, multiple external devices can be configured as a transmission control (MOTBUSTCP) master, a transmission control slave, a remote terminal (MODBUS RTU) master, and a remote terminal slave.

[0057] In some embodiments, the serial communication master station includes a transmission control master station, which is further configured to establish a communication channel with a serial communication slave station of the same type via Ethernet according to the IP information, port number and serial communication slave station ID in the configuration file, and periodically call the send function after connection to send data to the serial communication slave station of the same type.

[0058] By matching the corresponding serial communication slave station through the configuration file, the master and slave stations of the same type can actively send commands as needed and wait for the transmission control slave station to reply, thereby realizing data interaction between serial communication master and slave stations of the same type and improving the stability and efficiency of data transmission.

[0059] During the periodic calls to the send function, the sending period can be dynamically adjusted to match network quality, ensure stable data transmission, and prioritize the transmission of critical data.

[0060] Furthermore, such as Figure 6 As shown, the workflow of the transmission control master station is as follows: First, it creates a MODBUS communication instance based on the IP address and port number in the configuration file. It then checks if the instance creation was successful; if not, the failure is logged. If successful, it sets the transmission control slave ID and starts a timer. It then waits for a connection from the transmission control slave via Ethernet. After connection, it periodically calls the send function according to the timer to send data and waits to receive data. The send function can be configured with any function code based on the actual application, defining the starting address for reading and writing, the amount of data, and monitoring the communication status. If the communication status is normal, the communication data is directly processed. If communication is disconnected or times out, the error information is recorded in the log file for timely identification of the cause after a communication failure.

[0061] Application-layer programming allows for the configuration of arbitrary function codes, and interactive data can be directly stored in arrays, making data processing more convenient. At the same time, important information during the process can be written to log files in real time.

[0062] In some embodiments, the serial communication slave station includes a transmission control slave station, further configured to establish a connection with the transmission control master station, receive data sent by the transmission control master station, and provide feedback based on the received data. It is determined whether this connection is the first connection; if so, communication begins; otherwise, the previous connection is disconnected, and the current connection is re-established.

[0063] The serial communication slave station receives data transmitted by the serial communication master station, realizes data synchronization, optimizes the disconnection and reconnection mechanism, disconnects to release resources before reconnecting, avoids the master station misjudging the slave station's fault, reduces resource consumption, and maintains communication continuity.

[0064] Furthermore, Figure 7 A flowchart of the transmission control slave station's workflow, such as... Figure 7As shown, the transmission control slave creates a MODBUS communication instance based on the IP address and port number in the configuration file. If creation fails, the situation is logged. The slave ID is set, and it connects to the transmission control master via Ethernet. After successful communication instance creation, listening begins. It then waits to receive commands from the transmission control master and responds accordingly. When a connection is established with the master, it checks if it's a new port connection. If not, it continues receiving data; if so, it checks if it's the first connection. If so, it establishes the connection and starts receiving data; otherwise, it closes the previously established port and re-establishes the connection to receive data. This prevents situations where sockets are not closed in time, leading to system resource exhaustion and communication failure. Once communication is successfully established, it waits for commands from the master. Based on the command content, it checks if the data is normal. If so, it responds accordingly; otherwise, it logs the abnormal transmission control master command information for troubleshooting.

[0065] In some embodiments, the serial communication master station includes a remote terminal master station, which is further configured to communicate via a serial port, send instruction data, receive corresponding feedback data, determine whether the feedback data is qualified, and if so, send another instruction data; if not, record the abnormal state and send another instruction data.

[0066] The remote terminal master station establishes a communication line with the remote terminal slave station to achieve master-slave communication and ensure the stability of data transmission. Simultaneously, by judging the quality of feedback data and monitoring the communication status in real time, the system's ability to respond to abnormal conditions is improved.

[0067] Furthermore, such as Figure 8 As shown, the workflow of the remote terminal master station is as follows: The master station reads the port, baud rate, and other parameters set in the configuration file to create and initialize an instance. It sets the remote terminal slave ID, starts a timer, and establishes a connection via the board's RS485 serial port. After establishing the connection, it actively sends commands according to application requirements and waits for a response from the remote terminal slave. When receiving data, it checks whether the data reception was successful. If so, it periodically sends the next cycle of data; otherwise, it logs the information and then periodically sends the next cycle of data. Logs are recorded for instance creation failures or abnormal data reception. The information recorded in the logs allows for analysis of abnormal situations during remote terminal communication, facilitating fault location.

[0068] In some embodiments, the serial communication slave station includes a remote terminal slave station, which is further configured to communicate with the remote terminal master station via a serial port according to the port, baud rate and remote terminal slave station ID in the configuration file, receive and determine whether the instruction data sent by the remote terminal master station is qualified. If it is qualified, it replies with feedback data; if not, it waits for another instruction data.

[0069] After receiving command data, the remote terminal slave can pre-determine the validity of the command, reducing invalid processing and optimizing resource allocation. Once the command is deemed valid, it provides feedback based on the command, optimizing response capabilities.

[0070] Furthermore, such as Figure 9 As shown, the workflow of the remote terminal slave is as follows: The remote terminal slave calls the board's RS485 serial port peripheral for communication. It creates a MODBUS communication instance based on parameters such as port, baud rate, and slave ID set in the configuration file. In the main loop, it receives MODBUS requests. If the received data is normal, it processes the request and sends a response. If the received request does not meet expectations, it logs the request and continues to wait for the next request. The information recorded in the logs can be used to analyze abnormal situations in the MODBUS RTU communication process, facilitating fault location.

[0071] In conjunction with the above embodiments, this application, based on a Linux system, uniformly manages Ethernet and serial communication channels. A new thread is created for each established MODBUS communication channel. Thread priorities are set according to the importance and size of the communication data, prioritizing important communications. During data interaction between different threads, a data forwarding mechanism is set up so that when one thread receives specific data, it can accurately forward the data to other threads according to preset rules.

[0072] For example, data received by the MODBUS TCP master station is forwarded to the corresponding MODBUS RTU slave station and converted into other data formats, and vice versa, thereby enabling collaborative work between different communication methods.

[0073] Specifically, in this application, when a thread receives specific data, it accurately forwards the data to other threads according to preset rules. An address mapping relationship is established between different threads. Through the first thread, the system connects to the first device, and the data received from the first device is saved to a fixed address in the shared area. Through the second thread, the system connects to the second device. The second thread retrieves the data from the shared area according to the address mapping relationship and updates its own mapped area data. The data is then transmitted to the second device, thus achieving data forwarding. The triggering conditions for data transmission include: periodic timed triggering or event triggering by recognizing the received function code and offset address.

[0074] If the original data requires processing, it should be forcibly converted to other data types for further processing before forwarding. Examples include integer to floating-point conversion, numerical scaling, endianness adjustment, and bitwise operations. Another example is the conversion between ASCII characters and raw binary data; specifically, splitting a byte into two 4-bit binary bits and correspondingly decoding and encoding them as ASCII characters.

[0075] Communication between masters and between slaves is achieved by sharing a mapping area. For example, in an industrial field, both the third and fourth devices act as master stations and connect to the multi-channel serial communication system of this application for communication. This application connects to the third device via a third thread and to the fourth device via a fourth thread. The third and fourth threads share the mapping areas for holding registers and coils, enabling the mutual transmission of the two types of data.

[0076] In the industrial field, both the fifth and sixth devices act as slaves in the multi-channel serial communication system of this application. The fifth device is activated via the fifth thread, and the sixth device is activated via the sixth thread. The fifth and sixth threads share the mapping areas for holding registers and coils. For the fifth and sixth devices as slaves, the input register and discrete input data also need to be transmitted, but can only be read. This application modifies the mapping method to achieve data transmission. Specifically, the fifth thread reads the input register and discrete input data from the fifth device, and the sixth thread adds an offset address to the read input register and discrete input data before sending them to the holding register and coil of the sixth device to achieve read-only data transmission. The two slave devices need to define the data address offset in advance.

[0077] Furthermore, this application employs thread locks to ensure data consistency, force threads to access shared resources serially, and resolve data races and logical errors in concurrent environments.

[0078] In some embodiments, the multiplex serial communication system further includes: The logging module is configured to record important information about the MODBUS communication process. This important information includes communication parameters set in the configuration file and any exceptions that occur during communication.

[0079] The logging module execution process includes: initializing the logging module, configuring the logging path, setting the log file size and number of log files, traversing the log files and writing them sequentially, and clearing the first file and re-circling to write after all files are full, ensuring that disk space is not exhausted.

[0080] Log types include: ACTION, WARNING, and ERROR. During operation, information is categorized and written to the logs according to its importance.

[0081] The device can be switched between master and slave modes via configuration files, configured to any MODBUS mode, and supports simultaneous MODBUS communication with multiple devices. The threads do not interfere with each other, and the communication process can be recorded in real time.

[0082] Setting parameters such as IP address, port number, slave ID for MOTBUS TCP communication, and serial port, baud rate, and slave ID for MOTBUS RTU communication via configuration files is more convenient and faster.

[0083] After constructing the corresponding communication instance, wait for the connection to be established, and monitor the communication status throughout the process, recording all error information in the log file to facilitate fault location.

[0084] In some embodiments, the multiplex serial communication system further includes: The switching module is configured to switch between multiple serial communication master stations when the data sent by multiple serial communication master stations are from the same source, based on the life signal in the data sent by each serial communication master station. The life signal is used for data continuity detection. If the life signal is normal, the serial communication master station that sent the normal life signal is saved. If the life signal is abnormal, the serial communication master station that sent the abnormal life signal is disconnected.

[0085] Specifically, redundant connections are achieved through multi-channel MODBUS communication, and data accuracy is ensured by comparing multiple data streams. When data from different channels are from the same source but inconsistent, the faulty device is identified based on the life signal corresponding to each data stream, and the system automatically switches to the data from the normal device, ensuring the continuity of communication and the accuracy of the data.

[0086] The life signal is a signal that is continuously transmitted in a loop along with the data to be transmitted during the data transmission process. It has temporal continuity. If the life signal is discontinuous during a transmission, it means that an error has occurred in this transmission.

[0087] The switching module monitors the data transmission status in real time to ensure the correctness of data transmission. At the same time, it enables redundant data transmission to ensure uninterrupted data transmission and improve data transmission stability.

[0088] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0089] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0090] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A multi-channel serial communication system, characterized in that, include: Serial communication master station and serial communication slave station, each with various configurations, including... The current serial communication master station interacts with at least one type of serial communication master station via a shared area and / or a shared mapping area; sends data to a serial communication slave station of a different type than the current serial communication master station via another shared area; and sends data to a serial communication slave station of the same type via Ethernet and / or serial port. The current serial communication slave station receives data sent by at least one type of serial communication master station; receives data transmitted by a serial communication slave station of the same type; obtains the read data, increments the address of the read data by an offset, and transmits the data to another serial communication slave station of the same type according to the incremented offset address; The system also includes: a first transmission module and a second transmission module, with a shared area between them; the first transmission module has a first thread that communicates with the current serial communication master station, retrieves data from the current serial communication master station, and saves the data to the shared area; the second transmission module has a second thread that communicates with a serial communication master station or a serial communication slave station of a different type than the current serial communication master station, retrieves data from the shared area, updates internal data, and sends it to the serial communication master station or the serial communication slave station of a different type than the current serial communication master station. It also includes: a third transmission module and a fourth transmission module, both of which are connected to the first shared mapping area; the third transmission module is configured with a third thread, which communicates with the current serial communication master station, and the current serial communication master station uploads or receives data in the first shared mapping area; the fourth transmission module is configured with a fourth thread, which communicates with another serial communication master station of the same type, and the other serial communication master station of the same type uploads or receives data in the first shared mapping area; It also includes: a fifth transmission module and a sixth transmission module, both of which are connected to the second shared mapping area; the fifth transmission module is equipped with a fifth thread, which communicates with the current serial communication slave station to read data from the current serial communication slave station and upload it to the second shared mapping area; the sixth transmission module is equipped with a sixth thread, which communicates with another serial communication slave station of the same type to receive data from the second shared mapping area, adds the offset address of the data, and sends it to another serial communication slave station of the same type.

2. The multi-channel serial communication system according to claim 1, characterized in that, Also includes: The detection module detects all threads and determines whether any thread is in a dead state. If so, it controls the dead threads to restart automatically.

3. The multi-channel serial communication system according to claim 1, characterized in that, The serial communication master station includes a transmission control master station, which is further configured to establish a communication channel with a serial communication slave station of the same type via Ethernet based on the IP information, port number and serial communication slave station ID in the configuration file. After the connection is established, the sending function is periodically called to send data to the serial communication slave station of the same type.

4. The multi-channel serial communication system according to claim 3, characterized in that, The serial communication slave station includes a transmission control slave station, which is further configured to establish a connection with the transmission control master station, receive data sent by the transmission control master station, and provide feedback based on the received data; determine whether the current connection is the first connection, and if so, start communication; otherwise, disconnect the previous connection and reconnect the current connection.

5. The multi-channel serial communication system according to claim 1, characterized in that, The serial communication master station includes a remote terminal master station, which is further configured to communicate via a serial port, send instruction data, receive corresponding feedback data, determine whether the feedback data is qualified, and if so, send another instruction data; if not, record the abnormal status and send another instruction data.

6. The multi-channel serial communication system according to claim 5, characterized in that, The serial communication slave station includes a remote terminal slave station, which is further configured to communicate with the remote terminal master station via a serial port according to the port, baud rate and remote terminal slave station ID in the configuration file. It receives and judges whether the instruction data sent by the remote terminal master station is qualified. If it is, it replies with feedback data; if not, it waits for another instruction data.

7. The multi-channel serial communication system according to claim 1, characterized in that, Also includes: The switching module is configured to switch between multiple serial communication master stations when the data sent by multiple serial communication master stations are from the same source, based on the life signal in the data sent by each serial communication master station. The life signal is used for data continuity detection. If the life signal is normal, the serial communication master station that sent the normal life signal is saved. If the life signal is abnormal, the serial communication master station that sent the abnormal life signal is disconnected.

Citation Information

Patent Citations

  • Communication system compatible with multiple protocols, control method thereof and electronic equipment

    CN116055583A

  • Data transmission method and device, controller and data transmission system

    CN119402310A