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!