フィルターのクリア

Call External C Function From Stateflow

16 ビュー (過去 30 日間)
TAZ
TAZ 2017 年 9 月 14 日
編集済み: Vit Valek 2020 年 1 月 29 日
Does anyone know how to call an external (custom) C function from Stateflow? The documentation basically says to specify the include file in the code generation options, but when I try to update or build my model, Stateflow doesn't recognize the name of my function call. It sees it as an undefined function.
How do I declare my external C function for Stateflow?

回答 (1 件)

Sebastian Castro
Sebastian Castro 2017 年 9 月 15 日
If you go to the Model Configuration Parameters, there is a "Simulation Target" section where you specify the source files, header files, include folders, etc. needed
BTW, if you will also be generating C code from the chart, you can go to the "Code Generation > Custom Code" options and select "Use the same custom code settings as Simulation Target." This makes sure the same files are used and packaged up when you generate code.
- Sebastian
  1 件のコメント
Vit Valek
Vit Valek 2020 年 1 月 29 日
編集済み: Vit Valek 2020 年 1 月 29 日
I have solved it. You must include your header file and insert source file in Configuration Parameters:
Simulation Target -> Header file: #include "YourLib.h"
Simulation Target -> Source files: YourLib.c
Same changes make in Code Generation - Custom Code. If files aren't in same folder as simulated model, you must define Include directories (in pane Simulation Target and Code generation - Custom Code).
Last thing what do you need is change Action Language to C (View -> Property Inspector: Chart).
Vit

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by