S-function support with Simulink Desktop Real-Time in External Mode
8 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2020 年 5 月 26 日
編集済み: MathWorks Support Team
2022 年 3 月 11 日
I have written an S-function that uses Windows API functions. When I try to compile this model using sldrt.tlc to run the real-time simulation in External Mode, I receive the following build error using MATLAB R2020a:
In file included from ...\myFunction.c:134:
C:/PROGRA~1/MATLAB/R2020a/toolbox/sldrt/lib/include\Windows.h:16:2: error:
Attempt to include "windows.h"
C:/PROGRA~1/MATLAB/R2020a/toolbox/sldrt/lib/include\Windows.h:17:2: error:
The model being compiled contains a block that can run on host only and cannot be
compiled for External Mode. Please either switch to Normal Mode or remove the block.
When I add an S-Function to my model, is there a limitation as to the C library functions it can use with Simulink Desktop Real-Time simulation in External Mode?
採用された回答
MathWorks Support Team
2022 年 3 月 10 日
編集済み: MathWorks Support Team
2022 年 3 月 11 日
You can use S-functions in Simulink Desktop Real-Time external mode when the S-functions are self-contained. For example, the S-functions only call a limited subset of the standard C library, such as math and string functions and do not call file I/O, console I/O, or Windows API functions. An example of not-self-contained S-function would be a function that needs to #include <windows.h>.
Note that being able to simulate an S-function with other code generation targets—such as grt.tlc, ert.tlc, or slrealtime.tlc—does not a prove that it can be simulated with sldrt.tlc. For example, S-functions that are linked with dynamically linked libraries (DLLs) on Windows generally do not simulate with Simulink Desktop Real-Time because the DLLs are not available to the real-time kernel.
Refer to the following documentation for a list of unsupported and supported C functions:
Note that the above limitations do not apply for Normal or Accelerator Mode real-time simulations. To learn more about the different SLDRT simulation modes, see the following MATLAB Answers article:
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!