【问题标题】:Simulink Coder: How to specify custom C files from script when generating C code?Simulink Coder:生成 C 代码时如何从脚本中指定自定义 C 文件?
【发布时间】:2016-03-17 11:44:07
【问题描述】:

我有一个脚本,它对 Simulink 编码器生成的初始代码进行一些后处理。它创建了一个我希望添加到构建过程中的additional.c 文件。我想通过脚本将文件添加到构建过程中,所以我关注the docs here

所以我的脚本看起来像:

slbuild(gcs);
% generate additional.c file using files created by slbuild()
% ...
% now attempt to add additional.c to the build process as custom code
configs = getActiveConfigSet(gcs);
configs.set_param('SimUserSources', 'additional.c');
% now rebuild
slbuild(gcs)

我可以验证配置集是否已通过以下方式更新:

checkConfigIsSet = configs.get_param('SimUserSources'); 
disp(checkConfigIsSet); % prints: additional.c

但是,编码器似乎没有选择这个新配置。当我单击代码生成报告的Configuration settings at the time of code generation: click to open 部分时,我看到配置值未更新,additional.c 未编译到模型中。

请问我做错了什么?

【问题讨论】:

    标签: matlab simulink matlab-coder


    【解决方案1】:

    SimUserSources 用于 MATLAB Function 模块和 Stateflow 等模块使用的仿真构建。对于代码生成,您需要设置参数“CustomSource”。试试吧,

    slbuild(gcs);
    % generate additional.c file using files created by slbuild()
    % ...
    % now attempt to add additional.c to the build process as custom code
    configs = getActiveConfigSet(gcs);
    configs.set_param('CustomSource', 'additional.c');
    % now rebuild
    slbuild(gcs)
    

    【讨论】:

      猜你喜欢
      • 2019-12-25
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 2010-12-07
      • 2020-02-27
      • 2019-12-21
      • 2015-08-10
      • 1970-01-01
      相关资源
      最近更新 更多