S-Function creation for Target link generated code
Mostrar comentarios más antiguos
Hello Team,
I am creating on S-Function creation for Target Link generated codes.
I tried Legacy tool, but Legacy tool works well only when the input parameters and the return type are properly defined.
Example: When i have a function like==> double Sum( double a, double b).
Using def.OutputFcnSpec = 'double y1 = doubleIt(double u1, double u2)'.
But Target Link generated code, the main function is Void.
Example: The function looks like this, Void Sum(Void), in Sum.c file.
Facing difficulty in creating S-Function for this.
Can you please suggest any work around for the above issue.
Regards
Santhosh A
Respuestas (1)
Sahas
el 20 de Ag. de 2024
1 voto
As per my understanding of the question, you would like a way to generate “S-function” using “legacy tool” for a function whose “return” and “argument” parameters are of “void” type.
I was able to create a small example for this, please follow the steps below to create the “S-function” with required specifications:
- Create two code files named "sum.c" and "sum.h" that contain a void function and the headers, respectively.

- Generate the S-function using “legacy code tool”.

- A Simulink model will open with the required “void” type block.

To know more about using the “legacy code tool”, it’s integration with C/C++ code and a few examples, refer to the following documentation links:
- https:/www.mathworks.com/help/simulink/slref/legacy_code.html
- https://www.mathworks.com/help/simulink/sfg/integrating-existing-c-functions-into-simulink-models-with-the-legacy-code-tool
- https://www.mathworks.com/help/rtw/ug/legacy-code-tool-examples.html
I hope this is beneficial!
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!