Method and apparatus for dynamically loading channels and instances of services based on autosar ap platform
By using a file loader on the AutosarAP platform to load service configuration files into a shared memory library, adaptive applications can directly read channels and instances, solving the complex deployment problems caused by service migration and achieving simplified deployment and stable operation.
Patent Information
- Application Number
- CN202411470125.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-10-21
AI Technical Summary
In the AutosarAP platform, service migration requires modification of adaptive application code, which complicates the project release and deployment process and increases operational risks.
The configuration file of the service to be accessed is loaded into the shared memory library by the file loader. When the adaptive application needs to create or discover a service, it directly reads the communication channel and service instance from the memory library, avoiding recompiling the code.
It simplifies the project release and deployment process, reduces deployment risks, and improves system stability and response speed.
Smart Images

Figure CN119496815B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for dynamically loading service channels and instances based on the AutosarAP platform. Background Technology
[0002] With the continuous development of automotive intelligence and the diversification of functions, information interaction between ECUs (Electronic Control Units) and between applications is becoming increasingly frequent. In particular, with the addition of advanced application scenarios such as autonomous driving, the dynamic interaction of large amounts of data has led to a surge in communication pressure. AutoSar AP (Automotive Profile) adopts a service-oriented architecture (SOA), designed specifically for high-performance computing and communication to meet the communication needs of modern automotive intelligent ECUs.
[0003] When integrating communication protocols such as SomeIP, DDS, and IPC, AP software developers use a unified interface to implement SOA service provisioning and consumption, enabling interface with different underlying channel protocols. Service consumers use the `Find Service` method to discover services, while service providers use the `Create Service` method to create services. Both interfaces retain the same communication protocol and service instance (endpoint containing IP and port information). However, in actual development of adaptive applications (Apache APISIX, adaptive applications), each service on the platform must specify the channel and instance internally in its code when creating and discovering services; the channel and instance are hard-coded into the adaptive application. If a service is migrated to a different channel protocol, the adaptive application code must be modified, recompiled, and then flashed onto the board for execution, increasing the project deployment process. Summary of the Invention
[0004] This application provides a method and apparatus for dynamically loading service channels and instances based on the AutosarAP platform to solve the problem of complex project release and deployment processes.
[0005] In a first aspect, this application provides a method for dynamically loading service channels and instances based on the AutosarAP platform. The method includes: loading a configuration file of a service to be accessed into a shared memory library using a file loader, wherein the service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed; when it is detected that an adaptive application needs to create or discover a service, reading the configuration file from the memory library, wherein the adaptive application is an application that can dynamically adjust its functions and performance according to user needs and the environment; and passing the configuration file to the adaptive application so that the adaptive application can use the configuration file to create or discover a service.
[0006] Optionally, loading the configuration file of the service to be accessed into the shared memory library via the file loader includes: allocating a shared memory segment in the memory library for each configuration file of the service to be accessed, wherein the configuration files of different services to be accessed are different; loading the configuration file of each service to be accessed into the corresponding shared memory segment via the file loader; and reading the configuration file from the memory library includes: determining the target shared memory segment corresponding to the target accessed service, and reading the target configuration file of the target accessed service from the target shared memory segment.
[0007] Optionally, loading the configuration file of the service to be accessed into the shared memory library via the file loader includes: allocating the same shared memory segment for the configuration files of multiple services to be accessed in the memory library, wherein the configuration files of different services to be accessed are different; loading the configuration files of multiple services to be accessed into the same shared memory segment via the file loader; reading the configuration file from the memory library includes: reading the configuration files of all services to be accessed from the shared memory segment, and using the adaptive application to find the target configuration file of the target accessed service by traversing the data.
[0008] Optionally, allocating the same shared memory segment for configuration files of multiple services to be accessed in the memory library includes: reading configuration files of multiple services to be accessed from a set location through the file loader and converting the configuration files into a set file format; creating a topic message through the Publisher constructor; calling a set function and allocating the same shared memory segment for the configuration files in the memory library based on the topic message.
[0009] Optionally, loading configuration files of multiple services to be accessed into the same shared memory segment via the file loader includes: calling the Publisher method and passing in the configuration file with the set file format; converting the configuration file from the set file format into a data structure suitable for storage in the memory library; and calling the write method to write the converted configuration file into the shared memory segment.
[0010] Optionally, reading all configuration files of the services to be accessed from the shared memory segment and searching for the target configuration file of the target access service by traversing the data through the adaptive application includes: obtaining the topic parameter and callback function passed by the adaptive application, wherein the topic parameter is used to determine the address of the shared memory segment subscribed to by the topic, and the callback function is used to obtain the configuration file in the shared memory segment; returning the address of the shared memory segment to the adaptive application according to the topic parameter; obtaining all configuration files of the services to be accessed from the address of the shared memory segment, and calling the callback function to send the configuration file to the adaptive application; and traversing the configuration files of all the services to be accessed through the adaptive application and finding the configuration file of the target access service.
[0011] Optionally, returning the address of the shared memory segment to the adaptive application based on the topic parameter includes: determining the memory segment address to be searched based on the topic parameter; determining whether the memory segment address exists in the memory library; and if it exists, returning the memory segment address to the adaptive application.
[0012] Secondly, this application provides an apparatus for dynamically loading service channels and instances based on the AutosarAP platform. The apparatus includes: a loading module, used to load a configuration file of a service to be accessed into a shared memory library via a file loader, wherein the service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed; a reading module, used to read the configuration file from the memory library when it is detected that an adaptive application needs to create or discover a service, wherein the adaptive application is an application that can dynamically adjust its functions and performance according to user needs and the environment; and a transmission module, used to transmit the configuration file to the adaptive application so that the adaptive application can use the configuration file to create or discover a service.
[0013] Thirdly, this application provides an electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus.
[0014] Fourthly, this application also provides a computer storage medium storing computer-executable instructions for executing the method of dynamically loading service channels and instances based on the AutosarAP platform as described in any of the preceding claims of this application.
[0015] Compared with the prior art, the technical solution provided in this application has the following advantages: by loading the communication channel and service instance of the service to be accessed into the shared memory library through the file loader, the adaptive application can directly read the communication channel and service instance from the memory library when it needs to create or discover services. Even if the communication channel and service instance change, only the configuration file needs to be changed, and the communication channel and service instance in the memory library can remain up-to-date. It is not necessary to recompile the code of the adaptive application, thereby reducing the project release and deployment process and simplifying the project release and deployment process. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0018] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0019] Figure 1 A flowchart illustrating a method for dynamically loading service channels and instances based on the AutosarAP platform, as provided in this application embodiment;
[0020] Figure 2 This application provides a schematic diagram of a system architecture for dynamically loading services based on the AutosarAP platform, illustrating an embodiment of the present application.
[0021] Figure 3 The signaling diagram for accessing shared memory segments based on topic provided in the embodiments of this application;
[0022] Figure 4 Signaling diagram for adaptive application subscription shared memory data provided in embodiments of this application;
[0023] Figure 5 A flowchart illustrating the services provided in the embodiments of this application;
[0024] Figure 6 A schematic diagram illustrating the service registration and discovery process provided in the embodiments of this application;
[0025] Figure 7 A schematic diagram of a device structure for dynamically loading channels and instances of services based on the AutosarAP platform, provided in an embodiment of this application;
[0026] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0028] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0029] This application provides a method for dynamically loading service channels and instances based on the AutosarAP platform, which can be applied to electronic control units to shorten project release time, such as... Figure 1 As shown, it includes the following content.
[0030] Step 101: Load the configuration file of the service to be accessed into the shared memory library using the file loader. The service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed.
[0031] Step 102: When it is detected that the adaptive application needs to create a service or discover a service, read the configuration file from the memory library. The adaptive application is an application that can dynamically adjust its functions and performance according to user needs and environment.
[0032] Step 103: Pass the configuration file to the adaptive application so that the adaptive application can use the configuration file to create or discover services.
[0033] Generally, accessing a service requires specifying its communication channel and instance ID. Before an adaptive application creates or consumes a service, its code must first specify the instance and channel to access in order to discover or create the service. Therefore, the channel and instance are often hard-coded into the program. If the service's channel or instance changes, the adaptive application must be recompiled and then flashed onto the board to run. This presents two problems: first, it increases the project deployment process; second, replacing an already running program and redeploying it may introduce unpredictable factors, increasing operational risks.
[0034] To address the aforementioned issues, this application provides a schematic diagram of a system architecture for dynamically loading service channels and instances based on the AutosarAP platform, as shown below. Figure 2 As shown, the communication channels and service instances of the services to be accessed are loaded into the shared memory library through a file loader. In this way, when the adaptive application needs to create or discover services, it can directly read the communication channels and service instances from the memory library. Even if the communication channels and service instances change, only the configuration file needs to be changed, and the communication channels and service instances in the memory library can remain up-to-date. There is no need to recompile the code of the adaptive application, which reduces the project release and deployment process and simplifies the project release and deployment process.
[0035] In addition, this application does not require adjustments to the existing program, avoiding the uncontrollable risks brought about by program replacement and improving the stability of system operation.
[0036] Optionally, the file loader can not only automatically load communication channels and service instances into the memory library at preset time intervals, but also monitor any changes to communication channels and service instances in real time and update the data in the memory library immediately. This mechanism ensures that the system can respond quickly to changes in the underlying services.
[0037] Optionally, the service to be accessed in this application embodiment is the AutosarAP (Automotive Profile) service, which is a standardized software architecture for automotive applications, specifically designed for efficient communication between automotive electronic control units. For example, the service to be accessed may be accessing millimeter-level microwaves or accessing radar waves.
[0038] Optionally, the adaptive application in this application embodiment is an application that can dynamically adjust its functions and performance according to the user's needs and environment. It can intelligently allocate system resources according to the user's network conditions and device performance to improve the application's performance and response speed.
[0039] Each service to be accessed corresponds to a configuration file. When this application loads the configuration file into the shared memory library, it needs to allocate a memory segment in the memory library for the configuration file. This includes two embodiments: one embodiment is to configure the same shared memory segment for all configuration files, and the other embodiment is to configure a shared memory segment for different configuration files. For these two cases, the way the adaptive application finds the target configuration file of the target access service will also be different. The two embodiments are as follows.
[0040] The first embodiment includes the following steps.
[0041] Step 1. Allocate a shared memory segment in the memory library for the configuration file of each service to be accessed, where the configuration files of different services to be accessed are different;
[0042] Step 2. Load the configuration file of each service to be accessed into the corresponding shared memory segment using a file loader;
[0043] Step 3. Determine the target shared memory segment corresponding to the target access service, and read the target configuration file of the target access service from the target shared memory segment.
[0044] Each service to be accessed corresponds to a configuration file. For each service, the system allocates a dedicated shared memory segment for its configuration file. This means that the configuration information for each service is stored in a unique memory area completely isolated from other services. This approach not only ensures that configuration files between different services are not confused or overwritten, but also greatly reduces potential problems caused by data conflicts. In this way, it ensures that each service has a stable and secure operating environment, unaffected by other services.
[0045] After allocating the shared memory segment, the system uses a dedicated file loader to load the configuration file of each service to be accessed into its corresponding shared memory segment. This loading process is automated, ensuring that the configuration file is correctly placed in its intended location. Furthermore, because each service's configuration file is stored in its own dedicated shared memory segment, fast data access is guaranteed even under high concurrency, thus improving the overall system performance.
[0046] When a system needs to access a specific service, it first determines the target shared memory segment corresponding to that service. This process typically involves resolving service identifiers (such as service names, IDs, etc.) to accurately locate the correct shared memory segment. Once the target shared memory segment is determined, the system can directly read the target configuration file for that service from it. Because the configuration file for each service to be accessed is stored in a separate memory segment, this process is both efficient and secure, effectively avoiding potential delays or errors during data retrieval.
[0047] By implementing the above strategies, the system not only achieves effective management and rapid access to configuration files of different services to be accessed, but also greatly enhances data security and manageability. The configuration file of each service to be accessed is strictly isolated in its own memory segment, which not only prevents data conflicts between different services but also simplifies troubleshooting and maintenance.
[0048] The second embodiment includes the following steps.
[0049] Step 1. Allocate the same shared memory segment in the memory library for the configuration files of multiple services to be accessed, where the configuration files of different services to be accessed are different;
[0050] Step 2. Load the configuration files of multiple services to be accessed into the same shared memory segment using a file loader;
[0051] Step 3. Read all configuration files of the services to be accessed from the shared memory segment, and use the adaptive application to find the target configuration file of the target access service by traversing the data.
[0052] The system allocates the same shared memory segment for the configuration files of multiple services to be accessed. Although the configuration files of these services are different, they are centrally stored in the same memory area. This not only effectively saves memory resources but also simplifies the complexity of memory management. Centralized storage reduces memory fragmentation, improves memory utilization, and makes the system more efficient and flexible when handling a large number of services.
[0053] The file loader is responsible for loading configuration files from multiple services into the same shared memory segment. This loading process ensures the accuracy and integrity of the data; that is, the configuration file for each service must be correctly placed in its designated memory location. Through efficient algorithms and mechanisms, the file loader ensures that configuration file loading is both fast and reliable in a multi-service environment. Furthermore, centralized loading facilitates unified management and updates of configuration files, further improving system maintainability.
[0054] When a specific target service needs to be accessed, the adaptive application reads the configuration files of all services to be accessed from the shared memory segment. Then, it quickly locates the target configuration file for the desired service by traversing the data. This process relies on the powerful processing capabilities of the adaptive application, enabling it to efficiently filter out the required file from a large number of configuration files. This not only speeds up configuration file retrieval but also ensures data consistency and accuracy.
[0055] In both embodiments described above, the independent memory segment strategy emphasizes data isolation and security, making it suitable for applications with high stability and reliability requirements. The shared memory segment strategy, on the other hand, prioritizes resource sharing and response speed, making it suitable for services sensitive to memory resources or requiring rapid deployment. The most suitable strategy can be selected based on business needs and resource availability to achieve optimal system performance and efficiency. Regardless of the strategy chosen, effective shared memory management is crucial for ensuring stable system operation and efficient response.
[0056] In the second embodiment, the file loader accesses the shared memory segment based on topic publishing and subscription, and then adaptively subscribes to topics in the shared memory segment.
[0057] In the second embodiment, step 1 includes: reading configuration files of multiple services to be accessed from a set location through a file loader and converting the configuration files into a set file format; creating a topic message through the Publisher constructor; calling a set function and allocating the same shared memory segment in the memory library for the configuration files based on the topic message.
[0058] Figure 3 To implement a signaling graph for accessing shared memory segments based on topics, in Figure 3 In this context, Publisher, Topic, and memory can be encapsulated as dynamic libraries in an in-memory library for use by the file loader. The file loader is responsible for reading a JSON-formatted configuration file, which contains the communication channels and instances corresponding to different services to be accessed. For example, the configuration file may contain deployment information for two services to be accessed: Key Management Service and UpdateService, which use IPC:1 and IPC:2 channel instances respectively.
[0059] The file loader converts these JSON files into a specified file format, for example, a map file (std::map).<std::string,std::string> This message format allows the system to process and store configuration data more efficiently. After the file loader completes the data format conversion, the Publisher constructor creates a topic message named "map_message". This topic message is designed to carry key information about the configuration file for efficient management and access in the memory library. Subsequently, the file loader calls the create_memory_segment function, which allocates a shared memory segment based on the topic message. This shared memory segment will be used to store the format-converted configuration file, thus completing the step of configuring a shared memory segment for the configuration file.
[0060] In the second embodiment, step 2 includes: calling the Publisher method to pass in a configuration file with a set file format; converting the configuration file from the set file format into a data structure suitable for storage in the memory library; and calling the write method to write the converted configuration file into a shared memory segment.
[0061] like Figure 3 As shown, the file loader calls the Publisher method, passing the converted map message as a parameter. Inside this method, the data is first converted into a data structure that is suitable for storage in shared memory, and then the write method is called to store the data in the shared memory segment previously created based on the topic. This data storage method not only improves the system's response speed and data processing capabilities, but also enhances the system's scalability and flexibility.
[0062] To improve modularity and reusability, the related functionalities of Publisher, Topic, and memory can be encapsulated into a dynamic library. In this way, the file loader can call the interface in this library when needed, without having to repeatedly implement the shared memory management logic, which simplifies the development process and improves code maintainability.
[0063] The following is Figure 3 The overall process steps.
[0064] 1) Read the JSON configuration file.
[0065] The file loader first reads the specified JSON configuration file, which contains the communication channels and instances corresponding to the different services to be accessed. The data in this configuration file will then be converted into a std::map.<std::string,std::string> The formatted messages facilitate subsequent processing and storage.
[0066] 2) Create a shared memory segment.
[0067] In the Publisher constructor, a topic message named "map_message" is first created. Then, the create_memory_segment function is called to allocate a shared memory segment for the configuration file based on this topic message. This step ensures that data can be shared safely and efficiently among multiple processes.
[0068] 3) Publish messages to shared memory.
[0069] The file loader then calls the Publisher's method, passing the previously read and converted map message as a parameter. Inside this method, the map format file is first converted into a data structure suitable for storage in shared memory. After the conversion is complete, the write method is called to write the configuration file to the shared memory segment.
[0070] 4) Refresh shared memory periodically.
[0071] Considering that the JSON configuration file may be updated at any time, the file loader is designed to run periodically. In each run, it rereads the configuration file and updates the configuration file in the shared memory segment. This ensures that the data in the shared memory segment always reflects the current service deployment state. To achieve this, a timer or thread loop can be used to periodically check the file's modification time and update it accordingly.
[0072] In the second embodiment, step 3 specifically includes: obtaining the topic parameters and callback function passed by the adaptive application; returning the address of the shared memory segment to the adaptive application based on the topic parameters, wherein the topic parameters are used to determine the address of the shared memory segment subscribed to by the topic, and the callback function is used to obtain the configuration file in the shared memory segment; obtaining the configuration files of all services to be accessed from the address of the shared memory segment, and calling the callback function to send the configuration files to the adaptive application; and traversing the configuration files of all services to be accessed through the adaptive application, and finding the configuration file of the target access service.
[0073] The adaptive application passes a topic parameter and a callback function to the system. The topic parameter is used to determine the address of the shared memory segment to which the topic is subscribed, and the callback function is used to retrieve the configuration file in the shared memory segment.
[0074] Based on the received topic parameter, the system performs corresponding logical processing to determine the address of the shared memory segment to be searched. This step involves parsing the topic parameter to accurately match the corresponding memory location. Subsequently, the system needs to check whether the memory segment address actually exists in the memory library. If it exists, the address information is returned to the adaptive application; otherwise, if it does not exist, it may need to trigger an error handling process or return specific error information to the caller.
[0075] Once the adaptive application obtains the correct address of the shared memory segment, it initiates a topic message that requests the callback function passed to it before the system call to pass all the read configuration files to the adaptive application.
[0076] The adaptive application iterates through all the configuration files of the services it wants to access, identifying the target configuration file for the desired service. This process is based on techniques such as keyword search and regular expression matching, with the ultimate goal of accurately locating the required file from among numerous configuration files.
[0077] Figure 4 The signaling graph for subscribing to shared memory data for adaptive applications includes the following steps.
[0078] 1) Call the Subscriber method to retrieve data.
[0079] In adaptive applications, the Subscriber constructor accepts two parameters: a topic parameter and a callback function.
[0080] The `topic` parameter: This parameter is used to locate the shared memory segment. By calling the `create_memory_segment` function, the system checks whether the shared memory segment corresponding to this `topic` parameter already exists. If it exists, the function will return the address of the shared memory segment for subsequent data retrieval; if it does not exist, it may throw an exception or return an error code, prompting the user to take appropriate action.
[0081] Callback function: This callback function is used to retrieve data from the shared memory segment. Through this mechanism, the Subscriber can pass the found configuration file to the adaptive application.
[0082] 1) Obtain the shared memory address.
[0083] The system calls the Subscriber method to retrieve the topic parameters and callback function passed in by the data adaptive application, and then calls the create_memory_segment function to determine whether the shared memory segment created by the topic exists. If it exists, the subscription is considered complete.
[0084] 2) Execute the callback function.
[0085] When an adaptive application initiates a topic request, the system uses a callback function to package all configuration files read from the shared memory segment and send them to the adaptive application. The execution of the callback function not only sends the data back but may also perform additional logic during this process, such as data parsing and format conversion, to facilitate subsequent processing.
[0086] 3) Traverse and process the returned data.
[0087] The adaptive application receives all configuration files, traverses and parses them to extract the communication channels and instance information of the target access service.
[0088] In this application, the communication channel and instance information of the service to be accessed can be published to the in-memory library in a configurable manner as a topic. The adaptive application can subscribe to the topic to obtain the communication channel and instance information from the in-memory library. When the communication channel and instance information changes, only the JSON file needs to be replaced. The file loader will read the JSON file and publish it to the shared memory at regular intervals. The adaptive application can obtain the latest channel and instance of the target service by subscribing to the topic, and can dynamically load the new channel and instance without recompiling the adaptive application.
[0089] Once the adaptive application receives the communication channel and instance information of the target access service, it can pass this information to the service provider and service consumer. The service consumer uses the Find Service method to discover the service, and the service provider uses the Create Service method to create the service. The creation and discovery of services are described in detail below.
[0090] First, let's introduce the AP service.
[0091] Services in an AP are provided and consumed within processes, which are managed uniformly by the AP platform's EM execution management module (a process running on the AP platform). SOA service interfaces are divided into three types: method, event, and field.
[0092] Method: The client can call the service's internal interface. The call is triggered by the client and runs once per call, while the server passively receives the calls.
[0093] Event: The server can periodically notify the client, which is actively triggered by a local event on the server.
[0094] Field: Includes three methods: Set, Get, and Notifier. It can be set (Set), read (Get), or notified (Notifier). The server triggers a notification (Notifier) when data changes. The client can modify (Set) or read (Get) the data.
[0095] Figure 5 The flowchart for creating a service includes the following four steps.
[0096] The first step, in the AP service matrix, mainly configures information related to services and communication protocols. This includes: the communication channel used by the service (including someip, dds, and ipc) and related parameter configurations for the communication channel protocol; where someip and dds are used for cross-ECU communication, dds for high-load data transmission, and ipc for intra-ECU communication; specifying the type of interface under the service (method, event, or field), the input and output parameters of each interface, and the implementation method of each interface; defining the data type of the interface input and output parameters; and defining the communication behavior of the service, mainly reflecting the interaction relationship between services or within an ECU.
[0097] The second step is to import the AP service matrix into the Manifest configuration tool. The Manifest configuration tool combines the configuration information from the first step with the configuration of process resource allocation, process lifecycle management, access permissions, etc. running on the AP platform to generate an ARMXML file.
[0098] The third step involves the code generation tool generating platform-related configuration information, service skeleton code, and proxy code based on the imported armxml file.
[0099] The fourth step is to integrate the business process, i.e., the adaptive application, as needed. The consumer calls the service's proxy code to initiate access to the service, and the provider calls the service's skeleton code to implement the service.
[0100] Figure 6 A flowchart illustrating the service registration and discovery process, including, for example Figure 5 One step.
[0101] ① Service Provider: Register the instance ID (deployment information bound to the service, including event, field, and method interface information under the service, ECU IP and port information, etc.) and channel (communication protocol used: someip, dds, ipc) to the ECU1 service registry center.
[0102] Service consumer: Sends the instance ID and channel to the ECU2 service registry, indicating that it needs to find a certain service.
[0103] ② The service registry of ECU2 determines whether this ECU provides a lookup service. If not, the service registry of ECU2 will send a multicast message to the service registry of ECU1; if it does provide the service, it will be returned directly to the service consumer.
[0104] ③When the service registry of ECU1 receives the multicast message sent by the service registry of ECU2 and finds that ECU1 provides this service, the service registry of ECU1 will reply with a unicast message (carrying the IP and port information of the service provider).
[0105] ④The ECU2 service registry receives the unicast message and forwards it to the service consumer within ECU2.
[0106] ⑤ The service consumer of ECU2 obtains the IP and port for providing the service and establishes a direct connection with the service provider of ECU1.
[0107] This application provides a complete process for creating and discovering AutosarAP services, including the following steps.
[0108] Step 1: Implement access to the in-memory library using a publish-subscribe approach based on topics.
[0109] 1) Read the JSON configuration file.
[0110] The file loader first reads the specified JSON configuration file, which contains the communication channels and instances corresponding to the different services to be accessed. The data in this configuration file will then be converted into a std::map.<std::string,std::string> The formatted messages facilitate subsequent processing and storage.
[0111] 2) Create a shared memory segment.
[0112] In the Publisher constructor, a topic message named "map_message" is first created, and then the create_memory_segment function is called to allocate a shared memory segment for the configuration file based on this topic message.
[0113] 3) Publish messages to shared memory.
[0114] The file loader then calls the Publisher's method, passing the previously read and converted map message as a parameter. Inside this method, the map format file is first converted into a data structure suitable for storage in shared memory. After the conversion, the write method is called to write the configuration file to the shared memory segment.
[0115] Step 2: Adaptive application subscription to configuration files in the memory library.
[0116] 1) Obtain the shared memory address.
[0117] The system calls the Subscriber method to retrieve data, adapting to the application by passing in the topic parameter and callback function. The system calls the create_memory_segment function to determine if the shared memory segment created by the topic exists. If it exists, the subscription is considered complete.
[0118] 2) Execute the callback function.
[0119] The Subscriber method is called to retrieve data, and then the adaptive application sends topic information. The topic information carries a callback function, which packages all configuration files read from the shared memory segment and sends them to the adaptive application. The execution of the callback function not only sends the data back but may also perform additional logic during this process, such as data parsing and format conversion, to facilitate subsequent processing.
[0120] 3) Traverse and process the returned data.
[0121] The adaptive application receives all configuration files, traverses and parses them to extract the communication channels and instance information of the target access service.
[0122] Step 3: The service creator uses the Create Service method to create a service.
[0123] Step 4: The service creator and service consumer register the service. The service consumer uses the FindService method to discover the service.
[0124] Based on the same technical concept, this application provides a device for dynamically loading service channels and instances based on the AutosarAP platform, such as... Figure 7 As shown, the device includes:
[0125] Loading module 701 is used to load the configuration file of the service to be accessed into the shared memory library through a file loader. The service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed.
[0126] The reading module 702 is used to read the configuration file from the memory library when it is detected that the adaptive application needs to create a service or discover a service. The adaptive application is an application that can dynamically adjust its functions and performance according to user needs and environment.
[0127] The delivery module 703 is used to pass the configuration file to the adaptive application so that the adaptive application can use the configuration file to create or discover services.
[0128] Optionally, the loading module 701 is used to: allocate a shared memory segment in the memory library for the configuration file of each service to be accessed, wherein the configuration files of different services to be accessed are different; and load the configuration file of each service to be accessed into the corresponding shared memory segment through a file loader.
[0129] The reading module 702 is used to: determine the target shared memory segment corresponding to the target access service, and read the target configuration file of the target access service from the target shared memory segment.
[0130] Optionally, the loading module 701 is used to: load the configuration files of the services to be accessed into the shared memory library by a file loader, including: allocating the same shared memory segment in the memory library for the configuration files of multiple services to be accessed, wherein the configuration files of different services to be accessed are different; and loading the configuration files of multiple services to be accessed into the same shared memory segment by a file loader.
[0131] The reading module 702 is used to: read all configuration files of the services to be accessed from the shared memory segment, and use an adaptive application to find the target configuration file of the target access service by traversing the data.
[0132] Optionally, the loading module 701 is used for:
[0133] The file loader reads configuration files for multiple services to be accessed from a set location and converts the configuration files into a set file format.
[0134] Create topic messages using the Publisher constructor;
[0135] Call the configuration function and allocate the same shared memory segment in the memory bank for the configuration file based on the topic message.
[0136] Optionally, the loading module 701 is used for:
[0137] Call the Publisher method and pass in the configuration file that sets the file format;
[0138] Convert the configuration file from the specified file format into a data structure suitable for storage in memory;
[0139] Calling the write method writes the converted configuration file to the shared memory segment.
[0140] Optionally, the reading module 702 is used for:
[0141] Get the topic parameter and callback function passed in by the adaptive application. The topic parameter is used to determine the address of the shared memory segment subscribed to by the topic, and the callback function is used to retrieve the configuration file in the shared memory segment.
[0142] The address of the shared memory segment is returned to the adaptive application based on the topic parameter;
[0143] Retrieve the configuration files of all services to be accessed from the address of the shared memory segment, and call the callback function to send the configuration files to the adaptive application;
[0144] The adaptive application iterates through the configuration files of all services to be accessed and finds the configuration file of the target service.
[0145] Optionally, the reading module 702 is used for:
[0146] The memory segment address to be searched is determined based on the topic parameter;
[0147] Determine if a memory segment address exists in the memory library;
[0148] If it exists, return the memory segment address to the adaptive application.
[0149] like Figure 8 As shown, this application provides an electronic device including a processor 801, a communication interface 802, a memory 803, and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0150] The memory 803 is used to store computer programs.
[0151] In one embodiment of this application, when the processor 801 executes a program stored in the memory 803, it implements the method for dynamically loading channels and instances of services based on the AutosarAP platform provided in any of the foregoing method embodiments, including:
[0152] The configuration file of the service to be accessed is loaded into the shared memory library through a file loader. The service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed. When it is detected that the adaptive application needs to create or discover a service, the configuration file is read from the memory library. The adaptive application is an application that can dynamically adjust its functions and performance according to user needs and environment. The configuration file is then passed to the adaptive application so that the adaptive application can use the configuration file to create or discover the service.
[0153] Optionally, loading the configuration file of the service to be accessed into the shared memory library via a file loader includes: allocating a shared memory segment in the memory library for each configuration file of the service to be accessed, wherein the configuration files of different services to be accessed are different; loading the configuration file of each service to be accessed into the corresponding shared memory segment via a file loader; and reading the configuration file from the memory library includes: determining the target shared memory segment corresponding to the target accessed service, and reading the target configuration file of the target accessed service from the target shared memory segment.
[0154] Optionally, loading the configuration file of the service to be accessed into the shared memory library via a file loader includes: allocating the same shared memory segment for the configuration files of multiple services to be accessed in the memory library, wherein the configuration files of different services to be accessed are different; loading the configuration files of multiple services to be accessed into the same shared memory segment via a file loader; reading the configuration file from the memory library includes: reading the configuration files of all services to be accessed from the shared memory segment, and using an adaptive application to find the target configuration file of the target accessed service by traversing the data.
[0155] Optionally, allocating the same shared memory segment in the memory library for configuration files of multiple services to be accessed includes: reading configuration files of multiple services to be accessed from a set location through a file loader and converting the configuration files into a set file format; creating a topic message through the Publisher constructor; calling a setting function and allocating the same shared memory segment in the memory library for the configuration files based on the topic message.
[0156] Optionally, loading configuration files of multiple services to be accessed into the same shared memory segment via a file loader includes: calling the Publisher method and passing in a configuration file with a specified file format; converting the configuration file from the specified file format into a data structure suitable for storage in memory; and calling the write method to write the converted configuration file into the shared memory segment.
[0157] Optionally, reading the configuration files of all services to be accessed from the shared memory segment and searching for the target configuration file of the target service by traversing the data through the adaptive application includes: obtaining the topic parameter and callback function passed by the adaptive application, wherein the topic parameter is used to determine the address of the shared memory segment subscribed to by the topic, and the callback function is used to obtain the configuration file in the shared memory segment; returning the address of the shared memory segment to the adaptive application according to the topic parameter; obtaining the configuration files of all services to be accessed from the address of the shared memory segment and calling the callback function to send the configuration files to the adaptive application; and traversing the configuration files of all services to be accessed through the adaptive application and finding the configuration file of the target service.
[0158] Optionally, returning the address of the shared memory segment to the adaptive application based on the topic parameter includes: determining the memory segment address to be searched based on the topic parameter; determining whether the memory segment address exists in the memory library; and if it exists, returning the memory segment address to the adaptive application.
[0159] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method for dynamically loading service channels and instances based on the AutosarAP platform as provided in any of the foregoing method embodiments.
[0160] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0161] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0162] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0163] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for dynamically loading service channels and instances based on the AutosarAP platform, characterized in that, The method includes: The configuration file of the service to be accessed is loaded into the shared memory library through a file loader. The service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed. When it is detected that the adaptive application needs to create or discover services, the configuration file is read from the memory library, wherein the adaptive application is an application that can dynamically adjust its functions and performance according to user needs and environment; The configuration file is passed to the adaptive application so that the adaptive application can use the configuration file to create or discover services.
2. The method according to claim 1, characterized in that, Loading the configuration file of the service to be accessed into the shared memory library via the file loader includes: allocating a shared memory segment in the memory library for each configuration file of the service to be accessed, wherein the configuration files of different services to be accessed are different; and loading the configuration file of each service to be accessed into the corresponding shared memory segment via the file loader. Reading the configuration file from the memory library includes: determining the target shared memory segment corresponding to the target access service, and reading the target configuration file of the target access service from the target shared memory segment.
3. The method according to claim 1, characterized in that, Loading the configuration files of the services to be accessed into the shared memory library via the file loader includes: allocating the same shared memory segment for the configuration files of multiple services to be accessed in the memory library, wherein the configuration files of different services to be accessed are different; and loading the configuration files of multiple services to be accessed into the same shared memory segment via the file loader. Reading the configuration file from the memory library includes: reading all configuration files of the services to be accessed from the shared memory segment, and using the adaptive application to search for the target configuration file of the target access service by traversing the data.
4. The method according to claim 3, characterized in that, Allocating the same shared memory segment for configuration files of multiple services to be accessed in the memory library includes: The file loader reads configuration files of multiple services to be accessed from a set location and converts the configuration files into a set file format. Create topic messages using the Publisher constructor; The configuration function is invoked, and based on the topic message, the same shared memory segment is allocated in the memory library for the configuration file.
5. The method according to claim 4, characterized in that, Loading configuration files for multiple services to be accessed into the same shared memory segment via the file loader includes: Call the Publisher method and pass in the configuration file specifying the file format; Convert the configuration file from the specified file format into a data structure suitable for storage in the memory library; The write method is called to write the converted configuration file to the shared memory segment.
6. The method according to claim 3, characterized in that, Reading all configuration files of the services to be accessed from the shared memory segment, and using the adaptive application to find the target configuration file of the target access service by traversing the data, includes: Obtain the topic parameter and callback function passed in by the adaptive application, wherein the topic parameter is used to determine the address of the shared memory segment subscribed to by the topic, and the callback function is used to obtain the configuration file in the shared memory segment; The address of the shared memory segment is returned to the adaptive application based on the topic parameter; Obtain the configuration files of all services to be accessed from the address of the shared memory segment, and call the callback function to send the configuration files to the adaptive application; The adaptive application iterates through the configuration files of all services to be accessed and finds the configuration file of the target service.
7. The method according to claim 6, characterized in that, Returning the address of the shared memory segment to the adaptive application based on the topic parameter includes: The memory segment address to be searched is determined based on the topic parameter; Determine whether the memory segment address exists in the memory library; If it exists, the memory segment address is returned to the adaptive application.
8. A device for dynamically loading service channels and instances based on the AutosarAP platform, characterized in that, The device includes: The loading module is used to load the configuration file of the service to be accessed into the memory library of shared memory through a file loader, wherein the service to be accessed exists in the AutosarAP platform, and the configuration file includes the communication channel and service instance of the service to be accessed. The reading module is used to read the configuration file from the memory library when it is detected that the adaptive application needs to create a service or discover a service, wherein the adaptive application is an application that can dynamically adjust its functions and performance according to user needs and environment; The delivery module is used to pass the configuration file to the adaptive application so that the adaptive application can use the configuration file to create a service or discover a service.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-7.
Citation Information
Patent Citations
Secure communication method based on adaptive application and server
CN114980083A
Method and system for vehicle-mounted application to access network service, vehicle and storage medium
CN116233214A