How to incorporate legacy code using structure with pointer ?
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
Szabolcs Fodor
2018-7-24
Hello,
is there an update for this issue? I would also be interested in the answer.
Thanks in advance. \Szabi
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!