LibSystemO​utputCusto​mCode() return function inlining error

조회 수: 13 (최근 30일)
Sathishkumar Chakarapanai
Sathishkumar Chakarapanai 2023년 10월 5일
댓글: Sathishkumar Chakarapanai 2023년 10월 12일
Hi,
I am aiming to insert a custom code at the begining of model_step()function in an ert system with CodeFormat as "Embedded-C"
for example;
/* Model step function */
void ARM_R5_step(void)
{
----> /* Here I want to Insert my code */
boolean_T rtb_equal_to_count;
/* Sum: '<S1>/Sum' incorporates:
* Constant: '<S1>/INC'
* UnitDelay: '<S1>/X'
*/
/* End of Switch: '<S1>/Switch' */
}
and I have my custom_file_process.tlc file as follow;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Abstract:
%% Example Embedded Coder custom file processing template.
%%
%% Note: This file can contain any valid TLC code, which Embedded Coder
%% executes just prior to writing the generated source files to disk.
%% Using this template "hook" file, you are able to augment the generated
%% source code and create additional files.
%%
%% Copyright 1994-2021 The MathWorks, Inc.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%selectfile NULL_FILE
%% Uncomment this TLC line to execute the example
%% || ||
%% || ||
%% \/ \/
%assign ERTCustomFileTest = TLC_TRUE
%if EXISTS(ERTCustomFileTest) && ERTCustomFileTest == TLC_TRUE
%assign ss = CompiledModel.System[GetBaseSystemIdx()]
%assign CombineOutputUpdateFcns = 1
%openfile tmpBuf
/************************************/
/*** Custom code from TLC ***/
/************************************/
%closefile tmpBuf
%<LibSystemOutputCustomCode(ss,tmpBuf,"declaration")>
%endif
but this result an error shown below,
My question is,
Do you think I'm using the LibSystemOutputCustomCode() function correctly?
Is there another way I could approach this instead of using the LibSystemOutputCustomCode() function?

답변 (1개)

Mark McBroom
Mark McBroom 2023년 10월 12일
This block should allow you to insert code into the step() function: https://www.mathworks.com/help/ecoder/ref/systemupdate.html
  댓글 수: 1
Sathishkumar Chakarapanai
Sathishkumar Chakarapanai 2023년 10월 12일
Hi,
Thanks for your suggestion !
but the system update block is not solving the problem. As mentioned before I am aiming to insert a piece of code at the begining "header" or "declaration" section in model_step function.
If i use system update block to solve this problem it has inserted the custom code to "trailer" section of model_step function.

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

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by