Communication adaptive methods, devices, equipment, media, and software products supporting multiple protocols on RS485 bus

By implementing automatic adaptation of physical layer baud rate and link layer data format in RS485 bus devices, the problems of protocol compatibility and system scalability are solved, achieving plug-and-play and multi-protocol compatibility, and reducing system deployment and maintenance costs.

CN122340197APending Publication Date: 2026-07-03SIEMENS (CHINA) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SIEMENS (CHINA) CO LTD
Filing Date
2026-03-20
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing RS485 bus devices suffer from poor protocol compatibility, cumbersome communication parameter configuration, high system maintenance costs, and insufficient system scalability, making it impossible to achieve automatic adaptation of communication parameters and dynamic protocol compatibility.

Method used

By acquiring the physical layer electrical signals of the RS485 bus, the target baud rate is determined, the target data format parameters are determined based on the original frame data of the link layer, and data protocol detection and verification are performed to achieve full-dimensional automatic adaptation of communication parameters and dynamic compatibility with multiple protocols.

Benefits of technology

It enables plug-and-play functionality for RS485 bus devices, shortens system deployment time, improves deployment accuracy, reduces hardware and labor costs, and enhances system scalability and device compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122340197A_ABST
    Figure CN122340197A_ABST
Patent Text Reader

Abstract

This application discloses a communication adaptive method, apparatus, device, medium, and program product supporting multiple protocols on an RS485 bus. The method includes: acquiring physical layer electrical signals of the RS485 bus; determining a target baud rate compatible with the RS485 bus based on the characteristics of the physical layer electrical signals; acquiring raw link layer frame data on the RS485 bus based on the target baud rate; determining target data format parameters compatible with the RS485 bus based on the characteristics of the raw frame data; configuring the RS485 bus data transmission channel based on the target baud rate and the target data format parameters; and performing data protocol detection and verification based on the data transmission channel to obtain a target transmission protocol; and performing normal data communication based on the target transmission protocol. The technical solution in this application enables plug-and-play functionality for RS485 devices, improving deployment efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial communication technology, and in particular to a communication adaptive method, apparatus, RS485 bus device, computer-readable storage medium, and program product that supports multiple protocols on the RS485 bus. Background Technology

[0002] RS485 bus is widely used in industrial fields and building automation due to its advantages such as long transmission distance, strong anti-interference capability, and support for multi-node communication, connecting various field devices such as remote instruments, PLCs, sensors, and actuators. However, existing RS485 bus devices have many technical problems in practical applications, which seriously limit their versatility and scalability, and increase system configuration and maintenance costs. Specific problems are as follows:

[0003] 1) Poor protocol compatibility: Existing RS485 devices can only support a single fixed protocol, such as Modbus RTU, BACnetMSTP, Profibus DP or various proprietary protocols. Devices with different protocols cannot communicate directly with each other, and a single device cannot achieve multi-protocol compatibility, which limits the market application scope of the device.

[0004] 2) Cumbersome communication parameter configuration: Traditional solutions require professional technicians to manually configure communication parameters such as baud rate, data bits, parity bits, and stop bits for each device in advance, lacking automatic recognition and adaptive mechanisms; the manual configuration process is time-consuming and prone to errors, and incorrect parameter configuration directly leads to communication failure between devices.

[0005] 3) High system maintenance costs: The parameter configuration and debugging of the equipment require professional technicians. When troubleshooting equipment faults, the parameter settings need to be checked one by one. After the equipment is replaced, the parameters need to be reconfigured. When the system is expanded, additional protocol conversion equipment or gateways need to be added, which further increases the maintenance cost and labor cost.

[0006] 4) Insufficient system scalability: When adding new devices to the bus, protocol compatibility issues must be strictly considered, the configuration work is cumbersome, and the efficiency of system expansion is affected; if the new device is incompatible with the original system protocol, the device needs to be replaced or a gateway needs to be added, which increases the difficulty and cost of system expansion.

[0007] To address the aforementioned issues, current solutions primarily include protocol conversion gateway solutions, unified protocol solutions, and manual configuration solutions. However, all have significant limitations: protocol conversion gateway solutions require configuring dedicated gateways for each protocol, increasing system cost and complexity; unified protocol solutions require replacing all devices with the same protocol, necessitating substantial equipment investment and limiting the flexibility of device selection; manual configuration solutions still fail to solve the problems of time-consuming, error-prone, and high maintenance costs. Existing technologies have not achieved automatic adaptation of communication parameters or dynamic protocol compatibility, thus failing to fundamentally solve the aforementioned technical problems of RS485 bus devices. Summary of the Invention

[0008] In view of this, the embodiments of this application propose, on the one hand, a communication adaptive method supporting multiple protocols of RS485 bus, and on the other hand, a communication adaptive device, RS485 bus device, computer-readable storage medium and program product supporting multiple protocols of RS485 bus, so as to realize plug-and-play of RS485 bus device and improve deployment efficiency.

[0009] This application proposes a communication adaptive method supporting multiple protocols on an RS485 bus, comprising: acquiring physical layer electrical signals of the RS485 bus; determining a target baud rate compatible with the RS485 bus based on the characteristics of the physical layer electrical signals; acquiring raw link layer frame data on the RS485 bus based on the target baud rate; determining target data format parameters compatible with the RS485 bus based on the characteristics of the raw frame data; configuring the RS485 bus data transmission channel based on the target baud rate and the target data format parameters; and performing data protocol detection and verification based on the data transmission channel to obtain a target transmission protocol; and performing normal data communication based on the target transmission protocol.

[0010] In some implementations, determining the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signal includes: capturing effective pulse signals in the physical layer electrical signal through a timer, calculating the actual baud rate of the RS485 bus based on the pulse interval of the effective pulse signals, and matching the actual baud rate with multiple candidate baud rates to obtain the adapted target baud rate.

[0011] In some implementations, determining the target data format parameters compatible with the RS485 bus based on the characteristics of the original frame data includes: acquiring the original link layer frame data on the RS485 bus based on the target baud rate, sequentially detecting and matching the data bits, parity bits, and stop bits of the original frame data by traversing candidate data format parameters, and filtering out the target data format parameters that match the RS485 bus; or it includes: capturing the falling edge of the start bit of the RS485 bus through hardware circuitry, using the falling edge of the start bit as the frame timing start point, statistically analyzing the level state bit by bit along the time axis based on the target baud rate, and determining the data bit parameters based on the number of bit cycles of the continuous valid data level segment; after the data bits end... The process involves: detecting the presence of a single-bit-cycle parity level segment; determining the parity bit parameter based on the presence and level of the parity bit segment; then detecting the number of consecutive bit cycles of a stop bit high-level segment; determining the stop bit parameter based on the detected number of consecutive bit cycles of a stop bit high-level segment; and finally obtaining the target data format parameters for data bits, parity bits, and stop bits adapted to the RS485 bus. Alternatively, the process may include: acquiring a set number of raw frame data; calculating the parsing validity score of the set number of raw frame data for each candidate data format parameter; the parsing validity score = percentage of valid bytes without garbled characters + frame structure integrity - garbled character rate; and selecting the data format parameter with the highest score as the target data format parameter.

[0012] In some implementations, the step of detecting and verifying the data protocol based on the data transmission channel to obtain the target transmission protocol includes: collecting raw link layer frame data on the RS485 bus based on the data transmission channel; performing frame feature analysis and / or timing feature analysis on the raw link layer frame data; determining the target protocol from candidate protocols based on the analysis results; collecting raw link layer frame data according to the time slot of the target protocol; parsing the collected raw link layer frame data based on the target protocol; verifying the protocol validity of the parsed data; if the verification passes, determining the target protocol as the target transmission protocol; or including: pre-generating a statistical feature template for each protocol in the candidate protocols; collecting a set number of raw link layer frame data on the RS485 bus based on the data transmission channel; calculating the current statistical features of the set number of raw link layer frame data; clustering the current statistical features with each statistical feature template using a clustering algorithm; and determining the target transmission protocol based on the clustering results; wherein the statistical features include at least one of byte entropy information, frame length distribution information, and high-frequency byte information.

[0013] In some implementations, the method further includes: when the target transmission protocol identification fails, repeatedly performing the operation of detecting and verifying the data protocol based on the data transmission channel until a verified target transmission protocol is found; if no verified target transmission protocol is found after the number of repetitions reaches a set threshold, an automatic device restart mechanism is triggered, and after restarting, the operation of collecting the physical layer electrical signals of the RS485 bus and determining the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signals is re-executed.

[0014] This application proposes a communication adaptive device supporting multiple protocols on an RS485 bus, comprising: a first adaptation module, configured to acquire physical layer electrical signals of the RS485 bus and determine a target baud rate compatible with the RS485 bus based on the characteristics of the physical layer electrical signals; a second adaptation module, configured to acquire raw link layer frame data on the RS485 bus based on the target baud rate and determine a target data format parameter compatible with the RS485 bus based on the characteristics of the raw frame data; a third adaptation module, configured to configure the RS485 bus data transmission channel based on the target baud rate and the target data format parameter, and perform data protocol detection and verification based on the data transmission channel to obtain a target transmission protocol; and a communication control module, configured to control the device to perform normal data communication based on the target transmission protocol.

[0015] In some implementations, the first adaptation module captures valid pulse signals in the physical layer electrical signals using a timer, calculates the actual baud rate of the RS485 bus based on the pulse interval of the valid pulse signals, and matches the actual baud rate with multiple candidate baud rates to obtain the target baud rate for adaptation.

[0016] In some implementations, the second adaptation module acquires raw link layer frame data on the RS485 bus based on the target baud rate, and sequentially detects and matches the data bits, parity bits, and stop bits of the raw frame data by traversing candidate data format parameters, and filters out the target data format parameters that match the RS485 bus; alternatively, the second adaptation module captures the falling edge of the start bit of the RS485 bus through hardware circuitry, uses the falling edge of the start bit as the frame timing start point, and statistically analyzes the level state bit by bit along the time axis based on the target baud rate, determining the data bit parameters according to the number of bit cycles of continuous valid data level segments; after the data bits end, it checks whether there is a single bit cycle of parity. The parity bit parameter is determined based on the presence and level of the parity bit segment. Then, the number of consecutive bit cycles of the stop bit high-level segment is detected, and the stop bit parameter is determined based on this number. This yields the target data format parameters for the data bits, parity bits, and stop bits adapted to the RS485 bus. Alternatively, the second adaptation module collects a set number of raw frame data. For each candidate data format parameter, a parsing validity score is calculated for the set number of raw frame data. The parsing validity score = percentage of valid bytes without garbled characters + frame structure integrity - garbled character rate. The data format parameter with the highest score is selected as the target data format parameter.

[0017] In some implementations, the third adaptation module collects raw link layer frame data on the RS485 bus based on the data transmission channel, performs frame feature analysis and / or timing feature analysis on the raw link layer frame data, and determines the target protocol from candidate protocols based on the analysis results; it collects raw link layer frame data according to the time slots of the target protocol, parses the collected raw link layer frame data based on the target protocol, verifies the protocol validity of the parsed data, and if the verification passes, determines the target protocol as the target transmission protocol; or,

[0018] The third adaptation module pre-generates a statistical feature template for each candidate protocol; collects a set number of raw link layer frames on the RS485 bus based on the data transmission channel, and calculates the current statistical features of the set number of raw link layer frames; uses a clustering algorithm to cluster the current statistical features with each statistical feature template, and determines the target transmission protocol based on the clustering results; wherein, the statistical features include at least one of: byte entropy information, frame length distribution information, and high-frequency byte information.

[0019] Another communication adaptive device supporting multiple protocols on RS485 bus proposed in this application embodiment includes: at least one memory storing a computer program; and at least one processor for reading and executing the computer program to implement the communication adaptive method supporting multiple protocols on RS485 bus as described in any of the above embodiments.

[0020] This application proposes a computer-readable storage medium storing computer instructions; the computer instructions can be executed by at least one processor to implement the communication adaptive method supporting multiple protocols of RS485 bus as described in any of the above embodiments.

[0021] The program product proposed in this application includes: a computer program; the computer program can be executed by at least one processor and implement the communication adaptive method supporting multiple protocols of RS485 bus as described in any of the above embodiments.

[0022] In this embodiment, baud rate adaptation is performed at the physical layer, data format parameter adaptation at the link layer, and then multi-dimensional feature extraction and protocol adaptation are performed on the link layer data. This achieves full-dimensional automatic adaptation of communication parameters and dynamic compatibility with multiple protocols, enabling plug-and-play functionality for the device. Furthermore, since no hardware DIP switches, manual configuration of communication parameters, or additional protocol conversion gateways or hardware are required, system deployment time is shortened, errors caused by manual configuration are avoided, and the accuracy of system deployment is improved. Attached Figure Description

[0023] The preferred embodiments of this application will now be described in detail with reference to the accompanying drawings, so that those skilled in the art can more clearly understand the above and other features and advantages of this application, in which:

[0024] Figure 1 An exemplary flowchart of a communication adaptive method supporting multiple protocols on an RS485 bus provided in an embodiment of this application;

[0025] Figure 2 An exemplary structural diagram of a communication adaptive device supporting multiple protocols on an RS485 bus provided in this application embodiment;

[0026] Figure 3 This is an exemplary structural diagram of another communication adaptive device supporting multiple protocols on the RS485 bus, provided in an embodiment of this application.

[0027] The reference numerals and their meanings in the attached figures are as follows:

[0028] S11~S14: Steps

[0029] 201: First Adaptor Module

[0030] 202: Second Adaptor Module

[0031] 203: Third Adaptor Module

[0032] 204: Communication Control Module

[0033] 31: Memory

[0034] 32: Processor

[0035] 33: Bus Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this application clearer, the following examples are provided to further illustrate this application in detail.

[0037] Figure 1 This is an exemplary flowchart of a communication adaptive method supporting multiple protocols on the RS485 bus, as described in an embodiment of this application. Figure 1 As shown, the method may include the following processing:

[0038] Step S11: Acquire the physical layer electrical signal of the RS485 bus, and determine the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signal.

[0039] In this embodiment, after the device is powered on, serial port initialization and variable initialization are completed first. Simultaneously, hardware and software modules such as the baud rate detection timer, interrupt service routine (ISR), data acquisition counter, and comparator are initialized to prepare for subsequent parameter detection. Then, the bus data acquisition function is started to detect the physical layer electrical signals on the RS485 bus in real time, obtaining the raw signal source for subsequent processing.

[0040] In this step, determining the target baud rate compatible with the RS485 bus based on the characteristics of the physical layer electrical signal can be achieved in several ways. For example, a timer can be used to capture valid pulse signals in the physical layer electrical signal, and the actual baud rate of the RS485 bus can be calculated based on the pulse interval of the valid pulse signals. The actual baud rate can then be matched with multiple candidate baud rates to obtain the compatible target baud rate.

[0041] To reduce interference, noise filtering can be performed on the physical layer electrical signals first. For example, power-on interference filtering and bus signal filtering can be applied to the acquired raw RS485 bus electrical signals to remove transient interference when the device powers on, environmental noise during bus transmission, and other invalid signals, retaining only valid pulse signals to improve the accuracy of subsequent parameter detection. Then, the filtered valid pulse signals are captured by a timer after initialization, and pulse waveform data is acquired synchronously. Simultaneously, a counter and storage unit record key information such as pulse intervals and timing in real time, completing the quantization acquisition of physical layer pulse data.

[0042] Furthermore, before calculating the actual baud rate of the RS485 bus based on the pulse interval of the effective pulse signal, the validity of the pulse measurement results can be determined first to check whether analyzable raw bus pulse signals or waveform data have been captured. If not captured, it indicates that there is no effective signal on the RS485 bus or that the acquisition process is abnormal. The process can then return to the previous step of capturing the filtered effective pulse signal via a timer, continuously triggering signal acquisition. If captured, the actual baud rate of the RS485 bus is calculated using an algorithm based on the pulse interval data recorded in the storage unit. This actual baud rate is then matched with multiple candidate baud rates to obtain a suitable target baud rate, thus completing the initial coarse matching of the baud rate. This step supports a baud rate range of 9.6kbps to 115.2kbps and requires no manual configuration.

[0043] Step S12: Collect raw link layer frame data on the RS485 bus based on the target baud rate, and determine the target data format parameters that are compatible with the RS485 bus based on the characteristics of the raw frame data.

[0044] In this embodiment, after obtaining the target baud rate, the serial port (UART) can be reconfigured and initialized according to the target baud rate, so that the serial port hardware can adapt to the bus baud rate, laying the foundation for subsequent data format recognition.

[0045] In this step, there are several ways to determine the target data format parameters compatible with the RS485 bus based on the characteristics of the original frame data. Three of these methods are described below:

[0046] The first method involves acquiring raw frame data from the link layer on the RS485 bus based on the target baud rate, and sequentially detecting and matching the data bits, parity bits, and stop bits of the raw frame data by traversing candidate data format parameters, and then selecting the target data format parameters that match the RS485 bus.

[0047] For example, considering data format parameters including data bits (7 / 8 bits), parity bits (none / odd / even), and stop bits (1 / 2 bits), 12 candidate data format parameters can be obtained. Then, based on the re-initialized serial port, by traversing each data format parameter, the data bits (7 / 8 bits), parity bits (none / odd / even), and stop bits (1 / 2 bits) are automatically detected and matched sequentially to select the optimal data format parameter that matches the RS485 bus, achieving precise data format matching.

[0048] The second method involves capturing the falling edge of the start bit of the RS485 bus using hardware circuitry. This falling edge serves as the frame timing start point. Based on the target baud rate, the level states are statistically analyzed bit-by-bit along the time axis. The data bit parameters are determined based on the number of bit cycles for a continuous valid data level segment. After the data bits end, the presence of a single bit cycle of a parity bit level segment is detected. The parity bit parameters are determined based on the presence and level of this parity bit segment. Then, the number of bit cycles for a continuous stop bit high level segment is detected, and the stop bit parameters are determined based on this number. This process yields the target data format parameters (data bits, parity bits, and stop bits) compatible with the RS485 bus. An example is provided below.

[0049] First, the falling edge of the start bit of the bus signal (the UART start bit is low, transitioning from an idle high level) can be captured by hardware as the start of frame timing;

[0050] Then, based on the matched baud rate (with a known single bit period T), the level status is statistically analyzed bit by bit along the time axis:

[0051] 1) Starting from the end of the start bit (1×T), count the duration of the "continuous valid data level segment": if the duration is 7×T, then the data bits are determined to be 7 bits; if the duration is 8×T, then the data bits are determined to be 8 bits.

[0052] 2) After the data bits are finished, check if there is a "1×T parity bit level segment": if it exists, then further check the level polarity, and determine whether it is odd parity or even parity based on whether the level polarity is high or low; if it does not exist, then it is determined that there is no parity.

[0053] 3) After the check bit (or data bit) ends, check the duration of the "stop bit high level segment": if the duration is 1×T, then the stop bit is determined to be 1 bit; if the duration is 2×T, then the stop bit is determined to be 2 bits.

[0054] It can continuously detect a set number of frames of data, and lock the data format parameters after confirming that the parameters are consistent.

[0055] The third method involves collecting a set number of raw frame data; calculating the parsing validity score of the set number of raw frame data for each of the candidate data format parameters; the parsing validity score = percentage of valid bytes without garbled text + frame structure integrity (start bit + stop bit matching) - garbled text rate; and selecting the data format parameter with the highest score as the target data format parameter.

[0056] Furthermore, in this embodiment, the data format matching result can be further validated to check whether frame data conforming to the serial port formatting requirements can be received (i.e., whether the full parameter combination of baud rate + data bits + parity bits + stop bits is fully compatible with the bus). If it is not received correctly, it indicates that the data format parameters are mismatched, and the process returns to the operation of automatically identifying the data format by traversing candidate data format parameters based on the re-initialized serial port; if it is received correctly, it indicates that the full communication parameters are accurately compatible with the bus.

[0057] The above two steps start with the raw physical layer signal, filter, acquire, and calculate to complete baud rate matching, and then complete data format matching through serial port re-initialization and parameter traversal. Through two progressive data detections (raw pulse data → formatted serial port data), a closed loop from physical layer signal adaptation to link layer parameter matching is achieved, ensuring the accuracy and reliability of communication parameter adaptation.

[0058] Step S13: Based on the target baud rate and the target data format parameters, configure the RS485 bus data transmission channel, and perform data protocol detection and verification based on the data transmission channel to obtain the target transmission protocol.

[0059] In this embodiment, before initiating the multi-protocol identification process, serial port initialization and call variable initialization are first completed based on the target baud rate and target data format parameters, and the RS485 bus data transmission channel is configured. Simultaneously, preset multi-protocol standard rules (such as frame headers, timing sequences, function codes, and other characteristic rules for each protocol) are loaded. The multi-protocol may include BACnet MSTP, Modbus RTU, Profibus DP, and proprietary protocols.

[0060] The system collects link layer data on the RS485 bus in real time and checks whether it can acquire the original link layer frame byte stream data after communication parameter adaptation (baud rate and data format adaptation have been completed, but protocol-level parsing is not required). If no data is acquired, it indicates that there is no valid data transmission on the bus, and the system continues to wait and trigger data acquisition. If data is acquired, multi-dimensional detection can be initiated based on the acquired original link layer frame data, and feature matching can be performed according to preset protocol standard rules.

[0061] In this step, data protocol detection and verification are performed based on the data transmission channel. There are several ways to obtain the target transmission protocol. Two of them are described below:

[0062] The first method involves collecting raw link layer frame data from the RS485 bus via the data transmission channel, performing frame feature analysis and / or timing feature analysis on the raw link layer frame data, and determining the target protocol from the candidate protocols based on the analysis results.

[0063] The candidate protocol and its frame features and / or timing features may include:

[0064] BACnet MSTP

[0065] - Frame header characteristics: 0x55 0xFF

[0066] - Frame type characteristics: third byte 0x00~0x07

[0067] Modbus RTU

[0068] - Frame header characteristics: 0x01-0x06, 0x0F, 0x10

[0069] - Timing characteristics: Frame interval > 3.5 bytes

[0070] Profibus DP

[0071] - Fixed frame header: 0x10 / 0x68 / 0xA2 / 0xDC / 0xE5

[0072] - Timing characteristics: 100ms-500ms frame interval

[0073] Private Protocol

[0074] - Fixed frame header: 0x55 0xAA

[0075] After the target protocol is determined, it can be further verified. The verification process may include: collecting raw link layer frame data according to the time slots of the target protocol, parsing the collected raw link layer frame data based on the target protocol, verifying the protocol validity of the parsed data, and if the verification passes, then the target protocol is determined to be the target transmission protocol.

[0076] During specific verification, it can be checked whether the parsed data fully conforms to the technical specifications of the target protocol (including frame structure, verification rules, timing requirements, function code definitions, etc., such as CRC verification for Modbus RTU and frame type field requirements for BACnet MSTP). If received correctly, it indicates that the protocol match is completely accurate. If not received correctly, it indicates that the initially matched protocol does not match the actual bus protocol, and a protocol re-identification process can be triggered. For example, the operation of detecting and verifying the data protocol based on the data transmission channel can be returned until a verified target transmission protocol is found; if a verified target transmission protocol is still not found after the number of repetitions reaches a set threshold, an automatic device restart mechanism can be triggered. After restarting, the operation of collecting the physical layer electrical signals of the RS485 bus and determining the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signals can be re-executed. If a verified target transmission protocol still cannot be found after restarting, a notification that the protocol cannot be identified can be sent.

[0077] In the above process, through multi-dimensional feature extraction, protocol feature matching, and protocol validity verification, BACnet MSTP, Modbus RTU, Profibus DP, and private protocols can be automatically identified and switched without manual intervention.

[0078] The second approach: Considering that frame data from different protocols possess different statistical characteristics (such as byte entropy, field value distribution, frame length distribution, and other multi-dimensional features), protocol identification is achieved by calculating the statistical characteristics of the bus data and comparing them with the statistical templates of candidate protocols through clustering. Specifically, this may include:

[0079] For each candidate protocol, a statistical feature template for that protocol is pre-generated; a set number of raw link layer frame data are collected on the RS485 bus based on the data transmission channel, and the current statistical features of the set number of raw link layer frame data are calculated; the current statistical features are clustered with each statistical feature template using a clustering algorithm, and the target transmission protocol is determined based on the clustering results; wherein, the statistical features include at least one of byte entropy information, frame length distribution information, and high-frequency byte information.

[0080] Furthermore, if no candidate protocol is clustered, the current protocol is identified as a "private protocol" and its statistical characteristics are recorded to achieve self-learning.

[0081] In addition, in the second approach, after the target protocol is determined, it can be further verified.

[0082] Step S14: The control device performs normal data communication based on the target transmission protocol.

[0083] In this step, initialization can be performed according to the determined target transmission protocol: based on the protocol type of the target transmission protocol, the device's communication module, data parsing module, protocol interaction module, etc., are specifically initialized and configured to ensure that the device hardware and software are fully adapted to the communication requirements of the protocol. The device then enters normal operating mode and achieves stable application layer communication with devices on the RS485 bus that use the same protocol. Subsequently, this process can be triggered again to complete protocol rematching based on changes in the bus protocol.

[0084] In this embodiment, a closed loop is achieved from physical layer communication to link layer data interaction and then to application layer protocol adaptation through a progressive step-by-step process: physical layer communication parameter adaptation → link layer communication parameter adaptation → basic data acquisition and verification → multi-dimensional feature extraction → preliminary protocol matching → protocol specification parsing → protocol validity verification. This automates the entire process of RS485 bus device from signal adaptation to protocol communication, ultimately achieving plug-and-play functionality. Retry and restart mechanisms are also included to ensure the success rate of protocol recognition.

[0085] The above describes in detail the communication adaptive method supporting multiple protocols on the RS485 bus in the embodiments of this application. The following describes in detail the communication adaptive device supporting multiple protocols on the RS485 bus in the embodiments of this application. The communication adaptive device supporting multiple protocols on the RS485 bus in the embodiments of this application can be used to implement the communication adaptive method supporting multiple protocols on the RS485 bus in the embodiments of this application. For details not disclosed in detail in the device embodiments of this application, please refer to the corresponding descriptions in the method embodiments of this application; they will not be repeated here.

[0086] Figure 2 This is an exemplary structural diagram of a communication adaptive device supporting multiple protocols on the RS485 bus, as described in an embodiment of this application. Figure 2 As shown, the device may include: a first adapter module 201, a second adapter module 202, a third adapter module 203 and a fourth adapter module 204.

[0087] The first adaptation module 201 is used to acquire the physical layer electrical signals of the RS485 bus and determine the target baud rate that is compatible with the RS485 bus based on the characteristics of the physical layer electrical signals.

[0088] The second adaptation module 202 is used to collect raw link layer frame data on the RS485 bus based on the target baud rate, and determine the target data format parameters that are compatible with the RS485 bus based on the characteristics of the raw frame data.

[0089] The third adaptation module 203 is used to configure the RS485 bus data transmission channel based on the target baud rate and the target data format parameters, and to detect and verify the data protocol based on the data transmission channel to obtain the target transmission protocol.

[0090] The communication control module 204 is used to control the device to perform normal data communication based on the target transmission protocol.

[0091] The first adaptation module 201 can capture the effective pulse signal in the physical layer electrical signal through a timer, calculate the actual baud rate of the RS485 bus based on the pulse interval of the effective pulse signal, and match the actual baud rate with multiple candidate baud rates to obtain the target baud rate for adaptation.

[0092] The second adaptation module 202 can acquire raw link layer frame data on the RS485 bus based on the target baud rate, and sequentially detect and match the data bits, parity bits, and stop bits of the raw frame data by traversing candidate data format parameters, and filter out the target data format parameters that match the RS485 bus; alternatively, the second adaptation module 202 can also capture the falling edge of the start bit of the RS485 bus through hardware circuitry, use the falling edge of the start bit as the frame timing start point, and statistically analyze the level status bit by bit along the time axis based on the target baud rate, and determine the data bit parameters according to the number of bit cycles of continuous valid data level segments; after the data bits end, it detects whether there is a single bit cycle of parity bit voltage. The parity bit parameter is determined based on the presence and level of the parity bit level segment. Then, the number of bit cycles for the high-level stop bit segment is detected, and the stop bit parameter is determined based on this number. This yields the target data format parameters for the data bits, parity bit, and stop bit that are compatible with the RS485 bus. Alternatively, the second adaptation module 202 can collect a set number of raw frame data. For each candidate data format parameter, a parsing validity score is calculated for the set number of raw frame data. The parsing validity score = percentage of valid bytes without garbled characters + frame structure integrity - garbled character rate. The data format parameter with the highest score is selected as the target data format parameter.

[0093] The third adaptation module 203 can collect raw link layer frame data on the RS485 bus based on the data transmission channel, perform frame feature analysis and / or timing feature analysis on the raw link layer frame data, and determine the target protocol from the candidate protocols based on the analysis results; collect raw link layer frame data according to the time slot of the target protocol, and parse the collected raw link layer frame data based on the target protocol, and verify the protocol validity of the parsed data. If the verification is successful, the target protocol is determined to be the target transmission protocol; or, the third adaptation module 203 can pre-generate a statistical feature template for each protocol in the candidate protocols; collect a set number of raw link layer frame data on the RS485 bus based on the data transmission channel, and calculate the current statistical features of the set number of raw link layer frame data; use a clustering algorithm to cluster the current statistical features with each statistical feature template, and determine the target transmission protocol based on the clustering results; wherein the statistical features include at least one of byte entropy information, frame length distribution information, and high-frequency byte information.

[0094] Furthermore, if the third adaptation module 203 cannot adapt to the verified target transmission protocol, a protocol re-identification process can be triggered. For example, the operation of detecting and verifying the data protocol based on the data transmission channel can be returned until a verified target transmission protocol is found. If no verified target transmission protocol is found after the number of repetitions reaches a set threshold, an automatic device restart mechanism can be triggered. After restarting, the operation of acquiring the physical layer electrical signals of the RS485 bus and determining the target baud rate compatible with the RS485 bus based on the characteristics of the physical layer electrical signals can be re-executed. If a verified target transmission protocol still cannot be found after restarting, a notification that the protocol cannot be identified can be sent.

[0095] Figure 3 This is a schematic diagram of another communication adaptive device supporting multiple protocols on the RS485 bus, as described in an embodiment of this application. Figure 3 As shown, the electronic device may include at least one memory 31 and at least one processor 32. It may also include other components, such as communication ports. These components communicate via a bus 33.

[0096] At least one memory 31 is used to store a computer program. In one embodiment, the computer program can be understood to include... Figure 2 The diagram shows the various modules of a communication adaptive device supporting multiple protocols on the RS485 bus. Furthermore, at least one memory 31 can store an operating system, etc. The operating system includes, but is not limited to: Android, Symbian, Windows, Linux, etc.

[0097] At least one processor 32 is used to read and execute the computer program to implement the RS485 bus multi-protocol adaptive communication method described in the embodiments of this application. The processor 32 can be a CPU, processing unit / module, ASIC, logic module, or programmable gate array, etc. It can receive and send data through the communication port.

[0098] Furthermore, this application embodiment also provides an RS485 device, which may include: the communication adaptive device supporting multiple RS485 bus protocols as described in any of the above embodiments. The RS485 device may include remote instruments / meters, slave controllers, sensors, actuators, programmable logic controllers (PLCs), expansion I / O modules, and other RS485-based field devices.

[0099] Those skilled in the art will recognize that the descriptions in the embodiments of this application are merely exemplary and are not intended to limit the scope of protection of the embodiments of this application.

[0100] It should be noted that not all steps and modules in the above processes and structural diagrams are mandatory; some steps or modules can be omitted as needed. The execution order of the steps is not fixed and can be adjusted as required. The division of modules is merely for the convenience of description and functional division. In actual implementation, a module can be implemented by multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or in different devices.

[0101] It is understood that the modules in the above embodiments can be purely software modules or hardware modules, and hardware modules can be implemented mechanically or electronically. For example, a hardware module may include specially designed permanent circuits or logic devices (such as dedicated processors, such as FPGAs or ASICs) to perform specific operations. A hardware module may also include programmable logic devices or circuits (such as general-purpose processors or other programmable processors) temporarily configured by software to perform specific operations. The specific method used to implement the hardware module—whether it is mechanical, a dedicated permanent circuit, or a temporarily configured circuit (such as one configured by software)—can be determined based on cost and time considerations.

[0102] Furthermore, this application embodiment also provides a computer program product, including a computer program that can be executed by a processor to implement the communication adaptive method supporting multiple protocols of RS485 bus as described in this application embodiment. This application embodiment also provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the communication adaptive method supporting multiple protocols of RS485 bus as described in this application embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which software program code implementing the functions of any of the above embodiments is stored, and the computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium. Furthermore, the operating system or other system operating on the computer can perform some or all of the actual operations through instructions based on the program code. The program code read from the storage medium can also be written to a memory located in an expansion board inserted into the computer or to a memory located in an expansion unit connected to the computer. Subsequently, the CPU or other system installed on the expansion board or expansion unit can execute some or all of the actual operations based on the instructions of the program code, thereby implementing the functions of any of the above embodiments. Storage media implementations for providing program code include USB, floppy disk, hard disk, magneto-optical disk, optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tape, non-volatile memory cards, and ROM, etc. Alternatively, program code can be downloaded from a server computer via a communication network.

[0103] In this embodiment, by adapting communication parameters at the physical layer and link layer, and then performing multi-dimensional feature extraction and protocol adaptation on the link layer data, the entire process of RS485 bus device from signal adaptation to protocol communication is automated. This breaks through the limitations of the current single protocol and manual configuration, and realizes full-dimensional automatic adaptation of communication parameters and dynamic compatibility of multiple protocols. A single device can support multiple protocols such as BACnet MSTP, Modbus RTU, Profibus DP and proprietary protocols, solving the long-standing problem of multi-protocol compatibility in the industry.

[0104] Furthermore, since no hardware DIP switches or manual configuration of communication parameters are required, and no additional protocol conversion gateways or hardware are needed, the device can automatically complete parameter matching and protocol identification and switching after being connected to the RS485 bus, achieving true plug-and-play functionality. System deployment time is reduced by more than 80%, while avoiding errors caused by manual configuration and improving the accuracy of system deployment.

[0105] In addition, hardware costs are reduced because there is no need to purchase additional protocol conversion gateways and dedicated equipment; the configuration, debugging and troubleshooting of the equipment do not require professional technicians to operate throughout the process, reducing labor configuration costs; and no parameters need to be reconfigured when the equipment is replaced and the system is expanded, reducing maintenance costs by 60% and reducing the storage costs of spare parts.

[0106] Furthermore, by incorporating anti-interference optimization design, bus noise is effectively filtered out, improving the anti-interference capability and stability of RS485 bus communication. In some implementations, a single bus can support up to 32 devices, with a maximum communication distance of 1200 meters and a matching success rate exceeding 99.9%, demonstrating excellent performance. Adding new devices eliminates the need to consider protocol matching and parameter configuration, making system expansion more convenient and significantly improving device compatibility and system scalability.

[0107] The technical solutions in this application embodiment can be widely applied to various RS485 bus devices in industrial fields and building automation, including remote instruments / meters, slave controllers, sensors, actuators, programmable logic controllers (PLCs), expansion I / O modules, and other RS485-based field devices. This significantly improves the market competitiveness of the products, expands the market application scope of the equipment, enhances user satisfaction, and creates more business opportunities for related products.

[0108] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, without departing from the spirit and teachings of this application, the features described in the various embodiments and / or claims of this application can be combined and / or combined in various ways, and all such combinations and / or combinations fall within the scope of this application. The nouns and pronouns referring to persons in this patent application are not limited to specific genders.

Claims

1. A communication adaptive method for supporting RS485 bus multi-protocol, characterized in that, include: Acquire the physical layer electrical signals of the RS485 bus, and determine the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signals; Based on the target baud rate, raw frame data of the link layer on the RS485 bus is acquired, and target data format parameters adapted to the RS485 bus are determined based on the characteristics of the raw frame data. Based on the target baud rate and the target data format parameters, the RS485 bus data transmission channel is configured, and the data protocol is detected and verified based on the data transmission channel to obtain the target transmission protocol; Normal data communication is performed based on the target transmission protocol.

2. The communication adaptive method for supporting RS485 bus multi-protocol according to claim 1, characterized in that, The determination of the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signal includes: The effective pulse signal in the physical layer electrical signal is captured by a timer, and the actual baud rate of the RS485 bus is calculated based on the pulse interval of the effective pulse signal. The actual baud rate is then matched with multiple candidate baud rates to obtain the appropriate target baud rate.

3. The communication adaptive method for supporting RS485 bus multi-protocol according to claim 1 or 2, characterized in that, The determination of target data format parameters compatible with the RS485 bus based on the features of the original frame data includes: Based on the target baud rate, raw frame data of the link layer on the RS485 bus is acquired. The data bits, parity bits, and stop bits of the raw frame data are sequentially detected and matched by traversing candidate data format parameters, and target data format parameters matching the RS485 bus are selected; or this may include: The falling edge of the start bit of the RS485 bus is captured by hardware circuitry, and used as the frame timing start point. Based on the target baud rate, the level state is statistically analyzed bit by bit along the time axis. The data bit parameters are determined based on the number of bit cycles for a continuous valid data level segment. After the data bits end, the presence of a single bit cycle of a parity bit level segment is detected, and the parity bit parameters are determined based on the presence and level of the parity bit segment. Then, the number of bit cycles for a stop bit high level segment is detected, and the stop bit parameters are determined based on the detected number of bit cycles for a stop bit high level segment. This yields the target data format parameters for data bits, parity bits, and stop bits adapted to the RS485 bus; or includes: Collect a set number of raw frame data; for each data format parameter in the candidate data format parameters, calculate the parsing effectiveness score of the set number of raw frame data; the parsing effectiveness score = percentage of valid bytes without garbled text + frame structure integrity - garbled text rate; select the data format parameter with the highest score as the target data format parameter.

4. The communication adaptive method for supporting RS485 bus multi-protocol according to any one of claims 1 to 3, characterized in that, The step of detecting and verifying the data protocol based on the data transmission channel to obtain the target transmission protocol includes: Based on the data transmission channel, raw link layer frame data on the RS485 bus is collected, and frame feature analysis and / or timing feature analysis are performed on the raw link layer frame data; based on the analysis results, the target protocol is determined from the candidate protocols; Collect raw link layer frame data according to the time slot of the target protocol, parse the collected raw link layer frame data based on the target protocol, verify the protocol validity of the parsed data, and if the verification is successful, determine the target protocol as the target transmission protocol. Or include: For each candidate protocol, a statistical feature template for that protocol is generated in advance; Based on the data transmission channel, a set number of raw link layer frame data are collected on the RS485 bus, and the current statistical characteristics of the set number of raw link layer frame data are calculated. The current statistical features are clustered with each statistical feature template using a clustering algorithm, and the target transmission protocol is determined based on the clustering results. The statistical features include at least one of byte entropy information, frame length distribution information, and high-frequency byte information.

5. The communication adaptive method of supporting RS485 bus multi-protocol according to any one of claims 1 to 4, characterized in that, Further includes: If the target transmission protocol identification fails, the operation of detecting and verifying the data protocol based on the data transmission channel is repeated until a verified target transmission protocol is found. If no verified target transmission protocol is found after the number of repetitions reaches a set threshold, the device is automatically restarted. After restarting, the operation of collecting the physical layer electrical signal of the RS485 bus and determining the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signal is re-executed.

6. A communication adaptive device supporting multiple protocols on RS485 bus, characterized in that, include: The first adaptation module (201) is used to acquire the physical layer electrical signals of the RS485 bus and determine the target baud rate adapted to the RS485 bus based on the characteristics of the physical layer electrical signals. The second adaptation module (202) is used to collect raw frame data of the link layer on the RS485 bus based on the target baud rate, and determine the target data format parameters that are compatible with the RS485 bus based on the characteristics of the raw frame data. The third adaptation module (203) is used to configure the RS485 bus data transmission channel based on the target baud rate and the target data format parameters, and to detect and verify the data protocol based on the data transmission channel to obtain the target transmission protocol; The communication control module (204) is used to control the device to perform normal data communication based on the target transmission protocol.

7. The adaptive communication device supporting multiple protocols on RS485 bus according to claim 6, characterized in that, The first adaptation module (201) captures the effective pulse signal in the physical layer electrical signal through a timer, calculates the actual baud rate of the RS485 bus based on the pulse interval of the effective pulse signal, and matches the actual baud rate with multiple candidate baud rates to obtain the target baud rate for adaptation.

8. The communication adaptive device supporting multiple protocols on RS485 bus according to claim 6 or 7, characterized in that, The second adaptation module (202) collects the raw frame data of the link layer on the RS485 bus based on the target baud rate, and sequentially detects and matches the data bits, parity bits, and stop bits of the raw frame data by traversing candidate data format parameters, and filters out the target data format parameters that match the RS485 bus; or, The second adaptation module (202) captures the falling edge of the start bit of the RS485 bus through hardware circuitry, uses the falling edge of the start bit as the frame timing start point, and statistically analyzes the level state bit by bit along the time axis based on the target baud rate. It determines the data bit parameters based on the number of bit cycles for a continuous valid data level segment. After the data bits end, it detects whether there is a single bit cycle of a parity bit level segment, and determines the parity bit parameters based on the presence and level of the parity bit level segment. Then, it detects the number of bit cycles for a continuous stop bit high level segment, and determines the stop bit parameters based on the detected number of bit cycles for a continuous stop bit high level segment, thereby obtaining the target data format parameters for the data bits, parity bits, and stop bits adapted to the RS485 bus; or... The second adaptation module (202) collects a set number of raw frame data; for each data format parameter in the candidate data format parameters, it calculates the parsing validity score of the set number of raw frame data; The parsing validity score = percentage of valid bytes without garbled text + frame structure integrity - garbled text rate; Select the data format parameter with the highest score as the target data format parameter.

9. The communication adaptive device supporting multiple protocols on RS485 bus according to any one of claims 6 to 8, characterized in that, The third adaptation module (203) collects raw link layer frame data on the RS485 bus based on the data transmission channel, performs frame feature analysis and / or timing feature analysis on the raw link layer frame data, and determines the target protocol from the candidate protocols based on the analysis results. Collect raw link layer frame data according to the time slot of the target protocol, parse the collected raw link layer frame data based on the target protocol, verify the protocol validity of the parsed data, and if the verification is successful, determine the target protocol as the target transmission protocol. or, The third adaptation module (203) pre-generates a statistical feature template for each protocol in the candidate protocols; collects a set number of link layer raw frame data on the RS485 bus based on the data transmission channel, and calculates the current statistical features of the set number of link layer raw frame data. The current statistical features are clustered with each statistical feature template using a clustering algorithm, and the target transmission protocol is determined based on the clustering results; wherein, the statistical features include at least one of byte entropy information, frame length distribution information, and high-frequency byte information.

10. A communication adaptive device supporting multiple protocols on an RS485 bus, characterized in that, include: At least one memory (31) stores a computer program; as well as At least one processor (32) is configured to read and execute the computer program to implement the communication adaptive method supporting RS485 bus multi-protocol as described in any one of claims 1 to 5.

11. An RS485 bus device, characterized in that, include: The communication adaptive device supporting multiple protocols on RS485 bus as described in any one of claims 6 to 10.

12. A computer-readable storage medium storing computer instructions; characterized in that, The computer instructions can be executed by at least one processor to implement the adaptive communication method supporting multiple protocols on RS485 bus as described in any one of claims 1 to 5.

13. A computer program product, comprising a computer program; characterized in that, The computer program can be executed by at least one processor and implement the communication adaptive method supporting multiple protocols on RS485 bus as described in any one of claims 1 to 5.