Communication method and system based on conventional communication protocol and QT

By using the QVariant type and a generic container structure in the communication protocol, the data type extension and compatibility issues in existing technologies are resolved, achieving high efficiency and stability in data transmission.

CN121547503APending Publication Date: 2026-02-17QINGLAN JICHUANG MEDICAL EQUIP (CHENGDU) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202610081108.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-21
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing technologies cannot flexibly extend and be compatible with non-standard data types in communication protocols, resulting in low data transmission efficiency and poor stability.

Method used

Using the QVariant type as the data abstraction layer, combined with a general container type, and through the data structure of identifier field and byte stream field, it achieves seamless data type transfer and parsing, and supports data types not registered in the QT system.

Benefits of technology

It improves the flexibility and compatibility of data transmission, reduces encoding and decoding complexity, and ensures data integrity and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121547503A_ABST
    Figure CN121547503A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and system based on a conventional communication protocol and QT, which are applied to the technical field of intelligent communication, and the method comprises the following steps: a sending end obtains the data type of target data content needing to be sent; when the data type accords with the type supported by the QT, the sending end converts the data type of the target data content into a Qvariant type, adds a command word and packages the data into a data segment of a conventional communication protocol for sending; and when the data type does not accord with the type supported by the QT, the sending end converts the data type of the target data content into a general container type, then converts the general container type into a Qvariant type, adds a command word, and packages the data into a data segment of a conventional communication protocol for sending. According to the method, the encoding and decoding difficulty caused by numerous and jumbled data types can be effectively reduced; and meanwhile, the method also has good compatibility for self-defined data types, and has excellent convenience and expandability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent communication technology, and specifically to a communication method and system based on conventional communication protocols and QT. Background Technology

[0002] A typical conventional communication protocol includes: a start character (0xAA55) indicating the frame start address; a command (1) indicating the operation command code; a data length (1) indicating the length of the subsequent data fields (0~255); a data length indicating the actual transmitted data content checksum (CRC); and a CRC16 checksum for the entire frame content (excluding the start character). When new protocol content needs to be added, a new command word is added, and the encoding / decoding method for the data following the command word is agreed upon. The process of adding new command words is relatively complicated due to the different data content and encoding / decoding methods required, necessitating the addition of encoding and decoding code at both ends of the communication each time.

[0003] In the prior art, Chinese Patent Application No. CN202411453121.1 discloses a method for implementing a serialized and extensible control system communication protocol based on Qt. This method includes the following: using a general message structure, which comprises a message header and a message body. The message header consists of a frame header, timestamp, frame sequence number, message body length, number of data segments, message body CRC checksum, and reserved fields; serializing the message header and message body, and concatenating the serialized message header and message body into a QByteArray type message data; and efficient deserialization processing, which includes parsing the message header data, receiving the message body data, and deserializing the data segments. This invention, by introducing a general message structure, can be flexibly applied to communication between various control systems, improving the flexibility and versatility of the communication protocol; and by employing efficient serialization and parsing methods, it effectively improves data transmission efficiency and communication stability. However, because it uses QByteArray type message data, and this message data is formed by concatenating the message header and message body, it results in the inability to accurately reconstruct the received data and also prevents compatibility and extensibility. Summary of the Invention

[0004] In order to at least overcome the above-mentioned shortcomings in the prior art, the purpose of this application is to provide a communication method and system based on conventional communication protocols and QT.

[0005] In a first aspect, embodiments of this application provide a communication method based on conventional communication protocols and QT, including:

[0006] The sending end obtains the data type of the target data content to be sent;

[0007] When the data type conforms to the types supported by QT, the sending end converts the data type of the target data content to the Qvariant type, adds a command word, encapsulates it into a data segment of the regular communication protocol, and sends it.

[0008] When the data type does not conform to the types supported by QT, the sending end converts the data type of the target data content into a general container type, then into a Qvariant type, adds a command word, and encapsulates it into a data segment of a regular communication protocol for transmission; the general container type is a data type that is pre-registered in the QT object system.

[0009] In one possible implementation, the data structure of the general container type includes an identifier field and a byte stream field;

[0010] Converting the data type of the target data content to a generic container type includes:

[0011] The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

[0012] One possible implementation also includes:

[0013] When the receiving end receives a data packet sent via a conventional communication protocol, it reads the data segment of the conventional communication protocol into a Qvariant type to form the restored data content;

[0014] When the restored data content contains an identifier field, the receiving end extracts the identifier from the identifier field and calls the corresponding deserialization function to parse the byte stream of the byte stream field based on the identifier;

[0015] If the receiving end cannot identify the deserialization function corresponding to the identifier locally, it requests the deserialization function corresponding to the identifier from the server, and stores the deserialization function locally and parses the byte stream upon receiving the deserialization function.

[0016] In one possible implementation, the pre-registration of the general container type includes:

[0017] An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field;

[0018] The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

[0019] One possible implementation also includes:

[0020] When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

[0021] Secondly, embodiments of this application also provide a communication system based on conventional communication protocols and QT, including:

[0022] Sending end;

[0023] The sending end is configured as follows:

[0024] Obtain the data type of the target data content to be sent;

[0025] When the data type conforms to the types supported by QT, the data type of the target data content is converted to the Qvariant type, and after adding the command word, it is encapsulated into the data segment of the regular communication protocol and sent.

[0026] When the data type does not conform to the types supported by QT, the data type of the target data content is converted to a general container type, then converted to a Qvariant type, and then encapsulated into a data segment of a regular communication protocol after adding a command word before being sent; the general container type is a data type that is pre-registered in the QT object system.

[0027] In one possible implementation, the data structure of the general container type includes an identifier field and a byte stream field;

[0028] The sending end is also configured to:

[0029] The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

[0030] One possible implementation also includes:

[0031] Receiver;

[0032] The receiver is configured as follows:

[0033] When a data packet sent via a conventional communication protocol is received, the data segment of the conventional communication protocol is read into a Qvariant type to form the restored data content;

[0034] When the restored data content contains an identifier field, the identifier in the identifier field is extracted, and the corresponding deserialization function is called to parse the byte stream of the byte stream field based on the identifier;

[0035] If a deserialization function corresponding to the identifier cannot be identified locally, a request for a deserialization function corresponding to the identifier is made to the server, and upon receiving the deserialization function, the deserialization function is stored locally and parsed as a byte stream.

[0036] One possible implementation also includes:

[0037] Registration end;

[0038] The registration terminal is configured as follows:

[0039] An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field;

[0040] The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

[0041] One possible implementation also includes:

[0042] server;

[0043] The server is configured as follows:

[0044] When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

[0045] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0046] This invention discloses a communication method and system based on conventional communication protocols and QT. It utilizes QT's QVariant and meta-object system as a unified data abstraction layer, and achieves seamless transmission of complex and unknown data types in conventional communication protocol transmission through a predefined general container structure. It can effectively reduce the encoding and decoding difficulties caused by a wide variety of data types. At the same time, it has good compatibility with user-defined data types, and has excellent convenience and scalability. Attached Figure Description

[0047] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:

[0048] Figure 1 This is a schematic diagram of the method steps in an embodiment of this application. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0050] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0051] Please refer to the following: Figure 1 This is a flowchart illustrating a communication method based on a conventional communication protocol and QT provided in an embodiment of the present invention. Further, the communication method based on a conventional communication protocol and QT may specifically include the content described in steps S1-S3.

[0052] S1: The sending end obtains the data type of the target data content to be sent;

[0053] S2: When the data type conforms to the type supported by QT, the sending end converts the data type of the target data content to the Qvariant type, adds the command word, encapsulates it into the data segment of the regular communication protocol, and sends it.

[0054] S3: When the data type does not conform to the types supported by QT, the sending end converts the data type of the target data content into a general container type, then into a Qvariant type, adds a command word, and encapsulates it into a data segment of a regular communication protocol for transmission; the general container type is a data type that is pre-registered in the QT object system.

[0055] In existing technologies, although QByteArray type data is used to construct data segments, QByteArray type data only represents a continuous sequence of raw bytes and does not contain any metadata about how these bytes should be interpreted. Therefore, parsing still requires deserialization functions corresponding to different data types. In this embodiment, however, the data type of the target data content is first identified, and data types supported by the QT system are directly encapsulated into Qvariant type. Qvariant type data can encapsulate multiple different types of data while retaining the data type ID, thus facilitating data extraction and identification at the receiving end. This eliminates the need to consider the data type being transmitted.

[0056] For example, when carrying an array of string data, the Qvariant type data has the following format:

[0057] QStringList list;

[0058] list << info.fileName(); / / Add filenames

[0059] list << md5.toHex(); / / Add MD5 checksum of the file

[0060] list << QString::number(senddata.size()); / / Add the size of the data to be sent

[0061] list << QString::number(id); / / Add file ID

[0062] TCPSER_API.SendCMDToAll(RPCCMD_file_start, list);

[0063] When carrying an integer (int), the Qvariant type data has the following format:

[0064] TCPSER_API.SendCMDToIP(widget->IP(),RPCCMD_Get_Version,0);

[0065] As can be seen, Qvariant data types can be well adapted to different types of data, and can be directly compiled and sent using Qvariant data types. At the receiving end, only deserialization of Qvariant data types is needed to obtain the data content, without the need to configure additional deserialization functions for each data type.

[0066] In this application embodiment, the inventors discovered that in actual use, some manufacturers' sensors and other devices may use non-standard data formats, which cannot be included in the data types supported by the QT system. Therefore, this application embodiment requires corresponding processing for such data. Specifically, a general container type is registered in the QT system beforehand. This general container type can be encoded using Qvariant type data. The non-standard data format content is directly encapsulated within the general container, then converted to Qvariant type encoding before being sent. When the receiving end receives this data, it can use the Qvariant type deserialization function to parse the content in the general container, and then use the deserialization function of the non-standard data type for further parsing to obtain the data. The advantage of this operation is that the sending end does not need to care about the specific deserialization method of these data types; it only needs to directly convert the standard data type to the Qvariant type and encapsulate the non-standard data type into the general container to send the data. The receiving end only needs to use the same deserialization function to obtain the data for standard data types, and can call the corresponding deserialization function for further parsing for non-standard data types. Since all data types will eventually be converted to Qvariant, and Qvariant is a self-describing type container, with each data unit carrying its own runtime type information, there will be no misreading of data of different types due to offset resolution, thus ensuring data integrity.

[0067] In one possible implementation, the data structure of the general container type includes an identifier field and a byte stream field;

[0068] Converting the data type of the target data content to a generic container type includes:

[0069] The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

[0070] In the implementation of this application, the general container type needs to include two parts when constructing its data structure: an identifier field and a byte stream field. For the Qvariant type, the data type it identifies only represents the data type of the data within the Qvariant type. When converting the general container type to the Qvariant type, the Qvariant type only identifies that these data correspond to the general container type, without further indicating what kind of data is within the general container type. Therefore, an identifier field needs to be added to the data structure of the general container type to express what type of data is within the general container type. When encapsulating the target data content into the general container, the target data content needs to be serialized into a byte stream using the sequence function corresponding to the data type of the target data content. Then, the byte stream field is filled in, and the identifier is added to complete the data type conversion.

[0071] One possible implementation also includes:

[0072] When the receiving end receives a data packet sent via a conventional communication protocol, it reads the data segment of the conventional communication protocol into a Qvariant type to form the restored data content;

[0073] When the restored data content contains an identifier field, the receiving end extracts the identifier from the identifier field and calls the corresponding deserialization function to parse the byte stream of the byte stream field based on the identifier;

[0074] If the receiving end cannot identify the deserialization function corresponding to the identifier locally, it requests the deserialization function corresponding to the identifier from the server, and stores the deserialization function locally and parses the byte stream upon receiving the deserialization function.

[0075] In the implementation of this application embodiment, when the receiving end receives a data packet sent by a conventional communication protocol, the data segments can be parsed and restored using a deserialization function of the Qvariant type to form restored data content. If the restored data content does not contain an identifier field, it indicates that the restored data content is directly usable and its content has already been parsed. If the restored data content contains an identifier field, it indicates that this data is encapsulated in a general container. In this case, the corresponding deserialization function needs to be called for further parsing. It should be understood that the presence of an identifier field in the restored data content can be used as a way to determine whether the restored data content is data in a general container. Those skilled in the art can also use other methods to determine whether the restored data content is data in a general container, such as using the type ID in the Qvariant type. All of these should be considered equivalent to the embodiments of this application.

[0076] In this embodiment, when a device accesses the system, it generally needs to register with the server; otherwise, it cannot access the system. The registration information needs to include the data types used for various data transmissions. If there are non-standard data types, i.e., those not supported by QT, deserialization functions for these data types need to be provided and stored on the server. When the receiving end receives this non-standard data, it needs to parse it using the deserialization function. If the receiving end does not store the corresponding deserialization function locally, it can request the corresponding deserialization function from the server and store it locally. In this process, the deserialization functions that the receiving end needs to store locally only need to correspond to Qvariant types and non-standard data, resulting in a very small data volume.

[0077] In one possible implementation, the pre-registration of the general container type includes:

[0078] An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field;

[0079] The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

[0080] When implementing the embodiments of this application, it is necessary to pre-register the general container type in the QT system. This requires first creating a suitable intermediate structure, and then declaring and registering it in the QT system.

[0081] One possible implementation also includes:

[0082] When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

[0083] For example, this application provides a specific use case. First, pre-registration of the general container type is required. The general container structure `ExtDataContainer` is defined in the shared header file `protocol.h`, including an identifier field and a byte stream field. Then, it is declared using the QT macro `Q_DECLARE_METATYPE(ExtDataContainer)`. In the initialization function, `qRegisterMetaType` is called to complete runtime registration. When the sending end sends data of a type not supported by QT, a custom structure `FileInfo{QString name; QString md5;qint64 size;}` is added to the shared header file, and a type ID of 0x8001 is assigned. The `FileInfo` object is then converted to a byte stream and placed into the byte stream field of `ExtDataContainer`, with 0x8001 placed in the identifier field. `SendCMDToIP(deviceIP,RPCCMD_FileInfo, QVariant::fromValue(container))` is called to send the data. The receiving end reconstructs the first-layer protocol from the TCP stream, and after verifying the CRC, extracts the second-layer QVariant data, calling `QVariant::canConvert`. <extdatacontainer>() Determines whether it is an extended type, where typeId=0x8001 is identified, and the corresponding deserialization function is searched in the local preset type registry for restoration.

[0084] Based on the same inventive concept, embodiments of this application also provide a communication system based on conventional communication protocols and QT, including:

[0085] Sending end;

[0086] The sending end is configured as follows:

[0087] Obtain the data type of the target data content to be sent;

[0088] When the data type conforms to the types supported by QT, the data type of the target data content is converted to the Qvariant type, and after adding the command word, it is encapsulated into the data segment of the regular communication protocol and sent.

[0089] When the data type does not conform to the types supported by QT, the data type of the target data content is converted to a general container type, then converted to a Qvariant type, and then encapsulated into a data segment of a regular communication protocol after adding a command word before being sent; the general container type is a data type that is pre-registered in the QT object system.

[0090] In one possible implementation, the data structure of the general container type includes an identifier field and a byte stream field;

[0091] The sending end is also configured to:

[0092] The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

[0093] One possible implementation also includes:

[0094] Receiver;

[0095] The receiver is configured as follows:

[0096] When a data packet sent via a conventional communication protocol is received, the data segment of the conventional communication protocol is read into a Qvariant type to form the restored data content;

[0097] When the restored data content contains an identifier field, the identifier in the identifier field is extracted, and the corresponding deserialization function is called to parse the byte stream of the byte stream field based on the identifier;

[0098] If a deserialization function corresponding to the identifier cannot be identified locally, a request for a deserialization function corresponding to the identifier is made to the server, and upon receiving the deserialization function, the deserialization function is stored locally and parsed as a byte stream.

[0099] One possible implementation also includes:

[0100] Registration end;

[0101] The registration terminal is configured as follows:

[0102] An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field;

[0103] The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

[0104] One possible implementation also includes:

[0105] server;

[0106] The server is configured as follows:

[0107] When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

[0108] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0109] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.

[0110] The units described as separate components may or may not be physically separate. As will be apparent to those skilled in the art, the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0111] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0112] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or grid device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0113] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / extdatacontainer>

Claims

1. A communication method based on conventional communication protocols and QT, characterized in that, include: The sending end obtains the data type of the target data content to be sent; When the data type conforms to the types supported by QT, the sending end converts the data type of the target data content to the Qvariant type, adds a command word, encapsulates it into a data segment of the regular communication protocol, and sends it. When the data type does not conform to the types supported by QT, the sending end converts the data type of the target data content into a general container type, then into a Qvariant type, adds a command word, and encapsulates it into a data segment of a regular communication protocol for transmission; the general container type is a data type that is pre-registered in the QT object system.

2. The communication method based on conventional communication protocols and QT according to claim 1, characterized in that, The data structure of the general container type includes an identifier field and a byte stream field; Converting the data type of the target data content to a generic container type includes: The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

3. The communication method based on conventional communication protocols and QT according to claim 2, characterized in that, Also includes: When the receiving end receives a data packet sent via a conventional communication protocol, it reads the data segment of the conventional communication protocol into a Qvariant type to form the restored data content; When the restored data content contains an identifier field, the receiving end extracts the identifier from the identifier field and calls the corresponding deserialization function to parse the byte stream of the byte stream field based on the identifier; If the receiving end cannot identify the deserialization function corresponding to the identifier locally, it requests the deserialization function corresponding to the identifier from the server, and stores the deserialization function locally and parses the byte stream upon receiving the deserialization function.

4. The communication method based on conventional communication protocols and QT according to claim 1, characterized in that, The pre-registration of the general container type includes: An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field; The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

5. The communication method based on conventional communication protocols and QT according to claim 1, characterized in that, Also includes: When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

6. A communication system based on conventional communication protocols and QT, characterized in that, include: Sending end; The sending end is configured as follows: Obtain the data type of the target data content to be sent; When the data type conforms to the types supported by QT, the data type of the target data content is converted to the Qvariant type, and after adding the command word, it is encapsulated into the data segment of the regular communication protocol and sent. When the data type does not conform to the types supported by QT, the data type of the target data content is converted to a general container type, then converted to a Qvariant type, and then encapsulated into a data segment of a regular communication protocol after adding a command word before being sent; the general container type is a data type that is pre-registered in the QT object system.

7. A communication system based on conventional communication protocols and QT according to claim 6, characterized in that, The data structure of the general container type includes an identifier field and a byte stream field; The sending end is also configured to: The target data content is serialized into a byte stream and filled into the byte stream field, and the identifier corresponding to the data type of the target data content is filled into the identifier field.

8. A communication system based on conventional communication protocols and QT according to claim 7, characterized in that, Also includes: Receiver; The receiving end is configured as follows: When a data packet sent via a conventional communication protocol is received, the data segment of the conventional communication protocol is read into a Qvariant type to form the restored data content; When the restored data content contains an identifier field, the identifier in the identifier field is extracted, and the corresponding deserialization function is called to parse the byte stream of the byte stream field based on the identifier; If a deserialization function corresponding to the identifier cannot be identified locally, a request for a deserialization function corresponding to the identifier is made to the server, and upon receiving the deserialization function, the deserialization function is stored locally and parsed as a byte stream.

9. A communication system based on conventional communication protocols and QT according to claim 6, characterized in that, Also includes: Registration end; The registration terminal is configured as follows: An intermediate structure is created as a general container; the intermediate structure includes an identifier field and a byte stream field; The intermediate structure is declared in the QT object system using a dedicated declaration macro, and then registered in the QT object system using QT's registration function.

10. A communication system based on a conventional communication protocol and QT according to claim 6, characterized in that, Also includes: server; The server is configured as follows: When data content corresponding to a data type that is not supported by QT and is not registered on the server needs to be transmitted, register the identifier of that data type and the corresponding deserialization function on the server.

Citation Information

Patent Citations

  • Multi-type protocol message processing system and method and readable storage medium

    CN115633102A

  • Method for realizing two-way communication in process of calling Python module by C + +

    CN118259900A

  • Simulation data exchange method and system based on dynamic reflection mechanism

    CN118426990A

  • Implementation method of serialized extensible control system communication protocol based on Qt

    CN119363840A

  • Robot operation log visualization method based on QChart component of QT platform

    CN119883842A