Borrar filtros
Borrar filtros

S-Function parameter generates unnecessary array

2 visualizaciones (últimos 30 días)
Michael Frena
Michael Frena el 31 de En. de 2020
Comentada: Michael Frena el 13 de Feb. de 2020
Hi,
I am facing a problem with the c code generation of an S-Function:
I generated the S-Function with the legacy code tool. The only use of the S-Function is to insert a function call in the generated c-code. But as I need several calls to different functions, I am passing the respective name of the function as parameter event to the S-Function:
SFunction_Simulink.PNG
In the tlc file of the S-Function the Outputs function is defined like this to generated the function call:
%function Outputs(block, system) Output
%%
%assign event = LibBlockParameterString(P1)
%assign y1_ptr = LibBlockOutputSignalAddr(0, "", "", 0)
%%
%<event>( %<y1_ptr> );
%%
%endfunction
This way in the generated code appears always the function call passed as event e.g. dem_Call_Function1(dem_event_prefail);
Unfortuanetly also is generated for each call a uint16_t array of the size of the function call name which is not used at all, but just occupies space.
e.g. for dem_CallFunction1 there is generated:
uint16_t SFunction[18];
The array is initialized in the generated _data.c file like this:
{ 100U, 101U, 109U, 95U, 67U, 97U, 108U, 108U, 95U, 70U, 117U, 110U, 99U, 116U,
105U, 111U, 110U, 49U }
The question is now how could I avoid, that these useless arrays are getting generated?
  1 comentario
Michael Frena
Michael Frena el 13 de Feb. de 2020
I guess there is no way to avoid the generation.
What I did now to avoid the generation of the array is that I pass only an integer value to the S-function. And inside the TLC file this integer value is compared against an enumeration to select the correct Event-String.
This way only the integer value gets stored.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Target Language Compiler en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by