LibSystemO​utputCusto​mCode() return function inlining error

2 views (last 30 days)
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?

Answers (1)

Mark McBroom
Mark McBroom on 12 Oct 2023
This block should allow you to insert code into the step() function: https://www.mathworks.com/help/ecoder/ref/systemupdate.html
  1 Comment
Sathishkumar Chakarapanai
Sathishkumar Chakarapanai on 12 Oct 2023
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.

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!