Problem with referenced models that contain calls to source code (accelerated mode)
1 回表示 (過去 30 日間)
古いコメントを表示
I have master model that contains a referenced model which invokes a callback function from external c-code via stateflow. What is not working is to simulate the master model in accelerated mode. Everything else works: - code generation to d-space target OK - Simulate normal mode OK - Simulate the referenced model OK I have put in the configuration parameters for the referenced model: Simulation target -> Header file: #include "CarCfgBits.h" Simulation target -> Source files: carCfgBits.c
Error message: Subsystemlib.lib(Subsystem.obj) : error LNK2019: unresolved external symbol extractCarCfgBits referenced in function Subsystem ..\..\..\Subsystem_msf.mexw64 : fatal error LNK1120: 1 unresolved externals
It does not seem that the source code is available (and including function extractCarCfgBits), when generating code for simulation target accelerated mode (for master model). Thus, the "refmodel_msf.mexw64" file can not be generated.
I attach a screenshot of how my test setup (minimized version) to reproduce the problem looks like.
Appreciate any feedback and hints here!
回答 (2 件)
Shivang Menon
2016 年 11 月 3 日
編集済み: Shivang Menon
2016 年 11 月 3 日
I understand you are trying to include custom code in a stateflow chart and use that model as a reference model in a top model. However, running the parent model in accelerator results in linker errors.
I think the build should also fail if top model is in normal mode and you run the reference model block as accelerator.
This is an expected behaviour. The rationale is that it can cause inconsistencies between simulation and generated code in some cases. Consider the following example
A parent model and a child model, both containing Stateflow charts (though not necessarily the same Stateflow chart). Both models have the same source files listed in their custom code, and both Stateflow charts call a common function from custom code containing a global variable declared/defined in the custom code.
When generating code for the "final" build, (i.e. not the simulation target), the parent model's Stateflow chart and the child model's Stateflow chart will both call the same hand code function and use the same global variable.
In contrast, if we simulate with the child model in "accelerator mode", the results are quite different; The parent model's Stateflow chart uses a simulation target with the custom code compiled into it (including the global variable), but the child model uses its own separate simulation target that has a separate copy of the custom code (including the global variable).
This case wouldn't result in any sort of compilation/linking failure because the accelerated child model reference's simulation target is never linked with the parent model's. However, one case has two global variables while the other has only one, and their results are almost certain to differ.
Also, a stateflow chart is simply an S-function. So whatever limitations for model referencing apply to S-functions apply to stateflow charts as well. Refer to the following link for model referencing limitations in accelerator mode for S-functions:
Model Referencing Limitations : Refer to the Limitations on Accelerator Mode Referenced Models section.
The fact that the top model works while running in Rapid Accelerator mode is surprising - maybe you are invoking one of the S-function limitations from the above link for accelerator mode.
Hope this helps!
0 件のコメント
Anders Ekwall
2016 年 11 月 7 日
1 件のコメント
Hriday Ranjan
2020 年 9 月 25 日
Hi Anders Ekwall,
Did you find the solution of this problem, i am facing the same issue.
参考
カテゴリ
Help Center および File Exchange で Acceleration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!