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!