
Why does the generated code for a Simulink Function returns an argument instead of void when using the autosar.tlc target?
조회 수: 12 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2021년 11월 10일
편집: MathWorks Support Team
2023년 5월 19일
It is sought to generate embedded code using the autosar.tlc target from a Simulink model that uses a Simulink Function Caller block. The function prototype provided to the function is as follows,
myoutp = myfunc()
It is expected that the generated embedded code when using the autosar.tlc target for this Simulink Function Caller block has no output argument and the signature looks as follows,
void Rte_Call_CP_myfunc(UInt8* myoutp);
However, the generated embedded code when using the autosar.tlc from this Simulink Function has in fact the following signature,
Std_ReturnType Rte_Call_CP_myfunc(UInt8* State);
Why does the generated code for a Simulink Function returns an argument instead of void when using the autosar.tlc target?
where as it can be see the return type 'Std_ReturnType', which is defined under Std_Types.h is an alias to uint8:
typedef uint8 Std_ReturnType;
채택된 답변
MathWorks Support Team
2023년 5월 17일
편집: MathWorks Support Team
2023년 5월 19일
Please note that these stub-files generated by Simulink in case of the autosar.tlc target are not meant to be used in production and they have to be replaced by the stub-files provided by the corresponding RTE generator. These autogenerated files from Simulink are only meant to be used in a Software-In-the-Loop (SIL) simulation.
Although these stub files are meant to be used internally within Simulink, we strive to keep the implementation of the RTE APIs as close to what AUTOSAR specification dictates and also similar to what actual RTE generator would generate as much as possible.
In this particular example, it is used a return type 'Std_ReturnType' based on how AUTOSAR specification defines the Rte_Call* API to initiate the Client-Server communication as per Section 5.6.13 of the document that can be found in the following link,
So this is a design choice we made to always use "Std_ReturnType Rte_Call_*" in the RTE source code (stub file) and "void Rte_Call_*" in the application component source code since the return value from the access function is almost never used. See also the following screenshot from the AUTOSAR specifications document,

댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 AUTOSAR Blockset에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!