Main Content

Deploy the Generated Code

In this step of the tutorial, you explore mechanisms for deploying the generated code.

Example Main Program

To facilitate deployment of the generated code, the code generator produces an example main program that you can use to get started. The example main program is in the file ert_main.c. To use the algorithmic code (the model entry-point functions) generated for your application, you can copy the incomplete functions defined in ert_main.c, and then complete the functions by inserting your custom scheduling code.

Explore the example main program generated for model RollAxisAutopilot.

  1. If not already open, open your copy of the model RollAxisAutopilot.

  2. In the Apps gallery, click Embedded Coder.

  3. Regenerate the code.

  4. In the Code view, select file ert_main.c.

  5. Click in the Search field and select function rt_OneStep.

  6. Explore the incomplete wrapper function rt_OneStep. This function calls the model execution entry-point function, RollAxisAutopilot_step. Your application code can call rt_OneStep to run the model algorithm during each execution cycle.

  7. Click in the Search field and select function main.

  8. Explore the incomplete example main function. This function outlines the order and context in which your application code can call rt_OneStep and other model entry-point functions.

For more information, see Deploy Applications to Target Hardware.

Relocate Generated Code Files

Embedded Coder® provides a pack-n-go utility for relocating static and generated code files for a model to another development environment. File relocation is necessary when your system or integrated development environment (IDE) does not include MATLAB® and Simulink® products. The utility packages the files in a compressed file that you can relocate and unpack by using a standard zip utility. You can apply the pack-n-go utility from graphical and programming interfaces. For more information, see Relocate or Share Generated Code.

Share and Archive Code Generation Report

The Quick Start tool configures a model to produce an HTML code generation report. In addition to a summary of model and code information, the report includes:

  • A subsystem report

  • Generated code files

  • A code interface report

  • A traceability report

  • A static code metrics report

  • A code replacements report

  • A coder assumptions report

  • Optionally, a model web view

You can use this report outside of the Simulink environment, so it is suitable for sharing or for archival purposes. You can open the report from the tool or, on the C Code tab, click Open Report.

The default location for the code generation report files is in the html subfolder of the build folder, model_target_rtw/html/. In this case, target is the name of the System target file specified on the Code Generation pane. The default name for the top-level HTML report file is index.html.

Related Topics