How do I keep unused root-Level Inports in the generated code

4 次查看(过去 30 天)
Dear Community,
I have been looking for a simple solution to my problem, but cannot quite find the right approach.
I am generating C-Code using the Embedded Coder for a simple Algorithm. Now, the problem is that I want to fix the the number of inputs in the generated code, even if a particular input-signal remains unused. The background is that the algorithm is going to change over time but the interface should remain unchanged, because the C-function I am generating is embedded in a larger project.
When I generate the code, the number of arguments in the "step" function change, because the unused input signals are dropped (they get optimized).
My solution was to create a test point for the unused input signal. The problem is that a test point generates the "B-structure" in the code, which I don't want either.
So, my question is: is there a way to fix the root-level inports as inputs in the generated code regardless whether they are used or not?
I cannot find that checkbox in the configuration parameters.
Additional Info: I generate Code programatically, so using the App or the Simulink Interface is unfortunately not an option.
Thanks in advance!

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2021-1-7
In your model configuration, search for "block reduction", un-check it.
I assume you must have the root-level Inport blocks terminated somewhere. I was hoping this note in the help document of "block reduction" is relevant.
Dead Code Elimination. Any blocks or signals in anunused code path are eliminated from generated code.
  1 个评论
Sergio Delgado
Sergio Delgado 2021-1-15
Hello, Thanks for your answer.
This is the configuration file I am using (see attachment)
The "Block Reduction" is unchecked... still, the input arguments of the step-Function are gone.

请先登录,再进行评论。

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by