A coupler control method, device and medium supporting multi-protocol communication

By acquiring the initial communication protocol to construct query commands, monitoring responses in real time, determining the device protocol version type, and constructing corresponding data channels, the compatibility and scalability issues of the coupler in mixed-version device systems are resolved, enabling automated device identification and stable operation.

CN121309706BActive Publication Date: 2026-02-27SHENZHEN HUAMAO AOTE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511881253.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-02-27
Estimated Expiration
2045-12-15

AI Technical Summary

Technical Problem

Existing couplers lack dynamic awareness and negotiation mechanisms in systems dealing with hybrid device versions, causing legacy modules to be unable to correctly parse new protocol instructions, resulting in response timeouts or verification errors, thus limiting the system's compatibility and scalability.

Method used

By acquiring the initial communication protocol to construct query commands, monitoring responses in real time, determining the protocol version type based on the device matching status, and constructing corresponding data channels, the system achieves automated identification and compatibility management of devices with different versions.

Benefits of technology

Ensure rapid identification of new devices, improve initialization speed, enhance identification fault tolerance, optimize memory resource utilization, and improve the system's stable operation and scalability in hybrid networking environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121309706B_ABST
    Figure CN121309706B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of control or regulation systems, in particular to a coupler control method supporting multi-protocol communication, equipment and a medium.The method comprises the following steps: acquiring an initial communication protocol, constructing a first query instruction by using the initial communication protocol, and sending the first query instruction to a target physical address; monitoring in real time whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state; according to the device matching state, determining a protocol version type of an expansion module connected to the target physical address; and based on the protocol version type, constructing a data channel corresponding to the target physical address, so as to perform data interaction according to the data channel. The application has the effect of improving the expansibility and stability of a coupler system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of control or regulation systems, and in particular to a coupler control method supporting multi-protocol communication, a device and a medium. BACKGROUND

[0002] In a distributed system such as smart home or industrial automation control, a coupler serves as a core gateway device, responsible for connecting and managing various types of expansion modules such as sensors and actuators on the bus. With continuous iteration and update of technology, there are often expansion modules of different periods coexisting in the same system, and these modules may support different versions of communication protocols such as early low-speed simple protocols and later high-speed complex protocols.

[0003] Currently, the coupler mostly uses a pre-embedded single protocol standard for initialization configuration when establishing a communication link with an expansion module. This static configuration strategy assumes that all nodes on the bus have consistent communication capabilities. However, in application scenarios involving long-term maintenance or local upgrade of the system, there are often legacy modules developed based on early protocols coexisting with high-performance modules developed based on new protocols on the bus. Since the existing coupler lacks a dynamic sensing and negotiation mechanism for the communication capabilities of different nodes, when a command using a new protocol standard attempts to access a legacy module, it often causes the legacy module to produce a response timeout or a check error due to its inability to correctly parse the command, thereby causing the physical address to be mistakenly judged as faulty or offline by the system. This strong dependence on a single protocol objectively limits the compatibility and expansion flexibility of the system in a multi-version device coexistence environment, and therefore there is room for improvement. SUMMARY

[0004] To improve the scalability and stability of the coupler system, the present application provides a coupler control method supporting multi-protocol communication, a device and a medium.

[0005] The above invention objectives of the present application are achieved through the following technical solutions:

[0006] A coupler control method supporting multi-protocol communication, the coupler control method comprising:

[0007] obtaining an initial communication protocol, constructing a first query instruction using the initial communication protocol, and sending the first query instruction to a target physical address;

[0008] real-time monitoring whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state;

[0009] determining a protocol version type of an expansion module connected to the target physical address according to the device matching state;

[0010] based on the protocol version type, a data channel corresponding to the target physical address is constructed to perform data interaction according to the data channel.

[0011] By adopting the above technical solution, the first query instruction is sent to the target physical address by acquiring an initial communication protocol and constructing the first query instruction by using the initial communication protocol, so that a high-version protocol standard is preferentially used to initiate a handshake attempt to the device, thereby ensuring that the new device can be identified with optimal efficiency. By monitoring in real time whether a reply to the first query instruction is received within a first waiting time to determine a device matching state, the feedback of the device to the current protocol can be accurately obtained in real time, thereby providing a reliable decision basis for subsequent compatibility judgment. By determining the protocol version type of the extension module connected to the target physical address according to the device matching state, the automatic identification of the device capability can be realized. By constructing a corresponding data channel corresponding to the target physical address based on the protocol version type, the communication parameters and resources matched for devices of different versions can be configured, thereby ensuring the stable operation of the device in a mixed networking environment.

[0012] In a preferred example, the application can be further configured to: in the step of monitoring in real time whether a reply to the first query instruction is received from the target physical address within a first waiting time to determine a device matching state, specifically comprising:

[0013] If the reply is received within the first waiting time, data verification is performed on the reply, if the verification passes, the device matching state is determined to be a high-version matching state, and if the verification fails, a protocol downgrade mechanism is triggered.

[0014] If the reply is not received within the first waiting time, the protocol downgrade mechanism is triggered.

[0015] The device matching state is determined based on the protocol downgrade mechanism.

[0016] By adopting the above technical solution, by performing data verification on the reply received within the first waiting time and determining a high-version matching state when the verification passes, a device that completely supports the new protocol can be quickly locked, thereby improving the initialization speed of the high-performance device. By triggering the protocol downgrade mechanism when the verification fails or when the reply is not received within the first waiting time, the incompatible device can be avoided from being directly determined as a fault, thereby providing a retry opportunity for the compatible old device and enhancing the identification fault tolerance of the system.

[0017] In a preferred example, the application can be further configured to: in the step of determining the device matching state based on the protocol downgrade mechanism, specifically comprising:

[0018] Based on the protocol degradation mechanism, an alternate communication protocol is obtained, and a second query instruction is constructed according to the alternate communication protocol;

[0019] The second query instruction is sent to the target physical address, and it is monitored whether a reply from the target physical address to the second query instruction is received within a second waiting time, wherein the second waiting time is longer than the first waiting time;

[0020] If the reply is received within the second waiting time, the device matching state is determined as a low version matching state.

[0021] If the reply is not received within the second waiting time, the device matching state is determined as a no device response state.

[0022] By using the above technical solution, the alternate communication protocol is obtained based on the protocol degradation mechanism to construct and send the second query instruction, which can actively switch to a more compatible communication mode to detect the device again, thereby realizing automatic adaptation of the legacy device. By setting the second waiting time longer than the first waiting time for monitoring, sufficient response redundancy is provided for the old device with slow processing speed, thereby effectively preventing the low-speed device from being misjudged as offline due to response timeout, and improving the detection accuracy.

[0023] In a preferred example, the application can be further configured to determine the protocol version type of the extension module connected to the target physical address according to the device matching state, specifically including:

[0024] If the device matching state is a high version matching state, the protocol version type is determined as a first protocol version corresponding to the initial communication protocol.

[0025] If the device matching state is a low version matching state, the protocol version type is determined as a second protocol version corresponding to the alternate communication protocol.

[0026] If the device matching state is a no device response state, the protocol version type is determined as an offline state, and the target physical address is marked as an unusable address.

[0027] By using the above technical solution, the high version matching state, the low version matching state, and the no device response state are respectively determined as the first protocol version, the second protocol version, and the offline state, which can solidify the temporary handshake result as a persistent device attribute, thereby enabling the system to manage different devices separately and automatically shield the empty address node to improve the polling efficiency.

[0028] The application can be further configured in a preferred example as follows: the data channel corresponding to the target physical address is constructed based on the protocol version type, specifically including:

[0029] If the protocol version type is the first protocol version, a data buffer with a first size is allocated for the target physical address, and a data channel allowing transmission of basic control instructions and extended control instructions is established;

[0030] If the protocol version type is the second protocol version, a data buffer with a second size is allocated for the target physical address, and a data channel allowing transmission of basic control instructions is established, wherein the second size is smaller than the first size.

[0031] By using the above technical solution, when the protocol version type is the first protocol version, a data buffer with a first size is allocated and a channel allowing transmission of basic and extended control instructions is established, which can provide sufficient memory space and function authority for high-performance devices, thereby meeting their needs for large data throughput and complex function execution; when the protocol version type is the second protocol version, a data buffer with a smaller second size is allocated and a restricted channel is established, which can only occupy the minimum memory to meet the basic communication of old devices, thereby optimizing the memory resource utilization of the coupler and maximizing the number of accessible devices.

[0032] The application can be further configured in a preferred example as follows: if the protocol version type is the offline state, no data buffer is allocated for the target physical address, and the instruction sending to the target physical address is skipped in the data interaction process.

[0033] By using the above technical solution, when the protocol version type is the offline state, no data buffer is allocated and the instruction sending is skipped in the data interaction process, which can prevent memory leakage or invalid occupation, and eliminate the bus waiting time caused by sending invalid queries to empty addresses, thereby significantly improving the overall operation efficiency and resource utilization of the system.

[0034] The application can be further configured in a preferred example as follows: the coupler control method further includes:

[0035] When a control request for the target physical address is received, the type of instruction corresponding to the control request is determined;

[0036] If the instruction type is the extended control instruction, the corresponding protocol version type is obtained;

[0037] If the protocol version type is the second protocol version, the control request is intercepted, and feedback information is generated.

[0038] By adopting the technical scheme, when the control request confirmation is an extended control instruction but the protocol version type is the second protocol version, the request is intercepted and a feedback not supported is generated, which can prevent incompatible advanced instructions from being sent to old devices, thereby avoiding device freezing or communication bus congestion caused by parsing errors, and improving the robustness of system operation.

[0039] The application can be further configured in a preferred example as follows: the coupler control method further comprises:

[0040] In the process of data interaction according to the data channel, the communication state of the target physical address is monitored in real time;

[0041] When the number of consecutive communication failures of the target physical address is monitored to exceed a preset communication threshold, the protocol version type of the target physical address is reset to a to-be-detected state;

[0042] Based on the to-be-detected state, the step of constructing the first query instruction is re-executed to re-determine the protocol version type of the target physical address.

[0043] By adopting the technical scheme, the communication state is monitored in real time, and when the number of consecutive communication failures exceeds the threshold, the protocol version type is reset to the to-be-detected state, which can capture the dynamic changes such as replacement or plugging of devices on the bus in real time; by re-executing the step of constructing the first query instruction based on the to-be-detected state, the device type can be re-identified without restarting the system, thereby realizing hot plug adaptive support and self-healing function of the system, and reducing operation and maintenance cost.

[0044] The second application purpose is realized by the following technical scheme:

[0045] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above-mentioned coupler control method supporting multi-protocol communication when executing the computer program.

[0046] The third application purpose is realized by the following technical scheme:

[0047] A computer readable storage medium stores a computer program, and the computer program implements the steps of the above-mentioned coupler control method supporting multi-protocol communication when executed by a processor.

[0048] In summary, the application includes at least one of the following beneficial technical effects:

[0049] 1、By obtaining an initial communication protocol and sending a first query instruction to a target physical address using the initial communication protocol, the device can be probed using a high version protocol standard to ensure that the new device can be identified with optimal efficiency; by monitoring in real time whether a reply to the first query instruction is received within a first waiting time to determine the device matching state, the feedback of the device to the current protocol can be obtained in real time and accurately, thereby providing a reliable basis for subsequent compatibility judgment; by determining the protocol version type of the extension module connected to the target physical address according to the device matching state, the device capability can be automatically identified; by constructing a corresponding data channel corresponding to the target physical address based on the protocol version type, the communication parameters and resources can be matched for devices of different versions, thereby ensuring stable operation of the device in a mixed networking environment;

[0050] 2、By allocating a data buffer of a first size and establishing a channel allowing transmission of basic and extended control instructions when the protocol version type is a first protocol version, sufficient memory space and function permissions can be provided for high-performance devices, thereby meeting their demand for large data throughput and complex function execution; by allocating a data buffer of a second size smaller than the first size and establishing a restricted channel when the protocol version type is a second protocol version, only the minimum memory is occupied to meet the basic communication of old devices, thereby optimizing the memory resource utilization of the coupler and maximizing the number of accessible devices. BRIEF DESCRIPTION OF DRAWINGS

[0051] Figure 1 is an implementation flowchart of a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0052] Figure 2 is an implementation flowchart of step S20 in a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0053] Figure 3 is an implementation flowchart of step S23 in a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0054] Figure 4 is an implementation flowchart of step S30 in a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0055] Figure 5 is an implementation flowchart of step S40 in a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0056] Figure 6 is another implementation flowchart of a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0057] Figure 7 is another implementation flowchart of a coupler control method supporting multi-protocol communication in an embodiment of the present application;

[0058] Figure 8 is a schematic diagram of an internal structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following examples will facilitate further understanding of the role of the present application by those skilled in the art, but do not limit the present application in any form. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made. These all belong to the protection scope of the present application.

[0060] In the following description, specific details are set forth in order to provide a thorough understanding of embodiments of the present application. However, persons skilled in the art will understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

[0061] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0062] The present application is further described in detail below with reference to the accompanying drawings.

[0063] In an embodiment, as shown in Figure 1 The present application discloses a coupler control method supporting multi-protocol communication, specifically comprising the following steps:

[0064] S10: Obtain an initial communication protocol, construct a first query instruction using the initial communication protocol, and send the first query instruction to a target physical address.

[0065] Specifically, the initial communication protocol refers to a communication specification that is internally configured by default in the coupler software, usually representing the current highest performance standard or the latest version of the system, such as the V2.0 protocol supporting high-speed differential transmission. When performing this step, first, the target physical address to be detected is read from the polling list or task queue, then the encoder in the protocol stack is called, and according to the frame structure rules defined by the initial communication protocol, a data frame containing a specific frame header identifier, target address code and capability query operation code is encapsulated as the first query instruction. The instruction sequence is modulated and sent to the communication bus through the sending interface of the physical layer driver, which serves as the first handshake attempt to the target device, aiming to try to establish a connection in the optimal communication mode.

[0066] S20: Real-time monitoring whether a reply from the target physical address to the first query instruction is received within the first waiting time, and determining the device matching state.

[0067] Specifically, after the instruction sending action is completed, a high-precision hardware timer or software counter is immediately started to define the first waiting time, which represents the reasonable time delay range allowed by the device response under the current initial communication protocol. During this time window, the signal changes of the receiving port are continuously scanned or monitored through interrupts to capture the feedback data stream that may exist on the bus, and a logical flag, i.e., the device matching state, is generated according to the final result of this monitoring process. This state is an intermediate variable used to qualitatively describe whether the current attempted protocol is accepted by the target device, for example, if the expected reply is successfully received, it is marked as matching, if it times out or the reply is abnormal, it is marked as not matching or pending further confirmation, thereby providing a basis for subsequent logical branch decisions.

[0068] S30: According to the device matching state, determining the protocol version type of the expansion module connected to the target physical address.

[0069] Specifically, this step is a logical attribute archiving process. According to the device matching state output by the previous step, the internal pre-set state-type mapping table is consulted to convert the ambiguous handshake result into a clear device attribute definition, i.e., the protocol version type, which explicitly identifies whether the expansion module connected to the target physical address belongs to which generation of technology products, such as a high-version device supporting high-speed protocol, an old-version device supporting only basic protocol, or an idle address in offline state. Through this determination process, the software maps the unknown hardware entity on the physical bus to a logical object that can be recognized and managed by the operating system, completing the core part of device identification.

[0070] S40: Based on the protocol version type, constructing a data channel corresponding to the target physical address to perform data interaction according to the data channel.

[0071] Specifically, the construction of the data channel refers to the process of fine-tuned parameter configuration and resource loading of the communication link according to the determined protocol version type. The coupler will divide the data buffer space matching the protocol characteristics corresponding to the type in the internal memory, load the corresponding driver or protocol parsing stack, and configure the corresponding instruction permission mask and task priority, so as to establish a soft and hard combined dedicated logic path, ensuring that subsequent reporting of sensor data or issuing of control instructions can be accurately and non-blocking transmitted through the parameter adapted pipeline, realizing differentiated connection management for different capability devices.

[0072] In an embodiment, as shown in FIG. 2, in step S20, the step of determining the device matching state, i.e., monitoring in real time whether a reply from the target physical address to the first query instruction is received within the first waiting time, specifically includes: Figure 2

[0073] S21: If the reply is received within the first waiting time, data verification is performed on the reply. If the verification passes, the device matching state is determined to be the high version matching state. If the verification fails, the protocol downgrade mechanism is triggered.

[0074] Specifically, when the communication interface detects valid data frame input within the window period of the first waiting time, the integrity verification algorithm matched with the initial communication protocol is first called, such as CRC32 cyclic redundancy check or cumulative sum check, to decode and calculate the received bit stream, and the calculation result is compared with the check bit carried in the reply frame. If they are consistent, it means that the target device exists and can perfectly parse and respond to the high version of the initial protocol, so the device matching state is locked as the high version matching state, indicating that the handshake is successful once. Otherwise, if the signal is received but cannot pass the verification, or the parsed data frame format is incorrect, it usually implies that the opposite party may be an old version device using different encoding rules or baud rate, resulting in decoding garbled code. In order to not miss such compatible devices, the system determines that the current protocol is not applicable, and automatically activates the protocol downgrade mechanism to attempt to switch to the backup scheme.

[0075] S22: If no reply is received within the first waiting time, the protocol downgrade mechanism is triggered.

[0076] ​Specifically, if the timer counts up to the upper threshold of the first waiting time, such as 10 milliseconds, and the bus still maintains an idle level, no response signal is captured, which indicates that the target device cannot identify the high-speed initial protocol instruction or the address is not connected to a device at all. Since only one timeout cannot distinguish between the two cases, no error is directly reported and the program execution flow is transferred to the exception handling logic, that is, the protocol downgrade mechanism is triggered to change the communication parameters and detect again to ensure that the old device is not misjudged as offline due to the use of a too high version of the protocol.

[0077] S23: determining the device matching state based on the protocol downgrade mechanism.

[0078] Specifically, the protocol downgrade mechanism is a set of software-defined adaptive compatibility logic processes. When it is triggered, the current high-version communication task is temporarily suspended, the parameter configuration of the backup communication protocol is loaded, and a secondary handshake test process for compatible devices is started to execute. Through this series of backup scheme test processes, the real reason for the non-response or verification failure in the foregoing steps is further clarified to finally confirm the real connection of the physical address and solidify the detection result as the device matching state, thereby completing the accurate profiling of the unknown device type.

[0079] In an embodiment, as shown in FIG. 23, in step S23, that is, the step of determining the device matching state based on the protocol downgrade mechanism, specifically includes: Figure 3

[0080] S231: obtaining a backup communication protocol based on the protocol downgrade mechanism, and constructing a second query instruction according to the backup communication protocol.

[0081] Specifically, when entering the downgrade process, the coupler retrieves a preset backup communication protocol from the internally stored protocol library. The protocol usually refers to an old version of the communication standard with stronger compatibility, simpler frame structure, or lower baud rate, such as Protocol V1.0. Then the encoding module switches to the backup mode and re-encapsulates a data frame pointing to the same target physical address, that is, the second query instruction, according to the encoding rules defined by the backup mode. This process is equivalent to the coupler automatically switching the response means in logic, preparing to re-initiate a call in a low-speed format that the old device can understand, in order to establish a connection.

[0082] S232: sending the second query instruction to the target physical address and monitoring whether a reply from the target physical address to the second query instruction is received within a second waiting time, wherein the length of the second waiting time is greater than the length of the first waiting time.

[0083] ​Specifically, after sending the second query command for compatibility mode through the physical interface, the timing monitoring task for the second waiting time is immediately started. It is worth noting that, considering that older version expansion modules usually use processors with lower clock speeds or are in low-power mode, their wake-up and processing response speeds are often slower than those of new devices. Therefore, the second waiting time is configured to be significantly longer than the first waiting time, for example, set to 20 milliseconds or even more. By providing this asymmetric time redundancy, the system effectively prevents the communication timeout from being incorrectly judged due to the slow response of older devices, thereby ensuring the accuracy and robustness of compatibility detection.

[0084] S233: If a reply is received within the second waiting time, the device matching status is determined to be a low version matching status.

[0085] Specifically, if the communication interface successfully captures a response signal that conforms to the characteristics of the backup communication protocol within the extended listening window period and passes the corresponding low-version verification, this directly provides conclusive evidence that a functional but only old-version-supporting legacy module is indeed connected to the physical address. Subsequently, the internal status register is updated and locked to the low-version matching state, which indicates that the downgrade handshake strategy has been successfully implemented and the system has successfully identified and accepted the legacy device.

[0086] S234: If no response is received within the second waiting time, the device matching status is determined to be no device response status.

[0087] Specifically, if the bus remains silent after protocol switching attempts and extended waiting times, and no valid level transitions are detected, the possibility of protocol mismatch or slow device response can be logically ruled out. Thus, it can be concluded that no valid device is currently connected to the physical address. Therefore, the device matching status is ultimately marked as no device response, and no further retry operations are performed on the address, ending the current probe process to avoid unnecessary consumption of system resources on empty addresses.

[0088] In one embodiment, such as Figure 4 As shown, in step S30, which is the step of determining the protocol version type of the extension module connected to the target physical address based on the device matching status, the specific steps include:

[0089] S31: If the device matching status is a high version matching status, then the protocol version type is determined to be the first protocol version corresponding to the initial communication protocol.

[0090] Specifically, when the result output by the state monitoring module is the high version matching state, it indicates that the target device has successfully responded to the system default high-performance handshake request, and the coupler updates the table entry corresponding to the target physical address in the internal device attribute mapping table to the first protocol version, such as a V2.0 high-performance module, which not only confirms the device generation, but also means that all subsequent communication tasks for the address will be automatically invoked by the full-function instruction set and high-speed transmission driver to fully exert the performance advantage of the new device.

[0091] S32: If the device matching state is the low version matching state, the protocol version type is determined as the second protocol version corresponding to the backup communication protocol.

[0092] Specifically, when the state result shows the low version matching state, it means that the device can only establish a connection through the degraded compatible mode, and the protocol version type of the physical address is immediately locked as the second protocol version, such as a V1.0 compatible module, which is equivalent to labeling the device as an old version, notifying the subsequent processing link of the system that the instruction set range must be automatically limited and the old version communication parameters must be adapted when involving the address, to ensure seamless support for legacy devices in a mixed networking environment.

[0093] S33: If the device matching state is the no device response state, the protocol version type is determined as the offline state, and the target physical address is marked as an unusable address.

[0094] Specifically, for the object finally determined to be unresponsive, the protocol version type is explicitly set to the offline state, and the target physical address is marked as an unusable or invalid skip bit in the core routing table or the polling list. This action has important system optimization significance. In the subsequent periodic data polling task, the task scheduler will automatically ignore the access attempt to the address after reading the mark, until the next system reset or receiving a manually triggered scanning instruction, thereby effectively avoiding the waste of bus bandwidth on idle nodes and improving the overall polling efficiency.

[0095] In an embodiment, as shown in FIG. 4, Figure 5 In step S40, a data channel corresponding to the target physical address is constructed based on the protocol version type, specifically including:

[0096] S41: If the protocol version type is the first protocol version, a data buffer of the first size is allocated for the target physical address, and a data channel allowing transmission of basic control instructions and extended control instructions is established.

[0097] Specifically, for the first protocol version object identified as a high-performance new device, a generous strategy is adopted in memory resource allocation, and a large-capacity FIFO receiving buffer of a first size, such as 1024 bytes, is dynamically opened in the RAM heap area by the memory management unit to support burst transmission of complex waveform data or firmware packages, while in the channel permission configuration, an open logical pipe is established to remove the lock on all function codes and allow the transmission of extended control instructions, including firmware online upgrade, historical data readback, and other basic control instructions, thereby providing a full-featured interactive environment for the new device.

[0098] S42: If the protocol version type is the second protocol version, a data buffer of a second size is allocated for the target physical address, and a data channel allowing the transmission of basic control instructions is established, wherein the second size is smaller than the first size.

[0099] Specifically, for the second protocol version object identified as an old version module, a fine resource conservation strategy is executed, and only a small-capacity register mapping space of a second size, such as 64 bytes, significantly smaller than the first size, is allocated for it, which is sufficient to meet the communication needs of the old device with low speed and short frame, and avoids waste in limited on-chip RAM resources, while implementing control in channel permissions, shielding advanced function codes, and establishing a restricted channel allowing the transmission of only basic control instructions such as simple on-off control or state reading, thereby building a lightweight data path strictly matching its limited capabilities, so that the system can support access to a larger number of nodes.

[0100] In an embodiment, if the protocol version type is offline, no data buffer is allocated for the target physical address, and the instruction sending to the target physical address is skipped during data interaction.

[0101] Specifically, in order to optimize system resources, for offline state addresses of devices confirmed by detection to be not connected, no memory block application and mounting operation is performed, i.e., the corresponding software buffer pointer is set to null or the size is set to zero, to prevent memory leakage or invalid occupation, and after entering the data interaction logic of the main loop, the sending scheduler first checks the state bit of each target address, and once the offline flag is identified, all read and write operations for the address are directly shielded, so that the program pointer immediately jumps to the next address. This mechanism effectively eliminates bus timeout waiting caused by sending invalid instructions to empty addresses, and guarantees the smoothness of system operation.

[0102] In an embodiment, as shown in Figure 6 the coupler control method further includes:

[0103] S50: When receiving a control request for a target physical address, determining the instruction type corresponding to the control request.

[0104] Specifically, during the system enters the normal business operation period, when the upper application logic or the master chip issues an operation task for a specific expansion module, the coupler first plays the analysis function of the intelligent gateway, reads the function code field in the control request, identifies the specific operation intention according to the internally preset instruction set classification table, and determines whether the request belongs to the general basic instruction for simple state control or the expansion instruction type involving a large amount of data interaction or special configuration supported only by specific new devices.

[0105] S60: If the instruction type is an expansion control instruction, a corresponding protocol version type is obtained.

[0106] Specifically, if the analysis result of the previous step shows that the request belongs to a more complex expansion control instruction, for example, requesting to obtain the high-precision energy consumption curve data of the device or performing the writing of non-volatile parameters, considering that such instructions have higher requirements on the processing capacity of the device, the coupler will not blindly forward, but will immediately consult the device attribute table in the memory to retrieve the protocol version type currently bound to the target physical address, and use it as the basis for judging whether the advanced instruction can be executed, to confirm whether the target device has the corresponding software and hardware basis.

[0107] S70: If the protocol version type is a second protocol version, the control request is intercepted, and feedback information is generated.

[0108] Specifically, if it is found through table lookup that the target device is only the second protocol version supporting the old protocol, obviously its firmware does not support and cannot parse modern expansion instructions, at this time the coupler software intercepts the control request at the gateway level, terminates the sending action to the physical bus, and immediately returns a specific error code or a function not supported state feedback to the upper master logic. This mechanism effectively prevents the risk of device crash, program runaway or bus communication congestion caused by forcibly sending unrecognized random code instructions to old devices.

[0109] In an embodiment, as shown in Figure 7 the coupler control method further includes:

[0110] S1: In the process of data interaction according to the data channel, the communication state of the target physical address is monitored in real time.

[0111] Specifically, even after a successful connection is established and the daily periodic communication begins, the coupler remains vigilant and does not fully trust the current link stability, but continues to start a background link daemon, and counts the command response of each interaction period, such as recording the packet loss rate, check error rate or unanswered number in real time, through this continuous monitoring mechanism, the real-time health degree profile of each online device is established, which provides data support for capturing the dynamic changes of the system environment.

[0112] S2: When it is monitored that the number of consecutive communication failures of the target physical address exceeds the preset communication threshold, the protocol version type of the target physical address is reset to a to-be-detected state.

[0113] Specifically, if the system daemon finds that a certain address originally marked as normal suddenly has consecutive and exceeds the preset communication threshold, such as 3 or 5 consecutive communication timeouts or errors, which is usually a strong signal, indicating that the device at this position may have failed, powered off, or more commonly, replaced by the user with another model under the condition of uninterrupted power supply, in order to respond to this uncertainty, the coupler immediately takes state rollback measures, forcibly resets the protocol version type of the address from the current determined state to the to-be-detected state, which means on the one hand that the previous handshake conclusion is invalidated, and on the other hand it is removed from the normal polling queue and is ready for re-evaluation.

[0114] S3: Based on the to-be-detected state, the step of constructing the first query instruction is re-executed to re-determine the protocol version type of the target physical address.

[0115] Specifically, once an address is marked as a to-be-detected state, it will be re-added to the high-priority initialization scanning queue by the core scheduler, and the program logic will no longer follow the old channel parameters, but immediately jump back to the starting point of the flow, such as step S10, and try to call the initial communication protocol again to initiate a new inquiry. This mechanism can automatically perceive changes and automatically upgrade the protocol channel within a few cycles even if the user replaces the old module with a new one, without the need for manual intervention to complete the configuration update.

[0116] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0117] In one embodiment, an electronic device, which can be a server, is provided, and its internal structure diagram can be as shown in Figure 8An electronic device is shown. The electronic device includes a processor, a memory, a network interface and a database connected by a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is configured to store data information of an initial communication protocol, a first query instruction, a device matching state and a protocol version type. The network interface of the electronic device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a coupler control method supporting multi-protocol communication.

[0118] In one embodiment, an electronic device is provided, including a memory, a processor and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the following steps:

[0119] obtaining an initial communication protocol, constructing a first query instruction using the initial communication protocol, and sending the first query instruction to a target physical address;

[0120] real-time monitoring whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state;

[0121] determining a protocol version type of an extension module connected to the target physical address according to the device matching state;

[0122] constructing a data channel corresponding to the target physical address based on the protocol version type, and performing data interaction according to the data channel.

[0123] In one embodiment, a computer readable storage medium is provided, having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:

[0124] obtaining an initial communication protocol, constructing a first query instruction using the initial communication protocol, and sending the first query instruction to a target physical address;

[0125] real-time monitoring whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state;

[0126] determining a protocol version type of an extension module connected to the target physical address according to the device matching state;

[0127] constructing a data channel corresponding to the target physical address based on the protocol version type, and performing data interaction according to the data channel.

[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of functional units and modules is exemplified. In actual application, the above-mentioned functions can be completed by different functional units or modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the above-described functions.

[0130] The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A coupler control method supporting multi-protocol communication, characterized by, The coupler control method comprises: acquiring an initial communication protocol, constructing a first query instruction using the initial communication protocol, and sending the first query instruction to a target physical address; monitoring in real time whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state; determining a protocol version type of an extension module connected to the target physical address according to the device matching state; constructing a data channel corresponding to the target physical address based on the protocol version type, and performing data interaction according to the data channel; wherein the step of monitoring in real time whether a reply from the target physical address to the first query instruction is received within a first waiting time, and determining a device matching state, specifically comprises: if the reply is received within the first waiting time, performing data verification on the reply, if the verification is passed, determining that the device matching state is a high version matching state, if the verification is not passed, triggering a protocol downgrade mechanism; if the reply is not received within the first waiting time, triggering the protocol downgrade mechanism; determining the device matching state based on the protocol downgrade mechanism; the step of determining the device matching state based on the protocol downgrade mechanism, specifically comprises: acquiring a backup communication protocol based on the protocol downgrade mechanism, and constructing a second query instruction according to the backup communication protocol; sending the second query instruction to the target physical address, and monitoring whether a reply from the target physical address to the second query instruction is received within a second waiting time, wherein the length of the second waiting time is greater than the length of the first waiting time; if the reply is received within the second waiting time, determining that the device matching state is a low version matching state; if the reply is not received within the second waiting time, determining that the device matching state is a no device response state.

2. The coupler control method of claim 1, wherein the step of determining the protocol version type of the extension module connected to the target physical address according to the device matching state, specifically comprises: if the device matching state is a high version matching state, determining the protocol version type as a first protocol version corresponding to the initial communication protocol; if the device matching state is a low version matching state, determining the protocol version type as a second protocol version corresponding to the backup communication protocol; if the device matching state is a no device response state, determining the protocol version type as an offline state, and marking the target physical address as an unusable address.

3. The coupler control method of claim 2, wherein the step of constructing a data channel corresponding to the target physical address based on the protocol version type, specifically comprises: if the protocol version type is the first protocol version, allocating a data buffer of a first size to the target physical address, and establishing a data channel allowing transmission of basic control instructions and extension control instructions; If the protocol version type is the second protocol version, a data buffer with a second size is allocated for the target physical address, and a data channel allowing transmission of basic control instructions is established, wherein the second size is smaller than the first size.

4. The coupler control method of claim 2, wherein If the protocol version type is the offline state, no data buffer is allocated for the target physical address, and sending of instructions to the target physical address is skipped during data interaction.

5. The coupler control method of claim 3, wherein The coupler control method further comprises: when a control request for the target physical address is received, determining an instruction type corresponding to the control request; if the instruction type is the extended control instruction, obtaining a corresponding protocol version type; if the protocol version type is the second protocol version, intercepting the control request and generating feedback information.

6. The coupler control method of claim 1, wherein The coupler control method further comprises: during data interaction according to the data channel, the communication state of the target physical address is monitored in real time; when the number of consecutive communication failures of the target physical address is monitored to exceed a preset communication threshold, the protocol version type of the target physical address is reset to a to-be-detected state; based on the to-be-detected state, the step of constructing a first query instruction is re-executed to re-determine the protocol version type of the target physical address.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the coupler control method supporting multi-protocol communication according to any one of claims 1 to 6.

8. A computer-readable storage medium storing a computer program, the computer-readable storage medium comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 7. The computer program is executed by the processor to implement the steps of the coupler control method supporting multi-protocol communication according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Security negotiations between different versioned protocol devices to enable backward compatibility

    US20230051133A1