How to generate custom unoptimized code within a system composer software architecture model?

조회 수: 2 (최근 30일)
C-function code generation appears to work differently when generating code inside of a system composer software architecture model isntead of a standalone simulink model. I am trying to insert certain processer primitaves (mutexes) into my simulink model such that it is incorporated into the autogenerated code. It is a few simple lines of c++ code, so I opted to use the C-function block. In both cases, I have specified in the c-function dialogue window "Generate code as-is (optimizations off)"
Inside of an export-function simulink model, I created a c-function block that includes a comment and then a simple line of code, which generates correctly:
However, if I copy this exact same c-function into an export-function model within a system composer software architecture model, it no longer generates my my specified code. Instead, it generates function calls but does not define the functions anywhere. (Even doing a simple text search of my entire workspace only shows that the function call shown below gets generated).

채택된 답변

Josh Kahn
Josh Kahn 2025년 4월 8일
Hi @Alex,
I see the code from the c-caller block when I tried. Can you look at the attached and see if there are any differences in how we configured the models?
Josh
  댓글 수: 6
Alex
Alex 2025년 4월 14일
Are there any possible workarounds? We are using system composer for our software architecture which seems to heavily rely on Simulink Functions, but we absolutely need the ability to insert custom C++ code into the software.
Mark McBroom
Mark McBroom 2025년 4월 15일
The System Outputs block can be used as an alternate approach to inject arbitrary code into the generated C++ code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 System Composer에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by