Application layer code and bottom layer code integration method and device, server and medium

By configuring the code generation environment and running integration tools in the Simulink model, the application-layer code is automatically generated and integrated with the underlying code, the problem of low manual integration efficiency in the existing technology is solved, and fast and efficient software development is achieved.

CN119917161APending Publication Date: 2025-05-02CHONGQING CHANGAN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510100436.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, the integration of application layer code and underlying code needs to be completed manually, which can easily lead to bugs and integration efficiency, and is inconvenient for users to use.

Method used

By loading the Simulink model and the accompanying data dictionary, configuring the code generation environment, running the integration tool, calling preset functions to generate application layer code, and automatically integrating application layer code with the underlying code when the conditions are met.

Benefits of technology

It realizes automatic integration of application-level code and underlying code, improves software iteration rate, reduces compilation and integration efficiency, and facilitates users to quickly verify functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917161A_ABST
    Figure CN119917161A_ABST
Patent Text Reader

Abstract

The invention discloses an application layer code and bottom layer code integration method and device, a server and a medium, and relates to the technical field of vehicle software automatic development. The method comprises the following steps: loading a Simulink model and a matched data dictionary, and configuring a Simulink model code generation environment; running an integration tool of the Simulink model, and calling a first preset function to display a preset execution option; responding to the first preset execution command, clearing execution completion records of paths of the build integration project and all parts of a program in the SaveMAT folder, storing the corresponding paths of the build integration project into the SaveMAT folder under the condition that a path selection instruction of the build integration project is received, and calling a second preset function to generate an application layer code; and under the condition that the integration condition is met, calling a preset file to integrate the application layer code and the bottom layer code. Therefore, the application layer code is automatically generated by one key based on the Simulink model, the application layer code is integrated with the bottom layer code, and the program does not need to run from the beginning if an error is reported in the program running process, so that the integration efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of vehicle software automation development, and in particular to a method for integrating application layer code with underlying code, a device for integrating application layer code with underlying code, a computer-readable storage medium, and a server. Background Art

[0002] With the general trend of automobile intelligence, "software-defined cars" has become an industry consensus. The continuous upgrading and updating of vehicle functions requires rapid software development response. Model-based development is a mature method in the field of automotive software development. Application layer development engineers can generate embedded code with one click based on Simulink models. Sometimes, in order to verify whether a certain function meets the requirements, application layer development engineers need to integrate application layer code and underlying code by themselves. The integration of application layer code and underlying code needs to be done manually, which is prone to bugs, and the integration process is not continuous enough. Some steps require engineers to manually confirm before the program will continue to execute, which reduces the integration efficiency. In addition, application layer development engineers also need to spend time learning how to integrate, which is inconvenient for users who are not familiar with integration work.

[0003] In the related technology, a patent document with application number CN202210191208.0 and name "A one-click software code integration method and system" is disclosed. The method updates the existing application layer software source code and the underlying software source code to the compilation environment, and then calls the preset build file in the compilation environment. If the compilation is completed or terminated, it is determined whether there is a target file in the compilation environment. If so, a calibration interface A2L file is generated, and the address of each variable and parameter in the A2L file is matched based on the target file and the A2L file. The A2L file and all target files after the matching address are copied to the specified address. However, if an error is encountered during program operation, this method needs to run the program from the beginning, and the integration efficiency is low. Summary of the invention

[0004] One of the purposes of this application is to provide a method for integrating application layer code with underlying code; a second purpose is to provide a device for integrating application layer code with underlying code; a third purpose is to provide a computer-readable storage medium; and a fourth purpose is to provide a server.

[0005] In order to achieve the above purpose, the technical solution adopted in this application is as follows:

[0006] A method for integrating application layer code with underlying code, the method comprising: loading a Simulink model and a supporting data dictionary, and configuring a Simulink model code generation environment; running an integration tool for the Simulink model, and calling a first preset function to display preset execution options; responding to the first preset execution command, clearing the path of the build integration project and the execution completion records of each part of the program in the SaveMAT folder, and upon receiving a path selection instruction for the build integration project, storing the corresponding path of the build integration project in the SaveMAT folder, and calling a second preset function to generate application layer code; and when the integration conditions are met, calling the preset file to integrate the application layer code with the underlying code.

[0007] According to one embodiment of the present application, an elf file is generated after the application layer code and the underlying code are integrated, and the application layer code includes a first A2l file. The method also includes: calling a third preset function to merge the first A2l file to obtain a second A2l file; calling a fourth preset function to update the address information in the elf file to the second A2l file; and saving the second A2l file into the folder where the elf file is located.

[0008] According to one embodiment of the present application, the application layer code also includes c files and h files, and the method also includes: when the c files and h files are in the application layer code folder of the build integration project, and the integration version number of the build integration project is stored in the SaveMAT folder, and the target files generated by the last build in the build integration project are cleared, determining that the integration conditions are met.

[0009] According to an embodiment of the present application, the above method also includes: before calling the second preset function to generate application layer code, clearing subfiles and subfolders in the Simulink model cache folder and the code folder.

[0010] According to one embodiment of the present application, the above method also includes: responding to a second preset execution command, if an integrated version number exists in the SaveMAT folder, loading the integrated version number, building the integrated project path and the execution completion records of each part of the program, wherein the execution completion records of each part of the program include the execution completion flags of each part of the program; determining the execution progress according to the execution completion flags of each part of the program, and continuing the execution according to the execution progress.

[0011] According to an embodiment of the present application, the above method further includes: when the execution progress is that the Simulink model code generation process is terminated, re-calling the second preset function to generate the application layer code and then continuing the execution.

[0012] According to one embodiment of the present application, the above method also includes: responding to a third preset execution command, clearing the execution completion records of each part of the program; if there is a build integrated project path in the SaveMAT folder, loading the build integrated project path, and clearing the subfiles and subfolders in the Simulink model cache folder and the code folder before continuing execution; if there is no build integrated project path in the SaveMAT folder, reselecting the build integrated project path before continuing execution.

[0013] An integration device for application layer code and bottom layer code comprises: a loading module for loading a Simulink model and a supporting data dictionary, and configuring a Simulink model code generation environment; a display module for running an integration tool for the Simulink model, and calling a first preset function to display a preset execution option; a generation module for responding to a first preset execution command, clearing the path of a build integration project and execution completion records of each part of a program in a SaveMAT folder, and upon receiving a path selection instruction for a build integration project, storing the corresponding path of the build integration project in the SaveMAT folder, and calling a second preset function to generate application layer code; and an integration module for calling a preset file to integrate the application layer code with the bottom layer code when integration conditions are met.

[0014] A computer-readable storage medium stores an integrated program based on application layer code and underlying code, and the integrated program of application layer code and underlying code implements the aforementioned method of integrating application layer code and underlying code when executed by a processor.

[0015] A server, characterized in that it includes a memory, a processor, and an integrated program of application layer code and underlying code stored in the memory and executable on the processor. When the processor executes the integrated program of application layer code and underlying code, the aforementioned method of integrating application layer code and underlying code is implemented.

[0016] Beneficial effects of this application:

[0017] (1) This application can use the Simulink model to automatically generate application layer code, automatically integrate the application layer code with the underlying code, and automatically generate an A2L file with an address, so that application layer development engineers can quickly verify the function after modifying the upper layer logic, thereby improving the software iteration rate;

[0018] (2) This application can automatically generate application layer code with one click and integrate the application layer code with the underlying code, and determine in real time whether the program execution process reports an error. If an error is reported, the user can modify it according to the prompt. When executing again, the unfinished steps can be continued from the last program error point, thereby improving the efficiency of compilation and integration;

[0019] (3) This application can automatically name the generated target file according to the integrated version number of the build integrated project, so as to determine the integrated project corresponding to the target file;

[0020] (4) During the execution of the program, the application can prompt the user of the program progress through a pop-up window or command line message after each part is completed, and the pop-up window will automatically close after a certain period of time, which is convenient for the user to know the program execution progress without adding the user's additional operation of manually closing the pop-up window;

[0021] (5) When generating the A2L interface file, the application uses Matlab's own functions to edit the A2L file, such as calling the function rtw.asap2MergeMdlRefs to merge multiple A2L files, calling the function rtw.asap2SetAddress to write the address of the merged A2L according to the elf file generated by build, and generating an A2L file with an address. There is no need to call external A2L generation software, which is simple to operate and easy to implement;

[0022] (6) This application processes parameter loading and code integration separately. When the parameters do not need to be modified, there is no need to load the parameters, thereby improving execution efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A flowchart of a method for integrating application layer code with underlying code according to some embodiments of the present application;

[0024] Figure 2 A flowchart of a method for integrating application layer code with underlying code according to other embodiments of the present application;

[0025] Figure 3 is a flowchart of a method for integrating application layer code with underlying code according to some other embodiments of the present application;

[0026] Figure 4 It is a block diagram of an apparatus for integrating application layer code and bottom layer code according to some embodiments of the present application;

[0027] Figure 5 It is a block diagram of a server according to some embodiments of the present application. DETAILED DESCRIPTION

[0028] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.

[0029] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being 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 complicated.

[0030] The following describes in detail the method, device, server and medium for integrating application layer code and underlying code according to an embodiment of the present invention with reference to the accompanying drawings.

[0031] In some embodiments, Figure 1 FIG. 1 is a flow chart of a method for integrating application layer code with underlying code according to some embodiments of the present invention. Figure 1 The method for integrating the application layer code with the underlying code in the embodiment of the present application may include the following steps:

[0032] S110, load the Simulink model and the corresponding data dictionary, and configure the Simulink model code generation environment.

[0033] Specifically, when integrating the application layer code with the underlying code for the first time, you need to first write the script AutoIntegarteTool.m that automatically generates the application layer code and integrates the application layer code with the underlying code, then use the MATLAB sl_customization.m function to register the custom item AutoIntegarteTool, and finally enter sl_refresh_customizations in the MATLAB command line to update the Simulink toolbar and register the script AutoIntegarteTool.m that automatically generates the application layer code and integrates the application layer code with the underlying code under Tools of the Simulink model. Then load the Simulink model and the supporting data dictionary, and configure the application layer code generation environment.

[0034] S120, running the integrated tool of the Simulink model, and calling the first preset function to display preset execution options.

[0035] Specifically, after loading the Simulink model and the supporting data dictionary, and configuring the Simulink model code generation environment, create a new SaveMAT folder under the current path of the Simulink model to store the build integration project path, integration version number, and execution completion records of each part of the program. Then run the integration tool of the Simulink model, that is, run the AutoIntegarteTool under the Simulink model Tools, and call the first preset function, such as calling the listdlg function, to display the preset execution options, prompting the user to select the next execution process of the program, such as displaying the first preset option (reselect the path where the build integration project is located and compile the integration), the second preset option (continue execution from the last program error) and the third preset option (recompile the model and integrate), which can be added and modified later according to new requirements.

[0036] S130, in response to the first preset execution command, clears the path of the build integrated project and the execution completion records of each part of the program in the SaveMAT folder, and upon receiving the path selection instruction of the build integrated project, saves the corresponding path of the build integrated project into the SaveMAT folder, and calls the second preset function to generate application layer code.

[0037] Specifically, when the user triggers the first preset option (reselect the path where the build integrated project is located and compile the integration), the first preset execution command is responded to, the build integrated project path stored in the SaveMAT folder is deleted, and the execution completion records of each part of the stored program are cleared. Further, the uigetdir function is called to select the build integrated project path. If the user selects the build integrated project path, the corresponding build integrated project path is saved in the SaveMAT folder, and the second preset function is called, such as the rtwbuild function, to automatically generate the Simulink model application layer code; if the user does not select the build integrated project path, the program is terminated.

[0038] S140, when the integration condition is met, calling a preset file to integrate the application layer code with the bottom layer code.

[0039] Specifically, after the application layer code is automatically generated, the application layer code and the underlying code are integrated and prepared. After the integration preparation is completed, it is determined whether the integration conditions are met. If the integration conditions are met, the integration is formally carried out, and the preset files are called, such as the build.bat file, and the automatically generated target files (such as .hex, .elf, .map, etc.) are placed in the specified location to complete the integration of the application layer code and the underlying code. Among them, the target file is named in the form of integration version number + date, so that when the target file is used, it is easy to know which version of the integration project is generated based on.

[0040] In this way, the present application automatically generates application layer code and integrates the application layer code with the underlying code in one click based on the Simulink model, and if an error is encountered during program operation, there is no need to run the program from the beginning, thereby improving integration efficiency.

[0041] In some embodiments, an elf file is generated after the application layer code and the underlying code are integrated, and the application layer code includes a first A2l file. The method also includes: calling a third preset function to merge the first A2l file to obtain a second A2l file; calling a fourth preset function to update the address information in the elf file to the second A2l file; and saving the second A2l file into the folder where the elf file is located.

[0042] Specifically, the rtwbuild function is called to automatically generate the application layer code of the Simulink model, and multiple first A2l files will be generated eventually. The application layer code and the underlying code are integrated to generate the target file, which includes the elf file. The A2l address is written according to the elf file, and an A2L file with the address will be generated.

[0043] Exemplarily, an existing script for merging A2l files may be called to merge all first A2l files generated when the Simulink model automatically generates code into a second A2l file, or a third preset function may be called, such as calling the function rtw.asap2MergeMdlRefs to merge multiple first A2l files into a second A2l file. Then a fourth preset function may be called, such as calling the function rtw.asap2SetAddress, to parse the address information in the elf file, and update the parsed address information to the second A2l file, and name the second A2l file with the address in the form of integration version number + date, and copy it to the folder where elf is located, so that the second A2l file with the address can be used to know which version of the integration project it is generated based on.

[0044] It should be noted that when generating the A2L interface file, the functions provided by Matlab were used to edit the A2L file. For example, the function rtw.asap2MergeMdlRefs was called to merge multiple A2L files, and the function rtw.asap2SetAddress was called to write the address for the merged A2l according to the elf file generated by build, so as to generate an A2l file with an address. There is no need to call external A2L generation software, and the operation is simple and easy to implement. In addition, the A2L file with an address is automatically generated, which is convenient for application layer development engineers to quickly verify the function after modifying the upper-layer logic, greatly improving the software iteration rate.

[0045] In some embodiments, the application layer code also includes c files and h files, and the method also includes: when the c files and h files are in the application layer code folder of the build integration project, and the integration version number of the build integration project is stored in the SaveMAT folder, and the target files generated by the last build in the build integration project are cleared, determining that the integration conditions are met.

[0046] Specifically, after the application layer code is automatically generated, preparations are made for the integration of the application layer code and the underlying code. First, the application layer code (including c files and h files) compiled and generated by Simulink is copied to the application layer code folder of the build integration project. Then, the integration version number under the build integration project is modified as required, and the modified integration version number is stored in the SaveMAT folder. Finally, the target files generated by the last build in the build integration project (including .hex, .elf, .map, etc.) are cleared. If the above processes are all executed successfully, it is determined that the integration conditions are met, and the integration of the application layer code and the underlying code can continue.

[0047] In some embodiments, the above method further includes: before calling the second preset function to generate the application layer code, clearing the sub-files and sub-folders in the Simulink model cache folder and the code folder.

[0048] Specifically, generating application layer code includes: first opening the Simulink model to set the storage location of the code file and cache file, then clearing the sub-files and sub-folders in the current model cache folder and code folder, calling the second preset function, such as calling the rtwbuild function, to automatically generate Simulink model code, and finally generating c files, h files, A2l files, etc.

[0049] In some embodiments, the above method also includes: responding to a second preset execution command, if an integrated version number exists in the SaveMAT folder, loading the integrated version number, building the integrated project path and the execution completion records of each part of the program, wherein the execution completion records of each part of the program include the execution completion mark of each part of the program; determining the execution progress according to the execution completion mark of each part of the program, and continuing the execution according to the execution progress.

[0050] Specifically, in the process of automatic generation of application layer code, code integration preparation, integration of application layer code with underlying code, and writing to the second A2l address according to the elf file, each step will be marked as successful if executed successfully, forming an execution completion record. For example, the code integration preparation includes: Step 1, copying the application layer code (including c files and h files) compiled and generated by Simulink to the application layer code folder of the build integration project, Step 2, modifying the integration version number under the build integration project as required, and storing the modified integration version number in the SaveMAT folder, Step 3, clearing the target files (including .hex, .elf, .map, etc.) generated by the last build in the build integration project, and Step 1, Step 2 and Step 3 will be marked as successful if executed successfully, forming an execution completion record. The execution completion record is then saved in the SaveMAT folder, and the user is prompted with a pop-up window or command line message of the program progress. If a step fails to execute, the user will also be prompted with a pop-up window or command line message. After the user makes modifications according to the prompt, when the AutoIntegarteTool is executed again, the listdlg function is still called to display the preset execution options, showing the first preset option (reselect the path where the build integration project is located and compile the integration), the second preset option (continue execution from the last program error) and the third preset option (recompile the model and integrate).

[0051] When the user triggers the second preset option (continue execution from the last program error), the second preset execution command is responded to, and the stored build integrated project path and the execution completion records of each part of the program are loaded. Further, it is determined whether there is an integrated version number in the SaveMAT folder. If there is an integrated version number, the stored integrated version number is loaded first, and then the last program execution progress is determined based on the execution completion records of each part of the program; if there is no integrated version number, the last program execution progress is determined directly based on the execution completion records of each part of the program.

[0052] The execution completion record of each part of the program includes the execution completion mark of each part of the program. If there is a mark of the execution completion of a part in the execution completion record storage of each part of the program, the part can be skipped when executing again. In this way, the efficiency of compilation and integration can be improved.

[0053] In some embodiments, the above method further includes: when the execution progress is that the Simulink model code generation process is terminated, re-calling the second preset function to generate the application layer code and then continuing the execution.

[0054] Specifically, if the last program execution terminated the Simulink model code generation process, then the entire process of automatically generating application layer code needs to be completed, including creating a new Simulink model to set the storage location of code files and cache files, and then clearing the sub-files and sub-folders in the current model cache folder and code folder.

[0055] In some embodiments, the above method also includes: responding to a third preset execution command, clearing the execution completion records of various parts of the program; if there is a build integrated project path in the SaveMAT folder, loading the build integrated project path, and clearing the subfiles and subfolders in the Simulink model cache folder and the code folder before continuing execution; if there is no build integrated project path in the SaveMAT folder, reselecting the build integrated project path before continuing execution.

[0056] Specifically, when AutoIntegarteTool is executed again, the listdlg function is still called to display the preset execution options, including the first preset option (reselect the path where the build integration project is located and compile the integration), the second preset option (continue execution from the last program error) and the third preset option (recompile the model and integrate). When the user triggers the third preset option (recompile the model and integrate), the third preset execution command is responded to to determine whether there is a build integration project path in the SaveMAT folder. If there is a build integration project path, the stored build integration project path is loaded, and the subfiles and subfolders in the Simulink model cache folder and the code folder are cleared before continuing execution. If there is no build integration project path, the uigetdir function is called to select the build integration project path and continue execution.

[0057] In summary, the present application can use Simulink models to automatically generate application layer code, automatically integrate the application layer code with the underlying code, and automatically generate A2L files with addresses. There is no need to open the compiler project and copy c files and h files to the project when calling an external compiler. It is convenient for application layer development engineers to quickly verify functions by themselves after modifying the upper-level logic, thereby improving the software iteration rate. In addition, the application layer code can be automatically generated in one click, and during the integration of the application layer code and the underlying code, it can be determined in real time whether an error is reported during the program execution process. If an error is reported, the user can modify it according to the prompt, and when executing again, the unfinished steps can be continued from the last program error point, thereby improving the efficiency of compilation and integration. The generated target file can also be automatically named according to the integrated version number of the build integrated project, so as to determine the integrated project corresponding to the target file. In the program During the execution process, after each part is completed, the user will be prompted with the program progress through a pop-up window or command line message, and the pop-up window will automatically close after a certain period of time, which not only makes it convenient for users to know the program execution progress, but also does not require users to manually close the pop-up window; when generating the A2L interface file, the Matlab built-in function is used to edit the A2L file, such as calling the function rtw.asap2MergeMdlRefs to merge multiple A2L files, calling the function rtw.asap2SetAddress to write the address of the merged A2l according to the elf file generated by build, and generating an A2l file with an address. There is no need to call external A2L generation software, and the operation is simple and easy to implement; parameter loading and code integration can also be processed separately, and there is no need to load parameters when parameters do not need to be modified, which improves execution efficiency.

[0058] As a specific example, see Figure 2 The method for integrating the application layer code with the underlying code in the embodiment of the present application may further include the following steps:

[0059] S201, start.

[0060] S202, recording and storing data during program execution.

[0061] Specifically, the data stored during the program execution process includes the build integration project folder path, integration version number, and program execution completion marks. The build integration project folder path is stored to reduce the number of manual operations by the user; the integration version number and program execution completion marks are stored so that the program can automatically skip certain steps after errors are reported and modified during program execution, thereby improving integration efficiency.

[0062] S203, program execution process and build integrated project folder selection.

[0063] Specifically, the program execution process is divided into three types: reselecting the path where the build integration project is located and compiling and integrating, continuing execution from the last program error, and recompiling the model and integrating. The present invention has written three types, and can also be increased according to project requirements. Selecting the build integration project folder is to automatically implement application layer code updates, integrated version number modifications, etc.

[0064] S204, the Simulink model automatically generates application layer code.

[0065] Specifically, it includes preliminary preparation and formal compilation process, and the preliminary preparation includes creating / clearing the root folder of code and cache files.

[0066] S205, preparing the environment for integrating the application layer code with the underlying code.

[0067] Specifically, the integration environment preparation includes copying the c file and h file generated in S204 to the specified location of the build integration project, modifying the integration version number according to the specified format, and clearing the previous build integration result.

[0068] S206, integrating the application layer code with the underlying layer code.

[0069] Specifically, call the build.mat file preset in the build integration project.

[0070] S207, A21 address is written.

[0071] Specifically, all A2l files generated by S204 are merged into one A2l file, and then the address of the merged A2l file is written according to the elf file generated by S206, and the A2l file with the address is copied to the location of elf, and the user is prompted that the A2l address setting is completed, and the current path of MATLAB is switched to the build target file storage path.

[0072] S208, end.

[0073] As another specific example, see Figure 3 The method for integrating the application layer code with the underlying code in the embodiment of the present application may further include the following steps:

[0074] S301, start.

[0075] S302, load the Simulink model and data dictionary, and configure the model code generation environment.

[0076] S303, run the AutoIntegarteTool under the Simulink model Tool.

[0077] S304, create a new SaveMAT folder for storing the build integrated project path, integrated version number, and execution completion records of each part of the program.

[0078] S305, calling the listdlg function to prompt the user to select the next execution flow of the program.

[0079] S306, determine whether to select "reselect the path where the build integration project is located and compile the integration". If yes, execute S307; otherwise, execute S342.

[0080] S307, deleting the build integrated project path stored in the SaveMAT folder, and clearing the execution completion records of each part of the stored program.

[0081] S308, calling uigetdir function to select the build integrated project path and save it in the SaveMAT folder.

[0082] S309, determine whether to select the build integrated project path. If yes, execute S310; otherwise, execute S357.

[0083] Specifically, the build integration project is provided by the underlying development engineer. It is a compilation environment established based on the HighTec compiler, including the compilation call batch file build.bat. The compilation environment also includes the application layer software source code and the underlying software source code. The application layer code and the underlying code are stored in separate folders to facilitate classification and updating of the code during code compilation. After the compilation environment is established, it can be directly called by the one-click code integration tool. For frequent code integration in the later stage, there is no need to re-establish the compilation environment each time.

[0084] S310, specifies the root folder for the code files and cache files generated by compiling the Simulink model.

[0085] Specifically, the Simulink.fileGenControl function is called to specify a root folder for the code files and cache files generated by model compilation, so that the folders are not cluttered and file management is convenient.

[0086] S311, determine whether an error is reported during the folder creation process. If yes, execute S312; otherwise, execute S313.

[0087] S312, modify according to the error prompt, and then execute S303.

[0088] Specifically, by calling the sldiagviewer.reportError function, the Diagnostic View window is opened, which makes it easier for users to trace the cause of the error. The errors reported during the model compilation process are mostly caused by the following reasons: data type mismatch, undefined calibration quantity, unconfigured Autosar interface, etc.

[0089] S313, the execution of this part of the program is completed, record C1 and prompt success.

[0090] S314, clear the sub-files and sub-folders in the current model cache folder and code folder.

[0091] Specifically, clearing the root folder ensures that the current model code generation process will not report an error due to the previous result file.

[0092] S315, determine whether the clearing process reports an error. If so, execute S316; otherwise, execute S317.

[0093] S316, modify according to the error prompt, and then execute S303.

[0094] S317, this part of the program is executed and the record C2 is completed, and a success message is displayed.

[0095] S318, calling the rtwbuild function to compile the Simulink model and generate application layer code.

[0096] Specifically, the target files generated by model compilation include .c, .h, and .A2l files.

[0097] S319, determine whether the model compilation process reports an error. If yes, execute S320; otherwise, execute S321.

[0098] It should be noted that errors during model compilation may be caused by problems with the data dictionary. In this case, the user needs to execute "Load Data Dictionary" according to the prompts. If the model compilation process runs successfully, "Load Data Dictionary" will not be executed if errors are reported in subsequent steps.

[0099] S320, modify according to the error prompt, and then execute S303.

[0100] S321, this part of the program is executed and the record C3 is completed, and a success message is displayed.

[0101] S322, copy the application layer C code and H code generated by Simulink compilation to the application layer code folder of the build integrated project.

[0102] S323, determine whether an error is reported during the application layer code copying process. If yes, execute S324; otherwise, execute S325.

[0103] S324, modify according to the error prompt, and then execute S303.

[0104] S325, this part of the program is executed and the completion record C4 is displayed, and a success message is displayed.

[0105] S326, modify the integration version number under the build integration project as required and store it in the SaveMAT folder.

[0106] Specifically, the format of the integrated version number is version number + date. The version number is accumulated according to the program requirements, and the date is the current year, month and day.

[0107] S327, determine whether the integrated version number modification process reports an error. If so, execute S328; otherwise, execute S329.

[0108] S328, modify according to the error prompt, and then execute S303.

[0109] S329, this part of the program is executed and the record C5 is completed, and a success message is displayed.

[0110] S330, clear the target files (hex, elf, map, etc.) generated by the last build in the build integration project.

[0111] Specifically, clearing the last result ensures that the current build process will not report an error due to the last result file.

[0112] S331, determine whether the process of clearing the files generated by the last build reports an error. If yes, execute S332; otherwise, execute S333.

[0113] S332, modify according to the error prompt, and then execute S303.

[0114] S333, this part of the program is executed and the record C6 is completed, and a success message is displayed.

[0115] S334, calling the build.bat file preset in the compilation environment.

[0116] S335, determine whether the build process reports an error. If so, execute S336; otherwise, execute S337.

[0117] S336, modify according to the error prompt, and then execute S303.

[0118] S337, this part of the program is executed and the record C7 is completed, and a success message is displayed.

[0119] S338, call rtw.asap2MergeMdlRefs to merge all A2l files generated when the Simulink model automatically generates code.

[0120] S339, calling the function rtw.asap2SetAddress, and writing the address of the merged A2l according to the .elf file generated by build.

[0121] S340, copy the A2l file with the address to the location of .elf, and prompt the user that the A2l address setting is completed.

[0122] S341, MATLAB current path switches to the build target file storage path.

[0123] S342, determine whether to select "continue execution from the last program error point". If yes, execute S343; otherwise, execute S353.

[0124] S343, load the stored build integrated project path and the execution completion records of each part of the program.

[0125] Specifically, by executing 343, steps S308 and S309 can be omitted, thereby reducing the number of pop-up window selection steps and accelerating program execution efficiency.

[0126] S344, determine whether there is an integrated version number in the SaveMAT folder. If yes, execute S345; otherwise, execute S346.

[0127] Specifically, if the last time the program reported an error, the modification of the integrated version number has been completed, the version number modification part will be skipped later.

[0128] S345, load the stored integrated version number.

[0129] S346, determine whether the execution completion records of each part of the program include C1. If yes, execute S347; otherwise, execute S310.

[0130] S347, determine whether the execution completion records of each part of the program include C2. If yes, execute S348; otherwise, execute S314.

[0131] Specifically, if C2? is not included, it means that the model code generation process reports an error, but some code and cache files may have been generated. In order for the code generation process to be normal, it is necessary to clear the root folder of the code and cache files.

[0132] S348, determine whether the execution completion records of each part of the program include C3. If yes, execute S349; otherwise, execute S318.

[0133] S349, determine whether the execution completion records of each part of the program include C4. If yes, execute S350; otherwise, execute S322.

[0134] S350, determine whether the execution completion records of each part of the program include C5. If yes, execute S351; otherwise, execute S326.

[0135] S351, determine whether the execution completion records of each part of the program include C6. If yes, execute S352; otherwise, execute S330.

[0136] S352, determine whether the execution completion records of each part of the program include C7. If yes, execute S338; otherwise, execute S334.

[0137] Specifically, select "Continue execution from the last program error", and then determine in turn whether the execution completion record contains the record marks of the completion of each part of the execution. If it does, skip this part of the program, which can greatly improve the integration efficiency.

[0138] S353, determine whether to select "recompile model and integrate". If yes, execute S354; otherwise, execute S357.

[0139] S354, clearing the stored execution completion records of each part of the program.

[0140] S355, determine whether there is a build integrated project path in the SaveMAT folder. If yes, execute S356; otherwise, execute S308.

[0141] S356, load the stored build integrated project path, and then continue to execute S314.

[0142] S357, end.

[0143] Corresponding to the above embodiments, the present application also proposes a device for integrating application layer code and underlying code.

[0144] Reference Figure 4 The device for integrating the application layer code with the bottom layer code includes: a loading module 410, a display module 420, a generation module 430 and an integration module 440.

[0145] Among them, the loading module 310 is used to load the Simulink model and the supporting data dictionary, and configure the Simulink model code generation environment. The display module 320 is used to run the integration tool of the Simulink model, and call the first preset function to display the preset execution option. The generation module 330 is used to respond to the first preset execution command, clear the path of the build integrated project and the execution completion records of each part of the program in the SaveMAT folder, and when receiving the path selection instruction of the build integrated project, save the corresponding build integrated project path into the SaveMAT folder, and call the second preset function to generate the application layer code. The integration module 340 is used to call the preset file to integrate the application layer code with the underlying code when the integration conditions are met.

[0146] According to one embodiment of the present application, an elf file is generated after the application layer code and the underlying code are integrated, the application layer code includes a first A2l file, a third preset function is called to merge the first A2l file to obtain a second A2l file; a fourth preset function is called to update the address information in the elf file to the second A2l file; and the second A2l file is saved in the folder where the elf file is located.

[0147] According to one embodiment of the present application, the application layer code also includes c files and h files. When the c files and h files are in the application layer code folder of the build integration project, the integration version number of the build integration project is stored in the SaveMAT folder, and the target files generated by the last build in the build integration project are cleared, it is determined that the integration conditions are met.

[0148] According to one embodiment of the present application, before calling the second preset function to generate application layer code, sub-files and sub-folders in the Simulink model cache folder and the code folder are cleared.

[0149] According to one embodiment of the present application, in response to a second preset execution command, when an integrated version number exists in the SaveMAT folder, the integrated version number, the build integrated project path and the execution completion records of each part of the program are loaded, wherein the execution completion records of each part of the program include the execution completion flags of each part of the program; the execution progress is determined according to the execution completion flags of each part of the program, and execution is continued according to the execution progress.

[0150] According to an embodiment of the present application, when the execution progress is that the Simulink model code generation process is terminated, the second preset function is re-called to generate the application layer code and then the execution is continued.

[0151] According to one embodiment of the present application, in response to the third preset execution command, the execution completion records of various parts of the program are cleared; if there is a build integrated project path in the SaveMAT folder, the build integrated project path is loaded, and the subfiles and subfolders in the Simulink model cache folder and the code folder are cleared before continuing execution; if there is no build integrated project path in the SaveMAT folder, the build integrated project path is reselected before continuing execution.

[0152] It should be pointed out that the above-mentioned explanation of the implementation example and beneficial effects of the method for integrating application layer code with underlying code is also applicable to the device for integrating application layer code with underlying code in the embodiment of the present invention. To avoid redundancy, it will not be elaborated here.

[0153] Corresponding to the above embodiments, the present application also proposes a computer-readable storage medium.

[0154] The computer-readable storage medium of the present application stores an integrated program based on application layer code and underlying code, and when the integrated program of application layer code and underlying code is executed by a processor, the aforementioned method of integrating application layer code and underlying code is implemented.

[0155] It should be pointed out that the above-mentioned explanation of the embodiment and beneficial effects of the method for integrating application layer code with underlying code is also applicable to the computer-readable storage medium of the embodiment of the present invention, and will not be elaborated here in detail to avoid redundancy.

[0156] Corresponding to the above embodiment, the present application also proposes a server.

[0157] Reference Figure 5 The server of the present application includes a memory 510, a processor 520, and an integrated program of application layer code and underlying code stored on the memory 510 and executable on the processor 520. When the processor 520 executes the integrated program of application layer code and underlying code, the aforementioned method of integrating application layer code and underlying code is implemented.

[0158] It should be pointed out that the above-mentioned explanation of the embodiment and beneficial effects of the method for integrating application layer code with underlying code is also applicable to the server of the embodiment of the present invention, and will not be elaborated here in detail to avoid redundancy.

[0159] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0160] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0161] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0162] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0163] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0164] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

[0165] The above embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Any equivalent substitution or change made by a person skilled in the art based on the present invention is within the protection scope of the present invention.

Claims

1. A method for integrating application layer code with underlying code, characterized in that: The method comprises: Loading the Simulink model and the supporting data dictionary, and configuring the code generation environment of the Simulink model; Running the integrated tool of the Simulink model and calling the first preset function to display preset execution options; In response to the first preset execution command, clear the path of the build integrated project and the execution completion records of each part of the program in the SaveMAT folder, and when receiving the path selection instruction of the build integrated project, save the corresponding path of the build integrated project into the SaveMAT folder, and call the second preset function to generate the application layer code; When the integration condition is met, the preset file is called to integrate the application layer code with the bottom layer code.

2. The method for integrating application layer code with underlying code according to claim 1, characterized in that: After integrating the application layer code with the bottom layer code, an elf file is generated, wherein the application layer code includes a first A2l file, and the method further includes: Calling a third preset function to merge the first A21 file to obtain a second A21 file; Calling a fourth preset function to update the address information in the elf file to the second A21 file; Save the second A2l file into the folder where the elf file is located.

3. The method for integrating application layer code with underlying code according to claim 1, characterized in that: The application layer code also includes a c file and an h file, and the method also includes: When the c file and the h file are in the application layer code folder of the build integration project, the integration version number of the build integration project is stored in the SaveMAT folder, and the target file generated by the last build in the build integration project is cleared, it is determined that the integration condition is met.

4. The method for integrating application layer code with underlying code according to claim 1, characterized in that: The method further comprises: Before calling the second preset function to generate the application layer code, clear the subfiles and subfolders in the Simulink model cache folder and the code folder.

5. The method for integrating application layer code with underlying code according to claim 1, characterized in that: The method further comprises: In response to the second preset execution command, if the integrated version number exists in the SaveMAT folder, load the integrated version number, the build integrated project path and the execution completion record of each part of the program, wherein the execution completion record of each part of the program includes the execution completion mark of each part of the program; The execution progress is determined according to the execution completion flags of each part of the program, and the execution is continued according to the execution progress.

6. The method for integrating application layer code with underlying code according to claim 5, characterized in that: The method further comprises: When the execution progress is that the Simulink model code generation process is terminated, the second preset function is re-called to generate the application layer code and then the execution is continued.

7. The method for integrating application layer code with underlying code according to claim 1, characterized in that: The method further comprises: In response to a third preset execution command, clearing execution completion records of each part of the program; If the build integrated project path exists in the SaveMAT folder, load the build integrated project path, and continue execution after clearing subfiles and subfolders in the Simulink model cache folder and code folder; When the build integrated project path does not exist in the SaveMAT folder, the build integrated project path is reselected and the execution is continued.

8. An integration device for application layer code and bottom layer code, characterized in that: include: Loading module, used to load Simulink model and supporting data dictionary, and configure Simulink model code generation environment; A display module, used for running the integrated tool of the Simulink model and calling the first preset function to display the preset execution options; A generation module, configured to respond to the first preset execution command, clear the path of the build integrated project and the execution completion records of each part of the program in the SaveMAT folder, and upon receiving the path selection instruction of the build integrated project, store the corresponding path of the build integrated project into the SaveMAT folder, and call the second preset function to generate application layer code; The integration module is used to call a preset file to integrate the application layer code with the bottom layer code when the integration conditions are met.

9. A computer-readable storage medium, characterized in that: An integrated program based on application layer code and underlying code is stored thereon, and when the integrated program of application layer code and underlying code is executed by a processor, the method for integrating application layer code and underlying code according to any one of claims 1-7 is implemented.

10. A server, characterized in that: The invention comprises a memory, a processor and an integrated program of application layer code and underlying code stored in the memory and executable on the processor. When the processor executes the integrated program of application layer code and underlying code, the method for integrating application layer code and underlying code according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Software code one-key integration method and system

    CN114546408A