Interface calling method, system, electronic device and storage medium for vehicle-mounted application
By creating memory space and performing serialization processing at the microcontroller unit layer, the development process of the JNI interface is simplified, the problem of low efficiency in JNI interface development is solved, and efficient interface code development and maintenance are achieved.
Patent Information
- Application Number
- CN202211529950.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-30
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-11-30
AI Technical Summary
In automotive applications, the development efficiency of the JNI interface is low, especially in DDS services. When the MCU needs to interact with hundreds of controllers on the vehicle body, the Java virtual machine needs to save a large number of Java layer-to-C layer function mappings, resulting in complex development and high maintenance costs.
By creating memory space at the microcontroller layer, generating function pointers, serializing and encapsulating variable parameter types, and using cache index information and interface identifiers for deserialization, the mapping process between the Java layer and the C layer functions is simplified and integrated into a single function interface.
It improves the development efficiency of interface code, simplifies the complexity of interface development, and reduces maintenance costs.
Smart Images

Figure CN115934212B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of application interface technology, and in particular to a method, system, electronic device and storage medium for calling an interface of an in-vehicle application. Background Art
[0002] Currently, the Java Native Interface (JNI) is widely used on various platforms for interaction between Java code and code written in other languages. Its principle is that native code and the Java Virtual Machine (JVM) interact through JNI functions, and the Java Virtual Machine (JVM) maintains a snapshot of JNI function pointers. JNI functions are accessed through interface pointers, and native methods accept JNI interface pointers as parameters. The JVM ensures that the interface pointer passed to a native method remains the same when multiple calls are made from the same Java thread. However, a native method receives different JNI interface pointers when called from different Java threads.
[0003] However, since the DDS (Data Distribution Service) service requires a single service and a single interface, the MCU (Microcontroller Unit) obtains instructions from hundreds of controllers on the vehicle body from the CAN (Controller Area Network) bus, and then interacts with the Android application on the vehicle side according to the instructions. Hundreds of interfaces need to be registered with JNI, that is, the Java virtual machine needs to save the one-to-one mapping of the Java layer to the C layer function, so each interface needs to be written before data is called, and the development efficiency of the interface code is low. Summary of the Invention
[0004] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical elements or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0005] In view of the above-mentioned shortcomings of the prior art, the present invention discloses a method, system, electronic device and storage medium for calling an interface of an in-vehicle application, so as to facilitate Android application calling the interface.
[0006] The present invention discloses an interface calling method for an in-vehicle application, comprising: obtaining a variable parameter type and an interface identifier corresponding to an interface to be called; creating a memory space of a micro-control unit layer, and generating a function pointer corresponding to the memory space; serializing the variable parameter type and encapsulating it into the memory space, obtaining encapsulated data and serialization information corresponding to the encapsulated data, wherein the serialization information includes cache index information and the interface identifier; passing the function pointer into the micro-control unit layer, triggering the micro-control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtaining the variable parameter type, and passing the obtained variable parameter type into the interface to be called corresponding to the interface identifier, so as to call the interface to be called.
[0007] Optionally, creating a memory space for the micro control unit layer and generating a function pointer corresponding to the memory space includes: creating a Parcel object in a preset memory cache pool; using the Parcel object to map the memory space corresponding to the micro control unit layer, and generating a function pointer corresponding to the Parcel object.
[0008] Optionally, the variable parameter type is serialized and encapsulated into the memory space to obtain encapsulated data and serialization information corresponding to the encapsulated data, including: applying for a data memory block of the variable parameter type from the memory space, and determining cache index information based on the memory address of the data memory block; serializing the variable parameter type, and writing the serialized variable parameter type into the data memory block to obtain encapsulated data; generating serialization information corresponding to the encapsulated data based on the cache index information and the interface identifier.
[0009] Optionally, the cache index information includes at least one of the following: a data pointer parameter, used to carry a data pointer, the data pointer pointing to the first address of the data memory block; a data storage parameter, used to carry the size of the space occupied by the encapsulated data; a data storage parameter, used to carry the size of the space occupied by the memory space; a data cursor parameter, used to carry the next data address after the data memory block.
[0010] Optionally, the micro control unit layer deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type by the following method: reading the encapsulated data with the address pointed to by the data pointer as the starting address until the next data address is read; deserializing the encapsulated data to obtain the variable parameter type.
[0011] Optionally, after encapsulating the variable parameter type into the memory space and serializing it, the method further includes: obtaining a serialization result and adding the serialization result to the serialization information, wherein the serialization result includes serialization success or serialization failure; if the serialization result includes serialization failure, re-serializing the variable parameter type.
[0012] Optionally, before the micro control unit layer deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type, the method further includes: reading the serialization result from the serialization information; if the serialization result includes serialization failure, executing a preset destructor; if the serialization result includes serialization success, deserializing the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type.
[0013] The present invention discloses an interface calling system for an in-vehicle application, comprising: an acquisition module for acquiring a variable parameter type and an interface identifier corresponding to an interface to be called; a creation module for creating a memory space of a micro-control unit layer and generating a function pointer corresponding to the memory space; an encapsulation module for serializing the variable parameter type and encapsulating it into the memory space, obtaining encapsulated data and serialization information corresponding to the encapsulated data, wherein the serialization information includes cache index information and the interface identifier; a calling module for passing the function pointer into the micro-control unit layer, triggering the micro-control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtaining the variable parameter type, and passing the obtained variable parameter type into the interface to be called corresponding to the interface identifier, so as to call the interface to be called.
[0014] The present invention discloses an electronic device, comprising: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above method.
[0015] The present invention discloses a computer-readable storage medium, on which a computer program is stored: when the computer program is executed by a processor, the method described above is implemented.
[0016] Beneficial effects of the present invention:
[0017] By serializing the variable parameter types corresponding to the interface to be called and encapsulating them in the created memory space, and carrying the cache index information and interface identifier through the serialized information, the micro-control unit layer reads the variable parameter types from the memory space according to the cache index information, and passes the read variable parameter types to the interface to be called corresponding to the interface identifier to call the interface to be called. In this way, the variable parameter types corresponding to the interface to be called are encapsulated in the memory space, and then the variable parameter types are read through the serialized cache index information, and then the C layer is controlled to call the underlying interface according to the interface identifier. Compared with establishing the corresponding relationship between each Java layer and the C layer function separately, the variable parameter types required by the C layer function are integrated into a single function interface including the variable parameter types, which simplifies the complexity of interface development and thus improves the development efficiency of the interface code.
[0018] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. It is obvious that the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0020] Figure 1 This is a schematic structural diagram of a vehicle system according to an embodiment of the present invention;
[0021] Figure 2 This is a flow chart of an interface calling method for an in-vehicle application according to an embodiment of the present invention;
[0022] Figure 3 is a schematic diagram of a serialization protocol in an embodiment of the present invention;
[0023] Figure 4 This is a schematic diagram of the structure of an interface calling system for an in-vehicle application in an embodiment of the present invention;
[0024] Figure 5 It is a schematic structural diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and sub-samples in the embodiments can be combined with each other unless there is a conflict.
[0026] It should be noted that the illustrations provided in the following embodiments are merely schematic illustrations of the basic concept of the present invention. Therefore, the illustrations only show components related to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the type, quantity, and proportion of each component may be changed arbitrarily, and the component layout may also be more complex.
[0027] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it will be apparent to those skilled in the art that the embodiments of the present invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring the embodiments of the present invention.
[0028] In the description and claims of the embodiments of the present disclosure, as well as in the accompanying drawings, the terms "first," "second," and the like are used to distinguish similar items and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate to describe the embodiments of the present disclosure herein. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions.
[0029] Unless otherwise stated, the term "plurality" means two or more.
[0030] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B means: A or B.
[0031] The term "and / or" describes an association between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or A and B.
[0032] Combine Figure 1As shown, the embodiment of the present disclosure provides a vehicle-machine system. In the DDS service, the controller on the CAN bus of the entire vehicle is abstracted as an atomic service. There are hundreds of service-oriented objects in the entire vehicle, which are sent to the MCU through the CAN bus. The MCU then provides them to various vehicle-mounted applications (Android applications) and terminal services of the entertainment system through the HAL layer channel. At this time, the Java virtual machine needs to save the one-to-one mapping of the Java layer to the C layer function. The writing of hundreds of functions is very redundant. If automatic code generation is used, many difficulties will arise due to the different number of parameters and parameter types. At the same time, the Java virtual machine also requires a lot of maintenance costs to maintain this huge data comparison table.
[0033] Combine Figure 2 As shown, the embodiment of the present disclosure provides an interface calling method for an in-vehicle application, including:
[0034] Step S201, obtaining the variable parameter type and interface identifier corresponding to the interface to be called;
[0035] Step S202: creating a memory space of the microcontroller unit layer and generating a function pointer corresponding to the memory space;
[0036] Step S203: Serialize the variable parameter type and encapsulate it into the memory space to obtain the encapsulated data and the serialization information corresponding to the encapsulated data;
[0037] The serialization information includes cache index information and interface identifier;
[0038] Step S204, pass the function pointer to the micro control unit layer, trigger the micro control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtain the variable parameter type, and pass the obtained variable parameter type to the interface to be called corresponding to the interface identifier to call the interface to be called.
[0039] The interface calling method for the vehicle application provided by the embodiment of the present disclosure is adopted. By serializing and encapsulating the variable parameter type corresponding to the interface to be called in the created memory space, the serialized information carries the cache index information and the interface identifier, so that the micro control unit layer reads the variable parameter type from the memory space according to the cache index information, and passes the read variable parameter type to the interface to be called corresponding to the interface identifier to call the interface to be called. In this way, the variable parameter type corresponding to the interface to be called is encapsulated in the memory space, and then the variable parameter type is read through the serialized cache index information, and then the C layer is controlled to call the underlying interface according to the interface identifier. Compared with establishing the corresponding relationship between each Java layer and the C layer function separately, the variable parameter types required by the C layer function are integrated into a single function interface including the variable parameter type, which simplifies the complexity of interface development and thus improves the development efficiency of the interface code.
[0040] In some embodiments, the Java layer of the in-vehicle application uses Android language, Java language, etc., and the microcontroller unit layer (C layer) of the MCU uses C language, C++ language, etc., wherein the in-vehicle application and the MCU interact through the JNI interface.
[0041] Optionally, creating a memory space of the micro control unit layer and generating a function pointer corresponding to the memory space includes: creating a Parcel object in a preset memory cache pool; using the Parcel object to map the memory space corresponding to the micro control unit layer, and generating a function pointer corresponding to the Parcel object.
[0042] In some embodiments, Parcel.cpp of the C layer provides a continuous memory area to store data in order to cope with the data transmission problem between the Java layer and the C layer during the IPC process, and the memory area is used as the memory space of the micro control unit layer.
[0043] Optionally, the variable parameter type is serialized and encapsulated into the memory space to obtain the encapsulated data and the serialization information corresponding to the encapsulated data, including: applying for a data memory block of the variable parameter type from the memory space, and determining the cache index information based on the memory address of the data memory block; serializing the variable parameter type, and writing the serialized variable parameter type into the data memory block to obtain the encapsulated data; generating the serialization information corresponding to the encapsulated data based on the cache index information and the interface identifier.
[0044] Optionally, the cache index information includes at least one of the following: a data pointer parameter, used to carry a data pointer, the data pointer points to the first address of the data memory block; a data storage parameter, used to carry the size of the space occupied by the encapsulated data; a data storage parameter, used to carry the size of the space occupied by the memory space; a data cursor parameter, used to carry the next data address after the data memory block.
[0045] In some embodiments, a Parcel object is created; the init function in the JNI function is called to initialize the Parcel object, and the function pointer corresponding to the Parcel object is fed back by mapping the Parcel object to the memory space in Parcel.cpp, and the fed-back function pointer is stored in the long data structure mNativePtr; the Parcel class corresponding to the Parcel object is a container class for holding messages, and the Parcel object is used to transfer the serialized variable parameter type to the memory space in Parcel.cpp through the Binder mechanism.
[0046] In some embodiments, the variable parameter type is passed into the inject function, and the variable parameter type is transferred to the memory space by calling the inject function, wherein a data memory block is requested by calling the malloc function, and the data pointer parameter and the data cursor parameter are determined based on the memory address of the data memory block; each time the inject function is called, the cache index information is updated.
[0047] In some embodiments, the malloc function is used to apply for a continuous memory block area of a specified size and return the allocated memory area address as a void* type. When the specific location of the memory is unknown, dynamic memory allocation is required to bind the actual memory space, and the allocated size is the size required by the program.
[0048] In some embodiments, the variable parameter type is serialized by calling the serialize function.
[0049] Combine Figure 3 As shown, an embodiment of the present disclosure provides a serialization protocol to serialize variable parameter types, wherein the serialization protocol includes: a serialization result (mError), which is used to report an error when the serialized data cannot be aligned; a data pointer parameter (mData), which is used to carry a data pointer, and the data pointer points to the first address of a data memory block; a data storage parameter (mDataSize), which is used to carry the size of the space occupied by the encapsulated data; a data storage parameter (mDataCapacity), which is used to carry the size of the space occupied by the memory space, and the size of the space occupied by the memory space supports dynamic growth; a data cursor parameter (mDataPos), which is used to carry the next data address after the data memory block; and an interface identifier (sub), which is used to carry a unique identifier of the interface handle.
[0050] Optionally, the micro control unit layer deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type through the following method: read the encapsulated data with the address pointed to by the data pointer as the starting address until the next data address is read; deserialize the encapsulated data to obtain the variable parameter type.
[0051] In some embodiments, the function pointer is passed to the microcontroller layer through the invoke function, so that the microcontroller layer searches for the encapsulated data in the Parcel cache pool according to the function pointer, and reads the variable parameter type from the encapsulated data according to the read address (data pointer parameter + data storage parameter) < data cursor parameter.
[0052] Optionally, after encapsulating the variable parameter type into the memory space and serializing it, the method further includes: obtaining a serialization result and adding the serialization result to the serialization information, wherein the serialization result includes serialization success or serialization failure; if the serialization result includes serialization failure, re-serializing the variable parameter type.
[0053] Optionally, before the microcontroller unit layer deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type, the method also includes: reading the serialization result from the serialization information; if the serialization result includes serialization failure, executing a preset destructor function; if the serialization result includes serialization success, deserializing the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type.
[0054] Combine Figure 4 As shown, the embodiment of the present disclosure provides an interface calling system for an in-vehicle application, including an acquisition module 401, a creation module 402, a packaging module 403 and a calling module 404. The acquisition module 401 is used to obtain the variable parameter type and interface identifier corresponding to the interface to be called; the creation module 402 is used to create the memory space of the micro control unit layer and generate a function pointer corresponding to the memory space; the packaging module 403 is used to serialize the variable parameter type and encapsulate it into the memory space, and obtain the encapsulated data and the serialization information corresponding to the encapsulated data, wherein the serialization information includes cache index information and interface identifier; the calling module 404 is used to pass the function pointer to the micro control unit layer, trigger the micro control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtain the variable parameter type, and pass the obtained variable parameter type to the interface to be called corresponding to the interface identifier to call the interface to be called.
[0055] The interface calling system for the vehicle application provided by the embodiment of the present disclosure serializes and encapsulates the variable parameter type corresponding to the interface to be called in the created memory space, and carries the cache index information and interface identifier through the serialized information, so that the micro control unit layer reads the variable parameter type from the memory space according to the cache index information, and passes the read variable parameter type to the interface to be called corresponding to the interface identifier to call the interface to be called. In this way, the variable parameter type corresponding to the interface to be called is encapsulated in the memory space, and then the variable parameter type is read through the serialized cache index information, and then the C layer is controlled to call the underlying interface according to the interface identifier. Compared with establishing the corresponding relationship between each Java layer and the C layer function separately, the variable parameter types required by the C layer function are integrated into a single function interface including the variable parameter type, which simplifies the complexity of interface development and thus improves the development efficiency of the interface code.
[0056] Figure 5The following is a schematic diagram showing the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application. Figure 5 The computer system 500 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0057] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 into the random access memory (RAM) 503, such as executing the method in the above embodiment. Various programs and data required for system operation are also stored in the RAM 503. The CPU 501, ROM 502 and RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0058] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, and the like; an output section 507 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 510 as needed, so that a computer program read from the removable medium can be installed in the storage section 508 as needed.
[0059] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 509, and / or installed from a removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the various functions defined in the system of the present application are executed.
[0060] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0061] The embodiments of the present disclosure further provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in the embodiments is implemented.
[0062] Regarding the computer-readable storage media in the embodiments of the present disclosure, those skilled in the art will understand that all or part of the steps in implementing the aforementioned method embodiments can be accomplished by hardware associated with the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the aforementioned method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0063] The electronic device disclosed in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run the computer program, so that the electronic device executes each step of the above method.
[0064] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0065] The above-mentioned processors can be general-purpose processors, including central processing units (CPUs), graphics processing units (GPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0066] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible variations. Unless expressly required, individual components and functions are optional, and the order of operations may vary. Parts and subsamples of some embodiments may be included in or replace parts and subsamples of other embodiments. Moreover, the terms used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to also include the plural forms. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variations "comprises" and / or comprising refer to the presence of a stated subsample, whole, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other subsamples, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, an element defined by the statement "comprises a..." does not exclude the presence of other identical elements in the process, method or device that includes the element. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments can be referenced to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can be found in the description of the method part.
[0067] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0068] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units can be merely a logical functional division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, and can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, the functional units in the embodiments of the present disclosure may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0069] The flowcharts and block diagrams in the accompanying drawings show the possible implementation architectures, functions and operations of the systems, methods and computer program products according to the embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical functions. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in an order different from that disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified function or action, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A method for calling an interface of an in-vehicle application, characterized in that: include: Get the variable parameter type and interface identifier corresponding to the interface to be called; Create a memory space for the microcontroller layer and generate a function pointer corresponding to the memory space; Serializing the variable parameter type and encapsulating it into the memory space to obtain encapsulated data and serialization information corresponding to the encapsulated data, wherein the serialization information includes cache index information and the interface identifier; The function pointer is passed into the micro control unit layer, triggering the micro control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtaining the variable parameter type, and passing the obtained variable parameter type into the to-be-called interface corresponding to the interface identifier to call the to-be-called interface; Creating a memory space for the microcontroller layer and generating a function pointer corresponding to the memory space, including creating a Parcel object in a preset memory cache pool; mapping the memory space corresponding to the microcontroller layer using the Parcel object, and generating a function pointer corresponding to the Parcel object; Serializing the variable parameter type and encapsulating it into the memory space to obtain encapsulated data and serialization information corresponding to the encapsulated data, including applying for a data memory block of the variable parameter type from the memory space and determining cache index information based on a memory address of the data memory block; serializing the variable parameter type and writing the serialized variable parameter type into the data memory block to obtain encapsulated data; generating serialization information corresponding to the encapsulated data based on the cache index information and the interface identifier; The encapsulated data in the memory space is deserialized according to the cache index information corresponding to the function pointer, including reading the encapsulated data with the address pointed to by the data pointer as the starting address until the next data address is read; and deserializing the encapsulated data to obtain a variable parameter type.
2. The method according to claim 1, characterized in that The cache index information includes at least one of the following: A data pointer parameter, used to carry a data pointer, the data pointer pointing to the first address of the data memory block; Data storage parameters, used to carry the size of the space occupied by the encapsulated data; Data storage parameters, used to carry the size of the occupied space of the memory space; The data cursor parameter is used to carry the next data address after the data memory block.
3. The method according to any one of claims 1 to 2, characterized in that After encapsulating the variable parameter type into the memory space and serializing it, the method further includes: Obtaining a serialization result, and adding the serialization result to the serialization information, wherein the serialization result includes serialization success or serialization failure; If the serialization result includes serialization failure, the variable parameter type is serialized again.
4. The method according to claim 3, characterized in that The micro control unit layer deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer to obtain the variable parameter type, and the method further includes: Reading a serialization result from the serialization information; If the serialization result includes serialization failure, executing a preset destructor; If the serialization result includes serialization success, the encapsulated data in the memory space is deserialized according to the cache index information corresponding to the function pointer to obtain the variable parameter type.
5. An interface calling system for vehicle-mounted applications, characterized in that: include: The acquisition module is used to obtain the variable parameter type and interface identifier corresponding to the interface to be called; A creation module is used to create a memory space of the micro control unit layer and generate a function pointer corresponding to the memory space; An encapsulation module, configured to serialize the variable parameter type and encapsulate it into the memory space, obtaining encapsulated data and serialization information corresponding to the encapsulated data, wherein the serialization information includes cache index information and the interface identifier; A calling module, configured to pass the function pointer to the micro control unit layer, trigger the micro control unit layer to deserialize the encapsulated data in the memory space according to the cache index information, obtain a variable parameter type, and pass the obtained variable parameter type to the to-be-called interface corresponding to the interface identifier to call the to-be-called interface; The creation module creates the memory space of the microcontroller layer in the following manner, generates a function pointer corresponding to the memory space, and creates a Parcel object in a preset memory cache pool; uses the Parcel object to map the memory space corresponding to the microcontroller layer, and generates a function pointer corresponding to the Parcel object; The encapsulation module serializes the variable parameter type and encapsulates it into the memory space in the following manner, obtains encapsulated data and serialization information corresponding to the encapsulated data, applies to the memory space for a data memory block of the variable parameter type, and determines cache index information based on the memory address of the data memory block; serializes the variable parameter type and writes the serialized variable parameter type into the data memory block to obtain encapsulated data; generates serialization information corresponding to the encapsulated data based on the cache index information and the interface identifier; The calling module deserializes the encapsulated data in the memory space according to the cache index information corresponding to the function pointer in the following manner, reads the encapsulated data with the address pointed to by the data pointer as the starting address, and reads the encapsulated data until the next data address is read; deserializes the encapsulated data to obtain the variable parameter type.
6. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Mobile communication module sharing system and method in vehicular environment
CN104917830A
Inter-process communication method and device, computer device and readable storage medium
CN109933443A