Generate code for variable size bus signal

7 visualizaciones (últimos 30 días)
Martin Ekerstedt
Martin Ekerstedt el 15 de Ag. de 2019
I have a model that has bus signals as input and output. If I set the port dimensions of the input and output to 5, I get the following interface in generated C code.
// External inputs (root inport signals with auto storage)
typedef struct {
InputBusType InputBus[5]; // '<Root>/InputBus'
} ExtU_MyModel_T;
// External outputs (root outports fed by signals with auto storage)
typedef struct {
OutputBusType OutputBus[5]; // '<Root>/OutputBus'
} ExtY_MyModel_T;
// Root inport: '<Root>/InputBus' set method
void setInput(InputBusType localArgInput[5]);
// model step function
void step();
// Root outport: '<Root>/OutputBus' get method
OutputBusType getOutput() const;
How can I set the bus signals to have variable sized dimensions? I would like to get the following C code instead.
// External inputs (root inport signals with auto storage)
typedef struct {
InputBusType InputBus[]; // '<Root>/InputBus'
int InputBusSize;
} ExtU_MyModel_T;
// External outputs (root outports fed by signals with auto storage)
typedef struct {
OutputBusType OutputBus[]; // '<Root>/OutputBus'
int OutputBusSize;
} ExtY_MyModel_T;
// Root inport: '<Root>/InputBus' set method
void setInput(InputBusType localArgInput[], int size);
// model step function
void step();
// Root outport: '<Root>/OutputBus' get method
void getOutput(OutputBusType* output, int size);
I have managed to get the C code I want if I set the type of the signals to Integers, but it does not work with bus types.
Also I know that you can define variable size for the bus elements, but there is no option to do that for the parent bus object.
Here are some stuff that I have read and tried, but none of them helped me produce the C code I want.
I will be grateful for any help about this!
Regards
Martin Ekerstedt

Respuestas (0)

Categorías

Más información sobre Prepare Model Inputs and Outputs en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by