MATLAB Answers

0

MISRA rules violations of Generated Code for Embedded Coder

Ismael Lafoz 님이 질문을 제출함. 19 Sep 2018
최근 활동 Michael Burke 님이 답변함. 2 Dec 2019 18:34
Hi,
I am using Embedded Coder to generate C source code from a Simulink model, selecting MISRA-C compliance objective, and when I run Polyspace analysis, I get lots of MISRA rules violations.
How can this be fixed?
Regards.

  댓글 수: 0

로그인 to comment.

답변 수: 3

Anirban 님의 답변 4 Oct 2018

In addition to the previous answer, another possibility can be that you ran Polyspace for MISRA rules meant for handwritten code and not generated code. MISRA C:2012 (Appendix E) moves several rules from the Required category to the Advisory or Readability category if the code is generated from a model. If you ran Polyspace with the Required subset of MISRA C:2012 checkers for handwritten code, you might get more violations compared to the Required subset for generated code.
To run Polyspace with the MISRA C:2012 checker for generated code, use the Polyspace option Use generated code requirements ( -misra3-agc-mode). See documentation for the option . If you run Polyspace directly from Simulink, this option gets enabled automatically.

  댓글 수: 0

로그인 to comment.


Prakhar Jain 님의 답변 25 Sep 2018

The rules of MISRA C:2012 often gets updated with newer releases and a variety of reasons can be responsible for the violation. Please find the below rules for violation scenarios which has been made for the later releases and may be causing violations.
1) If there are identifiers beginning with underscore
2) If a reserved identifier or macro name is declared
Note: The above possible workaround may/may not work for your case.
In case you only expect to remove the warnings, you can always uncheck rules in the Coding Rules & Code Metrics in the configuration pane. Follow the below steps:
1) Open configuration pane
2) Click on the edit button as seen in the screenshot in red
3) Go to let's say rule no 21.2 and uncheck it as shown in screenshot in red
Here is an attached link for the same.
The above remove warnings can also be unchecked for other rule violations if required.

  댓글 수: 0

로그인 to comment.


Michael Burke 님의 답변 2 Dec 2019 18:34

Note: one thing that you should look at is the model configuration parameters. This link provides a good overview of what you should do to configure your model:

  댓글 수: 0

로그인 to comment.



Translated by