Method and system for serializing and deserializing communication data of Android system and automobile ECU (electronic control Unit) module

文档序号:7192 发布日期:2021-09-17 浏览:49次 中文

阅读说明:本技术 Android系统与汽车ECU模块通信数据序列化和反序列化方法及系统 (Method and system for serializing and deserializing communication data of Android system and automobile ECU (electronic control Unit) module ) 是由 程德心 杨凯 余贞金 于 2021-06-16 设计创作,主要内容包括:本发明提供一种Android系统与汽车ECU模块通信数据序列化和反序列化方法及系统,方法包括:在Android系统上,定义JNI封装数据互转接口;在序列化时,通过数据互转接口,将java类型数据转化为c++类型数据,根据AUTOSAR标准进行序列化;对c++类型数据成员进行反序列化,通过数据互转接口,将c++类型数据转换成java类型数据。本发明通过在Android系统上封装定义JNI的数据互转接口,实现java类型数据与c++类型数据之间的转换,并基于AUTOSAR标准进行数据序列化和反序列化,实现在Android系统上与汽车ECU模块基于SOMEIP协议通信的数据序列化和反序列化。(The invention provides a method and a system for serializing and deserializing communication data between an Android system and an automobile ECU module, wherein the method comprises the following steps: defining a JNI packaging data interchange interface on an Android system; during serialization, converting java type data into c + + type data through a data interchange interface, and serializing according to AUTOSAR standards; deserializing the c + + type data members, and converting the c + + type data into java type data through a data interchange interface. According to the method, the conversion between java type data and c + + type data is realized by packaging and defining a data interchange interface JNI on the Android system, data serialization and deserialization are performed based on the AUTOSAR standard, and data serialization and deserialization of communication between the Android system and the automobile ECU module based on the SOMEIP protocol are realized.)

1. A method for serializing and deserializing communication data between an Android system and an automobile ECU (electronic control unit) module is characterized by comprising the following steps:

defining a JNI packaging data conversion interface on an Android system, wherein the data conversion interface is used for realizing conversion between java type data and c + + type data;

during serialization, converting java type data into c + + type data through the data interconversion interface, and serializing c + + type data members according to AUTOSAR standards to form a first SOMEIP protocol communication data frame;

and during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data through the data conversion interface, and returning the java type data to the upper layer.

2. The method of claim 1, wherein said serializing c + + type data members according to the AUTOSAR standard to form first SOMEIP protocol communication data frames comprises:

and according to the AUTOSAR standard, inquiring the positions of c + + all-stage basic type data members in the communication data frame, and sequencing all the basic type data members one by one to form a first SOMEIP protocol communication data frame.

3. The method of claim 1, wherein said deserializing the c + + type data member to form a second SOMEIP protocol communication data frame during deserializing comprises:

during deserialization, the positions of the basic type data members of java in the communication data frame are inquired, and the deserialization is carried out on the basic type data members one by one according to the data type information of the basic type data members in the data description information table to form a second SOMEIP protocol communication data frame.

4. The method of claim 1,

for serialization and deserialization of the complex type data, converting the member type of the complex type data into a java type, and defining the java type in class, wherein the type of the java object is replaced by a jobject type in JNI;

and (4) taking out the members in the jobject by using the functions in the JNIENv function table, assigning the members to a C + + structure, and then carrying out serialization and deserialization.

5. The method of claim 4, wherein the complex type data comprises structure type data and group type data.

6. The method of any one of claims 1 to 4, wherein the serialization code and the deserialization code are automatically generated using a python script and a jinja2 template.

7. The method of claim 6, wherein automatically generating serialization code and deserialization code using a python script plus jinja2 template comprises:

using a pre-designated Excel form or an xml template file, receiving and storing a data structure designed by a user;

reading a data structure table or an xml file by a code generation script written by a python language to generate json format data, inputting the json format data into a pre-made data structure code template, and generating a corresponding code according to a data structure, wherein the data structure code template is a jinja2 template.

8. The method of claim 1, wherein the data serialization and deserialization further comprises:

and compiling a JNI data interchange interface and a C + + file through an Android NDK tool to generate so-base files of arm and x86 different CPU architectures, adding the so-base files into Android projects, and realizing data serialization and deserialization of the Android system and the automobile ECU module through SOMEIP protocol communication.

9. The utility model provides an Android system and car ECU module communication data serialization and deserialize system which characterized in that includes:

the system comprises a definition module and a data conversion module, wherein the definition module is used for defining a JNI packaging data conversion interface on an Android system, and the data conversion interface is used for realizing conversion between java type data and c + + type data;

the serialization module is used for converting java type data into c + + type data through the data inter-conversion interface during serialization, and serializing c + + type data members according to the AUTOSAR standard to form a first SOMEIP protocol communication data frame;

and the deserializing module is used for deserializing the c + + type data members to form a second SOMEIP protocol communication data frame during deserializing, converting the c + + type data into java type data through the data conversion interface and returning the java type data to the upper layer.

10. A computer readable storage medium, characterized in that a computer management like program is stored thereon, which when executed by a processor implements the steps of the Android system and automobile ECU module communication data serialization and deserialization method according to any one of claims 1-8.

Technical Field

The invention relates to the field of computers, in particular to a method and a system for serializing and deserializing communication data between an Android system and an automobile ECU module.

Background

With the rapid development of automobile intellectualization, the SOMEIP protocol is largely used in the vehicle-mounted ECU device for data communication of the vehicle-mounted ethernet, and the Android system-based communication with the vehicle-mounted ECU module must also use the SOMEIP protocol.

When the SOMEIP protocol is used for communication, data serialization and deserialization work must be carried out according to the AUTOSAR standard, the current vehicle-mounted Ethernet SOMEIP protocol is developed by using C + + language, the serialization and deserialization functions are realized by aiming at the C + + data structure by taking the AUTOSAR architecture as the standard, the C + + data structure is not matched with the Android system java language and the data structure, the AUTOSAR only specifies the communication data serialization standard of the C + + language and does not specify the java language, so that how to realize the serialization and deserialization of the C + + SOMEIP protocol by combining the java language with the Android system API meets the AUTOSAR standard, and the problem of communication with other vehicle-mounted ECU modules is to be solved.

Disclosure of Invention

Aiming at the technical problems in the prior art, the invention provides a method and a system for serializing and deserializing communication data between an Android system and an automobile ECU module.

According to a first aspect of the invention, a method for serializing and deserializing communication data between an Android system and an automobile ECU (electronic control unit) module is provided, which comprises the following steps: defining a JNI packaging data conversion interface on an Android system, wherein the data conversion interface is used for realizing conversion between java type data and c + + type data; during serialization, converting java type data into c + + type data through the data interconversion interface, and serializing c + + type data members according to AUTOSAR standards to form a first SOMEIP protocol communication data frame; and during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data through the data conversion interface, and returning the java type data to the upper layer.

On the basis of the technical scheme, the invention can be improved as follows.

Optionally, the serializing the c + + type data members according to the AUTOSAR standard to form a first SOMEIP protocol communication data frame includes: and according to the AUTOSAR standard, inquiring the positions of c + + all-stage basic type data members in the communication data frame, and sequencing all the basic type data members one by one to form a first SOMEIP protocol communication data frame.

Optionally, when deserializing, deserializing the c + + type data member to form a second SOMEIP protocol communication data frame includes: during deserialization, the positions of the basic type data members of java in the communication data frame are inquired, and the deserialization is carried out on the basic type data members one by one according to the data type information of the basic type data members in the data description information table to form a second SOMEIP protocol communication data frame.

Optionally, for serialization and deserialization of the complex type data, converting the member type of the complex type data into a java type, and defining the java type in class, wherein the type of the java object is replaced by a jobject type in the JNI; and (4) taking out the members in the jobject by using the functions in the JNIENv function table, assigning the members to a C + + structure, and then carrying out serialization and deserialization.

Optionally, the complex type data includes structure type data and array type data.

Optionally, the serialized code and the deserialized code are automatically generated by using the python script and the jinja2 template.

Optionally, the automatically generating serialized codes and deserialized codes by using the python script and the jinja2 template includes: using a pre-designated Excel form or an xml template file, receiving and storing a data structure designed by a user; reading a data structure table or an xml file by a code generation script written by a python language to generate json format data, inputting the json format data into a pre-made data structure code template, and generating a corresponding code according to a data structure, wherein the data structure code template is a jinja2 template.

Optionally, the data serialization and deserialization further comprises: and compiling a JNI data interchange interface and a C + + file through an Android NDK tool to generate so-base files of arm and x86 different CPU architectures, adding the so-base files into Android projects, and realizing data serialization and deserialization of the Android system and the automobile ECU module through SOMEIP protocol communication.

According to a second aspect of the present invention, there is provided a data serialization and deserialization system for communication between an Android system and an automobile ECU module, comprising: the system comprises a definition module and a data conversion module, wherein the definition module is used for defining a JNI packaging data conversion interface on an Android system, and the data conversion interface is used for realizing conversion between java type data and c + + type data; the serialization module is used for converting java type data into c + + type data through the data inter-conversion interface during serialization, and serializing c + + type data members according to the AUTOSAR standard to form a first SOMEIP protocol communication data frame; and the deserializing module is used for deserializing the c + + type data members to form a second SOMEIP protocol communication data frame during deserializing, converting the c + + type data into java type data through the data conversion interface and returning the java type data to the upper layer.

According to a third aspect of the present invention, an electronic device is provided, which includes a memory and a processor, where the processor is configured to implement the steps of the method for serializing and deserializing data of communication between an Android system and an automobile ECU module when executing a computer management class program stored in the memory.

According to a fourth aspect of the present invention, there is provided a computer readable storage medium having a computer management-like program stored thereon, the computer management-like program, when executed by a processor, implementing the steps of the method for serializing and deserializing data for communication between an Android system and an automotive ECU module.

According to the method and the system for serializing and deserializing the communication data between the Android system and the automobile ECU module, the conversion between java type data and c + + type data is realized by packaging and defining a data interchange interface of JNI on the Android system, and data serialization and deserialization are performed based on the AUTOSAR standard, so that data serialization and deserialization of communication between the Android system and the automobile ECU module based on the SOMEIP protocol are realized.

Drawings

FIG. 1 is a flow chart of a serialization and deserialization method of communication data between an Android system and an automobile ECU module provided by the invention;

FIG. 2 is a schematic diagram of a data serialization process;

FIG. 3 is a schematic diagram of a data deserialization process;

FIG. 4 is a schematic representation of the serialization of the structure;

FIG. 5 is a schematic structural diagram of a data serialization and deserialization system for communication between an Android system and an automobile ECU module, provided by the invention;

FIG. 6 is a schematic diagram of a hardware structure of a possible electronic device according to the present invention;

fig. 7 is a schematic diagram of a hardware structure of a possible computer-readable storage medium according to the present invention.

Detailed Description

The following detailed description of embodiments of the present invention is provided in connection with the accompanying drawings and examples. The following examples are intended to illustrate the invention but are not intended to limit the scope of the invention.

Fig. 1 is a flowchart of a serialization and deserialization method for communication data between an Android system and an automobile ECU module, as shown in fig. 1, the method includes: 101. defining a JNI packaging data conversion interface on an Android system, wherein the data conversion interface is used for realizing conversion between java type data and c + + type data; 102. during serialization, converting java type data into c + + type data through the data interconversion interface, and serializing c + + type data members according to AUTOSAR standards to form a first SOMEIP protocol communication data frame; 103. and during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data through the data conversion interface, and returning the java type data to the upper layer.

It can be understood that, when the SOMEIP protocol is used for communication, data serialization and deserialization must be performed according to the AUTOSAR standard, the vehicle-mounted Ethernet SOMEIP protocol is developed by using C + + language at present, and serialization and deserialization functions are realized by using the AUTOSAR framework as the standard, aiming at the C + + data structure and are not matched with the Android system java language and the data structure, so that a method for realizing the serialization and deserialization of the C + + SOMEIP protocol by using the java language and the Android system API is necessary to be provided.

The Android system uses java as a development language, and solves the problem of mutual conversion between java data types and C + + data types on the premise of data communication with C + + application programs based on an SOMEIP protocol. Therefore, in the first step of the technical scheme, a JNI is used for packaging a conversion interface of a java basic data type and a C + + data type, and the conversion interface can realize the conversion of the java data type and the C + + data type.

During serialization, java type data is converted into c + + type data through a mutual conversion interface, and then the c + + type data is serialized according to AUTOSAR standards to form a first SOMEIP protocol communication data frame.

And during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data according to the interconversion interface, and returning the java type data to the upper application layer.

According to the method, the conversion between java type data and c + + type data is realized by packaging and defining a data interchange interface JNI on the Android system, data serialization and deserialization are performed based on the AUTOSAR standard, and data serialization and deserialization of communication between the Android system and the automobile ECU module based on the SOMEIP protocol are realized.

In a possible implementation manner, the serializing the c + + type data members to form the first SOMEIP protocol communication data frame according to the AUTOSAR standard includes: and according to the AUTOSAR standard, inquiring the positions of c + + all-stage basic type data members in the communication data frame, and sequencing all the basic type data members one by one to form a first SOMEIP protocol communication data frame.

It can be understood that, before the data is serialized and deserialized, since the conversion between the java type data and the C + + type data needs to be performed, the conversion between the java data type and the C + + data type is implemented by using the JNI function in this embodiment. The JNIEnv function table comprises conversion functions of java and JNI data types, interface packaging is carried out by using the conversion functions, and a type conversion java local method is generated. Wherein, as shown in appendix 1, the Java data type is compared with the C + + base data type.

Appendix 1:

when data is serialized, as shown in fig. 2, in order to realize the serialization process, firstly, the java type is converted into the C + + type through the inter-conversion interface, and then the serialization function is called to generate the SOMEIP protocol communication data frame. The serialization function finds the positions of all levels of basic type data members in communication data according to the AUTOSAR standard, and serializes all the basic type data members one by one to form a SOMEIP protocol communication data frame, thereby realizing the serialization of the data.

In a possible embodiment, when deserializing, deserializing the c + + type data member to form a second SOMEIP protocol communication data frame includes: during deserialization, the positions of the basic type data members of java in the communication data frame are inquired, and the deserialization is carried out on the basic type data members one by one according to the data type information of the basic type data members in the data description information table to form a second SOMEIP protocol communication data frame.

It can be understood that, referring to fig. 3, the deserialization process of the data is specifically that, firstly, the received SOMEIP protocol communication data frame is deserialized into the C + + data type by the deserialization function, and then is converted into the java data type by Step1 and returns to the application layer. The deserializing function finds the position of each basic type data member in the communication data frame, and deserializes each basic type data member one by one according to the data type information of each basic type data member in the data description information table to form the communication data of the SOMEIP protocol, thereby realizing the deserialization of the data.

In a possible embodiment, it can be understood that, for serialization and deserialization of complex type data, for example, data of a structure or array type, java does not have this type, and is to be replaced by class, the member type in the structure is converted into java type according to the basic type comparison table in appendix 1 and is defined in class, the type of java object in JNI is replaced by a jobject type, the member assignment in the jobject is taken out to the C + + structure by using the function in the JNIEnv function table, and then serialization and deserialization are performed, and the serialization process of the structure refers to the structure serialization specification in fig. 4.

In a possible embodiment, it can be understood that, since the business needs may involve many complex types of data, and for the complex types of data, which are also composed of basic data types, the serialization and deserialization functions thereof may have a large amount of repeated codes. For repeated serialized and deserialized code, the serialized code is automatically generated using the python script plus jinja2 template.

In order to improve the development efficiency, a pre-specified Excel form or an xml template file is used, and a data structure designed by a user is received and stored. And reading a data structure table or an xml file by a code generation script written by a python language to generate json format data, inputting the data into a pre-made data structure code template, and generating a corresponding code according to a data structure.

And finally, compiling a JNI data interchange interface and a C + + file of codes of a C + + part in the engineering through an Android NDK tool to generate so-library files of arm and x86 different CPU architectures, adding the so-library files into an Android project, and realizing data serialization and deserialization of the communication between the Android system and the automobile ECU module through the SOMEIP protocol.

Referring to fig. 5, the invention provides a data serialization and deserialization system for communication between an Android system and an automobile ECU module, and the system includes a definition module 501, a serialization module 502 and a deserialization module 503, wherein:

a defining module 501, configured to define a JNI package data interchange interface on an Android system, where the data interchange interface is used to implement conversion between java-type data and c + + type data; a serialization module 502, configured to convert java-type data into c + + type data through the data inter-conversion interface during serialization, and serialize c + + type data members according to the AUTOSAR standard to form a first SOMEIP protocol communication data frame; and the deserializing module 503 is configured to deserialize the c + + type data members during deserializing to form a second SOMEIP protocol communication data frame, convert the c + + type data into java type data through the data interchange interface, and return the java type data to the upper layer.

It can be understood that the Android system and automobile ECU module communication data serialization and deserialization system provided by the embodiment of the invention corresponds to the Android system and automobile ECU module communication data serialization and deserialization method provided by each of the foregoing embodiments, and the relevant technical features of the Android system and automobile ECU module communication data serialization and deserialization system can refer to the relevant technical features of the Android system and automobile ECU module communication data serialization and deserialization method, and are not described herein again.

Referring to fig. 6, fig. 6 is a schematic view of an embodiment of an electronic device according to an embodiment of the invention. As shown in fig. 6, an embodiment of the present invention provides an electronic device 600, which includes a memory 610, a processor 620, and a computer program 611 stored in the memory 610 and operable on the processor 620, wherein the processor 620 implements the following steps when executing the computer program 611: defining a JNI packaging data conversion interface on an Android system, wherein the data conversion interface is used for realizing conversion between java type data and c + + type data; during serialization, converting java type data into c + + type data through the data interconversion interface, and serializing c + + type data members according to AUTOSAR standards to form a first SOMEIP protocol communication data frame; and during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data through the data conversion interface, and returning the java type data to the upper layer.

Referring to fig. 7, fig. 7 is a schematic diagram of an embodiment of a computer-readable storage medium according to the present invention. As shown in fig. 7, the present embodiment provides a computer-readable storage medium 700 having a computer program 711 stored thereon, the computer program 711, when executed by a processor, implementing the steps of: defining a JNI packaging data conversion interface on an Android system, wherein the data conversion interface is used for realizing conversion between java type data and c + + type data; during serialization, converting java type data into c + + type data through the data interconversion interface, and serializing c + + type data members according to AUTOSAR standards to form a first SOMEIP protocol communication data frame; and during deserializing, deserializing the c + + type data members to form a second SOMEIP protocol communication data frame, converting the c + + type data into java type data through the data conversion interface, and returning the java type data to the upper layer.

According to the method and the system for serializing and deserializing the communication data between the Android system and the automobile ECU module, provided by the embodiment of the invention, the conversion between java-type data and c + + type data is realized by packaging and defining a data interchange interface of JNI on the Android system, and data serialization and deserialization are carried out based on the AUTOSAR standard, so that data serialization and deserialization of communication between the Android system and the automobile ECU module based on the SOMEIP protocol are realized.

It should be noted that, in the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to relevant descriptions of other embodiments for parts that are not described in detail in a certain embodiment.

As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.

It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种用于变电站的可视化远程部署方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!