Configure Model to Add C API Signals in Code Generation
Configure the model to include the C API elements for signals and parameters in the generated model code.
Open the model CapiSigsParams
.
capiMdl = "CapiSigsParams";
open_system(capiMdl);
Enable C API Code Generation for Signals
To enable C API code generation for model signals:
Open the Configuration Parameters dialog box.
Navigate to the Code Generation > Interface pane.
In the Data exchange interface > Generate C API for section, select signals.
Click OK.
Alternatively, enter this in the Command Window:
set_param(capiMdl,RTWCAPISignals=true)
Configure Signals as Test Points
To prevent the code generator from optimizing the signals away, configure them to be test points (see Configure Signals as Test Points):
In the model, select the signals.
Open the Signal tab of the Simulink® canvas.
In the Monitor group, click Test Point.
Alternatively, use the capiSigsParamsHelper
MATLAB® program to programmatically configure the signals as test points.
capiSigsParamsHelper("signals")
In the next step of the example, you generate model code that contains C API elements for model signals, and you write external code that can interact with it. To continue to the next step of the example, use this in the Command Window:
openExample("simulinkcoder/CapiSigsParams03Example")