How can I run a Simulink model with a C S-Function on a Simulink Real-Time PC?

1 view (last 30 days)
I have a Simulink model with an S-Function Builder block in it. The S-Function Builder block defines a custom Outputs function and includes 2 extra C files which implement necessary functionality. I can successfully build the code for the Simulink Real-Time target, and it gets deployed on the Simulink Real-Time PC. However, after deployment, I see the following message in red in the bottom-right corner of the Real-Time PC screen:
To run the generated code outside the MATLAB environment, use the packNGo function.
I can build a .zip-file with the packNGo function, however I have no idea what to do with it and how to deploy it on the Real-Time PC.
How can I run a model with some custom C code on a Simulink Real-Time PC?
The build log and the project files are attached.

Answers (1)

Jon Lobo
Jon Lobo on 3 Jul 2018
Hi Mikhail,
I took a look at your example. It looks like you did everything right. The only issue is that you are using the UDP Send block from the DSP Systems Toolbox. This is not supported in Simulink Real-Time.
I was able to find this by using SimulinkRealTime.utils.getConsoleLog to see the line above "To Run the generated code outside the MATLAB environment...". The line above reads "Error: Could not open library: networkdevice.dll'.
Once I removed that block and used the UDP Send from Simulink Real-Time the application worked.

Community Treasure Hunt

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

Start Hunting!