How to incorporate legacy code using structure with pointer ?

2 views (last 30 days)
Hello,
I am used to integrate existing C code in Simulink model (using S-function or Legacy Code Tool).
The issue is that existing C code that I have to deal with uses complex structures with elements that are pointers.
Here an extract of the C code :
typedef enum
{
GRAD_OFF, //!< The gradator is switched OFF.
GRAD_ON, //!< The gradator is switched ON.
GRAD_INCREASE, //!< The gradator executes a fade-in.
GRAD_DECREASE, //!< The gradator executes a fade-out.
GRAD_PAUSED_AT_START, //!< The gradator is stopped in min position.
GRAD_PAUSED_AT_END //!< The gradator is stopped in max position.
} GRADATOR_STATE;
/*! \brief Variable part of an instance of class CLASS_GRADATOR.
*
*/
typedef struct
{
GRADATOR_STATE status; //!< Internal state of the gradator.
T_UWORD counter; //!< The gradator's cursor position.
T_UWORD nb_steps; //!< Number of steps to execute during a fade.
T_UWORD period; //!< Gradator's period in ms.
} GRADATOR_DATA;
/*! \class CLASS_GRADATOR
\brief This class is the core class of the gradator's composition.
* This class controls an analog actuator.
* The associated output can vary automatically according to a predefined shape.
*/
typedef struct
{
GRADATOR_DATA *data; //!< Points to the variable part of the gradator.
TYPE_REC recurrence; //!< Recurrence of the gradator.
} CLASS_GRADATOR;
Enumerated type GRADATOR_STATE and structure type GRADATOR_DATA are easy to import in Matlab (using a Simulink.IntEnumType and a Simulnik.Bus).
But I do not manage to import sructure type CLASS_GRADATOR because of element "data" which is a pointer on a structure type GRADATOR_DATA.
Is there a way to do that ?
Thank you for help
  2 Comments
Szabolcs Fodor
Szabolcs Fodor on 24 Jul 2018
Hello,
is there an update for this issue? I would also be interested in the answer.
Thanks in advance. \Szabi

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!