WO2020232707A1 - 分布式系统中通信协议版本号的更新 - Google Patents

分布式系统中通信协议版本号的更新 Download PDF

Info

Publication number
WO2020232707A1
WO2020232707A1 PCT/CN2019/088172 CN2019088172W WO2020232707A1 WO 2020232707 A1 WO2020232707 A1 WO 2020232707A1 CN 2019088172 W CN2019088172 W CN 2019088172W WO 2020232707 A1 WO2020232707 A1 WO 2020232707A1
Authority
WO
WIPO (PCT)
Prior art keywords
communication protocol
grammatical
information
data structure
text message
Prior art date
Application number
PCT/CN2019/088172
Other languages
English (en)
French (fr)
Inventor
曾健荣
王斌
周青松
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201980008482.6A priority Critical patent/CN111684766A/zh
Priority to PCT/CN2019/088172 priority patent/WO2020232707A1/zh
Publication of WO2020232707A1 publication Critical patent/WO2020232707A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/18Protocol analysers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD

Definitions

  • the present invention generally relates to the field of control technology of a distributed system, and more specifically relates to an update of a communication protocol version number in a distributed system.
  • a distributed system is a software system built on a network, which usually includes multiple modules, and these modules communicate with each other through the network using a certain communication protocol. In order to ensure the accuracy of communication, the communication protocol adopted by each module should be consistent.
  • a method for updating the version number of a communication protocol in a distributed system includes a plurality of modules, and the plurality of modules communicate with each other through a preset communication protocol, and the method includes : Generate respective syntax structure representations of the code version before modification and the modified code version, which are respectively defined as the first syntax structure representation and the second syntax structure representation; obtain the first syntax structure representation and the second syntax structure representation
  • the respective communication protocol data structures in each are defined as a first communication data structure and a second communication data structure; a first text message is generated based on all the grammatical information of the first communication data structure, and based on the second communication data structure Generate a second text message from all the grammatical information; calculate the respective unique identifiers of the first text message and the second text message, and define them as the first unique identifier and the second unique identifier, respectively; and compare the first A unique identifier and the second unique
  • the respective communication protocol data structures in the code version before modification and the code version after modification are generated based on a preset structure, and the preset structure conforms to the preset naming specification.
  • said acquiring the respective communication protocol data structures in the first syntax structure representation and the second syntax structure representation includes: parsing the first syntax structure representation and the second syntax structure representation The structure representation is used to search for a data structure conforming to the preset naming specification; and to obtain the data type of the first member of the data structure conforming to the preset naming specification to obtain the communication protocol data structure.
  • said generating the respective syntax structure representations of the code version before modification and the code version after modification includes: generating respective abstract syntax trees of the code version before modification and the code version after modification.
  • the generating a first text message based on all the grammatical information of the first communication data structure and generating a second text message based on all the grammatical information of the second communication data structure includes: Combine all the grammatical information of the first communication data structure into a first character string, and combine all the grammatical information of the second communication data structure into a second character string.
  • all the grammatical information includes self information and sub-member information of the communication data structure.
  • the self information includes domain name information, data structure type information, and occupation size information.
  • the sub-member information includes sub-member name information, basic data type information, structure/enumeration/union/definition type expansion information, and occupation size information.
  • said calculating the respective unique identifiers of the first text message and the second text message includes: calculating the respective messages of the first text message and the second text message Summary value.
  • the method is implemented based on a hook script of distributed version control software.
  • an automatic driving system includes a plurality of modules, and the plurality of modules communicate through a preset communication protocol, and the automatic driving system adopts any of the above
  • the distributed system updates the version number of the communication protocol to update the version number of the preset communication protocol.
  • a vehicle including the above-mentioned automatic driving system.
  • an unmanned aerial vehicle including the aforementioned automatic driving system.
  • a computing device includes a plurality of modules, and the plurality of modules communicate with each other through a preset communication protocol.
  • the computing device adopts any of the foregoing
  • the distributed system updates the version number of the communication protocol to update the version number of the preset communication protocol.
  • a storage medium with a computer program stored on the storage medium, and the computer program executes the method for updating a communication protocol version number of a distributed system according to any one of the above items during operation.
  • the method for updating the communication protocol version number of the distributed system generates a syntax structure representation for the code version before and after the modification, obtains the communication protocol data structure from the generated syntax structure representation, and compares the uniqueness of the communication protocol data structure To determine whether the communication protocol has changed. If there is a change, the communication protocol version number will be automatically updated. This greatly improves the reliability of the distributed system when the communication protocol changes and the efficiency of updating the communication protocol version number. This effectively solves the problem of manual methods. Problems that are easy to miss and inefficiency.
  • FIG. 1 shows a schematic flowchart of a method for updating a communication protocol version number in a distributed system according to an embodiment of the present invention
  • Figure 2 shows a more specific flow chart of a method for a distributed system to update a communication protocol version number according to an embodiment of the present invention
  • FIG. 3 shows a schematic structural block diagram of an example computing device that adopts a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention
  • Fig. 4 shows a schematic structural block diagram of an example automatic driving system that adopts a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention
  • Fig. 5 shows a schematic structural block diagram of an example drone using a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention.
  • the present invention provides a solution for updating the version number of a communication protocol in a distributed system.
  • the solution for updating the version number of a communication protocol in a distributed system according to an embodiment of the present invention is described below with reference to the accompanying drawings.
  • Fig. 1 shows a schematic flowchart of a method 100 for updating a communication protocol version number in a distributed system according to an embodiment of the present invention.
  • the method 100 for updating the version number of a communication protocol in a distributed system may include the following steps:
  • step S110 the respective grammatical structure representations of the code version before modification and the modified code version are generated, which are respectively defined as the first grammatical structure representation and the second grammatical structure representation.
  • the method shown in FIG. 1 can be used in a distributed system including multiple modules to automatically update the preset communication protocol version used in the communication between these modules.
  • the communication protocol may change when the code version is modified. Therefore, it is possible to determine whether the communication protocol has changed by comparing the respective communication protocol data structures in the code version before the modification and the code version after the modification.
  • the source code is directly analyzed to obtain the data structure of the communication protocol, not only the calculation amount is too large, but the accuracy is not high.
  • the respective grammatical structure representations such as abstract grammatical structure representations, may be generated for the code version before modification and the code version after modification, to be generated through analysis.
  • the grammatical structure is expressed to quickly obtain the data structure of the communication protocol in the code.
  • the syntax structure representation generated for the code version before modification may be defined as the first syntax structure representation
  • the syntax structure representation generated for the modified code version may be defined as the second syntax structure representation.
  • the first grammatical structure representation and the second grammatical structure representation are defined only for distinguishing each other, and have no other restrictive effects.
  • generating the respective syntax structure representations of the code version before modification and the code version after modification in step S110 may further include: generating abstract syntax trees (Abstract Syntax Trees) of the code version before modification and the code version after modification. , AST).
  • the syntax structure representations respectively generated for the code versions before and after the modification can be abstract syntax trees.
  • the abstract syntax tree generated for the code version before modification can be defined as the first abstract syntax tree
  • the abstract syntax tree generated for the code version before modification can be defined as the second abstract syntax tree.
  • the first abstract syntax tree and the second abstract syntax tree are defined only for distinguishing each other, and have no other restrictive effects.
  • abstract syntax tree (or syntax tree for short) is an abstract representation of the source code syntax structure. It expresses the grammatical structure of the programming language in a tree-like form, and each node on the tree represents a structure in the source code. Obtaining the respective communication protocol data structures in the code version before and after the modification based on the respective abstract syntax trees of the code version before and after the modification is not only efficient, but also highly reliable.
  • the CastXML tool can be used to generate the abstract syntax tree files of the respective code versions before and after the modification.
  • the CastXML tool can generate the structure organization relationship of the input code according to the grammar of C/C++, and describe the grammar tree in XML file format.
  • any other suitable method or tool may also be used to generate the respective abstract syntax tree files of the code versions before and after the modification.
  • step S120 the respective communication protocol data structures in the first grammatical structure representation and the second grammatical structure representation are acquired, which are defined as the first communication data structure and the second communication data structure, respectively.
  • the respective communication protocol data in the code versions before and after the modification can be obtained by parsing the generated abstract syntax tree file structure.
  • a preset structure conforming to the preset naming specification can be defined (for example, a macro is defined, The prefix can be communication_api), and the respective communication protocol data structures in the code versions before and after the modification are generated based on the preset structure. In this way, the communication protocol data structure can be identified in advance, so that the communication protocol data type can be found more efficiently from the abstract syntax number.
  • obtaining the respective communication protocol data structures in the first syntax structure representation and the second syntax structure representation in step S120 may further include: parsing the first syntax structure representation and the second syntax structure representation To search for a data structure that meets the preset naming specification; and obtain the data type of the first member of the data structure that meets the preset naming specification to obtain the communication protocol data structure.
  • the syntax structure representation file (such as an abstract syntax tree file) generated for each code version before and after the modification in step S110, and find a data structure that conforms to the preset naming specification, such as a structure with a prefix of communication_api , And then get the data type of the first member of these structures, that is, get the grammatical structure that represents the communication protocol data structure in the file.
  • the communication protocol data type obtained from the grammatical structure representation corresponding to the code version before modification can be defined as the first communication protocol data structure (may be referred to as the first communication data structure for short), and the modified
  • the communication protocol data type obtained in the syntax structure representation corresponding to the later code version is defined as the second communication protocol data structure (may be simply referred to as the second communication data structure).
  • the first communication data structure and the second communication data structure are defined only for distinguishing each other, and have no other limiting effect.
  • step S130 a first text message is generated based on all the grammatical information of the first communication data structure, and a second text message is generated based on all the grammatical information of the second communication data structure.
  • the unique identifiers of the respective communication protocol data structures in the code versions before and after the modification can be generated for determining the before and after modification based on the unique identifier. Whether the data structure of the communication protocol has changed.
  • the text message of the communication protocol data structure can be generated based on all the grammatical information of the communication protocol data structure, and the unique identifier of the communication protocol data structure can be generated based on the text message.
  • the text message may be a character string generated based on all the grammatical information of the communication protocol data structure, for example, all the grammatical information of the communication protocol data structure may be combined into a character string.
  • all the syntax information of the communication protocol data structure may include its own information and sub-member information of the communication data structure.
  • the self information may include domain name information (namespace name), data structure type (such as struct/union) information, and occupation size information.
  • the sub-member information may include sub-member name information, basic data type (such as int/char/float/long) information, structure/enumeration/union/definition type (typedef) expansion information and occupation size information.
  • the text information generated based on all the grammatical information of the communication protocol data type in the code version before modification can be defined as the first text information, and all the grammars based on the communication protocol data type in the modified code version
  • the text information generated by the information is defined as the second text information.
  • the first text information and the second text information are defined only for distinguishing each other, and have no other limiting effect.
  • step S140 the unique identifiers of the first text message and the second text message are calculated and defined as the first unique identifier and the second unique identifier, respectively.
  • the text message of the communication protocol data structure can be generated based on all the grammatical information of the communication protocol data structure, and the uniqueness of the communication protocol data structure can be generated based on the text message.
  • the unique identifier may be a message digest value (such as an MD5 value) of the text message. That is, the message digest value of the first text message can be calculated as the unique identifier of the communication protocol data type in the code version before modification, and the message digest value of the second text message can be calculated as the modified code The unique identifier of the communication protocol data type in the version.
  • the unique identifier of the first text information may be defined as the first unique identifier
  • the unique identifier of the second text information may be defined as the second unique identifier.
  • the first unique identifier and the second unique identifier are defined only for distinguishing each other, and have no other restrictive effect.
  • step S150 compare the first unique identifier and the second unique identifier, and update the version number of the preset communication protocol when the first unique identifier and the second unique identifier are different .
  • the communication before and after the modification can be determined by determining whether the unique identifiers of the respective communication protocol data structures in the code versions before and after the modification are the same. Whether the agreement has changed.
  • the unique identifiers of the respective communication protocol data structures in the code versions before and after the modification are the same, it indicates that the communication protocol has not changed before and after the modification; if the unique identifiers of the respective communication protocol data structures in the code versions before and after the modification are different, it indicates If the communication protocol changes before and after the modification, the version number of the communication protocol corresponding to the compared communication protocol data structure (such as the aforementioned preset communication protocol used for communication between the modules of the distributed system) can be updated. For example, you can change The version number of this communication protocol accumulates by 1. In this way, the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention is realized.
  • the method for updating the version number of the communication protocol in the distributed system described above may be implemented based on a hook script of distributed version control software (GIT).
  • GIT distributed version control software
  • the developer uses git commit to submit the code, and the GIT client automatically triggers the git post-commit script.
  • the post-commit script the above steps S110 to S150 can be implemented.
  • the code version before and after the submission the respective communication protocol data structure
  • the method for updating the communication protocol version number of the distributed system generates a syntax structure representation for the code version before and after the modification, obtains the communication protocol data structure from the generated syntax structure representation, and communicates by comparing The unique identification of the protocol data structure is used to determine whether the communication protocol has changed. If there is a change, the communication protocol version number will be automatically updated, which greatly improves the reliability of the distributed system to detect changes in the communication protocol and the efficiency of updating the communication protocol version number. The problem of easy omission and low efficiency in manual methods is solved.
  • Fig. 2 shows a more specific flow chart of a method for a distributed system to update a communication protocol version number according to an embodiment of the present invention.
  • the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention may include the following steps:
  • step S1 use git commit to submit the code to generate commit node a (that is, a code version), and the GIT client automatically triggers the git post-commit hook script.
  • GIT is a distributed version control software, originally created by Linus Torvalds, and released under GPL in 2005.
  • GIT can support a variety of hook scripts, triggered by some GIT commands, to complete user-defined automated operations.
  • step S1 The five steps after step S1 are divided into left and right branches.
  • the left branch is executed for the code version corresponding to commit node a
  • the right branch is executed for the code version before commit node a.
  • the left branch of these 5 steps is marked as S2A to S6A
  • the right branch is marked as S2B to S6B. It should be understood that the execution order of the left and right branches of each of the five steps may be in no particular order.
  • step S2A a C/C++ abstract syntax tree of the code version corresponding to the commit node a is generated.
  • step S2B a C/C++ abstract syntax tree of the code version before commit node a is generated.
  • AST In computer science, Abstract Syntax Tree (AST), or Syntax Tree for short, is an abstract representation of the syntax structure of source code. It expresses the grammatical structure of the programming language in a tree-like form, and each node on the tree represents a structure in the source code.
  • a common implementation tool is CastXML, which can generate the structure and organization relationship of the input code according to the grammar of C/C++, and describe the grammar tree in XML file format. After using the CastXML tool to generate the syntax tree file, you can parse this file to obtain the fully expanded string of the communication protocol data structure. The expanded string is used to calculate the MD5 value. When the MD5 value changes, it means that the communication protocol version number needs to be updated, as follows Will be described.
  • step S3A the syntax tree is parsed, and all data structures beginning with communication_api are found.
  • step S3B the syntax tree is parsed to find out all data structures beginning with communication_api.
  • step S4A the data types of the first members of these data structures are obtained, that is, all communication protocol data structures are obtained.
  • step S4B the data types of the first members of these data structures are obtained, that is, all communication protocol data structures are obtained.
  • the abstract syntax tree before and after submission is generated, and the communication protocol data structure is found according to the pre-defined identification of the communication protocol data structure.
  • the communication protocol data structure can be identified in the following ways: First, define the macro of the communication protocol declaration: #define COMM_API_EXPORT(type)struct communication_api##type ⁇ typea; ⁇ ; Then, in the definition of the communication protocol data structure Use COMM_API_EXPORT statement. Based on this, CastXML (or other tools) can be used to generate an abstract syntax tree and filter the structure in the syntax tree. When the name matches the beginning of communication_api, the first member type is obtained, which is the communication protocol data structure.
  • step S5A the syntax tree is parsed, the complete data structure of the data protocol is expanded, and a character string is generated.
  • step S5B the syntax tree is parsed, the complete data structure of the data protocol is expanded, and a character string is generated.
  • step S6A the summary information of the character string is calculated.
  • step S6B the summary information of the character string is calculated.
  • MD5 Message-Digest Algorithm
  • MD5 is a widely used cryptographic hash function that can generate a 128-bit (16-byte) hash value, which can be used to represent data digest information.
  • step S7 compare the MD5 values of all communication data structures before and after submission. If there is a change, update the version number of the corresponding communication data structure in step S8 (that is, add 1 to the version number of the communication protocol whose MD5 has changed), and in step S9 Use git commit--amend to append to commit a.
  • step S10 the post-commit hook script ends. For the communication data structure whose MD5 value has not changed, the version number of the corresponding communication protocol does not need to be updated, and the flow directly proceeds to step S10.
  • the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention has an automatic identification method of the data structure of the communication protocol: that is, based on the macro declaration and the abstract syntax tree, the script can be used to automatically identify and describe the communication protocol The data structure.
  • the method for updating the version number of the communication protocol in the distributed system according to the embodiment of the present invention can identify the change of the data structure: that is, based on the abstract syntax tree, all the grammatical information of a certain data structure (including the names and types of data structure members) can be obtained. Expansion, memory footprint, etc.), generate a string, and calculate the MD5 of the summary information. If the MD5 changes, it means that the data structure has changed.
  • the method for updating the version number of the communication protocol in the distributed system can realize the function of automatically updating and submitting the version number of the communication protocol through the post-commit and pre-push hook scripts of GIT.
  • the GIT-based method for automatically updating the communication protocol version can avoid the problems of labor cost, low efficiency, and high error probability caused by manual maintenance, and can be applied to the field of communication protocol consistency guarantee of the inter-process communication system.
  • the inter-process communication system refers to the communication system between software running on the computer (or embedded device).
  • the inter-process communication protocol refers to the negotiated communication information structure and definition between different processes.
  • the communication link can be various: such as network port, USB, serial port, etc.
  • the inter-process communication system contains a number of different program installation packages, and the communication protocol between each program needs to be consistent to ensure that the communication content can be correctly delivered and responded. Therefore, the method for updating the version number of the communication protocol in the distributed system according to the embodiment of the present invention can be applied to applications that require a large amount of inter-process communication (such as a robot system), which greatly improves the maintenance efficiency of the communication protocol and ensures the correctness of the communication.
  • the above exemplarily describes the method for updating the version number of the communication protocol in the distributed system according to the embodiment of the present invention.
  • the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention may be implemented in a distributed system, or may be implemented in any device, device, or system having a memory and a processor.
  • the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention can also be implemented in any inter-process communication system.
  • a computing device includes a plurality of modules, and the plurality of modules communicate through a preset communication protocol.
  • 2 describes the method for the distributed system to update the version number of the communication protocol to update the version number of the preset communication protocol.
  • the following describes a computing device using a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention with reference to FIG. 3.
  • FIG. 3 shows a schematic structural block diagram of an example computing device 300 that adopts a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention.
  • the computing device 300 includes multiple components (or called modules), including one or more processors 302, one or more storage devices 304, an input device 306, and an output device 308. These modules pass through a bus The system 310 and/or other forms of connection mechanisms (not shown) are interconnected. It should be noted that the components and structure of the computing device 300 shown in FIG. 3 are only exemplary and not restrictive, and the computing device may also have other components and structures as required.
  • the processor 302 may be a central processing unit (CPU) or another form of processing unit with data processing capability and/or instruction execution capability, and may control other components in the computing device 300 to perform desired functions.
  • CPU central processing unit
  • the processor 302 may be a central processing unit (CPU) or another form of processing unit with data processing capability and/or instruction execution capability, and may control other components in the computing device 300 to perform desired functions.
  • the storage device 304 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and/or nonvolatile memory.
  • the volatile memory may include random access memory (RAM) and/or cache memory (cache), for example.
  • the non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.
  • One or more computer program instructions can be stored on the computer-readable storage medium, and the processor 302 can run the program instructions to implement the update communication in the above-mentioned embodiment of the present invention (implemented by the processor).
  • the function of the protocol version number and/or other desired functions can also be stored in the computer-readable storage medium.
  • the input device 306 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, and a touch screen.
  • the output device 308 may output various information (for example, images or sounds) to the outside (for example, a user), and may include one or more of a display, a speaker, and the like.
  • the aforementioned components of the computing device 300 can communicate through a preset communication protocol, and use the aforementioned method of updating a communication protocol version number in a distributed system according to an embodiment of the present invention to automatically update the version number of the preset communication protocol.
  • the example computing device 300 that can adopt the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention can be implemented as a terminal such as a smart phone, a tablet computer, or any electronic device with computing capability.
  • a storage medium on which program instructions are stored, and when the program instructions are run by a computer or a processor, they are used to perform the distributed system update communication in the embodiments of the present invention.
  • the corresponding steps of the protocol version number method may include, for example, a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), USB memory, or any combination of the above storage media.
  • the computer-readable storage medium may be any combination of one or more computer-readable storage media.
  • an automatic driving system includes a plurality of modules, and the plurality of modules communicate with each other through a preset communication protocol.
  • the method for updating the version number of the communication protocol in the distributed system described in 1 and FIG. 2 updates the version number of the preset communication protocol.
  • FIG. 4 shows a schematic structural block diagram of an exemplary automatic driving system 400 that adopts a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention.
  • the automatic driving system 400 includes a vehicle position recognition module 410, a vehicle state recognition module 420, an external environment recognition module 430, a driving plan generation module 440, and a vehicle control module 450.
  • the vehicle position recognition module 410 is configured to recognize the position of the vehicle on the map.
  • the vehicle state recognition module 420 is configured to recognize the vehicle state of the vehicle.
  • the external environment recognition module 430 is configured to recognize the external environment of the vehicle.
  • the driving plan generation module 440 is configured to generate a driving plan based on the vehicle position recognized by the vehicle position recognition module 410, the vehicle state recognized by the vehicle state recognition module 420, and the external environment recognized by the external environment recognition module 430, which includes the automatic driving of the vehicle
  • the control target value of the control is configured to send instructions to the brakes of the vehicle based on the control target value of the travel plan generated by the travel plan generation module 440, thereby performing automatic driving control.
  • the automatic driving system 400 includes multiple modules, including a vehicle position recognition module 410, a vehicle state recognition module 420, an external environment recognition module 430, a driving plan generation module 440, and a vehicle control module 450, respectively.
  • the vehicle position recognition module 410, the vehicle state recognition module 420, and the external environment recognition module 430 all need to communicate with the travel plan generation module 440 (ie, transmit their recognition results to the travel plan generation module 440), and the travel plan generation module 440 needs to communicate with the vehicle control module 450 (that is, transmit the travel plan it generates to the vehicle control module 450). Therefore, these communications between these modules need to adopt a certain communication protocol, and the communication between these modules The agreement must be consistent to ensure the correct implementation of communication.
  • the automatic driving system 400 can use the method of updating the communication protocol version number according to the distributed system described above with reference to FIGS. 1 and 2 to detect whether the communication protocol between its modules has changed (whether it remains consistent), if If there is a change, it is automatically updated to properly maintain communication, thereby ensuring reliable and safe autonomous driving.
  • the automatic driving system 400 adopts the method of updating the communication protocol version number according to the distributed system described above with reference to FIG. 1 and FIG. 2 for the vehicle position recognition module 410, the vehicle state recognition module 420, the external environment recognition module 430, and the driving plan.
  • the process of detecting the consistency of the communication protocol between the generating module 440 and the vehicle control module 450, and updating the version number of the communication protocol when a change in the communication protocol is detected.
  • the vehicle position recognition module 410, the vehicle state recognition module 420, and the external environment recognition module 430 all need to communicate with the travel plan generation module 440 (ie, transmit their recognition results to the travel plan generation module 440)
  • the driving plan generation module 440 needs to communicate with the vehicle control module 450 (that is, transmit the generated driving plan to the vehicle control module 450), the vehicle position recognition module 410, the vehicle state recognition module 420, the external environment recognition module 430 and the vehicle
  • the control module 450 can respectively communicate with the driving plan generation module 440 using the same communication protocol.
  • the code that implements the vehicle position recognition module 410 is defined as the vehicle location recognition code
  • the code that implements the vehicle state recognition module 420 is defined as the vehicle state recognition code
  • the code that implements the external environment recognition module 430 is defined as the external environment recognition code
  • the realization of the driving plan generation module 440 is defined as the driving plan generation code
  • the realization of the vehicle control module 450 is defined as the vehicle control code.
  • the same structure conforming to the preset naming specification is used to define the communication protocol data structure (for example, the aforementioned data structure starting with communication_api). Based on this, it is possible to detect whether the data structure of the communication protocol has changed after implementing the modification of the code version of each of the aforementioned five modules.
  • the syntax structure representations (such as abstract syntax trees) of the code version and the code version before the code version can be generated based on the hook script of the distributed version control software, which are defined as The first grammatical structure representation and the second grammatical structure representation; then the respective communication protocol data structures in the first grammatical structure representation and the second grammatical structure representation are obtained (for example, the first grammatical structure representation and the first grammatical structure representation are parsed
  • the two grammatical structure means to find a data structure that meets the preset naming specification, and then obtain the data type of the first member of the data structure that meets the preset naming specification to obtain the communication protocol data structure), respectively defined as A first communication data structure and a second communication data structure; then a first text message is generated based on all the grammatical information of the first communication data structure, and a second text message is generated based on all the grammatical information of the second communication data structure ( For example, combine all the gram
  • the code version is compared with the code version before the code version, the MD5 value of the string formed by all the information of the respective communication protocol data structure is not equal, It means that the communication protocol data structure has changed compared with the code version before the code version, and the communication protocol version number corresponding to the communication protocol data structure should be modified (for example, the version number is accumulated by 1). If the code version is compared with the code version before the code version, the MD5 value of the string formed by all the information of the respective communication protocol data structure is equal, then the code version is compared with the code version before the code version If the communication protocol data structure has not changed, there is no need to modify the communication protocol version number corresponding to the communication protocol data structure.
  • the above methods can be used to detect whether the communication protocol data structure has changed, and the above methods can be used automatically when changes are made. Update the communication protocol version number.
  • the above exemplarily describes the automatic driving system and the automatic updating method of the communication protocol version number between its various modules according to the embodiments of the present invention. It should be understood that the automatic driving system shown in FIG. 4 is only exemplary. The driving system may also include any other required modules not shown, and the communication protocol between these modules may also be updated by using the method of updating the communication protocol version number of the distributed system according to the embodiment of the present invention.
  • the vehicle may include the automatic driving system described above, and the automatic driving system of the vehicle may update the communication protocol version number according to the distributed system of the embodiment of the present invention.
  • the communication protocol used for communication between its modules those skilled in the art can understand the method of updating the communication protocol in combination with the foregoing description. For the sake of brevity, it will not be repeated here.
  • an unmanned aerial vehicle may include a flight control system, the flight control system includes a plurality of modules, the plurality of modules through a preset communication protocol
  • the drone uses the method of updating the communication protocol version number of the distributed system described above with reference to FIG. 1 and FIG. 2 to update the version number of the preset communication protocol.
  • FIG. 5 shows a schematic structural block diagram of an example drone 500 that adopts a method for updating a communication protocol version number of a distributed system according to an embodiment of the present invention.
  • the UAV 500 includes a flight control system, and the flight control system includes a command signal receiving module 510, a sensor data processing module 520, and a control amount calculation module 530.
  • the instruction signal receiving module 510 is used to receive instructions from the remote controller (not shown) of the drone 500 and sensor signals from the sensors, and transmit the received sensor signals to the sensor data processing module 520, and The received command from the remote controller is transmitted to the control amount calculation module 530.
  • the sensor data processing module 520 is used to process and calculate the sensor signals to obtain position and posture information of the drone 500, for example, and transmit the position and posture information obtained by the processing to the control amount calculation module 530.
  • the control quantity calculation module 530 is configured to calculate the control quantity of the corresponding controller based on the instructions of the remote controller and the position and posture information, and output the control quantity to the driving mechanism.
  • the UAV 500 includes a flight control system, and the flight control system includes a plurality of modules, including a command signal receiving module 510, a sensor data processing module 520, and a control amount calculation module 530, respectively.
  • the instruction signal receiving module 510, the sensor data processing module 520, and the control amount calculation module 530 all need to communicate with each other. Therefore, these communications between these modules all need to adopt a certain communication protocol, and the communication protocol between these modules must be consistent to ensure the correct implementation of the communication.
  • the UAV 500 can use the method of updating the communication protocol version number according to the distributed system described above with reference to FIGS. 1 and 2 to detect whether the communication protocol between the various modules of its flight control system has changed (whether to maintain Consistent), if there is a change, it will be automatically updated to correctly maintain the communication, so as to achieve the correct and safe operation of the UAV.
  • the instruction signal receiving module 510, the sensor data processing module 520, and the control amount calculation module 530 all need to communicate with each other. Therefore, it is necessary to determine whether the communication protocol data structure in the codes that implement the instruction signal receiving module 510, the sensor data processing module 520, and the control amount calculation module 530 has changed in the modification of their respective code versions.
  • the code that implements the command signal receiving module 510 is defined as the command signal receiving code
  • the code that implements the sensor data processing module 520 is defined as the sensor data processing code
  • the control amount calculation module 530 is defined as the control amount calculation Code.
  • the same structure conforming to the preset naming specification is used to define the communication protocol data structure (for example, the aforementioned data structure starting with communication_api). Based on this, it is possible to detect whether the data structure of the communication protocol has changed after the code version of each of the aforementioned three modules is modified.
  • the syntax structure representations (such as abstract syntax trees) of the code version and the code version before the code version can be generated based on the hook script of the distributed version control software, which are defined as The first grammatical structure representation and the second grammatical structure representation; then the respective communication protocol data structures in the first grammatical structure representation and the second grammatical structure representation are obtained (for example, the first grammatical structure representation and the first grammatical structure representation are parsed
  • the two grammatical structure means to find a data structure that meets the preset naming specification, and then obtain the data type of the first member of the data structure that meets the preset naming specification to obtain the communication protocol data structure), respectively defined as A first communication data structure and a second communication data structure; then a first text message is generated based on all the grammatical information of the first communication data structure, and a second text message is generated based on all the grammatical information of the second communication data structure ( For example, combine all the gram
  • the code version is compared with the code version before the code version, the MD5 value of the string formed by all the information in the respective communication protocol data structure is not equal, It means that the communication protocol data structure has changed compared with the code version before the code version, and the communication protocol version number corresponding to the communication protocol data structure should be modified (for example, the version number is accumulated by 1). If the code version is compared with the code version before the code version, the MD5 value of the string formed by all the information of the respective communication protocol data structure is equal, then the code version is compared with the code version before the code version , The communication protocol data structure does not change, there is no need to modify the communication protocol version number corresponding to the communication protocol data structure.
  • the above method can be used to detect whether the communication protocol data structure has changed, and the above method is used to automatically update the communication protocol version number when it changes.
  • the above exemplarily describes the method for automatically updating the version number of the communication protocol between the UAV and its flight control system according to the embodiments of the present invention. It should be understood that the UAV and its flight shown in FIG. 5 The control system is only exemplary. The drone and its flight control system may also include any other modules that are not shown, and the communication protocol between these modules may also use the distributed system update communication according to the embodiment of the present invention. Method to update the protocol version number.
  • the above exemplarily describes the application scenario of the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention.
  • the method for updating the communication protocol version number of the distributed system according to the embodiment of the present invention and the device or system using it generates a syntax structure representation for the code version before and after the modification, and obtains communication from the generated syntax structure representation Protocol data structure, and by comparing the unique identification of the communication protocol data structure to determine whether the communication protocol has changed, if there is a change, the communication protocol version number is automatically updated, which greatly improves the reliability and update of the distributed system when the communication protocol changes.
  • the efficiency of the version number of the communication protocol effectively solves the problems of easy omission and low efficiency in manual methods.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another device, or some features can be ignored or not implemented.
  • the various component embodiments of the present invention may be implemented by hardware, or by software modules running on one or more processors, or by a combination of them.
  • a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some modules according to the embodiments of the present invention.
  • DSP digital signal processor
  • the present invention can also be implemented as a device program (for example, a computer program and a computer program product) for executing part or all of the methods described herein.
  • Such a program for realizing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals. Such signals can be downloaded from Internet websites, or provided on carrier signals, or provided in any other form.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)

Abstract

本发明提供一种分布式系统更新通信协议版本号的方法,该方法包括:生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一和第二语法结构表示;获取第一和第二语法结构表示中各自的通信协议数据结构,分别定义为第一和第二通信数据结构;基于第一和第二通信数据结构的所有语法信息分别生成第一和第二文本消息;计算第一和第二文本消息各自的唯一性标识,分别定义为第一和第二唯一性标识;比较第一和第二唯一性标识,并在第一和第二唯一性标识不同时更新预设通信协议的版本号。根据本发明实施例的分布式系统更新通信协议版本号的方法大大提高了分布式系统发现通信协议发生变化的可靠性和更新通信协议版本号的效率。

Description

分布式系统中通信协议版本号的更新
说明书
技术领域
本发明总地涉及分布式系统的控制技术领域,更具体地涉及一种分布式系统中通信协议版本号的更新。
背景技术
分布式系统是建立在网络之上的软件系统,其通常包括多个模块,这些模块之间要通过网络采用一定的通信协议进行通信。为了保证通信的准确性,各模块所采用的通信协议应当保持一致。
在现有的分布式系统中,当通信协议发生变化时,是以人工的方式更新通信协议版本,在通信协议中带上协议版本号,在接收方校验版本号。这样的方法存在如下缺点:(1)容易遗漏:当通信协议发生变化肉眼不易区分,例如:某个通信协议包含多级数据结构嵌套,当嵌套层的数据结构发生变化时,维护者非常容易遗漏该变化;(2)效率低下:当分布式系统中存在数量较多的模块时,靠人工方式更新通信协议版本效率非常低下。
因此,需要提供一种分布式系统中自动更新通信协议版本号的方案。
发明内容
为了解决上述问题而提出了本发明。根据本发明一方面,提供了一种分布式系统更新通信协议版本号的方法,所述分布式系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述方法包括:生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一语法结构表示和第二语法结构表示;获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构,分别定义为第一通信数据结构和第二通信数据结构;基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息;计算所述第一文本消息和所述第二文本消息各自的唯一性标识,分 别定义为第一唯一性标识和第二唯一性标识;以及比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述预设通信协议的版本号。
在本发明的一个实施例中,所述修改前的代码版本和所述修改后的代码版本中各自的通信协议数据结构均基于预设结构体而生成,所述预设结构体符合预设命名规范。
在本发明的一个实施例中,所述获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构包括:解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构;以及获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构。
在本发明的一个实施例中,所述生成修改前的代码版本和修改后的代码版本各自的语法结构表示,包括:生成修改前的代码版本和修改后的代码版本各自的抽象语法树。
在本发明的一个实施例中,所述基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息,包括:将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串。
在本发明的一个实施例中,所述所有语法信息包括通信数据结构的自身信息和子成员信息。
在本发明的一个实施例中,所述自身信息包括域名信息、数据结构类型信息和占用大小信息。
在本发明的一个实施例中,所述子成员信息包括子成员名字信息、基本数据类型信息、结构体/枚举/联合体/定义类型的展开信息和占用大小信息。
在本发明的一个实施例中,所述计算所述第一文本消息和所述第二文本消息各自的唯一性标识,包括:计算所述第一文本消息和所述第二文本消息各自的消息摘要值。
在本发明的一个实施例中,所述方法基于分散式版本控制软件的钩子 脚本来实现。
根据本发明另一方面,提供了一种自动驾驶系统,所述自动驾驶系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述自动驾驶系统采用上述任一项所述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。
根据本发明再一方面,提供了一种车辆,所述车辆包括上述的自动驾驶系统。
根据本发明又一方面,提供了一种无人机,所述无人机包括上述的自动驾驶系统。
根据本发明另一方面,提供了一种计算设备,所述计算设备包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述计算设备采用上述任一项所述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。
根据本发明另一方面,提供了一种存储介质,所述存储介质上存储有计算机程序,所述计算机程序在运行时执行上述任一项所述的分布式系统更新通信协议版本号的方法。
根据本发明实施例的分布式系统更新通信协议版本号的方法针对修改前后的代码版本生成语法结构表示,从所生成的语法结构表示中获取通信协议数据结构,并通过比较通信协议数据结构的唯一性标识来确定通信协议是否发生变化,如果发生变化则自动更新通信协议版本号,大大提高了分布式系统发现通信协议发生变化的可靠性和更新通信协议版本号的效率,有效解决了人工方式中容易遗漏和效率低下的问题。
附图说明
图1示出根据本发明实施例的分布式系统更新通信协议版本号的方法的示意性流程图;
图2示出根据本发明实施例的分布式系统更新通信协议版本号的方法的更具体的流程图;
图3示出采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例计算设备的示意性结构框图;
图4示出采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例自动驾驶系统的示意性结构框图;以及
图5示出采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例无人机的示意性结构框图。
具体实施方式
为了使得本发明的目的、技术方案和优点更为明显,下面将参照附图详细描述根据本发明的示例实施例。显然,所描述的实施例仅仅是本发明的一部分实施例,而不是本发明的全部实施例,应理解,本发明不受这里描述的示例实施例的限制。基于本发明中描述的本发明实施例,本领域技术人员在没有付出创造性劳动的情况下所得到的所有其它实施例都应落入本发明的保护范围之内。
在下文的描述中,给出了大量具体的细节以便提供对本发明更为彻底的理解。然而,对于本领域技术人员而言显而易见的是,本发明可以无需一个或多个这些细节而得以实施。在其他的例子中,为了避免与本发明发生混淆,对于本领域公知的一些技术特征未进行描述。
应当理解的是,本发明能够以不同形式实施,而不应当解释为局限于这里提出的实施例。相反地,提供这些实施例将使公开彻底和完全,并且将本发明的范围完全地传递给本领域技术人员。
在此使用的术语的目的仅在于描述具体实施例并且不作为本发明的限制。在此使用时,单数形式的“一”、“一个”和“所述/该”也意图包括复数形式,除非上下文清楚指出另外的方式。还应明白术语“组成”和/或“包括”,当在该说明书中使用时,确定所述特征、整数、步骤、操作、元件和/或部件的存在,但不排除一个或更多其它的特征、整数、步骤、操作、元件、部件和/或组的存在或添加。在此使用时,术语“和/或”包括相关所列项目的任何及所有组合。
为了彻底理解本发明,将在下列的描述中提出详细的步骤以及详细的结构,以便阐释本发明提出的技术方案。本发明的较佳实施例详细描述如下,然而除了这些详细描述外,本发明还可以具有其他实施方式。
如前所述,目前的分布式系统以人工方式更新通信协议版本,不仅容易遗漏通信协议的变化,而且效率低下。基于此,本发明提供一种分布式系统更新通信协议版本号的方案,下面结合附图来描述根据本发明实施例的分布式系统更新通信协议版本号的方案。
图1示出根据本发明实施例的分布式系统更新通信协议版本号的方法100的示意性流程图。如图1所示,分布式系统更新通信协议版本号的方法100可以包括如下步骤:
在步骤S110,生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一语法结构表示和第二语法结构表示。
在本发明的实施例中,图1所示的方法可用于包括多个模块的分布式系统自动更新这些模块之间的通信所采用的预设通信协议版本。一般地,通信协议可能在代码版本被修改时发生变化。因此,可以通过比较修改前的代码版本和修改后的代码版本中各自的通信协议数据结构来确定通信协议是否发生了变化。然而,如果直接对源代码进行分析来获取通信协议数据结构,不仅计算量过大,准确性也不高。
基于此,在本发明的实施例中,在步骤S110中,可以先针对修改前的代码版本和修改后的代码版本分别生成其各自的语法结构表示,例如抽象语法结构表示,以通过分析所生成的语法结构表示来快速获取代码中的通信协议数据结构。为了相区分,可以将针对修改前的代码版本生成的语法结构表示定义为第一语法结构表示,并将针对修改后的代码版本生成的语法结构表示定义为第二语法结构表示。此处,第一语法结构表示和第二语法结构表示仅为了相互区分彼此而定义,并无其他限制作用。
示例性地,步骤S110中的生成修改前的代码版本和修改后的代码版本各自的语法结构表示可以进一步包括:生成修改前的代码版本和修改后的代码版本各自的抽象语法树(Abstract Syntax Tree,AST)。也就是说,针对修改前和修改后的代码版本分别生成的语法结构表示可以为抽象语法树。其中,可以将针对修改前的代码版本生成的抽象语法树定义为第一抽象语法树,并将针对修改前的代码版本生成的抽象语法树定义为第二抽象语法树。此处,第一抽象语法树和第二抽象语法树仅为了相互区分彼此而定义,并无其他限制作用。
在计算机科学中,抽象语法树(或简称语法树)是源代码语法结构的一种抽象表示。它以树状的形式表现编程语言的语法结构,树上的每个节点都表示源代码中的一种结构。基于生成修改前后的代码版本各自的抽象语法树来获取修改前后的代码版本中各自的通信协议数据结构不仅效率高,而且可靠性也高。
在一个示例中,可以使用CastXML工具生成修改前后的代码版本各自的抽象语法树文件。CastXML工具能根据C/C++的语法,生成输入代码的结构组织关系,并以XML文件格式描述语法树。在其他示例中,也可以采用任何其他合适的方法或工具来生成修改前后的代码版本各自的抽象语法树文件。
下面继续参考图1,描述根据本发明实施例的分布式系统更新通信协议版本号的方法100的后续步骤。
在步骤S120,获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构,分别定义为第一通信数据结构和第二通信数据结构。
基于在步骤S110针对修改前后的代码版本分别生成的其各自的语法结构表示(如抽象语法树),可以通过解析所生成的抽象语法树文件,来获取修改前后的代码版本中各自的通信协议数据结构。在本发明的实施例中,为了便于快速从修改前后的代码版本的抽象语法树中获取到其各自的通信协议数据结构,可以定义符合预设命名规范的预设结构体(例如定义一个宏,其前缀可以为communication_api),并使得修改前后的代码版本中各自的通信协议数据结构均基于该预设结构体而生成。这样,可以事先将通信协议数据结构标识出来,使得更高效地从抽象语法数中查找到通信协议数据类型。
基于此,步骤S120中的获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构可以进一步包括:解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构;以及获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构。具体地,可以遍历步骤S110中针对修改前后的代码版本各自生成的语法结构表示文件(例如抽象语法树文件),并从 中查找符合所述预设命名规范的数据结构,例如前缀为communication_api的结构体,然后获取这些结构体的首成员的数据类型,即得到语法结构表示文件中的通信协议数据结构。
为了相区分,可以将从与修改前的代码版本相对应的语法结构表示中获取的通信协议数据类型定义为第一通信协议数据结构(可以简称为第一通信数据结构),并将从与修改后的代码版本相对应的语法结构表示中获取的通信协议数据类型定义为第二通信协议数据结构(可以简称为第二通信数据结构)。此处,第一通信数据结构和第二通信数据结构仅为了相互区分彼此而定义,并无其他限制作用。
在步骤S130,基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息。
基于在步骤S120获取的修改前后的代码版本中各自的通信协议数据结构,可以生成修改前后的代码版本中各自的通信协议数据结构的唯一性标识,以用于基于该唯一性标识来确定修改前后通信协议数据结构是否发生了变化。在本发明的实施例中,可以基于通信协议数据结构的所有语法信息来生成该通信协议数据结构的文本消息,并基于该文本消息生成该通信协议数据结构的唯一性标识。
示例性地,该文本消息可以是基于该通信协议数据结构的所有语法信息生成的字符串,例如,可以将该通信协议数据结构的所有语法信息组合成字符串。示例性地,通信协议数据结构的所有语法信息可以包括通信数据结构的自身信息和子成员信息。其中,所述自身信息可以包括域名信息(即namespace名)、数据结构类型(如struct/union)信息和占用大小信息。所述子成员信息可以包括子成员名字信息、基本数据类型(如int/char/float/long)信息、结构体/枚举/联合体/定义类型(typedef)的展开信息和占用大小信息。
为了相区分,可以将基于修改前的代码版本中的通信协议数据类型的所有语法信息生成的文本信息定义为第一文本信息,并将基于修改后的代码版本中的通信协议数据类型的所有语法信息生成的文本信息定义为第二文本信息。此处,第一文本信息和第二文本信息仅为了相互区分彼此而定义,并无其他限制作用。
在步骤S140,计算所述第一文本消息和所述第二文本消息各自的唯一性标识,分别定义为第一唯一性标识和第二唯一性标识。
如前所述的,在本发明的实施例中,可以基于一个通信协议数据结构的所有语法信息来生成该通信协议数据结构的文本消息,并基于该文本消息生成该通信协议数据结构的唯一性标识。示例性地,该唯一性标识可以是该文本消息的消息摘要值(如MD5值)。也就是说,可以计算第一文本消息的消息摘要值,以作为修改前的代码版本中的通信协议数据类型的唯一性标识,并计算第二文本消息的消息摘要值,以作为修改后的代码版本中的通信协议数据类型的唯一性标识。
为了相区分,可以将第一文本信息的唯一性标识定义为第一唯一性标,并将第二文本信息的唯一性标识定义为第二唯一性标。此处,第一唯一性标识和第二唯一性标识仅为了相互区分彼此而定义,并无其他限制作用。
在步骤S150,比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述预设通信协议的版本号。
基于在步骤S140计算得到的修改前后的代码版本中各自的通信协议数据结构的唯一性标识,可以通过确定修改前后的代码版本中各自的通信协议数据结构的唯一性标识是否相同来确定修改前后通信协议是否发生了变化。如果修改前后的代码版本中各自的通信协议数据结构的唯一性标识相同,则表明修改前后通信协议没有发生变化;如果修改前后的代码版本中各自的通信协议数据结构的唯一性标识不同,则表明修改前后通信协议发生了变化,则可以更新与被比较的通信协议数据结构相对应的通信协议(如前述的分布式系统各模块之间通信采用的预设通信协议)的版本号,例如可以将该通信协议的版本号累加1。如此,即实现了根据本发明实施例的分布式系统更新通信协议版本号的方法。
在本发明的实施例中,上述分布式系统更新通信协议版本号的方法可以基于分散式版本控制软件(GIT)的钩子脚本来实现。具体地,开发者使用git commit提交代码,GIT客户端自动触发git post-commit脚本,在post-commit脚本中,可以实施上述步骤S110到S150,当提交前后的代码 版本中各自的通信协议数据结构的唯一性标识不同时,可以更新对应的通信协议的版本号,并用git commit-amend追加提交。
基于上面的描述,根据本发明实施例的分布式系统更新通信协议版本号的方法针对修改前后的代码版本生成语法结构表示,从所生成的语法结构表示中获取通信协议数据结构,并通过比较通信协议数据结构的唯一性标识来确定通信协议是否发生变化,如果发生变化则自动更新通信协议版本号,大大提高了分布式系统发现通信协议发生变化的可靠性和更新通信协议版本号的效率,有效解决了人工方式中容易遗漏和效率低下的问题。
图2示出根据本发明实施例的分布式系统更新通信协议版本号的方法的更具体的流程图。如图2所示,根据本发明实施例的分布式系统更新通信协议版本号的方法可以包括如下步骤:
首先,在步骤S1,使用git commit提交代码,生成commit节点a(即一个代码版本),GIT客户端自动触发git post-commit钩子脚本。
其中,GIT是一个分散式版本控制软件,最初由linus torvalds创作,于2005年以GPL发布。GIT可支持多种hook脚本,由部分GIT命令触发,用于完成使用者自定义的自动化操作。
在步骤S1之后的5个步骤均分为左右两支分流进行,其中,左边分流是针对commit节点a对应的代码版本执行的,右边分流是针对commit节点a之前的代码版本执行的。为了将其两者进行区分,将这5个步骤的左边分支标记为S2A到S6A,右边分支标记为S2B到S6B。应理解,这5个步骤中每一步骤的左右两支分流的执行顺序可以是不分先后的。
在步骤S2A,生成commit节点a对应的代码版本的C/C++抽象语法树。在步骤S2B,生成commit节点a之前的代码版本的C/C++抽象语法树。
在计算机科学中,抽象语法树(Abstract Syntax Tree,AST),或简称语法树(Syntax tree),是源代码语法结构的一种抽象表示。它以树状的形式表现编程语言的语法结构,树上的每个节点都表示源代码中的一种结构。常见的实现工具是CastXML,能根据C/C++的语法,生成输入代码的结构组织关系,并以XML文件格式描述语法树。使用CastXML工具生成语法树文件之后,可解析此文件,获取通信协议数据结构的全展开字符串,展开的字符串用于计算MD5值,MD5值发生变化时表示通信协议版本号需 要更新,如下文将描述的。
在步骤S3A,解析语法树,找出所有以communication_api开头的数据结构。在步骤S3B,解析语法树,找出所有以communication_api开头的数据结构。
在步骤S4A,获取这些数据结构的首成员的数据类型,即得到所有通信协议数据结构。在步骤S4B,获取这些数据结构的首成员的数据类型,即得到所有通信协议数据结构。
在post-commit脚本中,生成提交前后的抽象语法树,根据预先定义的通信协议数据结构的标识找出通信协议数据结构。其中,可以通过下面的方式来标识通信协议数据结构:首先,定义通信协议声明的宏:#define COMM_API_EXPORT(type)struct communication_api##type{type a;};然后,在通信协议数据结构的定义处使用COMM_API_EXPORT声明。基于此,可利用CastXML(或者其他工具)生成抽象语法树,过滤语法树中的结构体,当名字符合communication_api开头时,获取其首成员类型,即为通信协议数据结构。
在步骤S5A,解析语法树,展开数据协议的完整数据结构,生成字符串。在步骤S5B,解析语法树,展开数据协议的完整数据结构,生成字符串。
在步骤S6A,计算字符串的摘要信息。在步骤S6B,计算字符串的摘要信息。
在抽象语法树中,查找通信数据结构的所有信息,包括其域名信息、基本数据类型、用户定义类型展开、类型数据长度信息等,组合成字符串,计算此字符串的MD5值,作为此通信数据结构的唯一标识符。其中,MD5(Message-Digest Algorithm,消息摘要算法)是一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值(hash value),可用于表示数据摘要信息。
在步骤S7,对比提交前后所有通信数据结构的MD5值,若发生变化,则在步骤S8更新对应通信数据结构的版本号(即将MD5发生变化的通信协议的版本号累加1),并在步骤S9用git commit--amend追加提交到commit a。在步骤S10,post-commit钩子脚本结束。对于MD5值未发生 变化的通信数据结构,其对应的通信协议的版本号则无需更新,流程直接行进到步骤S10。
以上结合图2描述了根据本发明实施例的分布式系统更新通信协议版本号的方法的更具体的操作。基于上面的描述,根据本发明实施例的分布式系统更新通信协议版本号的方法具有通信协议的数据结构的自动识别方法:即基于宏声明及抽象语法树,可使用脚本自动识别出描述通信协议的数据结构。此外,根据本发明实施例的分布式系统更新通信协议版本号的方法能够对数据结构的变化进行识别:即基于抽象语法树,获取某个数据结构的所有语法信息(含数据结构成员名字、类型展开、内存占用大小等),生成字符串,计算摘要信息MD5,若MD5发生变化,则表示数据结构发生变化。
总体上,根据本发明实施例的分布式系统更新通信协议版本号的方法可以通过GIT的post-commit与pre-push钩子脚本,实现自动更新并提交通信协议版本号的功能,只需在通信数据结构定义处,使用宏声明为通信协议,后续的所有版本号的更新都由GIT的钩子脚本完成。该基于GIT的自动更新通信协议版本的方法可以避免人工维护带来的人力成本、效率低下、出错概率高的问题,可应用于进程间通信系统的通信协议一致性保障领域。进程间通信系统指运行于计算机(或嵌入式设备)上的软件间的通信系统。进程间通信协议指不同进程间协商好的通信信息结构及其定义,通信的链路可以是多种多样的:如网口、USB、串口等。进程间通信系统中包含多个不同程序安装包,各个程序间通信协议需要保持一致性,从而保证通信内容能正确传递和响应。因此,根据本发明实施例的分布式系统更新通信协议版本号的方法可应用于需要大量进程间通信的应用(如机器人系统)中,大大提高通信协议的维护效率,并保证通信的正确性。
以上示例性地描述了根据本发明实施例的分布式系统更新通信协议版本号的方法。示例性地,根据本发明实施例的分布式系统更新通信协议版本号的方法可以在分布式系统中实现,也可以在任何具有存储器和处理器的设备、装置或者系统中实现。此外,根据本发明实施例的分布式系统更新通信协议版本号的方法也可以在任何进程间通信系统中实现。
根据本发明另一方面,提供了一种计算设备,所述计算设备包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述计算设备采用上文参照图1和图2描述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。下面结合图3描述采用根据本发明实施例的分布式系统更新通信协议版本号的方法的计算设备。图3示出了采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例计算设备300的示意性结构框图。
如图3所示,计算设备300包括多个组件(或称为模块),分别为一个或多个处理器302、一个或多个存储装置304、输入装置306、输出装置308,这些模块通过总线系统310和/或其它形式的连接机构(未示出)互连。应当注意,图3所示的计算设备300的组件和结构只是示例性的,而非限制性的,根据需要,所述计算设备也可以具有其他组件和结构。
所述处理器302可以是中央处理单元(CPU)或者具有数据处理能力和/或指令执行能力的其它形式的处理单元,并且可以控制所述计算设备300中的其它组件以执行期望的功能。
所述存储装置304可以包括一个或多个计算机程序产品,所述计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。所述易失性存储器例如可以包括随机存取存储器(RAM)和/或高速缓冲存储器(cache)等。所述非易失性存储器例如可以包括只读存储器(ROM)、硬盘、闪存等。在所述计算机可读存储介质上可以存储一个或多个计算机程序指令,处理器302可以运行所述程序指令,以实现上文所述的本发明实施例中(由处理器实现)的更新通信协议版本号的功能以及/或者其它期望的功能。在所述计算机可读存储介质中还可以存储各种应用程序和各种数据,例如所述应用程序使用和/或产生的各种数据等。
所述输入装置306可以是用户用来输入指令的装置,并且可以包括键盘、鼠标、麦克风和触摸屏等中的一个或多个。
所述输出装置308可以向外部(例如用户)输出各种信息(例如图像或声音),并且可以包括显示器、扬声器等中的一个或多个。
计算设备300的上述组件之间可以通过预设通信协议进行通信,并采用前述的根据本发明实施例的分布式系统更新通信协议版本号的方法来自动 更新所述预设通信协议的版本号。
示例性地,可采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例计算设备300可以被实现为诸如智能手机、平板电脑等终端,或任何具有计算能力的电子设备。
根据本发明再一方面,提供了一种存储介质,在所述存储介质上存储了程序指令,在所述程序指令被计算机或处理器运行时用于执行本发明实施例的分布式系统更新通信协议版本号的方法的相应步骤。所述存储介质例如可以包括智能电话的存储卡、平板电脑的存储部件、个人计算机的硬盘、只读存储器(ROM)、可擦除可编程只读存储器(EPROM)、便携式紧致盘只读存储器(CD-ROM)、USB存储器、或者上述存储介质的任意组合。所述计算机可读存储介质可以是一个或多个计算机可读存储介质的任意组合。
根据本发明又一方面,提供了一种自动驾驶系统,所述自动驾驶系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述自动驾驶系统采用上文参照图1和图2描述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。下面结合图4描述采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例自动驾驶系统。图4示出了采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例自动驾驶系统400的示意性结构框图。
如图4所示,自动驾驶系统400包括车辆位置识别模块410、车辆状态识别模块420、外部环境识别模块430、行驶计划生成模块440以及车辆控制模块450。其中,车辆位置识别模块410配置为识别车辆在地图上的位置。车辆状态识别模块420配置为识别车辆的车辆状态。外部环境识别模块430配置为识别车辆的外部环境。行驶计划生成模块440配置为基于车辆位置识别模块410识别的车辆位置、车辆状态识别模块420识别的车辆状态以及外部环境识别模块430识别的外部环境,生成行驶计划,该行驶计划包括车辆的自动驾驶控制的控制目标值。车辆控制模块450配置为基于行驶计划生成模块440生成的行驶计划的控制目标值向车辆的制动器发送指令,从而执行自动驾驶控制。
如图4所示,自动驾驶系统400包括多个模块,分别为车辆位置识别 模块410、车辆状态识别模块420、外部环境识别模块430、行驶计划生成模块440以及车辆控制模块450。其中,车辆位置识别模块410、车辆状态识别模块420和外部环境识别模块430均需要与行驶计划生成模块440进行通信(即,将它们的识别结果传送至行驶计划生成模块440),行驶计划生成模块440需要与车辆控制模块450进行通信(即,将它生成的行驶计划传送至车辆控制模块450),因此,这些模块之间的这些通信均需要采用一定的通信协议,且这些模块之间的通信协议必须保持一致才能保证通信的正确实施。基于此,自动驾驶系统400可以采用根据上文参照图1和图2描述的分布式系统更新通信协议版本号的方法来检测其各模块之间的通信协议是否发生变化(是否保持一致),如果发生变化,则自动进行更新,以正确地保持通信,从而确保可靠、安全的自动驾驶。
下面具体描述自动驾驶系统400采用根据上文参照图1和图2描述的分布式系统更新通信协议版本号的方法对车辆位置识别模块410、车辆状态识别模块420、外部环境识别模块430、行驶计划生成模块440以及车辆控制模块450这些模块之间的通信协议的一致性进行检测、以及检测到通信协议发生变化时更新通信协议版本号的过程。
首先,如前所述,车辆位置识别模块410、车辆状态识别模块420和外部环境识别模块430均需要与行驶计划生成模块440进行通信(即,将它们的识别结果传送至行驶计划生成模块440),行驶计划生成模块440需要与车辆控制模块450进行通信(即,将它生成的行驶计划传送至车辆控制模块450),车辆位置识别模块410、车辆状态识别模块420、外部环境识别模块430和车辆控制模块450分别可以采用相同的通信协议与行驶计划生成模块440通信。因此,需要确定实现车辆位置识别模块410、车辆状态识别模块420、外部环境识别模块430、行驶计划生成模块440以及车辆控制模块450这些模块的代码中的通信协议数据结构是否在其各自代码版本的修改中发生变化。
为了相区别,将实现车辆位置识别模块410的代码定义为车辆位置识别代码,将实现车辆状态识别模块420的代码定义为车辆状态识别代码,将实现外部环境识别模块430的定义为外部环境识别代码,将实现行驶计划生成模块440的定义为行驶计划生成代码,并将实现车辆控制模块450 的定义为车辆控制代码。在这些代码中,均采用符合预设命名规范的相同结构体来定义通信协议数据结构(例如前述的以communication_api为开头的数据结构)。基于此,可以在实现前述五个模块中各模块的代码版本的修改后检测其通信协议数据结构是否发生变化。
例如,对于车辆状态识别代码的一个代码版本,可以基于分散式版本控制软件的钩子脚本中生成该代码版本和该代码版本之前的代码版本各自的语法结构表示(例如抽象语法树),分别定义为第一语法结构表示和第二语法结构表示;然后获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构(例如解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构,然后获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构),分别定义为第一通信数据结构和第二通信数据结构;接着基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息(例如将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串);然后计算所述第一文本消息和所述第二文本消息各自的唯一性标识(例如计算所述第一文本消息和所述第二文本消息各自的MD5值),分别定义为第一唯一性标识和第二唯一性标识;最后比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述第一通信协议的版本号。也就是说,对于车辆状态识别代码的一个代码版本,如果该代码版本与该代码版本之前的代码版本相比,其各自的通信协议数据结构的所有信息组合成的字符串的MD5值不相等,则说明该代码版本与该代码版本之前的代码版本相比,通信协议数据结构发生了变化,此时应当修改与该通信协议数据结构相对应的通信协议版本号(如将版本号累加1)。如果该代码版本与该代码版本之前的代码版本相比,其各自的通信协议数据结构的所有信息组合成的字符串的MD5值相等,则说明该代码版本与该代码版本之前的代码版本相比,通信协议数据结构未发生变化,则无需修改与该通信协议数据结构相对应的通信协议版本号。
类似地,对于车辆状态识别代码、外部环境识别代码、行驶计划生成 代码和车辆控制代码,都可以采用采用上述的方法来检测其中的通信协议数据结构是否发生变化,以及在变化时采用上述方法自动更新通信协议版本号。
以上示例性地描述了根据本发明实施方式的自动驾驶系统及其各模块之间的通信协议版本号的自动更新方法,应理解,图4中所示的自动驾驶系统仅是示例性的,自动驾驶系统还可以包括其他任何未示出的需要的模块,这些模块之间的通信协议也可以采用根据本发明实施例的分布式系统更新通信协议版本号的方法来更新。
根据本发明的再一方面,还提供了一种车辆,所述车辆可以包括上文中所述的自动驾驶系统,该车辆的自动驾驶系统可以根据本发明实施例的分布式系统更新通信协议版本号的方法来更新其各模块之间用于通信的通信协议,本领域技术人员可以结合前文所述来理解更新通信协议的方法,为了简洁,此处不再赘述。
根据本发明的又一方面,还提供了一种无人机,所述无人机可以包括飞行控制系统,所述飞行控制系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述无人机采用上文参照图1和图2描述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。下面结合图5描述采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例无人机。图5示出了采用根据本发明实施例的分布式系统更新通信协议版本号的方法的示例无人机500的示意性结构框图。
如图5所示,无人机500包括飞行控制系统,所述飞行控制系统包括指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530。其中,所述指令信号接收模块510用于接收来自无人机500的遥控器(未示出)的指令和来自传感器的传感器信号,并将接收到的传感器信号传送至传感器数据处理模块520,并将接收到的遥控器的指令传送至控制量计算模块530。所述传感器数据处理模块520用于对所述传感器信号进行处理和运算,得到诸如无人机500的位置姿态信息等,并将其处理得到的位置姿态信息传送至控制量计算模块530。所述控制量计算模块530用于基 于所述遥控器的指令和所述位置姿态信息计算相应控制器的控制量,并将控制量输出至驱动机构。
如上所述,无人机500包括飞行控制系统,所述飞行控制系统包括多个模块,分别为指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530。其中,指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530这三者之间彼此均需要进行通信。因此,这些模块之间的这些通信均需要采用一定的通信协议,且这些模块之间的通信协议必须保持一致才能保证通信的正确实施。基于此,无人机500可以采用根据上文参照图1和图2描述的分布式系统更新通信协议版本号的方法来检测其飞行控制系统的各模块之间的通信协议是否发生变化(是否保持一致),如果发生变化,则自动进行更新,以正确地保持通信,从而实现无人机的正确安全运行。
下面具体描述无人机500采用根据上文参照图1和图2描述的分布式系统更新通信协议版本号的方法对指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530这些模块之间的通信协议的一致性进行检测、以及检测到通信协议发生变化时更新通信协议版本号的过程。
首先,如前所述,指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530这三者之间彼此均需要进行通信。因此,需要确定实现指令信号接收模块510、传感器数据处理模块520以及控制量计算模块530这些模块的代码中的通信协议数据结构是否在其各自代码版本的修改中发生变化。
为了相区别,将实现指令信号接收模块510的代码定义为指令信号接收代码,将实现传感器数据处理模块520的代码定义为传感器数据处理代码,并将实现控制量计算模块530的定义为控制量计算代码。在这些代码中,均采用符合预设命名规范的相同结构体来定义通信协议数据结构(例如前述的以communication_api为开头的数据结构)。基于此,可以在实现前述三个模块中各模块的代码版本的修改后检测其通信协议数据结构是否发生变化。
例如,对于指令信号接收代码的一个代码版本,可以基于分散式版本控制软件的钩子脚本中生成该代码版本和该代码版本之前的代码版本各自 的语法结构表示(例如抽象语法树),分别定义为第一语法结构表示和第二语法结构表示;然后获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构(例如解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构,然后获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构),分别定义为第一通信数据结构和第二通信数据结构;接着基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息(例如将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串);然后计算所述第一文本消息和所述第二文本消息各自的唯一性标识(例如计算所述第一文本消息和所述第二文本消息各自的MD5值),分别定义为第一唯一性标识和第二唯一性标识;最后比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述第一通信协议的版本号。也就是说,对于指令信号接收代码的一个代码版本,如果该代码版本与该代码版本之前的代码版本相比,其各自的通信协议数据结构的所有信息组合成的字符串的MD5值不相等,则说明该代码版本与该代码版本之前的代码版本相比,通信协议数据结构发生了变化,此时应当修改与该通信协议数据结构相对应的通信协议版本号(如将版本号累加1)。如果该代码版本与该代码版本之前的代码版本相比,其各自的通信协议数据结构的所有信息组合成的字符串的MD5值相等,则说明该代码版本与该代码版本之前的代码版本相比,通信协议数据结构未发生变化,则无需修改与该通信协议数据结构相对应的通信协议版本号。
类似地,对于传感器数据处理代码和控制量计算代码,都可以采用采用上述的方法来检测其中的通信协议数据结构是否发生变化,以及在变化时采用上述方法自动更新通信协议版本号。
以上示例性地描述了根据本发明实施方式的无人机及其飞行控制系统的各模块之间的通信协议版本号的自动更新方法,应理解,图5中所示的无人机及其飞行控制系统仅是示例性的,无人机及其飞行控制系统还可以包括其他任何未示出的需要的模块,这些模块之间的通信协议也可以采 用根据本发明实施例的分布式系统更新通信协议版本号的方法来更新。
以上示例性地描述了根据本发明实施例的分布式系统更新通信协议版本号的方法的应用场景。基于上面的描述,根据本发明实施例的分布式系统更新通信协议版本号的方法及其使用其的设备或系统针对修改前后的代码版本生成语法结构表示,从所生成的语法结构表示中获取通信协议数据结构,并通过比较通信协议数据结构的唯一性标识来确定通信协议是否发生变化,如果发生变化则自动更新通信协议版本号,大大提高了分布式系统发现通信协议发生变化的可靠性和更新通信协议版本号的效率,有效解决了人工方式中容易遗漏和效率低下的问题。
尽管这里已经参考附图描述了示例实施例,应理解上述示例实施例仅仅是示例性的,并且不意图将本发明的范围限制于此。本领域普通技术人员可以在其中进行各种改变和修改,而不偏离本发明的范围和精神。所有这些改变和修改意在被包括在所附权利要求所要求的本发明的范围之内。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。例如,以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个设备,或一些特征可以忽略,或不执行。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本发明并帮助理解各个发明方面中的一 个或多个,在对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该本发明的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如相应的权利要求书所反映的那样,其发明点在于可以用少于某个公开的单个实施例的所有特征的特征来解决相应的技术问题。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域的技术人员可以理解,除了特征之间相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的一些模块的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。本发明可以借助于包括有若干不同元件的硬件以及借 助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
以上所述,仅为本发明的具体实施方式或对具体实施方式的说明,本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。本发明的保护范围应以权利要求的保护范围为准。

Claims (33)

  1. 一种分布式系统更新通信协议版本号的方法,所述分布式系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述方法包括:
    生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一语法结构表示和第二语法结构表示;
    获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构,分别定义为第一通信数据结构和第二通信数据结构;
    基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息;
    计算所述第一文本消息和所述第二文本消息各自的唯一性标识,分别定义为第一唯一性标识和第二唯一性标识;以及
    比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述预设通信协议的版本号。
  2. 根据权利要求1所述的方法,其特征在于,所述修改前的代码版本和所述修改后的代码版本中各自的通信协议数据结构均基于预设结构体而生成,所述预设结构体符合预设命名规范。
  3. 根据权利要求2所述的方法,其特征在于,所述获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构包括:
    解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构;以及
    获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构。
  4. 根据权利要求1所述的方法,其特征在于,所述生成修改前的代码版本和修改后的代码版本各自的语法结构表示,包括:
    生成修改前的代码版本和修改后的代码版本各自的抽象语法树。
  5. 根据权利要求1所述的方法,其特征在于,所述基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息,包括:
    将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串。
  6. 根据权利要求5所述的方法,其特征在于,所述所有语法信息包括通信数据结构的自身信息和子成员信息。
  7. 根据权利要求6所述的方法,其特征在于,所述自身信息包括域名信息、数据结构类型信息和占用大小信息。
  8. 根据权利要求6所述的方法,其特征在于,所述子成员信息包括子成员名字信息、基本数据类型信息、结构体/枚举/联合体/定义类型的展开信息和占用大小信息。
  9. 根据权利要求1所述的方法,其特征在于,所述计算所述第一文本消息和所述第二文本消息各自的唯一性标识,包括:
    计算所述第一文本消息和所述第二文本消息各自的消息摘要值。
  10. 根据权利要求1-9中的任一项所述的方法,其特征在于,所述方法基于分散式版本控制软件的钩子脚本来实现。
  11. 一种自动驾驶系统,其特征在于,所述自动驾驶系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述自动驾驶系统采用权利要求1-10中的任一项所述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。
  12. 一种车辆,其特征在于,所述车辆包括自动驾驶系统,所述自动驾驶系统包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述预设通信协议的版本号通过包括以下步骤的方法来更新,所述步骤包括:
    生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一语法结构表示和第二语法结构表示;
    获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构,分别定义为第一通信数据结构和第二通信数据结构;
    基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息;
    计算所述第一文本消息和所述第二文本消息各自的唯一性标识,分别定义为第一唯一性标识和第二唯一性标识;以及
    比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述预设通信协议的版本号。
  13. 根据权利要求12所述的车辆,其特征在于,所述修改前的代码 版本和所述修改后的代码版本中各自的通信协议数据结构均基于预设结构体而生成,所述预设结构体符合预设命名规范。
  14. 根据权利要求13所述的车辆,其特征在于,所述获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构包括:
    解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构;以及
    获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构。
  15. 根据权利要求12所述的车辆,其特征在于,所述生成修改前的代码版本和修改后的代码版本各自的语法结构表示,包括:
    生成修改前的代码版本和修改后的代码版本各自的抽象语法树。
  16. 根据权利要求12所述的车辆,其特征在于,所述基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息,包括:
    将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串。
  17. 根据权利要求16所述的车辆,其特征在于,所述所有语法信息包括通信数据结构的自身信息和子成员信息。
  18. 根据权利要求17所述的车辆,其特征在于,所述自身信息包括域名信息、数据结构类型信息和占用大小信息。
  19. 根据权利要求17所述的车辆,其特征在于,所述子成员信息包括子成员名字信息、基本数据类型信息、结构体/枚举/联合体/定义类型的展开信息和占用大小信息。
  20. 根据权利要求12所述的车辆,其特征在于,所述计算所述第一文本消息和所述第二文本消息各自的唯一性标识,包括:
    计算所述第一文本消息和所述第二文本消息各自的消息摘要值。
  21. 根据权利要求12-20中的任一项所述的车辆,其特征在于,所述方法基于分散式版本控制软件的钩子脚本来实现。
  22. 一种无人机,其特征在于,所述无人机包括飞行控制系统,所述飞行控制系统包括多个模块,所述多个模块之间通过预设通信协议进行通 信,所述预设通信协议的版本号通过包括以下步骤的方法来更新,所述步骤包括:
    生成修改前的代码版本和修改后的代码版本各自的语法结构表示,分别定义为第一语法结构表示和第二语法结构表示;
    获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构,分别定义为第一通信数据结构和第二通信数据结构;
    基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息;
    计算所述第一文本消息和所述第二文本消息各自的唯一性标识,分别定义为第一唯一性标识和第二唯一性标识;以及
    比较所述第一唯一性标识和所述第二唯一性标识,并在所述第一唯一性标识和所述第二唯一性标识不同时更新所述预设通信协议的版本号。
  23. 根据权利要求22所述的无人机,其特征在于,所述修改前的代码版本和所述修改后的代码版本中各自的通信协议数据结构均基于预设结构体而生成,所述预设结构体符合预设命名规范。
  24. 根据权利要求23所述的无人机,其特征在于,所述获取所述第一语法结构表示和所述第二语法结构表示中各自的通信协议数据结构包括:
    解析所述第一语法结构表示和所述第二语法结构表示,以查找符合所述预设命名规范的数据结构;以及
    获取符合所述预设命名规范的数据结构的首成员的数据类型,以得到所述通信协议数据结构。
  25. 根据权利要求22所述的无人机,其特征在于,所述生成修改前的代码版本和修改后的代码版本各自的语法结构表示,包括:
    生成修改前的代码版本和修改后的代码版本各自的抽象语法树。
  26. 根据权利要求22所述的无人机,其特征在于,所述基于所述第一通信数据结构的所有语法信息生成第一文本消息,并基于所述第二通信数据结构的所有语法信息生成第二文本消息,包括:
    将所述第一通信数据结构的所有语法信息组合成第一字符串,并将所述第二通信数据结构的所有语法信息组合成第二字符串。
  27. 根据权利要求26所述的无人机,其特征在于,所述所有语法信息包括通信数据结构的自身信息和子成员信息。
  28. 根据权利要求27所述的无人机,其特征在于,所述自身信息包括域名信息、数据结构类型信息和占用大小信息。
  29. 根据权利要求27所述的无人机,其特征在于,所述子成员信息包括子成员名字信息、基本数据类型信息、结构体/枚举/联合体/定义类型的展开信息和占用大小信息。
  30. 根据权利要求22所述的无人机,其特征在于,所述计算所述第一文本消息和所述第二文本消息各自的唯一性标识,包括:
    计算所述第一文本消息和所述第二文本消息各自的消息摘要值。
  31. 根据权利要求22-30中的任一项所述的无人机,其特征在于,所述方法基于分散式版本控制软件的钩子脚本来实现。
  32. 一种计算设备,其特征在于,所述计算设备包括多个模块,所述多个模块之间通过预设通信协议进行通信,所述计算设备采用权利要求1-10中的任一项所述的分布式系统更新通信协议版本号的方法来更新所述预设通信协议的版本号。
  33. 一种存储介质,其特征在于,所述存储介质上存储有计算机程序,所述计算机程序在运行时执行如权利要求1-10中的任一项所述的分布式系统更新通信协议版本号的方法。
PCT/CN2019/088172 2019-05-23 2019-05-23 分布式系统中通信协议版本号的更新 WO2020232707A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201980008482.6A CN111684766A (zh) 2019-05-23 2019-05-23 分布式系统中通信协议版本号的更新
PCT/CN2019/088172 WO2020232707A1 (zh) 2019-05-23 2019-05-23 分布式系统中通信协议版本号的更新

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/088172 WO2020232707A1 (zh) 2019-05-23 2019-05-23 分布式系统中通信协议版本号的更新

Publications (1)

Publication Number Publication Date
WO2020232707A1 true WO2020232707A1 (zh) 2020-11-26

Family

ID=72451453

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/088172 WO2020232707A1 (zh) 2019-05-23 2019-05-23 分布式系统中通信协议版本号的更新

Country Status (2)

Country Link
CN (1) CN111684766A (zh)
WO (1) WO2020232707A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568876A (zh) * 2021-08-04 2021-10-29 江苏爱玛车业科技有限公司 自动生成dbc文件的方法和装置

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112799677B (zh) * 2021-02-05 2023-09-12 北京字节跳动网络技术有限公司 一种编译期的hook方法、装置、设备及存储介质
CN114064041B (zh) * 2021-11-18 2022-08-02 宁波波导易联电子有限公司 通过Android系统将控车矩阵文件生成控车代码的方法及系统
CN113868231B (zh) * 2021-12-03 2022-03-18 南昌龙旗信息技术有限公司 数据结构的更新方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101018231A (zh) * 2007-02-07 2007-08-15 重庆重邮信科股份有限公司 一种自适应协议版本的探测方法
CN102090040A (zh) * 2008-06-07 2011-06-08 相干逻辑公司 传输和接收供多媒体流使用的控制信息
CN102377821A (zh) * 2011-10-17 2012-03-14 邦讯技术股份有限公司 网络终端设备的版本智能更新方法和装置
US20160216959A1 (en) * 2015-01-22 2016-07-28 Bank Of America Corporation Modular system including management and deployment of software updates and revisions
CN108429764A (zh) * 2018-05-28 2018-08-21 烽火通信科技股份有限公司 一种基于私有协议的数据传输和解析的方法

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AUPO418896A0 (en) * 1996-12-12 1997-01-16 Quantum Networks Pty Ltd A distributed operating system
US7539686B2 (en) * 2004-03-12 2009-05-26 Microsoft Corporation Tag-based schema for distributing update metadata in an update distribution system
US8713144B2 (en) * 2007-09-14 2014-04-29 Ricoh Co., Ltd. Workflow-enabled client
US9430545B2 (en) * 2013-10-21 2016-08-30 International Business Machines Corporation Mechanism for communication in a distributed database
US9807083B2 (en) * 2015-06-05 2017-10-31 Sony Corporation Distributed white list for security renewability

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101018231A (zh) * 2007-02-07 2007-08-15 重庆重邮信科股份有限公司 一种自适应协议版本的探测方法
CN102090040A (zh) * 2008-06-07 2011-06-08 相干逻辑公司 传输和接收供多媒体流使用的控制信息
CN102377821A (zh) * 2011-10-17 2012-03-14 邦讯技术股份有限公司 网络终端设备的版本智能更新方法和装置
US20160216959A1 (en) * 2015-01-22 2016-07-28 Bank Of America Corporation Modular system including management and deployment of software updates and revisions
CN108429764A (zh) * 2018-05-28 2018-08-21 烽火通信科技股份有限公司 一种基于私有协议的数据传输和解析的方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568876A (zh) * 2021-08-04 2021-10-29 江苏爱玛车业科技有限公司 自动生成dbc文件的方法和装置
CN113568876B (zh) * 2021-08-04 2024-03-26 江苏爱玛车业科技有限公司 自动生成dbc文件的方法和装置

Also Published As

Publication number Publication date
CN111684766A (zh) 2020-09-18

Similar Documents

Publication Publication Date Title
WO2020232707A1 (zh) 分布式系统中通信协议版本号的更新
US9021462B2 (en) Systems and methods for provisioning equipment
CN106796585B (zh) 条件验证规则
US8887135B2 (en) Generating test cases for functional testing of a software application
CN111858472B (zh) 文件格式转换方法、装置、计算机设备及存储介质
CN110659494A (zh) 一种可扩展的智能合约漏洞检测方法
US20180210719A1 (en) Mechanisms for Declarative Expression Of Data Types For Data Storage
CN111683066B (zh) 异构系统集成方法、装置、计算机设备和存储介质
US20170052884A1 (en) Generic test automation for restful web services applications
US10127037B2 (en) Method for recognizing application type
US9043651B2 (en) Systematic failure remediation
CN111144839A (zh) 一种项目构建方法、持续集成系统及终端设备
CN109460220A (zh) 报文预定义代码生成方法、装置、电子设备和存储介质
CN109299205B (zh) 将规划行业使用的空间数据进行入库的方法和装置
CN109165209B (zh) 数据库中对象类型的数据校验方法、装置、设备及介质
CN112015752A (zh) 一种数据动态查询的方法、装置、电子设备和存储介质
US20140337655A1 (en) Integrated interface system for power-system monitoring and control system
CN113110832A (zh) 一种智能高效代码生成方法、装置及存储介质
CN110515944B (zh) 基于分布式数据库的数据存储方法、存储介质和电子设备
US20180123900A1 (en) Scenario driven, technology agnostic network simulation
US20180123899A1 (en) Technology agnostic network simulation
CN112269588B (zh) 算法的升级方法、装置、终端和计算机可读存储介质
CN110866007B (zh) 大数据应用和表的信息管理方法、系统和计算机设备
US20170364354A1 (en) Committed program-code management
US8560650B2 (en) Network device and method for setting parameters of the network device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19929741

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19929741

Country of ref document: EP

Kind code of ref document: A1