Function calls between s-functions in simulink

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

Answers (1)

Kaustubha Govind
Kaustubha Govind on 4 Apr 2012
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.

Categories

Find more on Block Authoring and Simulation Integration 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!