Stateflow & embedded coder

10 次查看(过去 30 天)
YOUNGHOO
YOUNGHOO 2025-12-12,5:05
编辑: Aditya 2025-12-17,6:44
안녕하세요,
Simulink/Stateflow를 활용하여 모델을 만들고, embedded coder를 이용해 c언어로 생성하여 사용중에 있습니다.
생성된 c코드의 코딩규칙 검사를 진행 중 stateflow에서 생성된 함수에 대해 질문이 있어 문의드립니다.
Stateflow chart 블럭에 초기 진입 시 생성되는 함수 static void M_enter_internal_c1_...(... uint32_T 변수A ... ) 및 진입 이후 생성되는 내부 함수 static void M_Sensor_Selection_Logic(... const uint32_T *변수A ...) 가 정의됩니다.
위 처럼 stateflow에서 uint32로 정의한 동일한 Local 변수를 함수에서 다른 자료형 (const uint32_T <-> uint32_T)으로 사용하고 있어, 코딩규칙 검사에 어긋나게 됩니다.
혹시 이를 방지하기 위한 c code gen. 설정이나 stateflow 블록 파라미터를 설정할 수 있는지 궁금합니다.
(함수 패키징 시 인라인, 재사용 불가/가능 함수 등 관련이 없었습니다.)
감사합니다.

回答(1 个)

Aditya
Aditya 2025-12-17,6:44
编辑:Aditya 2025-12-17,6:44
Hi,
Stateflow generates local variables as function arguments in different forms:e.g., uint32_T variableA in one function, and const uint32_T *variableA in another.This inconsistency can cause coding rule (e.g., MISRA) violations during code review, These can be the causes:
  • Stateflow automatically determines function argument types based on data scope and usage:
  • Inputs are often passed as const pointers.
  • Local data may be passed by value.
  • There is no direct setting to force all function arguments to use the same type.
Embedded Coder Options
  • There is no built-in option to force consistent argument types for Stateflow-generated functions.
  • Changing Data Scope/Storage Class (e.g., to ExportedGlobal) affects variable visibility, but not how arguments are passed.
Stateflow Block Parameters
  • No parameter allows control over function argument types.

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!