Can I call external binary code (DLL, LIB, EXE) during a Simulink Desktop Real-Time simulation?

8 views (last 30 days)
I have model containing an S-functions that calls into external binary code (DLL, LIB, EXE). I would like to run this simulation in real-time on my Windows PC using Simulink Desktop Real-Time (SLDRT) in External Mode. Is this possible?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Mar 2022
Edited: MathWorks Support Team on 11 Mar 2022
It is not possible to call external binary code when using SLDRT in External Mode. This is a fundamental limitation that has to do with how SLDRT External Mode works.
The reason is that the code for a DLL, LIB or EXE is compiled for Windows, which is an environment completely different than the SLDRT kernel. This means that the Windows API is not available at all, memory allocation is done in a very different way, and calls to all these Windows functions are already compiled to the binary and this cannot be changed. As an example, let's take malloc() - although it looks the same in Windows source and in SLDRT source, it does very different things when compiled. Another way to look at the reasons - no-one would probably try to use a binary library compiled for Windows in Linux, although the source code of the library may be compilable for both.
Note that the same limitation does 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:

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!