Equipment communication protocol generation method and system based on pre-compiling
By using a pre-compiled device communication protocol generation method, the issues of flexibility and maintainability of device communication protocols are resolved, achieving an efficient and reliable device integration ecosystem suitable for industrial automation and the Internet of Things (IoT) fields.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN NEBULA ELECTRONICS CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-28
AI Technical Summary
The existing equipment communication protocols lack flexibility and maintainability, resulting in high development and maintenance costs, difficulty in quickly responding to equipment hardware changes and protocol adjustments, and poor portability and configurability.
The method of generating pre-compiled device communication protocols is adopted. By separating storage device configuration parameters and communication protocol templates, the pre-compilation engine is used to inject static parameters into the template to generate pre-compiled protocol instances during the system initialization phase, and dynamic data is processed during the runtime phase. It supports configuration files in XML or JSON format and type-aware formatting mechanisms.
It improves the flexibility and maintainability of protocol configuration, reduces development and iteration costs, enhances response speed and system throughput, and improves the accuracy and reliability of data transmission, making it suitable for heterogeneous environments with multiple devices and protocols.
Smart Images

Figure CN121940460A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of device communication technology in industrial automation and the Internet of Things, and in particular to a method and system for generating pre-compiled device communication protocols. Background Technology
[0002] In the fields of industrial automation control, intelligent device management, and Internet of Things (IoT) applications, various peripheral devices (such as sensors, actuators, and controllers) need to interact with the main control system according to specific communication protocols. These protocols typically define key elements such as data frame structure, command word definition, parameter location arrangement, and verification mechanisms.
[0003] Currently, the mainstream implementation of device communication protocols relies on hard-coding technology. In this traditional model, the specific details of the protocol are directly embedded in the software source code; specifically, device-related parameters (such as device address, channel number, fixed instruction code, etc.) are often predefined in the code as constants; and the entire packet assembly logic, including parameter arrangement order, data format conversion (e.g., integer to hexadecimal byte conversion), and checksum generation, is all implemented through manually written code functions. Although hard-coding is straightforward, it has the following significant technical limitations in practical applications: (1) Insufficient flexibility and adaptability: The communication protocol and device parameters are deeply coupled within the code. When the device hardware is replaced, the parameters are changed (such as the device address or communication channel is adjusted), or new types of communication protocols need to be supported, the developers must modify the source code and recompile, build and deploy the entire software system. This not only increases the development and maintenance burden, but also makes it difficult for the system to respond quickly to diverse device types and dynamically changing field application needs.
[0004] (2) Low development and maintenance efficiency: For each new peripheral or protocol, developers usually need to write and debug communication code from scratch. A lot of repetitive work restricts development efficiency. At the same time, the protocol logic is scattered in many parts of the code, making system maintenance difficult. Any minor protocol adjustment may require a lot of source code to be checked and modified, which not only increases the probability of errors but also increases maintenance costs.
[0005] (3) Poor portability and configurability: The protocol processing logic is fixed in the code, which means that when the system is ported to a project that uses different peripherals or communication protocols, a lot of code-level modifications are required. The code reuse is low and it is difficult to achieve quick switching of peripherals or combination of functions through simple configuration.
[0006] Therefore, how to provide a pre-compiled device communication protocol generation method and system to improve the flexibility and maintainability of protocol configuration, reduce development and iteration costs, and thus create an open and sustainable device integration ecosystem has become an urgent technical problem to be solved. Summary of the Invention
[0007] The technical problem to be solved by this invention is to provide a method and system for generating pre-compiled device communication protocols, thereby improving the flexibility and maintainability of protocol configuration, reducing development and iteration costs, and creating an open and sustainably evolving device integration ecosystem.
[0008] In a first aspect, the present invention provides a method for generating a pre-compiled device communication protocol, comprising the following steps: Step S1: Set device configuration parameters and communication protocol template, and store the device configuration parameters and communication protocol template separately; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format that includes static parameter placeholders and dynamic parameter placeholders; Step S2: During the system initialization phase, the pre-compilation engine is called to inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache. Step S3: During the system operation phase, the input service request is obtained, and the dynamic service data carried by the service request is injected into the dynamic parameter placeholder of the pre-compiled protocol instance through the runtime adapter to generate the final device communication protocol. Step S4: Generate a communication message based on the device communication protocol and send the communication message through the communication interface.
[0009] Furthermore, in step S1, the device configuration parameters and communication protocol template are stored in an XML or JSON format configuration file.
[0010] Furthermore, in step S2, the pre-compilation engine formats the corresponding static parameter into a binary data string or hexadecimal data string that conforms to the communication protocol template according to the parameter data type defined in the device configuration parameters, and then injects it into the static parameter placeholder of the corresponding communication protocol template.
[0011] Furthermore, in step S3, the runtime adapter uses a type-aware formatting mechanism to format the dynamic business data into a binary data string or hexadecimal data string that conforms to the requirements of the communication protocol template, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
[0012] Furthermore, step S4 specifically includes: A communication message is generated based on the device communication protocol, a checksum is calculated and added to the communication message by an integrity verification engine, and then the communication message is sent through the communication interface.
[0013] Secondly, the present invention provides a device communication protocol generation system based on pre-compiled technology, comprising the following modules: An initialization module is used to set device configuration parameters and communication protocol templates, and to store the device configuration parameters and communication protocol templates separately; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format that includes static parameter placeholders and dynamic parameter placeholders; The pre-compiled protocol instance generation module is used to call the pre-compilation engine during the system initialization phase, inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache. The device communication protocol generation module is used to obtain input service requests during system operation, inject the dynamic service data carried by the service requests into the dynamic parameter placeholders of the pre-compiled protocol instance through the runtime adapter, and generate the final device communication protocol. The communication message sending module is used to generate communication messages based on the device communication protocol and send the communication messages through the communication interface.
[0014] Furthermore, in the initialization module, the device configuration parameters and communication protocol templates are stored in configuration files in XML or JSON format.
[0015] Furthermore, in the pre-compiled protocol instance generation module, the pre-compilation engine formats the corresponding static parameters into binary or hexadecimal data strings that conform to the communication protocol template according to the parameter data types defined in the device configuration parameters, and then injects them into the static parameter placeholders of the corresponding communication protocol template.
[0016] Furthermore, in the device communication protocol generation module, the runtime adapter adopts a type-aware formatting mechanism to format the dynamic business data into a binary data string or hexadecimal data string that conforms to the requirements of the communication protocol template, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
[0017] Furthermore, the communication message sending module is specifically used for: A communication message is generated based on the device communication protocol, a checksum is calculated and added to the communication message by an integrity verification engine, and then the communication message is sent through the communication interface.
[0018] The advantages of this invention are: 1. By setting device configuration parameters and communication protocol templates, the device configuration parameters and communication protocol templates are stored separately. Device configuration parameters include static parameters and parameter data types. The communication protocol template defines a message format containing static parameter placeholders and dynamic parameter placeholders. During system initialization, the pre-compilation engine is called to inject the static parameters from the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generating a pre-compiled protocol instance and storing it in the template optimization cache. During system operation, input service requests are obtained, and the dynamic service data carried by the service requests is injected into the dynamic parameter placeholders of the pre-compiled protocol instance through the runtime adapter, generating the final device communication protocol. Finally, based on the device communication protocol... The system generates communication messages and sends them through the communication interface. This involves separating and storing device configuration parameters from the communication protocol template, and using a pre-compilation engine during system initialization to inject static parameters into the communication protocol template to generate a pre-compiled protocol instance. This fundamentally changes the traditional hard-coding approach, allowing device changes or protocol adjustments to take effect simply by modifying the external configuration file, without needing to modify or recompile the core code. Simultaneously, this architecture forms a universal protocol generation framework, enabling support for new devices by simply adding the corresponding configuration without repeatedly developing the underlying logic. Ultimately, this greatly improves the flexibility and maintainability of protocol configuration, significantly reduces development and iteration costs, and fosters an open and sustainably evolving device integration ecosystem.
[0019] 2. By injecting static parameters into the communication protocol template during the system initialization phase through a pre-compilation mechanism, a pre-compiled protocol instance is generated and cached. Thus, during the system runtime phase, only the injection of dynamic business data needs to be processed. This separate processing method reduces runtime computational overhead and avoids re-parsing the template and static parameters for each communication request, significantly improving the response speed of protocol generation and system throughput. Especially in high-frequency communication scenarios, caching pre-compiled instances can effectively reduce CPU and memory resource consumption, meeting the requirements of modern IoT devices for low latency and high efficiency.
[0020] 3. Device configuration parameters and communication protocol templates are stored separately and support XML or JSON formats, which makes configuration management more modular and user-friendly. Users or administrators can easily adjust device parameters or protocol formats by modifying configuration files without recompiling or deploying the entire system. This design reduces system coupling, facilitates subsequent upgrades and customization, and is particularly suitable for heterogeneous environments with multiple devices and protocols, improving the scalability and maintainability of the technology.
[0021] 4. By introducing a type-aware formatting mechanism, static parameters and dynamic business data are formatted according to the parameter data type (such as binary or hexadecimal) before placeholders are injected during the pre-compilation and runtime phases. This avoids common data type mismatch errors in traditional protocol generation, such as integer overflow or string encoding problems, thereby improving the accuracy and interoperability of communication messages, helping to reduce debugging time, and enhancing the reliability of the system in critical applications such as industrial control.
[0022] 5. By adding checksums to communication messages through the integrity verification engine, the robustness of data transmission is enhanced. The verification mechanism can detect and correct errors in the message during transmission, prevent data corruption or loss, comply with the security standards of the communication protocol, and is particularly suitable for scenarios with harsh network environments or high reliability requirements (such as autonomous driving or medical equipment), reducing the risk of communication failure and improving the overall system stability.
[0023] 6. It adopts a clear modular structure, such as a pre-compilation engine, runtime adapter, and template optimization cache, which makes the responsibilities of each component clear and facilitates independent testing and optimization; the caching mechanism reduces redundant calculations, while the modular design supports pluggable expansion, such as easy integration of new protocol templates or data types; this resource optimization not only reduces hardware costs but also improves the reusability of the system, making it suitable for resource-constrained environments such as cloud computing or edge computing.
[0024] 7. By separating storage device configuration parameters and communication protocol templates, the pre-compilation engine injects static parameters into the template and caches pre-compiled instances during system initialization, significantly improving the efficiency and performance of protocol generation and reducing runtime overhead. Meanwhile, the use of XML or JSON format in configuration files enhances system flexibility and maintainability, while the type-aware formatting mechanism ensures type safety and correctness in data processing, avoiding common errors. Furthermore, the integrity verification engine improves communication reliability and data integrity, and the modular design optimizes resource utilization, making the technology more adaptable to multi-device scenarios and critical applications. Overall, this achieves efficient, reliable, and scalable communication protocol generation. Attached Figure Description
[0025] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0026] Figure 1 This is a flowchart of a pre-compiled device communication protocol generation method according to the present invention.
[0027] Figure 2 This is a schematic diagram of the structure of a pre-compiled device communication protocol generation system according to the present invention. Detailed Implementation
[0028] The overall idea of the technical solution in the embodiments of this application is as follows: By storing device configuration parameters and communication protocol templates separately, and using a pre-compilation engine to inject static parameters into the communication protocol template in advance during the system initialization phase to generate a pre-compiled protocol instance, it fundamentally changes the traditional hard-coding method, enabling device changes or protocol adjustments to take effect only by modifying external configuration files without modifying and recompiling the core code. At the same time, this architecture forms a general protocol generation framework, allowing new devices to be supported only by supplementing corresponding configurations without repeating the development of underlying logic, ultimately enhancing the flexibility and maintainability of protocol configuration, reducing development and iteration costs, and thus creating an open and sustainable evolving device integration ecosystem.
[0029] Please refer to Figures 1 to 2 as shown in the following, a preferred embodiment of a method for generating a device communication protocol based on pre-compilation includes the following steps: Step S1: Set device configuration parameters and a communication protocol template, and store the device configuration parameters and the communication protocol template separately; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format including static parameter placeholders and dynamic parameter placeholders. Step S2: During the system initialization phase, call the pre-compilation engine to inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template to generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache; at this time, the static parameter placeholders have been replaced by static parameters, while the dynamic parameter placeholders remain. Step S3: During the system operation phase, obtain the input service request, and inject the dynamic service data carried by the service request into the dynamic parameter placeholders of the pre-compiled protocol instance through a runtime adapter to generate the final device communication protocol. Step S4: Generate a communication message based on the device communication protocol, and send the communication message through a communication interface (such as RS485, CAN, Ethernet).
[0030] In step S1, the device configuration parameters and the communication protocol template are stored in a configuration file in XML format or JSON format.
[0031] That is, a separate design of device configuration parameters and communication protocol templates is adopted: Configuration file of device configuration parameters (DevConfig) => Define device parameters Configuration file of communication protocol template (Protocol) => Define communication template <!-- Example of device configuration parameters --> <devconfig devid="20"> <jsonconfig> <param name="channel" value="1" type="int"> < / jsonconfig> < / devconfig> <!-- Communication protocol template example --> <command Id="SET_RELAY"> <param Id="channel" Source="prefilled"> <send Default="01 7D {channel} {state}" / > In step S2, according to the parameter data types defined in the device configuration parameters, the pre-compilation engine formats the corresponding static parameters into a binary data string or a hexadecimal data string that conforms to the communication protocol template, and then injects them into the static parameter placeholder of the corresponding communication protocol template.
[0032] During specific implementation, the static parameters are first formatted according to the data types (such as integers, floating-point numbers, boolean values, etc.).
[0033] In step S3, the runtime adapter adopts a type-aware formatting mechanism to format the dynamic service data into a binary data string or a hexadecimal data string that meets the requirements of the communication protocol template according to the data type, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
[0034] Step S4 is specifically as follows: Generate a communication message based on the device communication protocol, calculate and add a check code (such as CRC) to the communication message through the integrity check engine, and then send the communication message through the communication interface.
[0035] The key optimization methods of the present invention are as follows: Template固化技术: 将设备特有静态参数提前注入通信协议模板: / / Original template before optimization char* template = "01 7D {channel} {state}"; / / After pre-compilation (device channel = 1) char* compiled = "01 7D 01 {state}"; / / Significantly reduce runtime processing Hierarchical replacement strategy: During initialization: Device parameters => Static replacement (once) During runtime: User input => Dynamic replacement (only need to process the changed part) A preferred embodiment of a device communication protocol generation system based on pre-compilation according to the present invention includes the following modules: Initialization module, used to set device configuration parameters and communication protocol templates, and separately store the device configuration parameters and communication protocol templates; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format containing static parameter placeholders and dynamic parameter placeholders. Pre-compiled protocol instance generation module, used in the system initialization stage, call the pre-compiled engine, inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache; at this time, the static parameter placeholders have been replaced by static parameters, while the dynamic parameter placeholders remain. Device communication protocol generation module, used in the system operation stage, obtain the input service request, and inject the dynamic service data carried by the service request into the dynamic parameter placeholders of the pre-compiled protocol instance through the runtime adapter to generate the final device communication protocol. Communication message sending module, used to generate a communication message based on the device communication protocol and send the communication message through a communication interface (such as RS485, CAN, Ethernet).
[0036] In the initialization module, the device configuration parameters and communication protocol templates are stored in a configuration file in XML format or JSON format.
[0037] That is, a separate design of device configuration parameters and communication protocol templates is adopted: Configuration file (DevConfig) of device configuration parameters => Define device parameters Configuration file (Protocol) of communication protocol template => Define communication template <!-- Example of device configuration parameters --> <devconfig devid="20"> <jsonconfig> <param name="channel" value="1" type="int"> < / jsonconfig> < / devconfig> <!-- Example of communication protocol template --> <command Id="SET_RELAY"> <param Id="channel" Source="prefilled"> <send Default="01 7D {channel} {state}" / > In the pre-compiled protocol instance generation module, the pre-compiled engine formats the corresponding static parameters into a binary data string or hexadecimal data string that conforms to the communication protocol template according to the parameter data types defined in the device configuration parameters, and then injects them into the static parameter placeholders of the corresponding communication protocol template.
[0038] In specific implementation, the static parameters are first formatted according to the data type (integer, floating point number, boolean, etc.).
[0039] In the device communication protocol generation module, the runtime adapter uses a type-aware formatting mechanism to format the dynamic business data into a binary data string or hexadecimal data string that conforms to the requirements of the communication protocol template, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
[0040] The communication message sending module is specifically used for: A communication message is generated based on the device communication protocol, and a checksum (such as CRC) is calculated and added to the communication message through an integrity verification engine. The communication message is then sent through the communication interface.
[0041] The key optimization method of this invention is as follows: Template-based embedding technology: Pre-injecting the device's unique static parameters into the communication protocol template. / / Original template before optimization char* template = "01 7D {channel} {state}"; / / After pre-compilation (device channel=1) char* compiled = "01 7D 01 {state}"; / / Significantly reduces runtime processing Layered replacement strategy: During initialization: Equipment parameters => Static replacement (one-time) At runtime: User input => Dynamic replacement (only the changing parts need to be processed) In summary, the advantages of this invention are as follows: 1. By setting device configuration parameters and communication protocol templates, the device configuration parameters and communication protocol templates are stored separately. Device configuration parameters include static parameters and parameter data types. The communication protocol template defines a message format containing static parameter placeholders and dynamic parameter placeholders. During system initialization, the pre-compilation engine is called to inject the static parameters from the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generating a pre-compiled protocol instance and storing it in the template optimization cache. During system operation, input service requests are obtained, and the dynamic service data carried by the service requests is injected into the dynamic parameter placeholders of the pre-compiled protocol instance through the runtime adapter, generating the final device communication protocol. Finally, based on the device communication protocol... The system generates communication messages and sends them through the communication interface. This involves separating and storing device configuration parameters from the communication protocol template, and using a pre-compilation engine during system initialization to inject static parameters into the communication protocol template to generate a pre-compiled protocol instance. This fundamentally changes the traditional hard-coding approach, allowing device changes or protocol adjustments to take effect simply by modifying the external configuration file, without needing to modify or recompile the core code. Simultaneously, this architecture forms a universal protocol generation framework, enabling support for new devices by simply adding the corresponding configuration without repeatedly developing the underlying logic. Ultimately, this greatly improves the flexibility and maintainability of protocol configuration, significantly reduces development and iteration costs, and fosters an open and sustainably evolving device integration ecosystem.
[0042] 2. By injecting static parameters into the communication protocol template during the system initialization phase through a pre-compilation mechanism, a pre-compiled protocol instance is generated and cached. Thus, during the system runtime phase, only the injection of dynamic business data needs to be processed. This separate processing method reduces runtime computational overhead and avoids re-parsing the template and static parameters for each communication request, significantly improving the response speed of protocol generation and system throughput. Especially in high-frequency communication scenarios, caching pre-compiled instances can effectively reduce CPU and memory resource consumption, meeting the requirements of modern IoT devices for low latency and high efficiency.
[0043] 3. Device configuration parameters and communication protocol templates are stored separately and support XML or JSON formats, which makes configuration management more modular and user-friendly. Users or administrators can easily adjust device parameters or protocol formats by modifying configuration files without recompiling or deploying the entire system. This design reduces system coupling, facilitates subsequent upgrades and customization, and is particularly suitable for heterogeneous environments with multiple devices and protocols, improving the scalability and maintainability of the technology.
[0044] 4. By introducing a type-aware formatting mechanism, static parameters and dynamic business data are formatted according to the parameter data type (such as binary or hexadecimal) before placeholders are injected during the pre-compilation and runtime phases. This avoids common data type mismatch errors in traditional protocol generation, such as integer overflow or string encoding problems, thereby improving the accuracy and interoperability of communication messages, helping to reduce debugging time, and enhancing the reliability of the system in critical applications such as industrial control.
[0045] 5. By adding checksums to communication messages through the integrity verification engine, the robustness of data transmission is enhanced. The verification mechanism can detect and correct errors in the message during transmission, prevent data corruption or loss, comply with the security standards of the communication protocol, and is particularly suitable for scenarios with harsh network environments or high reliability requirements (such as autonomous driving or medical equipment), reducing the risk of communication failure and improving the overall system stability.
[0046] 6. It adopts a clear modular structure, such as a pre-compilation engine, runtime adapter, and template optimization cache, which makes the responsibilities of each component clear and facilitates independent testing and optimization; the caching mechanism reduces redundant calculations, while the modular design supports pluggable expansion, such as easy integration of new protocol templates or data types; this resource optimization not only reduces hardware costs but also improves the reusability of the system, making it suitable for resource-constrained environments such as cloud computing or edge computing.
[0047] 7. By separating storage device configuration parameters and communication protocol templates, the pre-compilation engine injects static parameters into the template and caches pre-compiled instances during system initialization, significantly improving the efficiency and performance of protocol generation and reducing runtime overhead. Meanwhile, the use of XML or JSON format in configuration files enhances system flexibility and maintainability, while the type-aware formatting mechanism ensures type safety and correctness in data processing, avoiding common errors. Furthermore, the integrity verification engine improves communication reliability and data integrity, and the modular design optimizes resource utilization, making the technology more adaptable to multi-device scenarios and critical applications. Overall, this achieves efficient, reliable, and scalable communication protocol generation.
[0048] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for generating a pre-compiled device communication protocol, characterized in that: Includes the following steps: Step S1: Set device configuration parameters and communication protocol template, and store the device configuration parameters and communication protocol template separately; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format that includes static parameter placeholders and dynamic parameter placeholders; Step S2: During the system initialization phase, the pre-compilation engine is called to inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache. Step S3: During the system operation phase, the input service request is obtained, and the dynamic service data carried by the service request is injected into the dynamic parameter placeholder of the pre-compiled protocol instance through the runtime adapter to generate the final device communication protocol. Step S4: Generate a communication message based on the device communication protocol and send the communication message through the communication interface.
2. The method for generating a pre-compiled device communication protocol as described in claim 1, characterized in that: In step S1, the device configuration parameters and communication protocol template are stored in an XML or JSON configuration file.
3. The method for generating a pre-compiled device communication protocol as described in claim 1, characterized in that: In step S2, the pre-compilation engine formats the corresponding static parameters into binary or hexadecimal data strings that conform to the communication protocol template according to the parameter data types defined in the device configuration parameters, and then injects them into the static parameter placeholders of the corresponding communication protocol template.
4. The method for generating a pre-compiled device communication protocol as described in claim 1, characterized in that: In step S3, the runtime adapter uses a type-aware formatting mechanism to format the dynamic business data into a binary data string or hexadecimal data string that conforms to the requirements of the communication protocol template, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
5. The method for generating a pre-compiled device communication protocol as described in claim 1, characterized in that: Step S4 specifically involves: A communication message is generated based on the device communication protocol, a checksum is calculated and added to the communication message by an integrity verification engine, and then the communication message is sent through the communication interface.
6. A device communication protocol generation system based on pre-compiled protocols, characterized in that: Includes the following modules: An initialization module is used to set device configuration parameters and communication protocol templates, and to store the device configuration parameters and communication protocol templates separately; the device configuration parameters include static parameters and parameter data types; the communication protocol template defines a message format that includes static parameter placeholders and dynamic parameter placeholders; The pre-compiled protocol instance generation module is used to call the pre-compilation engine during the system initialization phase, inject the static parameters in the device configuration parameters into the static parameter placeholders of the corresponding communication protocol template, generate a pre-compiled protocol instance, and store the pre-compiled protocol instance in the template optimization cache. The device communication protocol generation module is used to obtain input service requests during system operation, inject the dynamic service data carried by the service requests into the dynamic parameter placeholders of the pre-compiled protocol instance through the runtime adapter, and generate the final device communication protocol. The communication message sending module is used to generate communication messages based on the device communication protocol and send the communication messages through the communication interface.
7. The device communication protocol generation system based on pre-compiled technology as described in claim 6, characterized in that: In the initialization module, the device configuration parameters and communication protocol templates are stored in configuration files in XML or JSON format.
8. The device communication protocol generation system based on pre-compiled technology as described in claim 6, characterized in that: In the pre-compiled protocol instance generation module, the pre-compilation engine formats the corresponding static parameters into binary or hexadecimal data strings that conform to the communication protocol template according to the parameter data types defined in the device configuration parameters, and then injects them into the static parameter placeholders of the corresponding communication protocol template.
9. The device communication protocol generation system based on pre-compiled technology as described in claim 6, characterized in that: In the device communication protocol generation module, the runtime adapter uses a type-aware formatting mechanism to format the dynamic business data into a binary data string or hexadecimal data string that conforms to the requirements of the communication protocol template, and then injects it into the dynamic parameter placeholder of the pre-compiled protocol instance.
10. The device communication protocol generation system based on pre-compiled technology as described in claim 6, characterized in that: The communication message sending module is specifically used for: A communication message is generated based on the device communication protocol, a checksum is calculated and added to the communication message by an integrity verification engine, and then the communication message is sent through the communication interface.