How to force enumeration type to be defined in generated code.

조회 수: 8 (최근 30일)
Martin Beaucage
Martin Beaucage 2018년 9월 5일
댓글: Martin Beaucage 2018년 12월 7일
Hello,
We use Simulink to make programs for our new controller. The Simulink model generates C code (using Embedded coder, Simulink coder) that we compile and load on the controller. We have made custom blocks to show information in our user interface tool. One of these blocks (ItemConfiguration) allow us to define variables that will be visible by the user and we have Read and Write blocks to access theses variables in the model. The ItemConfiguration block uses TLC code to make a structure in the C code containing the configured variables. The Read and Write blocks read or write these variables with data from the model.
With my ItemConfiguration block, if I define a variable named toto of enumeration type (type defines in a .m file) the code generation will make a structure containing a variable names toto with type enumeration type. When I use Read or write blocks, conversion to this enumeration type are used so during code generation Simulink includes the type definition in the C code.
The problem I have is that if the toto variables is not used by any Read or Write blocks the type definition is not included in the C code and when I build the compiler tells me the type is undefined, which is normal. I would like to know if it is possible in the TLC code to force a specific type to be included in the generated code?
Thanks,
Martin
  댓글 수: 2
Maurice Gonska
Maurice Gonska 2018년 12월 7일
Hello Martin,
have you solved the problem?
I have a similar problem.
Br Maurice
Martin Beaucage
Martin Beaucage 2018년 12월 7일
Hello Maurice,
We modified our "ItemConfiguration" block to create, in a subsystem, a constant going into a terminator for each different enumeration type used. During compilation there variables are removed since they do nothing but it forces the inclusion of the types during code generation.
Regards,
Martin

댓글을 달려면 로그인하십시오.

답변 (1개)

Arunkumar M
Arunkumar M 2018년 12월 7일
If you are using Data Dictionary, you can define your enumerations there. On code generation, this will be included in the generated header file.
On the other hand, if your enumerations are already defined in a .h file, then you can use the property Imported From File in your enumeration definition and give the header name to include it in the generated code

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by