Generate code for variable size bus signal

조회 수: 7 (최근 30일)
Martin Ekerstedt
Martin Ekerstedt 2019년 8월 15일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Prepare Model Inputs and Outputs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by