MATLAB: Enumeration Code Generation with Embedded Coder (autosar.tlc)

autosarcode generationEmbedded Coderenumeration

Hello,
does anyone have a clue what causes the following error message and how I can overcome this problem? I have a Simulink model that uses the enumeration defined in "State_Car.m"
classdef State_Car < Simulink.IntEnumType
enumeration
PARKEN_BN_NIO(1)
PARKEN_BN_IO(2)
STANDFKT_KUNDE_NICHT_IM_FZG(3)
WOHNEN(5)
PRUEFEN_ANALYSE_DIAGNOSE(7)
FAHRBEREITSCHAFT_HERSTELLEN(8)
FAHREN(10)
FAHRBEREITSCHAFT_BEENDEN(12)
SIGNAl_UNBEFUELLT(15)
end
end
The error message I get during build process is:
### Build procedure for model: 'swc_heat_2017b' aborted due to an error.
The header file of the enumerated type State_Car, should be set to Rte_Type.h. To fix this error, update the getHeaderFile method of the enumeration type to return Rte_Type.h

Best Answer

Hi Yu Zhao!
As per the AUTOSAR standard, all data types must have a definition generated in Rte_type.h. This is the reason for the error and it is not possible to use a different header when doing AUTOSAR code generation.
For data types used solely inside of a SWC (not in the definition of a port) you only need to specify the header file as Rte_type.h only if you want the data type to be exported as an IncludedDataTypeSet.
Here's a small example for the implementation of the getHeaderFile method:
classdef State_Car < Simulink.IntEnumType
enumeration
On(1)
Off(2)
end
methods (Static = true)
function retVal = getHeaderFile()
retVal = 'Rte_Type.h';
end
end
end
Have a great day!
~Lucas