S-function support with Simulink Desktop Real-Time in External Mode
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 26 Mai 2020
Bearbeitet: MathWorks Support Team
am 11 Mär. 2022
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?
Akzeptierte Antwort
MathWorks Support Team
am 10 Mär. 2022
Bearbeitet: MathWorks Support Team
am 11 Mär. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!