AUTOSAR Code Generator always writes True to Boolean variable at the time of Initialization
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2020-8-7
回答: MathWorks Support Team
2020-8-10
The AUTOSAR code generator seems to be optimising out a boolean enable flag, and assuming it is always true.
采纳的回答
MathWorks Support Team
2020-8-7
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 个评论
更多回答(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!