Automatic code generation method and system for some / ip data type
The automatic code generation method solves the problems of inefficiency, error-proneness, and complex handling of nested types in the definition of SOME/IP protocol data types in intelligent connected vehicle software development. It achieves efficient and accurate code generation and version synchronization, and adapts to the development specifications of different enterprises.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA FAW CO LTD
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-30
AI Technical Summary
In the development of intelligent connected vehicle software, the SOME/IP protocol's data type definition process suffers from problems such as low efficiency of manual translation, susceptibility to errors, difficulty in version synchronization, and complex handling of nested types.
It employs an automatic code generation method, which generates type definition code that conforms to C language specifications through data dictionary reading, type classification and identification and processing, multi-round iterative dependency resolution, naming standardization and code generation output. It supports the parsing and processing of multi-dimensional arrays and multi-level nested structures, and provides data boundary verification and version one-to-one correspondence.
It automates code generation, reduces manual coding time, improves development efficiency, lowers error rates, ensures code version consistency and adaptability, supports complex data type definition requirements, and enhances the coherence and robustness of the development process.
Smart Images

Figure CN122308840A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle system development, and in particular to automatic code generation methods for SOME / IP data types, automatic code generation systems for SOME / IP data types, electronic devices, storage media, and vehicle development platforms. Background Technology
[0002] In the development of intelligent connected vehicle software, SOME / IP (Scalable Service-Oriented Middleware IP), as the core communication protocol of the AUTOSAR Adaptive Platform (AP), requires that the data types of service interfaces be precisely defined in C language. The current industry generally adopts the following development process:
[0003] System engineers use Microsoft Excel spreadsheets to maintain a "data dictionary," defining metadata such as signal names, data types (basic types, enumerations, structures, arrays), value ranges, precision, and units. Existing technology suffers from the following prominent problems:
[0004] Manual translation is inefficient and error-prone: When faced with hundreds or even thousands of data types, manual coding is time-consuming and prone to spelling errors, type mismatches (such as mistakenly writing uint16 as int16), and inconsistent array lengths.
[0005] Version synchronization difficulties: After the Excel data dictionary is updated, the C code is difficult to synchronize in a timely manner, resulting in communication parsing failure or system abnormalities;
[0006] Nested types are complex to handle: When a structure contains other structures or arrays (such as VehicleInfo containing SensorArray[8]), manual maintenance is required to strictly follow the definition order, which is costly.
[0007] Therefore, there is a need for an automatic code generation strategy for SOME / IP data types to reduce the risk of errors for system engineers during the development process and improve development efficiency. Summary of the Invention
[0008] The purpose of this invention is to provide an automatic code generation method for SOME / IP data types, an automatic code generation system for SOME / IP data types, an electronic device, a storage medium, and a vehicle development platform, thereby solving at least one of a number of technical problems.
[0009] Manual translation is inefficient and error-prone; version synchronization is difficult; and handling nested types is complex.
[0010] This invention provides the following solution:
[0011] According to a first aspect of the present invention, an automatic code generation method for SOME / IP data types is provided, applied to the development of SOME / IP protocols in the AUTOSAR Adaptive Platform architecture of intelligent connected vehicles, comprising:
[0012] S1, Data dictionary read: Obtain the data dictionary for SOME / IP protocol communication;
[0013] The data dictionary for SOME / IP protocol communication includes worksheets in the form of Excel files and named with predefined conventions (e.g., "DataType Definition").
[0014] The data dictionary includes metadata such as signal name, data type, value range, precision, and unit.
[0015] S2, Data Type Classification, Identification and Processing: Open the Excel file from step S1, classify each row of data in the worksheet into one of the following: basic data type, enumeration type, structure type, array type, and perform specific parsing processing for different types;
[0016] Specifically, by identifying merged cells in Excel, the boundaries and member composition of the structure type are determined, thus completing the parsing of the structure type;
[0017] S3, Multi-round Iterative Dependency Resolution: Employs a multi-round scanning strategy to resolve nested dependency relationships between various types of data;
[0018] The first round of scanning processes basic data types and independent enumeration types that have no other type dependencies.
[0019] Based on the first round of scanning, each subsequent round of scanning only processes struct types and array types whose dependencies are already defined, until all data types are defined, or circular dependencies that cannot be resolved in step S3 are identified;
[0020] S4, Naming Standardization Processing: Standardize the names of each data type after parsing according to preset naming rules;
[0021] Standardized configuration includes removing redundant prefixes from the original name and adding a unified project-specific prefix to avoid naming conflicts with other software modules;
[0022] S5, Standard Code Generation Output: Converts all data types that have undergone naming standardization into type definition code that conforms to C language specifications;
[0023] In this process, the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file are converted into code comments, generating a C language header file that can be included in the compilation project.
[0024] Furthermore, including:
[0025] In step S2, the basic data types include integers and floating-point numbers. The parsing and processing of integers and floating-point numbers involves converting them into the standard C language basic data type representation while retaining the original metadata.
[0026] The enumeration type parsing process converts the "name: value" pairing into a C language standardized constant definition;
[0027] The array type parsing process automatically identifies the basic / enumerated type of the array elements and the maximum number of elements, and generates the corresponding C language array definition.
[0028] Furthermore, including:
[0029] In step S2, the parsing process for the structure type also includes verifying whether the types of each member of the structure have been defined.
[0030] If it is not defined, the structure type is temporarily stored. After its member types are defined, the stored structure type is retrieved to complete the subsequent processing.
[0031] Furthermore, including:
[0032] In step S3, the execution logic of the multi-round scanning strategy is as follows:
[0033] After each round of scanning is completed, the list of defined data types is updated;
[0034] In the next round of scanning, based on the updated list of defined data types, the dependencies of the data types to be processed are matched until the list of data types to be processed is empty, or a circular dependency is detected.
[0035] Furthermore, including:
[0036] In step S3, if a circular dependency is identified, a circular dependency warning message is generated.
[0037] The message includes the names of all data types with circular dependencies and their mutual references.
[0038] Furthermore, including:
[0039] In step S4, the preset naming rule is set to a dynamically configurable rule;
[0040] The dynamically configurable rules include support for adjusting prefix removal, addition, character format, and length limits according to the development specifications of different enterprises.
[0041] According to a second aspect of the present invention, an automatic code generation system for SOME / IP data types is provided, applied to the development of SOME / IP protocols in the AUTOSAR Adaptive Platform architecture of intelligent connected vehicles, comprising:
[0042] Data dictionary reading module: used to obtain the data dictionary for SOME / IP protocol communication;
[0043] The data dictionary for SOME / IP protocol communication includes worksheets in the form of Excel files and named with predefined conventions (e.g., "DataType Definition").
[0044] The data dictionary includes metadata such as signal name, data type, value range, precision, and unit.
[0045] Type classification processing module: Communicates with the data dictionary reading module to open the Excel file, and is used to classify each row of data in the worksheet into one of the following types: basic data type, enumeration type, structure type, and array type, and perform exclusive parsing processing for different types;
[0046] Specifically, by identifying merged cells in Excel, the boundaries and member composition of the structure type are determined, thus completing the parsing of the structure type;
[0047] Multi-round iterative dependency resolution module: Communicates with the type classification processing module and is used to resolve nested dependency relationships between various types of data using a multi-round scanning strategy;
[0048] The first round of scanning processes basic data types and independent enumeration types that have no other type dependencies.
[0049] Based on the first round of scanning, each subsequent round of scanning only processes struct types and array types whose dependencies are already defined, until all data types are defined, or circular dependencies that cannot be resolved in multiple rounds of iterative dependency resolution modules are identified;
[0050] Naming standardization module: Communicates with the multi-round iterative dependency resolution module and is used to standardize the names of each data type that has been resolved according to preset naming rules;
[0051] Standardized configuration includes removing redundant prefixes from the original name and adding a unified project-specific prefix to avoid naming conflicts with other software modules;
[0052] Code generation output module: Communicates with the naming standardization module and is used to convert all data types that have undergone naming standardization into type definition code that conforms to the C language specification;
[0053] In this process, the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file are converted into code comments, generating a C language header file that can be included in the compilation project.
[0054] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0055] The memory stores computer programs that, when executed by a processor, cause the processor to perform steps such as those of an automatic code generation method for SOME / IP data types.
[0056] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, comprising: storing a computer program executable by an electronic device, wherein when the computer program is run on the electronic device, the electronic device causes the electronic device to perform steps such as an automatic code generation method for SOME / IP data types.
[0057] According to a fifth aspect of the present invention, a vehicle development platform is provided, comprising:
[0058] Electronic devices for implementing steps such as automatic code generation methods for SOME / IP data types;
[0059] The processor runs programs and, when the program is running, executes steps such as automatic code generation methods for SOME / IP data types from data output by the electronic device.
[0060] Storage medium used to store programs that, when run, execute steps such as automatic code generation methods for SOME / IP data types on data output from electronic devices.
[0061] The above solution achieves the following beneficial technical effects:
[0062] This application reduces the manual translation work of several hours to seconds by replacing manual coding with automated parsing and generation. At the same time, it automatically generates auxiliary code such as data boundary verification, format conversion, and variable initialization through deep utilization of metadata, further reducing the workload of engineers for secondary development. The incremental generation mode only updates the code for the modified data types, avoiding the redundant operation of full generation and improving the efficiency of code update.
[0063] This application uses full-dimensional data dictionary verification (missing metadata, abnormal format, value conflicts, etc.) and code pre-verification (C language syntax + SOME / IP protocol requirements) to identify and locate various errors in advance; the standardized parsing and generation logic eliminates transcription errors such as spelling, type matching, and array length errors caused by manual translation; multi-round iterative dependency parsing ensures that the nested type definition order is compliant; the generated code can be directly incorporated into the compilation project without additional modification costs.
[0064] This application supports the parsing and processing of multidimensional arrays and multi-level nested structures, adapting to the complex data type definition requirements in actual development; the naming rules are dynamically expanded, adding C language reserved word avoidance and duplicate name uniqueness processing, which can flexibly adapt to the personalized naming specifications of different enterprises; by merging cells to identify structure boundaries, there is no need to change the engineers' original dictionary maintenance habits, reducing the cost of solution implementation and adaptation.
[0065] This application establishes a one-to-one correspondence between the data dictionary and the generated code versions, providing a clear basis for code traceability; it adds conflict detection for multi-user collaborative editing to avoid content overwriting and conflict issues in multi-device editing of the dictionary; and it generates independent version logs and incremental modification logs, making it easier for engineers to quickly locate code changes and ensuring version consistency between the data dictionary and the code from the root.
[0066] This application provides standardized APIs and trigger interfaces to support seamless integration with AUTOSAR AP development tools, Git code version management tools, and in-vehicle software compilation tools. It achieves full automation of the process, from automatically generating code after saving an Excel dictionary to automatically committing the generated code to the repository. This avoids tedious manual triggering and improves the overall continuity of the development process.
[0067] This application generates precise prompts with specific location and type for issues such as circular dependencies, data dictionary anomalies, and code syntax errors, allowing engineers to quickly locate and resolve problems, significantly reducing troubleshooting time. All parsing, generation, and verification logic is automated, reducing maintenance costs associated with manual intervention. At the same time, the solution can handle edge scenarios such as empty structures and extremely long arrays, improving robustness in practical engineering applications. Attached Figure Description
[0068] Figure 1 This is a flowchart of an automatic code generation method for SOME / IP data types provided by one or more embodiments of the present invention.
[0069] Figure 2 This is a structural diagram of an automatic code generation system for SOME / IP data types provided by one or more embodiments of the present invention.
[0070] Figure 3 This is a block diagram of an electronic device structure for an automatic code generation method for SOME / IP data types provided in one or more embodiments of the present invention. Detailed Implementation
[0071] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0072] Figure 1 This is a flowchart of an automatic code generation method for SOME / IP data types provided by one or more embodiments of the present invention.
[0073] like Figure 1 The automatic code generation method for SOME / IP data types shown is applied to the development of SOME / IP protocols in the AUTOSAR Adaptive Platform architecture for intelligent connected vehicles. The automatic code generation method for SOME / IP data types includes:
[0074] S1, Data dictionary read: Obtain the data dictionary for SOME / IP protocol communication;
[0075] The data dictionary for SOME / IP protocol communication includes worksheets in Excel format, named using a predefined convention ("DataType Definition").
[0076] The data dictionary includes metadata such as signal name, data type, value range, precision, and unit.
[0077] S2, Data Type Classification, Identification and Processing: Open the Excel file from step S1, classify each row of data in the worksheet into one of the following: basic data type, enumeration type, structure type, array type, and perform specific parsing processing for different types;
[0078] Specifically, by identifying merged cells in Excel, the boundaries and member composition of the structure type are determined, thus completing the parsing of the structure type;
[0079] S3, Multi-round Iterative Dependency Resolution: Employs a multi-round scanning strategy to resolve nested dependency relationships between various types of data;
[0080] The first round of scanning processes basic data types and independent enumeration types that have no other type dependencies.
[0081] Based on the first round of scanning, each subsequent round of scanning only processes struct types and array types whose dependencies are already defined, until all data types are defined, or circular dependencies that cannot be resolved in step S3 are identified;
[0082] S4, Naming Standardization Processing: Standardize the names of each data type after parsing according to preset naming rules;
[0083] Standardized configuration includes removing redundant prefixes from the original name and adding a unified project-specific prefix to avoid naming conflicts with other software modules;
[0084] S5, Standard Code Generation Output: Converts all data types that have undergone naming standardization into type definition code that conforms to C language specifications;
[0085] In this process, the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file are converted into code comments, generating a C language header file that can be included in the compilation project.
[0086] Specifically, in another specific embodiment, the standard code generation output step supports an incremental generation mode. By comparing the differences between the current data dictionary and the previous version, only the modified / added / deleted data types can be updated with code, while retaining the code definitions of the unmodified data types. At the same time, an incremental modification log is generated to mark the code changes.
[0087] In another specific embodiment, the edit version information and modification time of the Excel data dictionary are extracted, a unique version identifier is added to the generated C language header file, a one-to-one correspondence between "data dictionary version - code version" is established, and the version association information is written into the header file comments and a separate version log file.
[0088] In another specific embodiment, the generated C language type definition code is double-checked for C language syntax specifications and SOME / IP protocol data type requirements. If the check passes, the final header file is output; if the check fails, a syntax error message is generated and the line of code with the error is located.
[0089] In another specific embodiment, the data dictionary reading step also includes multi-user collaborative editing conflict detection. If a conflict record of simultaneous editing on multiple devices is detected in the Excel data dictionary, a conflict prompt message is immediately generated, marking the node, time and content of the conflicted editing. The subsequent parsing steps are executed after the conflict is resolved.
[0090] In another specific embodiment, a toolchain integration step is also included, providing standardized API interfaces and trigger interfaces to support interface with AUTOSAR AP development tools, Git code version management tools, and vehicle software compilation tools, thereby realizing an automated process of automatically triggering code generation after saving the Excel dictionary and automatically committing the generated code to the Git repository.
[0091] In this embodiment, it includes:
[0092] In step S2, the basic data types include integers and floating-point numbers. The parsing and processing of integers and floating-point numbers involves converting them into the standard C language basic data type representation while retaining the original metadata.
[0093] The enumeration type parsing process converts the "name: value" pairing into a C language standardized constant definition;
[0094] The array type parsing process automatically identifies the basic / enumerated type of the array elements and the maximum number of elements, and generates the corresponding C language array definition.
[0095] Specifically, in another embodiment, the array type also includes multidimensional arrays. The parsing process for multidimensional arrays involves automatically identifying the array's dimensions, the number of elements in each dimension, and the basic element type, generating a multidimensional array definition that conforms to the C language specification. The structure type also includes multi-level nested structures. The identification and definition of members of multi-level nested structures are completed through multiple rounds of iterative dependency parsing.
[0096] In this embodiment, it includes:
[0097] In step S2, the parsing process for the structure type also includes verifying whether the types of each member of the structure have been defined.
[0098] If it is not defined, the structure type is temporarily stored. After its member types are defined, the stored structure type is retrieved to complete the subsequent processing.
[0099] In this embodiment, it includes:
[0100] In step S3, the execution logic of the multi-round scanning strategy is as follows:
[0101] After each round of scanning is completed, the list of defined data types is updated;
[0102] In the next round of scanning, based on the updated list of defined data types, the dependencies of the data types to be processed are matched until the list of data types to be processed is empty, or a circular dependency is detected.
[0103] In this embodiment, it includes:
[0104] In step S3, if a circular dependency is identified, a circular dependency warning message is generated.
[0105] The message includes the names of all data types with circular dependencies and their mutual references.
[0106] In this embodiment, it includes:
[0107] In step S4, the preset naming rule is set to a dynamically configurable rule;
[0108] The dynamically configurable rules include support for adjusting prefix removal, addition, character format, and length limits according to the development specifications of different enterprises.
[0109] Specifically, in another specific embodiment, the preset naming rules also include C language reserved word avoidance rules and duplicate name differentiation rules. If the original name of the data type is a C language reserved word, a preset suffix is automatically added. If multiple data type names are duplicated after standardization, suffixes are added sequentially according to the sequence number to achieve name uniqueness.
[0110] In this embodiment, it includes:
[0111] In step S5, the standard basic data types of the C language include uint8_t, uint16_t, int16_t, qs_float32_t, and double. The generated C language type definition code includes the standardized definition format of the typedef keyword.
[0112] In this embodiment, it includes:
[0113] In step S5, the generated C language header file is a .h format file. The file does not require manual modification and can be directly imported into the compilation project of the intelligent connected vehicle software.
[0114] In this embodiment, a data dictionary verification step is also included:
[0115] In step S1, after the data dictionary is read, the metadata in the worksheet is checked for missing data, inconsistent formats, or conflicting values.
[0116] If it exists, then generate the corresponding verification error message, indicating the error location and error type.
[0117] Specifically, in another embodiment, the data dictionary verification step further includes verification of abnormal data definitions. Abnormal data definitions include array length of 0 / negative number, duplicate / non-integer enumeration values, value range not matching data type, and undefined type of structure member reference. After an abnormality is detected, the abnormal type and the corresponding data dictionary line number are clearly stated in the error message.
[0118] In another specific embodiment, a metadata deep utilization step is also included, which generates data boundary verification code based on the value range in the data dictionary, generates data format conversion code based on the precision, and generates variable initialization code based on the initial value. The code and type definition code are written together into a C language header file.
[0119] Figure 2 This is a structural diagram of an automatic code generation system for SOME / IP data types provided by one or more embodiments of the present invention.
[0120] like Figure 2 The automated code generation system shown is for SOME / IP data types and is applied to the development of SOME / IP protocols in the AUTOSAR Adaptive Platform architecture for intelligent connected vehicles. It includes:
[0121] Data dictionary reading module: used to obtain the data dictionary for SOME / IP protocol communication;
[0122] The data dictionary for SOME / IP protocol communication includes worksheets in Excel format, named using a predefined convention ("DataType Definition").
[0123] The data dictionary includes metadata such as signal name, data type, value range, precision, and unit.
[0124] Type classification processing module: Communicates with the data dictionary reading module to open the Excel file, and is used to classify each row of data in the worksheet into one of the following types: basic data type, enumeration type, structure type, and array type, and perform exclusive parsing processing for different types;
[0125] Specifically, by identifying merged cells in Excel, the boundaries and member composition of the structure type are determined, thus completing the parsing of the structure type;
[0126] Multi-round iterative dependency resolution module: Communicates with the type classification processing module and is used to resolve nested dependency relationships between various types of data using a multi-round scanning strategy;
[0127] The first round of scanning processes basic data types and independent enumeration types that have no other type dependencies.
[0128] Based on the first round of scanning, each subsequent round of scanning only processes struct types and array types whose dependencies are already defined, until all data types are defined, or circular dependencies that cannot be resolved in multiple rounds of iterative dependency resolution modules are identified;
[0129] Naming standardization module: Communicates with the multi-round iterative dependency resolution module and is used to standardize the names of each data type that has been resolved according to preset naming rules;
[0130] Standardized configuration includes removing redundant prefixes from the original name and adding a unified project-specific prefix to avoid naming conflicts with other software modules;
[0131] Code generation output module: Communicates with the naming standardization module and is used to convert all data types that have undergone naming standardization into type definition code that conforms to the C language specification;
[0132] In this process, the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file are converted into code comments, generating a C language header file that can be included in the compilation project.
[0133] Specifically, in another embodiment, the system also includes a metadata deep utilization module, which is communicatively connected to the data dictionary reading module and the code generation output module. This module is used to generate data boundary verification code based on the value range of the data dictionary, generate data format conversion code based on the precision, generate variable initialization code based on the initial value, and transmit the code to the code generation output module to write it into a C language header file.
[0134] In another specific embodiment, the system further includes an incremental generation module, which is communicatively connected to the data dictionary reading module and the code generation output module. This module is used to compare the differences between the current and previous versions of the data dictionary, mark the data types that have been modified / added / deleted, and control the code generation output module to update the code only for the differences and generate an incremental modification log.
[0135] In another specific embodiment, the system also includes a version association module, which is connected to the data dictionary reading module and the code generation output module. This module is used to extract the version and modification time of the Excel data dictionary, add a unique version identifier to the generated C language header file, establish and store the correspondence between "data dictionary version - code version", and write the version information into the header file comments and an independent version log file.
[0136] In another specific embodiment, the system further includes a code pre-verification module, which is communicatively connected to the code generation output module. This module performs dual verification on the generated C language code for both C language syntax and SOME / IP protocol data type requirements. If the verification passes, the code generation output module is triggered to output the final header file. If the verification fails, a syntax error message is generated and the line of code with the error is located.
[0137] In another specific embodiment, the data dictionary reading module further includes a collaborative conflict detection unit, which is used to detect conflict records of simultaneous editing on multiple terminals of the Excel data dictionary, generate conflict prompt information including conflict node, time, and edited content, and suspend the transmission of data to the type classification processing module before the conflict is resolved.
[0138] In another specific embodiment, the system also includes a toolchain integration module that communicates with the code generation output module, provides standardized API interfaces and trigger interfaces, and supports interface with AUTOSAR AP development tools, Git code version management tools, and vehicle software compilation tools to achieve automated triggering of code generation and automatic version submission.
[0139] In this embodiment, the type classification processing module includes a basic type submodule, an enumeration type submodule, a structure type submodule, and an array type submodule. The four submodules perform dedicated parsing processing for their respective data types. The structure type submodule also has a structure member type definition verification function.
[0140] Specifically, in another embodiment, the array type submodule supports multidimensional array parsing, which can automatically identify the dimensions of the multidimensional array, the number of elements in each dimension, and the basic element type and generate the corresponding C language definition; the structure type submodule supports multi-level nested structure parsing, and works with the multi-round iterative dependency parsing module to complete the member identification and definition of multi-level nested structures.
[0141] In this embodiment, the multi-round iterative dependency resolution module includes a defined type management unit and a circular dependency detection unit. The defined type management unit is used to update the list of defined data types after multiple rounds of scanning in real time, and the circular dependency detection unit is used to identify circular dependencies between data types and generate prompt information.
[0142] In this embodiment, the naming standardization module includes a rule configuration unit and a name processing unit. The rule configuration unit supports dynamically adjusting naming rules according to enterprise development specifications, and the name processing unit performs specific operations such as removing redundant prefixes and adding project prefixes.
[0143] Specifically, in another embodiment, the rule configuration unit is also configured with C language reserved word avoidance rules and duplicate name differentiation rules, and the name processing unit has the functions of adding reserved word suffixes and adding duplicate name sequence number suffixes to ensure that all data type names after standardization are unique and not C language reserved words.
[0144] In this embodiment, the system also includes a data dictionary verification module, which is communicatively connected to the data dictionary reading module. It is used to verify the integrity, format uniformity, and value rationality of the data dictionary's metadata, and to generate and output verification error message.
[0145] Specifically, in another embodiment, the data dictionary verification module further includes an abnormal data definition verification unit, which is used to verify abnormal data such as array length being 0 / negative, duplicate / non-integer enumeration values, value range not matching data type, and structure member references to undefined types. The generated error message includes the abnormal type and the corresponding data dictionary line number.
[0146] In another specific embodiment, the data dictionary verification module further includes an empty type / excessively long array verification unit, which is used to verify empty structures, empty arrays, and excessively long arrays that exceed a preset length threshold. It generates completion prompts for empty types and generates risk warnings for excessively long arrays, and marks the array name and length.
[0147] It is worth noting that although this system / device only discloses the above-mentioned modules / units, it does not mean that this system / device is limited to the above-mentioned basic functional modules. On the contrary, what this invention intends to express is that, based on the above-mentioned basic functional modules, those skilled in the art can add one or more functional modules in combination with the prior art to form an infinite number of embodiments or technical solutions. That is to say, this system is open rather than closed. It cannot be assumed that the scope of protection of the claims of this invention is limited to the above-disclosed basic functional modules just because this embodiment only discloses a few basic functional modules.
[0148] In one specific embodiment, an automatic code generation method for SOME / IP data types is disclosed, aiming to solve: 1. Eliminating the repetitive work and error risks of manually translating Excel to C code. 2. Achieving automatic synchronization between the data dictionary and C code to ensure consistency. 3. Supporting dependency resolution for complex nested types (structures, arrays), and other core issues. It strives to significantly improve development efficiency: 1. Compressing hours of manual coding to second-level automatic generation; 2. Completely eliminating human error: avoiding transcription errors in key parameters such as type, length, and initial values.
[0149] In this embodiment, based on the illustration of the data dictionary in Excel, the following steps are performed:
[0150] (1) Read and understand the data dictionary in Excel
[0151] The system first opens the specified Excel file and locates the worksheet named "DataType Definition". This worksheet contains all the data required for communication, pre-filled by the system engineer according to specifications. For example:
[0152] A certain signal is called "vehicle speed", its type is "unsigned 16-bit integer", and its value range is 0 to 65535;
[0153] A certain state is called "running mode", which is an enumeration containing "start=0" and "stop=1";
[0154] A complex piece of information is called "vehicle information," which is a structure containing two sub-items: "vehicle speed" and "operating mode."
[0155] There are also arrays like "8-channel temperature sensor" that represent a group of values of the same type.
[0156] This embodiment automatically identifies these different categories of data and understands the relationships between them.
[0157] (2) Process different types of data according to their categories.
[0158] The system categorizes each row of data in Excel into one of the following four categories and processes it accordingly:
[0159] Basic data types (such as integers and floating-point numbers):
[0160] It automatically converts the data into a standard representation used in software development, while retaining the original units, precision, initial values, and other descriptive information, generating annotated definitions.
[0161] Enumeration types (such as state, mode):
[0162] The "name:value" pairing (such as "startup:0") is automatically converted into a set of standardized constant definitions, ensuring that the software will not confuse whether "startup" is 0 or 1 when it is used.
[0163] Structure type (composite data):
[0164] The system identifies which rows belong to the same structure by recognizing "merged cells" in the Excel file (a common practice in the automotive industry). It then lists each member of the structure (such as "vehicle speed" or "status") one by one, ensuring that the type of each member has been correctly defined.
[0165] Array type (a set of identical data):
[0166] It automatically identifies the element type (such as "temperature value") and maximum number (such as 8) of the array and generates the corresponding array definition.
[0167] (3) Intelligent handling of the "chicken or the egg" dependency problem
[0168] In real-world projects, it's common to encounter situations where "structure A contains structure B, but B hasn't been defined yet." Manually handling this requires repeatedly adjusting the order, which is extremely tedious.
[0169] This embodiment employs a "multi-round scanning" strategy:
[0170] The first round processes all simple data that does not depend on other types (such as basic types and independent enumerations).
[0171] The second round attempts to handle structs that only depend on types defined in the first round;
[0172] This process is repeated until all data is successfully defined, or an unresolved circular dependency is identified.
[0173] This method can automatically clarify complex reference relationships without human intervention.
[0174] (4) Standardize naming and output standard format files.
[0175] To comply with enterprise development standards, the system will automatically standardize the generated names. For example, unnecessary prefixes (such as "SF_") will be removed from the original names.
[0176] Add a consistent project prefix (such as "qs_sf_md_") to avoid conflicts with other modules;
[0177] The output file retains the Chinese descriptions, value ranges, and other information from the original Excel file as comments for developers to refer to.
[0178] Ultimately, the system outputs a standard header file (.h file), which software engineers can directly incorporate into the compilation project without any modifications.
[0179] In this embodiment, SOA is a software architecture pattern that organizes and provides application functionality through services, and it is applied in the automotive industry. SOA is widely used in the development of in-vehicle software systems to support the integration and interaction of various functions and services.
[0180] In this embodiment, SOME / IP (Scalable service-oriented middleware over IP) is an IP-based communication protocol stack suitable for distributed systems in the automotive field. It provides scalable service-oriented middleware to support communication and interaction between various electronic control units (ECUs) within the vehicle.
[0181] In this embodiment, a flexible communication mechanism based on the SOME / IP protocol stack is provided, supporting message publishing and subscription, as well as service discovery and invocation. This enables efficient message transmission and data exchange within the vehicle's internal network, allowing different software modules to work collaboratively and provide complex automotive functions.
[0182] In this embodiment, the SOME / IP protocol stack plays an important role in realizing the service-oriented architecture and communication within the vehicle, providing a reliable solution for the development and integration of automotive software systems.
[0183] In this embodiment, the number of stacks in the SOME / IP protocol stack (also known as the number of client services) usually varies depending on the specific implementation and application requirements, so there is no fixed standard value.
[0184] In this embodiment, based on the SOME / IP protocol stack, the number of client services is typically determined by the application's requirements and system design. Each service corresponds to a service interface; therefore, the number of services in the stack depends on the number of services and functions required in a specific automotive application.
[0185] In this embodiment, the number of services in the stack is typically determined based on the vehicle's internal functions and module divisions. These services may cover functions such as diagnostics, control, and communication. In actual development, engineers need to determine the number of services in the stack based on system design and application requirements, and configure and program accordingly.
[0186] Therefore, in this embodiment, determining the number of stacks in the SOME / IP protocol stack requires analysis and decision-making based on the specific application scenario and system design.
[0187] The core innovation of this embodiment lies in using merged cells in Excel to identify structure boundaries: no additional marking is required, and engineering practices are naturally utilized.
[0188] Multi-round iterative dependency resolution mechanism: solves the problem of nested type definition order and ensures that the generated code is compileable;
[0189] Dynamic naming rule configuration: Achieve enterprise-level naming convention adaptation through prefix replacement;
[0190] A unified parsing framework for four data types (Basic / Enum / Struct / Array); solving the problem of automatic code generation for SOME / IP data types. Currently, there is no evidence to prove that the aforementioned distinguishing technical features are existing technologies.
[0191] In another specific embodiment, the above embodiments have some risks when implemented in engineering, which may affect the technical effect. These risks are also disclosed in this application, as follows:
[0192] 1. Due to the strong formatting dependency of Excel data dictionaries, there is a lack of formatting error tolerance and validation mechanisms.
[0193] The current solution relies excessively on engineers pre-filling Excel spreadsheets according to specifications: for example, requiring a fixed worksheet name "DataType Definition," the use of merged cells to identify structures, and specifying data types / value ranges in a particular format. This application establishes a more robust format validation and error-tolerance mechanism to prevent the solution from failing to parse in the following situations:
[0194] Worksheet naming error (e.g., spelled as "DataTypeDefine"), incorrect use of merged cells (e.g., structure members not merged, non-structure members mistakenly merged);
[0195] Key data items are missing in Excel (such as array length not filled in, or no matching values in the enumeration).
[0196] The data fields are entered in inconsistent formats (e.g., some write "uint16", while others write "unsigned 16-bit integer").
[0197] In the automotive industry, non-standard formatting is a frequent problem when multiple people collaborate to maintain dictionaries, and this defect will directly affect the practicality of the solution.
[0198] 2. The handling of circular dependencies only involves "identification" and lacks specific feedback and location mechanisms.
[0199] Although this application employs "multiple rounds of scanning until all data definitions are completed, or until an unsolvable circular dependency is confirmed," further rules need to be established based on this application to report circular dependency issues to engineers.
[0200] For example, clear error messages (such as which types have circular dependencies); dependency log output, so that engineers can quickly locate the nodes of circular dependencies; and preset temporary handling solutions (such as skipping circular dependency types and generating marked comments) to prevent the entire code generation process from being interrupted and affecting development efficiency.
[0201] 3. The lack of detection and processing for abnormal data may lead to the risk of generating error codes.
[0202] This application considers "standard dictionary definitions," but when detecting illegal / conflicting data definitions in Excel, the program will directly generate code that does not conform to C language standards, causing compilation failure, if the following conditions exist:
[0203] For example, the data type definition is invalid (such as a type not recognized by the custom program, or an array length of 0 / negative); there are enumeration value conflicts / duplicates (such as "Start: 0" and "Stop: 0"), or the enumeration value is not an integer; the structure member type is not defined (such as referencing a non-existent basic type); the value range does not match the data type (such as writing the value range of uint8 type as -10~200).
[0204] Based on this application, the detection and processing strategies for illegal / conflicting data definitions need to be further enriched.
[0205] 4. The naming rules need to be further enriched to ensure extensibility; otherwise, they will not be able to adapt to complex enterprise standards in the future.
[0206] This application specifically emphasizes the basic naming configuration of "removing redundant prefixes and adding a unified project prefix," but the naming conventions of some companies in the automotive industry cannot be fully disclosed, and the existing mechanisms are not compatible.
[0207] For example, automatic conversion of camelCase / underscore naming and keyword filtering (such as avoiding the use of C language reserved words);
[0208] For example, there may be strict limits on name length, or the naming may be hierarchical according to "module-function-type";
[0209] Requirements such as automatically adding suffixes to distinguish duplicate names may result in the current naming conventions not conforming to or being incompatible with company standards.
[0210] 5. This application addresses the "synchronization of dictionary and code," but does not yet address the version management issue of the Excel dictionary itself.
[0211] The version synchronization in this application is limited to "code can be regenerated after dictionary update", but in reality, it may be limited by multi-person collaborative version control of Excel data dictionary:
[0212] If multiple engineers edit an Excel dictionary simultaneously, editing conflicts and data overwriting are likely to occur.
[0213] Without an Excel dictionary version tracking mechanism, the generated code will also fail if the dictionary is modified incorrectly.
[0214] Based on the proposed solution, further steps should be taken to address the association between dictionary versions and code versions by setting up a quick match function to determine which dictionary version corresponds to a specific code version, thus resolving the deep-seated version consistency issue.
[0215] 6. This application also has a parsing vulnerability in its handling of the boundaries of complex nested types.
[0216] In addition to supporting nested structures and arrays, this application also needs to expand its ability to handle more complex nested scenarios and address potential parsing vulnerabilities.
[0217] Such scenarios may occur in actual development, such as multidimensional arrays (e.g., SensorArray [8][4]), nested arrays / structures; special cases such as enumerations as structure members and array elements as structures; handling of empty structures, empty arrays, and excessively long arrays. If the program does not handle these scenarios specifically, it may lead to parsing failure or the generation of error code.
[0218] 7. This application also needs to consider integration with existing development toolchains to ensure it fits into existing enterprise processes.
[0219] This application currently achieves one-way generation of "Excel → .h file", but the automotive industry already has mature development toolchains (such as AUTOSAR AP tools, code management tool Git, compilers, and diagnostic tools). For this application's solution to be implemented, it also needs enhanced integration with these tools.
[0220] For example, automatically generating code after saving an Excel file, and automatically updating code after committing a dictionary in Git;
[0221] The system provides standardized interfaces for other tools to use, thereby integrating into the enterprise's automated build process.
[0222] The generated .h file needs to be optimized for compatibility with the AUTOSAR tool, and engineers will need to make further adjustments and development.
[0223] 8. Based on the existing Excel metadata, we should further deepen its utilization.
[0224] The Excel data dictionary contains rich metadata such as value range, precision, unit, and initial value. This solution only includes this information as comments in the .h file. Further, more in-depth utilization is also possible.
[0225] For example, it can automatically generate data validation code based on the value range (such as numeric boundary checks for uint8 type); it can automatically generate data conversion logic based on precision (such as rounding from floating-point to integer); and it can automatically generate variable initialization code based on the initial value, further improving development efficiency.
[0226] 9. Set up a generation mechanism for incremental code generation to control the impact of full generation on development efficiency.
[0227] Building upon this application, incremental generation is further extended. If only a small type in the Excel dictionary is modified (such as changing a certain enumeration value), the program will still generate the entire .h file:
[0228] A full build can lead to a messy modification history in the code files, making it difficult for engineers to pinpoint "which type of modification was made this time";
[0229] While full generation may still take seconds when dealing with thousands of data types, it increases the cost of file storage and version management, and does not conform to the "incremental update" principle of software development.
[0230] Figure 3 This is a block diagram of an electronic device structure for an automatic code generation method for SOME / IP data types provided in one or more embodiments of the present invention.
[0231] like Figure 3 As shown, this application provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0232] The memory stores a computer program that, when executed by a processor, causes the processor to perform steps of an automatic code generation method oriented towards SOME / IP data types.
[0233] This application also provides a computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of an automatic code generation method oriented towards SOME / IP data types.
[0234] This application also provides a vehicle development platform, including:
[0235] An electronic device for implementing an automatic code generation method for SOME / IP data types;
[0236] The processor runs programs and, when the programs are running, executes the steps of an automatic code generation method targeting SOME / IP data types from data output by the electronic device.
[0237] Storage medium for storing programs that, when run, execute automatic code generation methods oriented towards SOME / IP data types on data output from electronic devices.
[0238] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0239] The electronic device comprises a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on the operating system. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory. The operating system can be any one or more computer operating systems that control the electronic device through processes, such as Linux, Unix, Android, iOS, or Windows. Furthermore, in this embodiment of the invention, the electronic device can be a smartphone, tablet computer, or other handheld device, or a desktop computer, portable computer, or other electronic device; there is no particular limitation in this embodiment.
[0240] In this embodiment of the invention, the executing entity for electronic device control can be an electronic device itself, or a functional module within an electronic device capable of calling and executing a program. The electronic device can obtain the firmware corresponding to the storage medium. This firmware is provided by the supplier, and different storage media may have the same or different firmware; no limitation is made here. After obtaining the firmware corresponding to the storage medium, the electronic device can write this firmware into the storage medium; specifically, it burns the firmware corresponding to the storage medium into the storage medium. The process of burning the firmware into the storage medium can be implemented using existing technology, and will not be elaborated upon in this embodiment of the invention.
[0241] Electronic devices can also obtain reset commands corresponding to the storage media. The reset commands corresponding to the storage media are provided by the supplier. The reset commands corresponding to different storage media can be the same or different, and no restrictions are imposed here.
[0242] At this time, the storage medium of the electronic device is a storage medium on which the corresponding firmware has been written. The electronic device can respond to the reset command corresponding to the storage medium on which the corresponding firmware has been written, thereby resetting the storage medium on which the corresponding firmware has been written according to the reset command. The process of resetting the storage medium according to the reset command can be implemented by existing technology and will not be described in detail in this embodiment of the invention.
[0243] For ease of description, the above devices are described separately by function as various units and modules. Of course, in implementing this application, the functions of each unit and module can be implemented in one or more software and / or hardware.
[0244] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the meaning consistent with their meaning in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined.
[0245] For the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0246] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0247] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatic code generation for SOME / IP data types, characterized in that, The automatic code generation method for SOME / IP data types includes: S1, Data dictionary read: Obtain the data dictionary for SOME / IP protocol communication; The data dictionary for SOME / IP protocol communication includes worksheets in Excel format with pre-defined names. S2, Data Type Classification, Identification and Processing: Open the Excel file from step S1, classify each row of data in the worksheet into one of the following: basic data type, enumeration type, structure type, array type, and perform specific parsing processing for different types; S3, Multi-round Iterative Dependency Resolution: Employs a multi-round scanning strategy to resolve nested dependency relationships between various types of data; S4, Naming Standardization Processing: Standardize the names of each data type after parsing according to preset naming rules; S5, Standard Code Generation Output: Converts all data types that have undergone naming standardization into type definition code that conforms to C language specifications; It also includes synchronously converting the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file into code comments, generating a C language header file that can be included in the compilation project.
2. The automatic code generation method for SOME / IP data types according to claim 1, characterized in that, include: In step S2, the basic data types include integers and floating-point numbers. The parsing process for integers and floating-point numbers involves converting them into the standard C language basic data type representation while retaining the original metadata. The enumeration type parsing process involves converting the pairing relationships of data into standardized C language constant definitions. The array type parsing process involves automatically identifying the basic / enumerated type of the array elements and the maximum number of elements, and generating the corresponding C language array definition.
3. The automatic code generation method for SOME / IP data types according to claim 1, characterized in that, include: In step S2, the parsing process for the structure type also includes verifying whether the types of each member of the structure have been defined. If it is not defined, the structure type is temporarily stored. After its member types are defined, the stored structure type is retrieved to complete the subsequent processing.
4. The automatic code generation method for SOME / IP data types according to claim 1, characterized in that, include: In step S3, the execution logic of the multi-round scanning strategy is as follows: After each round of scanning is completed, the list of defined data types is updated; In the next round of scanning, based on the updated list of defined data types, the dependencies of the data types to be processed are matched until the list of data types to be processed is empty, or a circular dependency is detected.
5. The automatic code generation method for SOME / IP data types according to claim 1, characterized in that, include: In step S3, if a circular dependency is identified, a circular dependency warning message is generated. The prompt information This includes the names of all data types that have circular dependencies and their mutual references.
6. The automatic code generation method for SOME / IP data types according to claim 1, characterized in that, include: In step S4, the preset naming rule is set to a dynamically configurable rule; The dynamically configurable rules include support for adjusting prefix removal, addition, character format, and length limits according to different development specifications.
7. An automatic code generation system for SOME / IP data types, characterized in that, The automatic code generation system for SOME / IP data types includes: Data dictionary reading module: used to obtain the data dictionary for SOME / IP protocol communication; The data dictionary for SOME / IP protocol communication includes worksheets in Excel format with pre-defined names. The data dictionary includes metadata such as signal name, data type, value range, precision, and unit. Type classification processing module: Communicates with the data dictionary reading module to open Excel files, and is used to classify each row of data in the worksheet into one of the following types: basic data type, enumeration type, structure type, and array type, and perform dedicated parsing processing for different types; Specifically, by identifying merged cells in Excel, the boundaries and member composition of the structure type are determined, thus completing the parsing of the structure type; Multi-round iterative dependency resolution module: Communicates with the type classification processing module and is used to resolve nested dependency relationships between various types of data using a multi-round scanning strategy; The first round of scanning processes basic data types and independent enumeration types that have no other type dependencies. Based on the first round of scanning, each subsequent round of scanning only processes struct types and array types whose dependencies are already defined, until all data types are defined, or circular dependencies that cannot be resolved in multiple rounds of iterative dependency resolution modules are identified; Naming standardization module: Communicates with the multi-round iterative dependency resolution module and is used to standardize the names of each data type that has been resolved according to preset naming rules; Standardized configuration includes removing redundant prefixes from the original name and adding a unified project-specific prefix to avoid naming conflicts with other software modules; Code generation output module: Communicates with the naming standardization module and is used to convert all data types that have undergone naming standardization into type definition code that conforms to the C language specification; In this process, the value range, precision, unit, and Chinese description metadata in the data dictionary of the Excel file are converted into code comments, generating a C language header file that can be included in the compilation project.
8. An electronic device, characterized in that, include: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory stores a computer program that, when executed by a processor, causes the processor to perform the steps of the automatic code generation method for SOME / IP data types as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, include: The device stores a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of the automatic code generation method for SOME / IP data types as described in any one of claims 1 to 6.
10. A vehicle development platform, characterized in that, include: An electronic device for implementing the steps of the automatic code generation method for SOME / IP data types as described in any one of claims 1 to 6; A processor that runs a program, which, when the program is running, performs the steps of the automatic code generation method for SOME / IP data types as described in any one of claims 1 to 6 from data output by the electronic device. A storage medium for storing a program that, when run, performs the steps of the automatic code generation method for SOME / IP data types as described in any one of claims 1 to 6 on data output from an electronic device.