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!