Simulink Coder-Customizing grt.tlc generated source code.

Dear Techies, I am working in Code generation using Simulink Coder.(dont have Embedded Coder license).I am using grt.tlc.
The generated code is messy.It is having my algorithm and some other RTW codes.I want to customize to remove RTW code dependencies.Currently the generated code contains the following in model.h file.I want to generate code without these interfaces.
Anybody can help me in this regard?
Ex: /* Macros for accessing real-time model data structure */ #ifndef rtmGetBlkStateChangeFlag # define rtmGetBlkStateChangeFlag(rtm) ((rtm)->ModelData.blkStateChange) #endif
#ifndef rtmSetBlkStateChangeFlag # define rtmSetBlkStateChangeFlag(rtm, val) ((rtm)->ModelData.blkStateChange = (val)) #endif
regards, Joseph

 Accepted Answer

There are very few code customization options are available with GRT target. AFAIK, there is no option in grt to remove the part of code you have mentioned.
There are 2 alternatives:- You can write a matlab script to post process the generated code OR use ERT target.

6 Comments

Hi Tab, Thanks for the answers.I am pretty new to Code generation technologies.So could you explain me the concept of post processing/ any example script you have please send it to me.
Thanks in advance
Just open the generated files in matlab script. Use various string search command like strcmp(), strfind(), regexp() to find & delete the functions/lines which you want to remove.
Thanks.Is it possible to give the post processing m-file name in Code generation config settings?
If your intention is to call the m-file automatically after code generation, then you have 2 options:-
  • Write a script to generated the code and then call your customization script. Like below
function GenerateMyCode(mdlName)
rtwbuild(mdlName); % Generated the code
MyCustomization(); % Call your script to edit generated code
end
  • Implement the hook function of grt target and call your script at after_tlc or before_make point. In this way your script will be called automatically, whenever you will build the model.
See Customizing the Target Build Process with the STF_make_rtw Hook File in Simulink coder help.
Thanks a lot for your answers.I will look into this documentation.
Hi Tab,
Is it possible to pass buildinfo structure (To access the generated source codes for edition) as parameter to mycustomization ? like below function GenerateMyCode(mdlName) rtwbuild(mdlName); % Generated the code MyCustomization(buildinfo ); % Call your script to edit generated code end

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!