Enabling the generation of MISRA C compliant code

You can use the two solutions supporting MISRA C, the Object Execution Framework (OXF) and MicroC-MXF solution.

About this task

For the Rhapsody® OXF solution:
  • You can generate MISRA C compliant code if you add the MISRA C settings and the MISRA C types to your Rhapsody model.
For the Rhapsody MicroC-MXF solution:
  • You can generate MISRA C compliant code using MicroC-MXF with Rhapsody -C model.

This document describes the current assessment regarding MISRA-98 and MISRA-2004 compliance of MicroC-MXF with Rhapsody latest versions.

Procedure

  1. Create a MicroC project, and develop your application. MicroC already includes the various types and settings regarding MISRA C.
  2. You should not add the MISRA C settings or the MisraTypes package. MicroC has the MISRA settings built into it.

What to do next

Note: The following modeling constructs must be avoided to get MISRA compliant generated code:
For both, MicroC and MISRA C:
  • Relations with unlimited multiplicity, such as *.
  • Usage of the dynamic memory allocations, and instantiations during runtime.
For MicroC, only:
  • RiCString, RiCMap, RiCStack, RiCCollection, RiCMemoryManager & MemAlloc , using the properties:
    • CG::Framework::RiCStack = Exclude
    • CG::Framework::RiCMap = Exclude
    • CG::Framework::RiCList = Exclude
    • CG::Framework::RiCCollection = Exclude
  • Using Rapid-Ports that use the property CG::Framework::RapidPorts = NO_RAPID_PORTS.
  • Usage of “IS_IN” and “IS_COMPLETED” state operators using the properties:
    • CG::Framework::RiCReactiveStateMacros = Exclude
    • CG::Framework::RiCReactiveGenMacros = Exclude
  • Usage of RiCGen operation via GUI operators rather than hardcoded.
  • Inline RiCTaskEM_doExecute() using the property C_CG:Class::InlineActiveBaseDoExecute = True.
  • mxf Constructs that are not fully compliant:
    • RiCString: there are MISRA violations associated with RiCString(.c, h), mostly due to the non-compliance of the Standard libraries.
    • RiCMap: there are some MISRA violations associated with RiCMap(.c, h), mostly for the usage of the map sorting algorithm.
    • RiCStack, RiCCollection, RiCHeap, RiCQueue: there are MISRA violations associated with those modules (.c, h).