AUTOSAR Code Generator always writes True to Boolean variable at the time of Initialization

3 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
Simulink prevents writing 0 / false at the time of initialization for AUTOSAR because the initialization of the output block depends on the Real Time Environment (RTE).
Hence, a setting in Code Generation pane (optimization) of Configuration parameters in Simulink, known as "zeroExternalMemoryAtStartup" is checked by default for autosar.tlc.
This setting removes root level I/O zero initialization.This can not be unchecked in "autosar.tlc". It can be unchecked in "ert.tlc".
Hence, the generated code always assumes that variable to be True. There is no current workaround available to change this behavior and that is expected.
However, In this case, the data byte is getting assigned with 1, because the data range of the output variable of the MATLAB function(data) is set to (1 - TxTPMsgBufferSize).
Since NFCControlReq.Enable is of type boolean and is assigned to a variable of whose range is > 1, the generated code gets optimized by assigning the value to 1.
One can avoid this by making a change for the output of the MATLAB function block.
You can refer to "datarangechange.jpg" to view the change to be done. I am also attaching "working_model.zip" file for your reference. (attached in case files)

更多回答(0 个)

类别

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

标签

尚未输入任何标签。

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by