Include C-code in Simulink with pointers within a structure
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i would like to integrate a structure which contains pointers into simulink like
typedef struct {
uint16_t id;
uint16_t *value;
} Queueitem_t;
pointers that are declared alone work like
extern uint16_t * var;
Does anyone have any idea how i do it. when running "Simulink.importExternalCTypes("headerfile")" i always get an error message -> Invalid use of operator.
0 comentarios
Respuestas (1)
Varun
el 15 de Sept. de 2023
Hi Roman,
I understand that you are trying to create “Simulink.Bus” object using the function “Simulink.importExternalCTypes” to a ‘C’ header file which consists of a struct which has a data type of pointer.
According to MATLAB R2023a, pointer data types are not supported in Simulink, that is why you are getting the above error while creating “Simulink.Bus” object.
However, you can follow an alternative approach to achieve similar functionalities of the pointer data type.
The idea is to use a data type that Simulink supports in place of the pointer. Since pointers are 64 bits long, use a Simulink data type that is 64 bits long. Then, in the external C code, convert the datatype used by Simulink to/from a unit16*. The best approach is to use a 64-bit integer in Simulink, since most C compilers will allow you to cast an integer to a pointer. But this requires the Fixed-Point Toolbox. If you have a license for this, then set the data type of the variable to be ufix(64). If you don't have a Fixed-Point license, then you can select a built-in Simulink data type that is 64 bits long, for example double.
Please refer to this MATLAB Answers post to learn more:
Hope this helps.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!