In this step of the tutorial, you explore mechanisms for deploying the generated code.
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
rtwdemo_roll
.
If not already open, open your copy of the model
rtwdemo_roll
.
In the Apps gallery, click Embedded Coder.
Regenerate the code.
In the Code view, select file ert_main.c
.
Click in the Search field and select function
rt_OneStep
.
Explore the incomplete wrapper function rt_OneStep
. This function
calls the model execution entry-point function, rtwdemo_roll_step
.
Your application code can call rt_OneStep
to run the model algorithm
during each execution cycle.
Click in the Search field and select function
main
.
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 Generated Standalone Executable Programs To Target Hardware.
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 Code to Another Development Environment.
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
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 Latest Report.
The default location for the code generation report files is in the
html
subfolder of the build folder,
.
model
_target
_rtw/html/
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
target
or
model
_codegen_rpt.html
.subsystem
_codegen_rpt.html
Use these links to explore more ways to customize, verify, and deploy generated production code.
Task | Reference |
---|---|
Quickly generate readable, efficient code from your model | Generate Code by Using the Quick Start Tool |
Consider model design and configuration for code generation | Design Models for Generated Embedded Code Deployment |
Learn about generated entry-point functions | |
Achieve code reuse | Choose a Componentization Technique for Code Reuse |
Specify default configurations for categories of data elements and functions across a model | Configure Default C Code Generation for Categories of Data Elements and Functions |
Override default configurations for individual entry-point functions | Configure Names for Individual C Entry-Point Functions and Configure Name and Arguments for Individual Step Functions |
Override default configurations for individual data elements | C Code Generation Configuration for Model Interface Elements and Organize Parameter Data into a Structure by Using Struct Storage Class |
Compare normal mode simulation results against software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation results for numerical equivalency | SIL and PIL Simulations and Choose a SIL or PIL Approach |
Collect code coverage metrics for generated code during SIL or PIL simulation | Code Coverage |
Use generated example main code as a starting point to deploy generated executable programs | Deploy Generated Standalone Executable Programs To Target Hardware |