Clear Filters
Clear Filters

Speedgoat Target Model Building fails with a generated S-Function

2 views (last 30 days)
I'm having problems with a model that I upgraded from R2018b to R2021b. The project worked fine in R2018b, but with R2021b, the building fails.
  • Dictionary (MyDict.sldd), containing Bus MyBus and Enum MyEnum definitions. The bus uses the Enum definition.
  • Model (SFunModel.slx) that refers to the dictionary, provides an output of data type MyBus. Using this model and the target "rtwsfcn.tlc", an S-Function is generated.
  • Another Model (BaseModel.slx) that contains the S-Function generated from SFunModel.slx. This model is built for target "slrt.tlc" (R2018b) or target "slrealtime.tlc" (R2021b)
With R2021b, the building of BaseModel.slx fails due to the following error:
.../SFunModel_sfcn_rtw/SFunModel_sid.h:37:47: error: 'SFunModel_rtZMyBus' was not declared in this scope
The constant SFunModel_rtZMyBus is defined in "SFunModel_sf.cpp", but for some reason is not know by the compiler.
When comparing the generated files of the two Matlab releases, R2018b did not generate this variable "SFunModel_rtZMyBus" in the file "SFunModel_sid.h". I'm not quite sure what's going on here. I've noticed that this variable also vanishes in R2021b if the default value for MyEnum is 0, and not 1.
I've attached two examples, one for R2018b, where everything works fine, and a second example for R2021b, which fails. For both examples, first the script "CreateSFun.m" needs to be run to create the S-Function, then "CompileBaseModel.m" needs to be run to compile the model using the S-function.
I hope someone at Mathworks can help me out with this problem.

Answers (0)


Find more on Simulink Coder in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!