init function for each SWC mandatory in autosar?

1 次查看(过去 30 天)
I am mapping my SWC to autosar code generator.
Each time it comes back with init() function, though I don't want the init() at all.
Is the init function required for autosar? if not, how can I get rid of it from my generated code by modifing the options?
thanks,

回答(1 个)

Amish
Amish 2023-12-15
Hi Vivian,
I understand that you are trying to map the SWC to AUTOSAR code generator and are getting the “init[NM1] ” function in the generated code.
Before understanding how to get rid of it, you can try to understand the reason for this function’s presence. In AUTOSAR, the “init” function is typically generated for initializing the component and is considered good practice for ensuring that the component starts in a known state. However, it is not strictly mandatory if your component does not require any initialization.
As you suspect, it is possible to get rid of the “init” function by modifying respective options.
  1. To do so, you can go the Model Settings (or use CTRL+E).
  2. In the code generation option (in the left pane), you can navigate to the custom code option.
  3. You can disable the generation of the “init” function from here by disabling the “Initialize Code” in the Additional source code option.
  4. Please make sure to apply the changes and then regenerate for the changes to take place into effect.
For further help with configuring AUTOSAR code generation, you can also refer to the link:
Hope this helps

类别

Help CenterFile Exchange 中查找有关 AUTOSAR Blockset 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by