SOMEIP-based code generation method and apparatus, and terminal

By generating message definitions and corresponding codes for SOMEIP services, the problem of low efficiency in manual code writing in the prior art is solved, and more efficient and accurate code generation is achieved.

CN120215910APending Publication Date: 2025-06-27CHERY AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510276345.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The prior art requires manual writing of a large amount of repetitive and tedious code when encapsulating and parsing SOMEIP messages, resulting in low efficiency and accuracy of code generation.

Method used

By obtaining the configuration file of the SOMEIP service, generating message definitions, and generating corresponding serialization and deserialization code based on this, avoiding manual writing of duplicate code.

Benefits of technology

Improves the efficiency and accuracy of code generation and saves time to write code manually, developers do not need to understand the underlying details of the SOMEIP protocol.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215910A_ABST
    Figure CN120215910A_ABST
Patent Text Reader

Abstract

The invention provides a code generation method and device based on SOMEIP and a terminal, and belongs to the technical field of vehicle communication. The method comprises the following steps: acquiring a configuration file of the SOMEIP service; generating a message definition of the SOMEIP service based on the configuration file; generating a serialized code and a deserialized code associated with the SOMEIP service based on the message definition of the SOMEIP service; wherein the serialization code is used for serializing the message definition in the process of packaging the SOMEIP message to obtain a byte sequence in the effective load field, and the deserialization code is used for deserializing the byte sequence in the effective load field of the SOMEIP message in the process of analyzing the SOMEIP message to obtain the message definition of the SOMEIP service. According to the technical scheme, manual writing of a large number of repeated and tedious codes is avoided, and the code generation efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of vehicle communication technologies, and particularly to a code generation method, device, and terminal based on SOMEIP. Background Art

[0002] With the development of vehicle electronic technologies, Ethernet communication is gradually playing an important role in the vehicle's electronic architecture. Among them, SOMEIP is an important protocol that supports vehicle Ethernet communication and is used to implement communication between electronic control units in the vehicle. A SOMEIP message consists of a header and a payload. The payload includes serialized data to be transmitted. However, the packing and parsing of the payload usually require manual code writing, resulting in relatively low efficiency and accuracy of code generation. Summary of the Invention

[0003] Embodiments of this application provide a code generation method, device, and terminal based on SOMEIP, which can improve the efficiency and accuracy of code generation. The technical solutions are as follows:

[0004] On the one hand, a code generation method based on SOMEIP is provided. The method includes:

[0005] Obtain a configuration file of the SOMEIP service, where the configuration file includes the name of the SOMEIP service, the parameters it includes, and the data type of each parameter;

[0006] Based on the configuration file of the SOMEIP service, generate a message definition of the SOMEIP service, where the message definition is used to represent the parameters included in the SOMEIP service and the data type of each parameter through structured data;

[0007] Based on the message definition of the SOMEIP service, generate serialization code and deserialization code associated with the SOMEIP service;

[0008] Among them, the serialization code is used to serialize the message definition during the process of encapsulating a SOMEIP message to obtain a byte sequence in the payload field, and the deserialization code is used to deserialize the byte sequence in the payload field of the SOMEIP message during the process of parsing the SOMEIP message to obtain the message definition of the SOMEIP service.

[0009] On the other hand, a code generation device based on SOMEIP is provided. The device includes:

[0010] An acquisition module, configured to acquire a configuration file of a SOMEIP service, where the configuration file includes the name of the SOMEIP service, the included parameters, and the data type of each parameter;

[0011] A first generation module, configured to generate a message definition of the SOMEIP service based on the configuration file of the SOMEIP service, where the message definition is used to represent the parameters included in the SOMEIP service and the data type of each parameter through structured data;

[0012] A second generation module, configured to generate serialization code and deserialization code associated with the SOMEIP service based on the message definition of the SOMEIP service;

[0013] Wherein, the serialization code is used to serialize the message definition during the process of encapsulating a SOMEIP message to obtain a byte sequence in the payload field, and the deserialization code is used to deserialize the byte sequence in the payload field of the SOMEIP message during the process of parsing the SOMEIP message to obtain the message definition of the SOMEIP service.

[0014] In some embodiments, the first generation module is configured to extract service information of the SOMEIP service from the configuration file, where the service information includes the name of the SOMEIP service, the included parameters, and the data type of each parameter; and generate a message definition of the SOMEIP service based on the service information of the SOMEIP service.

[0015] In some embodiments, the first generation module is configured to parse the configuration file to obtain service information of multiple SOMEIP services; save the service information of the multiple SOMEIP services to a text file in a preset format; and for any one of the SOMEIP services, traverse the text file to obtain the service information of the SOMEIP service.

[0016] In some embodiments, the configuration file is a file in ARXML format, and the text file is a file in JSON format.

[0017] In some embodiments, the second generation module is configured to generate first code based on the message definition of the SOMEIP service and the SOMEIP protocol, where the first code is used to convert the message definition into structured data; and generate second code based on the structured data and the AUTOSAR standard, where the second code is used to serialize the structured data into a byte sequence in the payload field of the SOMEIP message.

[0018] In some embodiments, the second generation module is configured to generate a third code based on the byte sequence in the payload field of the SOMEIP message and the AUTOSAR standard, where the third code is used to deserialize the byte sequence into structured data; and generate a fourth code based on the structured data and the SOMEIP protocol, where the fourth code is used to convert the structured data into the message definition of the SOMEIP service.

[0019] In some embodiments, the apparatus further includes:

[0020] A creation module, configured to, when the configuration file includes multiple SOMEIP services, create a serialization interface based on the serialization code associated with each SOMEIP service, where the serialization interface is used to serialize the message definition of any one of the SOMEIP services; and create a deserialization interface based on the deserialization code associated with each SOMEIP service, where the deserialization interface is used to deserialize the byte sequence in the payload field of any SOMEIP message.

[0021] In some embodiments, the apparatus further includes:

[0022] A first invocation module, configured to, when receiving the message definition of any SOMEIP service, obtain the service identifier of the SOMEIP service, where the service identifier is used to uniquely identify the SOMEIP service; and invoke the serialization interface based on the service identifier, and through the serialization interface, invoke the serialization code associated with the SOMEIP service based on the service identifier, so as to serialize the message definition of the SOMEIP service through the serialization code to obtain the byte sequence in the payload field of the SOMEIP message.

[0023] In some embodiments, the apparatus further includes:

[0024] A second invocation module, configured to, when receiving any SOMEIP message, obtain the service identifier corresponding to the SOMEIP message, where the service identifier is used to uniquely identify the SOMEIP service; and invoke the deserialization interface based on the service identifier, and through the deserialization interface, invoke the deserialization code associated with the SOMEIP service based on the service identifier, so as to deserialize the byte sequence in the payload field of the SOMEIP message through the serialization code to obtain the message definition of the SOMEIP service.

[0025] On the other hand, a terminal is provided, which includes a processor and a memory. The memory is used to store at least one segment of computer program, and the at least one segment of computer program is loaded and executed by the processor to implement the SOMEIP-based code generation method in the embodiments of the present application.

[0026] On the other hand, a computer-readable storage medium is provided, in which at least one segment of computer program is stored, and the at least one segment of computer program is loaded and executed by a processor to implement the SOMEIP-based code generation method in the embodiments of the present application.

[0027] On the other hand, a computer program product is provided, including a computer program, and the computer program is executed by a processor to implement the SOMEIP-based code generation method in the embodiments of the present application.

[0028] The embodiments of the present application provide a SOMEIP-based code generation method. By obtaining the configuration file of the SOMEIP service and generating message definitions and corresponding serialization and deserialization codes based on this, it avoids manually writing a large amount of repetitive and cumbersome codes in the process of encapsulating and parsing SOMEIP messages. Developers do not need to deeply understand the underlying details of the SOMEIP protocol and complex data processing logics, and only need to focus on the implementation of business functions. By adopting the above method, the time for manually writing codes can be saved, and the efficiency and accuracy of code generation are improved. Description of the Drawings

[0029] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0030] Figure 1 is a schematic diagram of the implementation environment of a SOMEIP-based code generation method provided according to an embodiment of the present application;

[0031] Figure 2 is a flowchart of a SOMEIP-based code generation method provided according to an embodiment of the present application;

[0032] Figure 3 is a flowchart of another SOMEIP-based code generation method provided according to an embodiment of the present application;

[0033] Figure 4 is a schematic diagram of a configuration file provided according to an embodiment of the present application;

[0034] Figure 5 It is a schematic diagram of a JSON file provided according to an embodiment of the present application;

[0035] Figure 6 It is a schematic diagram of a message definition provided according to an embodiment of the present application;

[0036] Figure 7 It is a schematic diagram of calling a serialization interface provided according to an embodiment of the present application;

[0037] Figure 8 It is a schematic diagram of calling a deserialization interface provided according to an embodiment of the present application;

[0038] Figure 9 It is a block diagram of a code generation device based on SOMEIP provided according to an embodiment of the present application;

[0039] Figure 10 It is a schematic structural diagram of a terminal provided according to an embodiment of the present application. Detailed implementation manners

[0040] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.

[0041] In the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and effects. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor are the quantity and execution order limited.

[0042] In the present application, the term "at least one" means one or more, and the meaning of "multiple" is two or more.

[0043] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.), and signals involved in the present application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions.

[0044] Figure 1 It is a schematic diagram of the implementation environment of a code generation method based on SOMEIP provided according to an embodiment of the present application. Refer to Figure 1 , and this implementation environment includes: terminal 101 and vehicle 102. Terminal 101 and vehicle 102 can communicate data through a wired network or a wireless network.

[0045] Among them, the terminal 101 is a code generation device, which is used to generate message definitions and related serialization and deserialization codes according to the configuration file of the SOMEIP service. Optionally, the terminal 101 can be a device such as a smartphone, a laptop, or a desktop computer. The vehicle 101 is a function test device, which is used to comprehensively test the functions implemented by the generated serialization and deserialization codes to ensure the stability and reliability of the SOMEIP service in the actual vehicle electronic environment.

[0046] In some embodiments, a configuration file containing the SOMEIP service name, parameters, and data types can be obtained through the terminal 101. The code generation script running on the terminal 101 parses the service information in the configuration file and generates the message definition of the SOMEIP service according to certain rules, and then generates the corresponding serialization and deserialization codes. Optionally, the generated codes are stored in a specified directory of the terminal 101 in the form of files for subsequent testing and deployment.

[0047] The vehicle 101 generally includes function test devices such as an intelligent driving domain controller and a cockpit domain controller. Through the above function test devices, different working conditions and communication scenarios can be simulated to perform function tests on the generated serialization code and deserialization code associated with the SOMEIP service.

[0048] During the test, ECU nodes such as the intelligent driving domain controller and the cockpit domain controller can simulate SOMEIP communication to verify whether the functions of the serialization code and deserialization code associated with the SOMEIP service are normal. For example, in the intelligent driving domain, it can be tested whether the driving assistance functions (such as adaptive cruise control, lane keeping assistance, etc.) of the intelligent driving domain controller can work properly through the SOMEIP protocol, that is, whether the intelligent driving domain controller can control the cockpit domain controller through SOMEIP messages. Through the above implementation environment, developers can efficiently complete the code generation and function test work of the SOMEIP service to ensure that the SOMEIP service in the automotive electronic system can run stably and reliably.

[0049] Figure 2 is a flowchart of a SOMEIP-based code generation method according to an embodiment of the present application. As Figure 2 shown, taking the method as being executed by the terminal as an example, the method includes the following steps:

[0050] 201. The terminal obtains the configuration file of the SOMEIP service.

[0051] In the embodiments of the present application, SOMEIP (Scalable service-Oriented MiddlewarE over IP) is a communication protocol used in the field of automotive electronics. A SOMEIP service is a service unit with specific functions defined based on this protocol, such as a vehicle temperature monitoring service, a door status monitoring service, etc. SOMEIP services can communicate and interact between different ECUs (Electronic Control Units) of a vehicle to implement various functions of the vehicle electronic system.

[0052] In the configuration file of the SOMEIP service, detailed information about the SOMEIP service is recorded, including but not limited to the name of the service, the parameters included in the service, and the data type of each parameter, etc. The configuration file can ensure that the definition and use of the SOMEIP service are more standardized and normalized, thereby facilitating the identification and invocation of the SOMEIP service by different devices.

[0053] Optionally, the configuration file can be pre-stored in the local storage device of the terminal, or the configuration file may also be stored on a server or other devices. Correspondingly, the terminal can read the configuration file from the local storage or obtain the configuration file from the server or other devices. The embodiments of the present application do not limit this.

[0054] 202. The terminal generates a message definition of the SOMEIP service based on the configuration file of the SOMEIP service. The message definition is used to represent the parameters included in the SOMEIP service and the data type of each parameter through structured data.

[0055] In the embodiments of the present application, the terminal parses the obtained configuration file to obtain service information such as the name of the SOMEIP service, the parameters, and the data type of the parameters. Then, based on the service information obtained by parsing, the terminal generates a message definition of the SOMEIP service according to certain rules. Among them, the message definition is structured data presented in a specific data structure form. For example, the message definition can be a Proto Message. A Proto Message is a data structure defined in Protobuf (Protocol Buffers, a lightweight and efficient structured data serialization protocol).

[0056] 203. The terminal generates serialization code and deserialization code associated with the SOMEIP service based on the message definition of the SOMEIP service.

[0057] In the embodiments of the present application, serialization refers to the process of converting structured data into a byte sequence that can be transmitted using the SOMEIP protocol. Serialization code is the program code used to implement this conversion process. In network transmission based on the SOMEIP protocol, the serialization code is used to serialize the message definition during the process of encapsulating SOMEIP messages, obtaining the byte sequence in the Payload field. Among them, the data carried by the Payload field is also the data transmitted by the SOMEIP message.

[0058] Deserialization is the opposite of serialization and is the process of restoring a byte sequence to structured data. Deserialization code is the program code that implements this restoration process. In network transmission based on the SOMEIP protocol, when a SOMEIP message is received, the byte sequence in the Payload field of the SOMEIP message can be deserialized through the deserialization code to obtain the message definition of the SOMEIP service, realizing the parsing of the SOMEIP message.

[0059] The embodiments of the present application provide a SOMEIP-based code generation method. By obtaining the configuration file of the SOMEIP service and generating the message definition and corresponding serialization and deserialization code based on this, it avoids manually writing a large amount of repetitive and cumbersome code during the process of encapsulating and parsing SOMEIP messages. Developers do not need to deeply understand the underlying details of the SOMEIP protocol and complex data processing logic, and only need to focus on the implementation of business functions. By adopting the above method, the time for manually writing code can be saved, and the efficiency and accuracy of code generation are improved.

[0060] Figure 3 is a flowchart of another SOMEIP-based code generation method provided according to the embodiments of the present application. As Figure 3 shown, taking the example that this method is executed by a terminal, the method includes the following steps:

[0061] 301. The terminal obtains the configuration file of the SOMEIP service.

[0062] In the embodiments of the present application, step 301 is the same as step 201 above and will not be elaborated here.

[0063] In addition, it should be noted that the configuration file can be an ARXML (AUTOSAR XML) file, which is an XML format file that follows the AUTOSAR (Automotive Open System Architecture) standard. The ARXML files of different vehicles or different vehicle models are different. Correspondingly, during the process of SOMEIP-based code generation for a certain vehicle model, the terminal can obtain the ARXML file corresponding to this vehicle model.

[0064] 302. The terminal extracts the service information of the SOMEIP service from the configuration file. The service information includes the name of the SOMEIP service, the parameters included, and the data type of each parameter.

[0065] In the embodiments of the present application, the configuration file usually records the service information of multiple SOMEIP services. The SOMEIP service is a service unit with specific functions defined based on this protocol, such as the vehicle temperature monitoring service, the door status monitoring service, etc. The service information of the SOMEIP service includes but is not limited to the service name, the parameters used in the service, and the data type of the parameters, etc. Optionally, the data type of the parameters includes but is not limited to basic data types (such as integers, floating-point numbers), composite data types (such as structures, arrays), and enumerated data types, etc.

[0066] Figure 4 is a schematic diagram of a configuration file provided according to the embodiments of the present application. As Figure 4 shown, this configuration file records the parameters used in the SOMEIP service named "IDT_ADAS_strt_TrafficSign", such as parameters like DTE_TSRSt, DTE_TrafficSignID, etc., and the data type of each parameter.

[0067] The process of the terminal extracting the service information of the SOMEIP service from the configuration file will be described below.

[0068] In some embodiments, the terminal parses the configuration file to obtain the service information of multiple SOMEIP services. Optionally, when the configuration file is an ARXML file, the terminal can first load the ARXML file, that is, a string in XML format, and then use an XML parsing library to traverse the XML nodes in the ARXML file to extract the service information of multiple SOMEIP services. Then, the terminal saves the service information of the multiple SOMEIP services extracted in a preset format to a text file. Correspondingly, the text file is used to store the service information in the preset format. Subsequently, when obtaining the service information of any SOMEIP service, the terminal can extract the service information of this SOMEIP service by traversing this text file. Since compared with a text file that only contains service information, the configuration file also includes other information of the SOMEIP service and the information contained is relatively complex. Therefore, by extracting and saving the service information of the SOMEIP service in a text file, it is convenient to quickly extract the service information of any SOMEIP service in a text file with less information in the future, improving the information processing efficiency.

[0069] Optionally, the text file can be a file in JSON format, that is, a JSON file. A JSON file is a lightweight data interchange format file, usually with the extension.json. Figure 5 is a schematic diagram of a JSON file provided according to an embodiment of the present application. As Figure 5 shown, the file contains service information of the SOMEIP service named "IDT_ADAS_strt_TrafficSign". This service includes 3 parameters of uint8_t (integer) type and 3 parameters of float (floating point) type.

[0070] 303. The terminal generates a message definition of the SOMEIP service based on the service information of the SOMEIP service.

[0071] In the embodiment of the present application, for any SOMEIP service, the terminal generates a message definition of the SOMEIP service according to the service information of the SOMEIP service according to certain rules. For example, the terminal can convert the service information of the SOMEIP service into a predefined data structure to obtain the message definition. Among them, the message definition is structured data presented in a specific data structure form. For example, the message definition can be a Proto Message. Correspondingly, the terminal can obtain the service information of each SOMEIP service by traversing the JSON file and generate the Proto Message of each SOMEIP service in the above manner. Further, the terminal can save the Proto Message of each SOMEIP service in a proto file. Figure 6 is a schematic diagram of a message definition provided according to an embodiment of the present application. As Figure 6 shown, the data structure of this Proto Message corresponds one-to-one with the data structure in the above Figure 5 shown JSON file.

[0072] 304. The terminal generates serialization code and deserialization code associated with the SOMEIP service based on the message definition of the SOMEIP service.

[0073] In the embodiments of the present application, the serialization code is the program code used to implement the serialization process of data. Among them, serialization is the process of converting structured data into a byte sequence that can be transmitted using the SOMEIP protocol. The deserialization code is the program code used to implement the restoration of the byte sequence to structured data. For example, in network transmission based on the SOMEIP protocol, the serialization code is used to serialize the message definition during the process of encapsulating SOMEIP messages, obtaining the byte sequence in the Payload field. The data carried in the Payload field is also the data transmitted by the SOMEIP message. Correspondingly, when receiving a SOMEIP message, the deserialization code can deserialize the byte sequence in the Payload field of the SOMEIP message to obtain the message definition of the SOMEIP service, realizing the parsing of the SOMEIP message.

[0074] Taking any SOMEIP service as an example, the generation process of the serialization code associated with the SOMEIP service will be described below.

[0075] In some embodiments, the terminal generates a first code according to the message definition of the SOMEIP service and the SOMEIP protocol. Among them, according to the SOMEIP protocol, the data structures supported by the SOMEIP protocol can be determined, and then, according to the message definition and the supported data structures, targeted conversion code, that is, the first code, is generated. The first code is mainly used to extract the field values in the message definition and convert them into the structure data supported by the SOMEIP protocol. Then, the terminal generates a second code according to the structure data and the AUTOSAR standard. Among them, AUTOSAR (Automotive Open System Architecture) is the automotive open system architecture standard, which is used to provide a standardized software architecture and interface for the development of automotive electronic systems. The AUTOSAR standard defines the interaction methods, data formats, communication protocols, etc. between software components, ensuring that software components developed by different suppliers can be seamlessly integrated in automotive electronic systems. The second code is used to serialize the structure data into the byte sequence in the Payload field of the SOMEIP message. Correspondingly, the first code and the second code constitute the serialization code associated with the SOMEIP service, jointly completing the serialization of the message definition of the SOMEIP service; and then, when there is a serialization requirement for the message definition of the SOMEIP service in the future, the serialization code can be directly called, without manually writing code each time, improving the data processing efficiency.

[0076] The generation process of the deserialization code associated with the SOMEIP service will be described below.

[0077] In some embodiments, the terminal generates a third code according to the byte sequence in the payload field of the SOMEIP message and the AUTOSAR standard. The third code is used to deserialize the byte sequence into structured data. Then, the terminal generates a fourth code according to the structured data and the SOMEIP protocol. The fourth code is used to convert the structured data into the message definition of the SOMEIP service. The third code and the fourth code constitute the deserialization code associated with the SOMEIP service, and jointly complete the deserialization of the byte sequence related to the SOMEIP service; furthermore, when there is a deserialization requirement related to the SOMEIP service subsequently, the deserialization code can be directly called without manually writing code each time, improving the data processing efficiency.

[0078] It should be noted that the above steps are described by taking one SOMEIP service as an example. In the case where the configuration file includes multiple SOMEIP services, the terminal can generate the serialization code and deserialization code associated with each SOMEIP service in the above manner.

[0079] In some embodiments, after the terminal generates the serialization code associated with each SOMEIP service, it can create a serialization interface. The serialization interface is used to provide the serialization function for the message definition of any SOMEIP service. For example, for the SOMEIP application running on the vehicle intelligent driving domain controller, the application can call the serialization interface to serialize the message definition of the SOMEIP service into a byte sequence that can be filled in the Payload when encapsulating the SOMEIP message. Correspondingly, the terminal can also create a deserialization interface according to the deserialization code associated with each SOMEIP service. The deserialization interface is used to provide the deserialization function for the byte sequence in the payload field of any SOMEIP message. By encapsulating the serialization code and deserialization code associated with each SOMEIP service into a unified interface, it is convenient for the upper-layer application to quickly implement data serialization or deserialization by calling the corresponding interface, simplifies the complexity of data processing, and improves the data processing efficiency.

[0080] Taking the data communication based on the SOMEIP protocol as an example, the process of encapsulating and parsing SOMEIP messages during the communication process will be described through the following two cases respectively.

[0081] Case 1: When the SOMEIP application receives the message definition (Proto message) of any SOMEIP service, obtain the service identifier of the SOMEIP service. Herein, the service identifier is used to uniquely identify the SOMEIP service. Optionally, the service identifier can be service_id. Then, the SOMEIP application calls the serialization interface based on the service identifier. For example, pass the service identifier as a parameter into the serialization interface to call the serialization code associated with the SOMEIP service through the serialization interface based on the service identifier, and then serialize the message definition of the SOMEIP service through the serialization code to obtain the byte sequence in the Payload of the SOMEIP message. Then, the SOMEIP application can encapsulate the SOMEIP message according to the byte sequence and send the SOMEIP message to the target ECU using the vsomeip communication interface. The above process can be referred to Figure 7 the schematic diagram of calling the serialization interface shown in

[0082] Case 2: When the SOMEIP application receives the SOMEIP message sent by any ECU, the SOMEIP application obtains the service identifier corresponding to the SOMEIP message. Then, the SOMEIP application calls the deserialization interface based on the service identifier to call the deserialization code associated with the SOMEIP service through the deserialization interface based on the service identifier, and deserialize the byte sequence in the payload field of the SOMEIP message through the serialization code to obtain the message definition of the SOMEIP service. Optionally, the SOMEIP application can perform post-processing on the message definition (Proto message), such as data verification, format verification, etc., which is not limited in the embodiments of the present application. The above process can be referred to Figure 8 the schematic diagram of calling the deserialization interface shown in

[0083] The embodiments of the present application provide a SOMEIP-based code generation method. By obtaining the configuration file of the SOME / IP service and generating the message definition and corresponding serialization and deserialization codes based on this, it avoids manually writing a large amount of repetitive and cumbersome codes in the process of encapsulating and parsing SOMEIP messages. Developers do not need to deeply understand the underlying details of the SOME / IP protocol and complex data processing logics, and only need to focus on the implementation of business functions. By adopting the above method, the time for manually writing codes can be saved, and the efficiency and accuracy of code generation are improved.

[0084] Figure 9 is a block diagram of a SOMEIP-based code generation device provided according to the embodiments of the present application. The device is used to execute the steps when the above SOMEIP-based code generation method is executed. Refer to Figure 9, the SOMEIP-based code generation device includes: an acquisition module 901, a first generation module 902, and a second generation module 903.

[0085] The acquisition module 901 is configured to acquire a configuration file of the SOMEIP service, where the configuration file includes the name of the SOMEIP service, the included parameters, and the data type of each parameter;

[0086] The first generation module 902 is configured to generate a message definition of the SOMEIP service based on the configuration file of the SOMEIP service, where the message definition is used to represent the parameters included in the SOMEIP service and the data type of each parameter through structured data;

[0087] The second generation module 903 is configured to generate serialization code and deserialization code associated with the SOMEIP service based on the message definition of the SOMEIP service;

[0088] Among them, the serialization code is used to serialize the message definition during the process of encapsulating the SOMEIP message to obtain a byte sequence in the payload field, and the deserialization code is used to deserialize the byte sequence in the payload field of the SOMEIP message during the process of parsing the SOMEIP message to obtain the message definition of the SOMEIP service.

[0089] In some embodiments, the first generation module 902 is configured to extract service information of the SOMEIP service from the configuration file, where the service information includes the name of the SOMEIP service, the included parameters, and the data type of each parameter; and generate a message definition of the SOMEIP service based on the service information of the SOMEIP service.

[0090] In some embodiments, the first generation module 902 is configured to parse the configuration file to obtain service information of multiple SOMEIP services; save the service information of the multiple SOMEIP services to a text file in a preset format; for any SOMEIP service, traverse the text file to obtain the service information of the SOMEIP service.

[0091] In some embodiments, the configuration file is a file in ARXML format, and the text file is a file in JSON format.

[0092] In some embodiments, the second generation module 903 is configured to generate first code based on the message definition of the SOMEIP service and the SOMEIP protocol, where the first code is used to convert the message definition into structure data; and generate second code based on the structure data and the AUTOSAR standard, where the second code is used to serialize the structure data into a byte sequence in the payload field of the SOMEIP message.

[0093] In some embodiments, the second generation module 903 is configured to generate a third code based on a byte sequence in the payload field of a SOMEIP message and the AUTOSAR standard, where the third code is used to deserialize the byte sequence into structured data; and generate a fourth code based on the structured data and the SOMEIP protocol, where the fourth code is used to convert the structured data into a message definition of a SOMEIP service.

[0094] In some embodiments, the apparatus further includes:

[0095] A creation module, configured to, when the configuration file includes multiple SOMEIP services, create a serialization interface based on the serialization code associated with each SOMEIP service, where the serialization interface is used to serialize the message definition of any SOMEIP service; and create a deserialization interface based on the deserialization code associated with each SOMEIP service, where the deserialization interface is used to deserialize a byte sequence in the payload field of any SOMEIP message.

[0096] In some embodiments, the apparatus further includes:

[0097] A first invocation module, configured to, when receiving the message definition of any SOMEIP service, obtain the service identifier of the SOMEIP service, where the service identifier is used to uniquely identify the SOMEIP service; and invoke the serialization interface based on the service identifier, and through the serialization interface, invoke the serialization code associated with the SOMEIP service based on the service identifier, so as to serialize the message definition of the SOMEIP service through the serialization code to obtain a byte sequence in the payload field of the SOMEIP message.

[0098] In some embodiments, the apparatus further includes:

[0099] A second invocation module, configured to, when receiving any SOMEIP message, obtain the service identifier corresponding to the SOMEIP message, where the service identifier is used to uniquely identify the SOMEIP service; and invoke the deserialization interface based on the service identifier, and through the deserialization interface, invoke the deserialization code associated with the SOMEIP service based on the service identifier, so as to deserialize a byte sequence in the payload field of the SOMEIP message through the serialization code to obtain the message definition of the SOMEIP service.

[0100] An embodiment of the present application provides a code generation device based on SOMEIP. By obtaining the configuration file of the SOMEIP service and generating message definitions and corresponding serialization and deserialization codes based on this, it avoids manually writing a large amount of repetitive and cumbersome codes during the process of encapsulating and parsing SOMEIP messages. Developers do not need to deeply understand the underlying details of the SOMEIP protocol and complex data processing logic, and only need to focus on the implementation of business functions. By adopting the above method, the time for manually writing codes can be saved, and the efficiency and accuracy of code generation are improved.

[0101] It should be noted that: for the code generation device based on SOMEIP provided in the above embodiment, only the above division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the terminal is divided into different functional modules to complete all or part of the functions described above. In addition, the code generation device based on SOMEIP provided in the above embodiment and the embodiment of the code generation method based on SOMEIP belong to the same concept, and the implementation process can be seen in the method embodiment, which will not be elaborated here.

[0102] Figure 10 It is a schematic structural diagram of a terminal according to an embodiment of the present application. The terminal 1000 can be a portable mobile terminal, such as: a smart phone, a tablet computer, a notebook computer or a desktop computer. The terminal 1000 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, etc.

[0103] Generally, the terminal 1000 includes: a processor 1001 and a memory 1002.

[0104] The processor 1001 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the volume clouds of the content to be displayed on the display screen. In some embodiments, the processor 1001 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.

[0105] The memory 1002 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 1002 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1002 is used to store at least one computer program, and the at least one computer program is used to be executed by the processor 1001 to implement the SOMEIP-based code generation method provided in the method embodiments of the present application.

[0106] In some embodiments, the terminal 1000 may further optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002, and the peripheral device interface 1003 may be connected through a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 1003 through a bus, signal lines, or a circuit board. The peripheral devices include at least one of a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007, and a power supply 1008.

[0107] The peripheral device interface 1003 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 can be implemented on separate chips or circuit boards, and this embodiment does not limit this.

[0108] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. In some embodiments, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so on. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 may further include a circuit related to NFC (Near Field Communication), and this application does not limit this.

[0109] The display screen 1005 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on or above the surface of the display screen 1005. The touch signals can be input to the processor 1001 as control signals for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there may be one display screen 1005, which is disposed on the front panel of the terminal 1000; in other embodiments, there may be at least two display screens 1005, which are respectively disposed on different surfaces of the terminal 1000 or in a foldable design; in other embodiments, the display screen 1005 may be a flexible display screen, which is disposed on the curved surface or the folding surface of the terminal 1000. Even, the display screen 1005 can also be set to an irregular non-rectangular shape, that is, a special-shaped screen. The display screen 1005 can be prepared from materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0110] The camera module 1006 is used to collect images or videos. In some embodiments, the camera module 1006 includes a front camera and a rear camera. Generally, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are respectively any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, so as to realize the function of background blurring by fusing the main camera and the depth-of-field camera, the function of panoramic shooting by fusing the main camera and the wide-angle camera, and the VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera module 1006 may further include a flash. The flash can be a single-color-temperature flash or a dual-color-temperature flash. The dual-color-temperature flash refers to the combination of a warm-light flash and a cold-light flash, and can be used for light compensation under different color temperatures.

[0111] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals for input to the processor 1001 for processing, or input to the radio frequency circuit 1004 to achieve voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1000. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 1007 may further include a headphone jack.

[0112] The power supply 1008 is used to supply power to each component in the terminal 1000. The power supply 1008 may be alternating current, direct current, a disposable battery or a rechargeable battery. When the power supply 1008 includes a rechargeable battery, the rechargeable battery may support wired charging or wireless charging. The rechargeable battery may also be used to support fast charging technology.

[0113] In some embodiments, the terminal 1000 further includes one or more temperature sensors 1009. The one or more temperature sensors 1009 include but are not limited to: an acceleration sensor 1010, a gyroscope sensor 1011, a pressure sensor 1012, an optical sensor 1013, and a proximity sensor 1014.

[0114] The acceleration sensor 1010 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established with the terminal 1000. For example, the acceleration sensor 1010 can be used to detect the components of the gravitational acceleration on the three coordinate axes. The processor 1001 can control the display screen 1005 to display the user interface in a horizontal view or a vertical view according to the gravitational acceleration signal collected by the acceleration sensor 1010. The acceleration sensor 1010 can also be used for collecting game or user's motion data.

[0115] The gyroscope sensor 1011 can detect the body direction and rotation angle of the terminal 1000. The gyroscope sensor 1011 can cooperate with the acceleration sensor 1010 to collect the 3D actions of the user on the terminal 1000. According to the data collected by the gyroscope sensor 1011, the processor 1001 can implement the following functions: motion sensing (such as changing the UI according to the user's tilting operation), image stabilization during shooting, game control, and inertial navigation.

[0116] The pressure sensor 1012 can be disposed on the side frame of the terminal 1000 and / or the lower layer of the display screen 1005. When the pressure sensor 1012 is disposed on the side frame of the terminal 1000, it can detect the holding signal of the user on the terminal 1000, and the processor 1001 can perform left / right hand recognition or quick operation according to the holding signal collected by the pressure sensor 1012. When the pressure sensor 1012 is disposed on the lower layer of the display screen 1005, the processor 1001 can control the operable controls on the UI interface according to the pressure operation of the user on the display screen 1005. The operable controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0117] The optical sensor 1013 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the display screen 1005 according to the ambient light intensity collected by the optical sensor 1013. Optionally, when the ambient light intensity is high, the display brightness of the display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the display screen 1005 is decreased. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera module 1006 according to the ambient light intensity collected by the optical sensor 1013.

[0118] The proximity sensor 1014, also known as the distance sensor, is disposed on the front panel of the terminal 1000. The proximity sensor 1014 is used to collect the distance between the user and the front of the terminal 1000. In one embodiment, when the proximity sensor 1014 detects that the distance between the user and the front of the terminal 1000 is gradually decreasing, the processor 1001 controls the display screen 1005 to switch from the lit state to the off state; when the proximity sensor 1014 detects that the distance between the user and the front of the terminal 1000 is gradually increasing, the processor 1001 controls the display screen 1005 to switch from the off state to the lit state.

[0119] Those skilled in the art can understand that Figure 10 the structure shown does not limit the terminal 1000, and it may include more or fewer components than shown, or combine some components, or adopt different component arrangements.

[0120] The embodiments of the present application further provide a computer-readable storage medium, in which at least one segment of computer program is stored, and the at least one segment of computer program is loaded and executed by a processor to implement the SOMEIP-based code generation method in the above embodiments. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0121] The embodiments of the present application further provide a computer program product, including a computer program, and the computer program is executed by a processor to implement the SOMEIP-based code generation method in the embodiments of the present application.

[0122] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium, and the above-mentioned storage medium can be a read-only memory, a magnetic disk, or an optical disc, etc.

[0123] The above are only optional embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A code generation method based on SOMEIP, characterized in that: The method comprises: Obtain a configuration file of the SOMEIP service, wherein the configuration file includes the name of the SOMEIP service, the parameters included, and the data type of each parameter; Based on the configuration file of the SOMEIP service, a message definition of the SOMEIP service is generated, wherein the message definition is used to represent the parameters included in the SOMEIP service and the data type of each parameter through structured data; Based on the message definition of the SOMEIP service, generate a serialization code and a deserialization code associated with the SOMEIP service; Among them, the serialization code is used to serialize the message definition in the process of encapsulating the SOMEIP message to obtain the byte sequence in the payload field, and the deserialization code is used to deserialize the byte sequence in the payload field of the SOMEIP message in the process of parsing the SOMEIP message to obtain the message definition of the SOMEIP service.

2. The method according to claim 1, characterized in that: The generating the message definition of the SOMEIP service based on the configuration file of the SOMEIP service comprises: Extracting service information of the SOMEIP service from the configuration file, the service information including the name of the SOMEIP service, the parameters included, and the data type of each parameter; Based on the service information of the SOMEIP service, a message definition of the SOMEIP service is generated.

3. The method according to claim 2, characterized in that The extracting the service information of the SOMEIP service from the configuration file comprises: Parsing the configuration file to obtain service information of multiple SOMEIP services; Saving the service information of the plurality of SOMEIP services to a text file according to a preset format; For any of the SOMEIP services, the text file is traversed to obtain the service information of the SOMEIP service.

4. The method according to claim 3, characterized in that The configuration file is a file in ARXML format, and the text file is a file in JSON format.

5. The method according to claim 1, characterized in that The generating, based on the message definition of the SOMEIP service, a serialization code associated with the SOMEIP service comprises: Based on the message definition of the SOMEIP service and the SOMEIP protocol, generating a first code, wherein the first code is used to convert the message definition into structure data; Based on the structure data and the AUTOSAR standard, a second code is generated, where the second code is used to serialize the structure data into a byte sequence in a payload field of a SOMEIP message.

6. The method according to claim 1, characterized in that The generation process of the deserialization code associated with the SOMEIP service includes: Based on the byte sequence in the payload field of the SOMEIP message and the AUTOSAR standard, generating a third code, wherein the third code is used to deserialize the byte sequence into structure data; Based on the structure data and the SOMEIP protocol, a fourth code is generated, wherein the fourth code is used to convert the structure data into a message definition of the SOMEIP service.

7. The method according to claim 1, characterized in that The method further comprises: In the case where the configuration file includes multiple SOMEIP services, creating a serialization interface based on the serialization code associated with each of the SOMEIP services, wherein the serialization interface is used to serialize the message definition of any of the SOMEIP services; Based on the deserialization code associated with each SOMEIP service, a deserialization interface is created, and the deserialization interface is used to deserialize the byte sequence in the payload field of any SOMEIP message.

8. The method according to claim 7, characterized in that The method further comprises: Upon receiving a message definition of any SOMEIP service, obtaining a service identifier of the SOMEIP service, wherein the service identifier is used to uniquely identify the SOMEIP service; The serialization interface is called based on the service identifier, and the serialization code associated with the SOMEIP service is called through the serialization interface based on the service identifier, so as to serialize the message definition of the SOMEIP service through the serialization code to obtain the byte sequence in the payload field of the SOMEIP message.

9. The method according to claim 7, characterized in that: The method further comprises: When any SOMEIP message is received, obtaining a service identifier corresponding to the SOMEIP message, where the service identifier is used to uniquely identify the SOMEIP service; The deserialization interface is called based on the service identifier, and the deserialization code associated with the SOMEIP service is called through the deserialization interface based on the service identifier, so as to deserialize the byte sequence in the payload field of the SOMEIP message through the serialization code to obtain the message definition of the SOMEIP service.

10. A code generation device based on SOMEIP, characterized in that: The device comprises: An acquisition module, used to acquire a configuration file of a SOMEIP service, wherein the configuration file includes a name of the SOMEIP service, included parameters, and a data type of each parameter; A first generating module, configured to generate a message definition of the SOMEIP service based on a configuration file of the SOMEIP service, wherein the message definition is used to represent parameters included in the SOMEIP service and a data type of each parameter through structured data; A second generating module, configured to generate a serialization code and a deserialization code associated with the SOMEIP service based on a message definition of the SOMEIP service; Among them, the serialization code is used to serialize the message definition in the process of encapsulating the SOMEIP message to obtain the byte sequence in the payload field, and the deserialization code is used to deserialize the byte sequence in the payload field of the SOMEIP message in the process of parsing the SOMEIP message to obtain the message definition of the SOMEIP service.

11. A terminal, characterized in that: The terminal includes a processor and a memory, the memory is used to store at least one computer program, and the at least one computer program is loaded by the processor and executes the SOMEIP-based code generation method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store at least one computer program, and the at least one computer program is used to execute the SOMEIP-based code generation method according to any one of claims 1 to 9.