Is it possible to generate a standalone executable in external mode including an S-Function of a C/C++ code that performs TCP/IP communication?
6 views (last 30 days)
Show older comments
Hello Everyone,
I am working on a simulation by coupling two software (OpenFresco and Simulink) through TCP/IP communication. It works fine when using Simulink Desktop Real-Time in Normal or Accelerator modes. But, I have tried to use external mode in conjunction with a Raspberry Pi 4 Model B (RBP4B) as external hardware, and I am having trouble generating the standalone executable before running the code in real-time.
First, I’m using Matlab release 2021a, with Simulink version 10.3 and Simulink Support Package for Raspberry Pi Hardware version 21.1.1. The Simulink model includes an S-function block written in C++, as shown below. This code allows for TCP/IP communication with the OpenFresco software running as a server on the same local network.
As I show in the following screenshots, the source code is referenced in the “Code Generation” settings window. To compile the C++ code, I have used either Microsoft Visual Studio 2019 version 16.10.0 or MinGW-w64 version 21.1.0 compilers, both with the same bad results.
In the following lines, I’ll try to explain the error message. When trying to generate the executable, multiple syntax errors appear on the screen (in Spanish):
C:\...\matrix.h(194): error C2143: error de sintaxis: falta '{' delante de ':'
When modifying the indicated line of code, the error is modified and replaced by another:
C:\...\matrix.h(194): error C2433: 'Matrix': 'inline' no se permite en las declaraciones de datos
If I keep modifying the source code, the error continues changing. The problem with this is that the initial simulation that used to work with Simulink Desktop Real-Time and Normal/Accelerator modes doesn’t work anymore.
I appreciate your help in trying to figure this out and solve my issue. Thanks!
-----------------------------
The complete error message and the source code of the S-Function are attached.
0 Comments
Answers (1)
Jan Houska
on 7 Jun 2021
Hi Diego,
to build a model for Simulink Desktop Real-Time external mode, you must set your system target file to either sldrt.tlc or to sldrtert.tlc. This can be best done by selecting the Desktop Real-Time app from the app gallery.
However, I don't think that you will be able to compile the S-function for Simulink Desktop Real-Time external mode. It is very likely that the S-function is designed for Windows and uses Windows API and libraries, and Windows API is not available in the real-time kernel. It may be worth trying, but please don't be disappointed if it doesn't work.
Also, it's a question what exactly will external mode bring to the solution. If I understand your setup correctly, the Simulink model only works for value setting and monitoring for Raspberry Pi. In such a setup, I don't see much advantage using external mode and it may be easiest to just stay with normal mode.
Good Luck, Jan
0 Comments
See Also
Categories
Find more on Target Computer Setup 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!