Function calls between s-functions in simulink
显示 更早的评论
Hi,
I have a large embedded C code (multiple .c and .h files), with distinctive functions representing actual parts of the system, so it's somewhat model-based.
However, most of the functions request additional information (besides the input parameters), and this happens via function calls.
Is it possible, to break this dollop down to distinctive S-functions that can be simulated in simulink, with inputs and outputs, AND the possibility to call specific functions of another dollop (the remaining base C code)?
As far as I know, the legacy code tool can only transform the whole code, and that wouldn't help me much. Is there a solution?
Thank you, Attila
P.S. Though it's April 1st, this is not a joke... Happy fool's day!
回答(1 个)
Kaustubha Govind
2012-4-4
1 个投票
You are asking a somewhat difficult question - it's hard to tell how breaking down your code into S-functions will work without knowing how your code control-flow and data-marshaling works. If you are able to refactor your code into distinct functions of two categories: ones that represent the system itself which can be S-functions and ones that are utilities that can be called from S-functions. The former can be applied to the Legacy Code Tool to generate S-function wrappers for them. The latter can be compiled into libraries that you can link against your S-functions so that the code can be shared by multiple S-function blocks. You should also be careful about data that may need to be shared by multiple blocks.
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!