Rte_Type.h file in generated code for AUTOSAR with Matlab function in Simulink

90 ビュー (過去 30 日間)
Albert Buils
Albert Buils 2017 年 11 月 23 日
コメント済み: qing zhou 2022 年 8 月 23 日
I want to generate C code for AUTOSAR from a Simulink with a Matlab function block. Simulink model is created with an existing arxml with enumerated data types, and a .m file is created like this:
Simulink.defineIntEnumType( 'OffOn_T', ...
{'OffOn_Off','OffOn_On','OffOn_Error','OffOn_NotAvailable'}, ...
[0 1 2 3], ...
'DefaultValue', 'OffOn_Off', ...
'StorageType', 'int32', ...
'HeaderFile', 'Rte_Type.h', ...
'AddClassNameToEnumNames', false);
This datatype is used as an input/output an treated in Matlab function block.
When I generate code I have this error
Data 'hmi_rqst_data' (#51) has compiled structure or enumeration type 'OffOn_T', which specifies custom header file 'Rte_Type.h'.
This custom header file must be directly or indirectly included in model's Configuration Parameters 'Simulation Target/Header file' field.
No '#include "<headerfile>"' is detected in 'Simulation Target/Header file' field.'
Component:MATLAB Function | Category:Coder error
include header file
If I include header file in Simulation Target Custom code header file I have this error:
...
fatal error: Rte_Type.h: No such file or directory
compilation terminated.
File Rte_Type.h is created when C code is generated, so why I'm getting this error?
How can I use enumerated dataype in Matlab function in this situation (Embedded Coder for AUTOSAR)?

回答 (2 件)

Deepika Mani
Deepika Mani 2020 年 11 月 13 日
編集済み: Deepika Mani 2020 年 11 月 13 日
Enable the code gen setting checkbox as in the snapshot below: Simulation Target -> 'Generate typedefs.......'
Changing the data scope to 'Exported' will help you just simulate the model, but Autosar validation will throw you an error asking you to make it 'Auto'. So enabling the code gen setting shall work.
  2 件のコメント
zhong ming
zhong ming 2021 年 3 月 5 日
感谢!这个问题困扰了多半年,今天看到您的解决的方法,终于解决了该问题!
qing zhou
qing zhou 2022 年 8 月 23 日
Great!!!

サインインしてコメントする。


David Fink
David Fink 2018 年 2 月 22 日
  1 件のコメント
Saurabh Vyas
Saurabh Vyas 2022 年 1 月 20 日
Doing this removed the enumerated signals from the FMU so I don't think this is the solution.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAUTOSAR Blockset についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by