Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Real-Time Workshop - Generate S-Function for Subsystem with custom compile Flags

Subject: Real-Time Workshop - Generate S-Function for Subsystem with custom compile Flags

From: Jonathan Schmalhofer

Date: 11 Apr, 2013 14:46:06

Message: 1 of 2

Hello,

I need to create a S-Function from a Simulink-Subsystem with Real-Time Workshop. Inside my Subsystem I have a S-Function for which I need to set custom Compile-Flags to build/compile correctly.

Currently I right-click on my Subsystem in Simulink and click on "Real-Time Workshop" > "Build". This works correctly, but I can not set the addtional CompileFlags.

My Workaround so far was: I edit the "mexopts.bat"-File and add "/DmyCustomFlag" to the line "set COMPFLAGS=". This works perfectly nice and everything compiles as it should, BUT is not my desired workflow.

Instead of changing the "mexopts.bat"-File, I also tried to set the following Parameter in my Simulink-File:

set_param('FasCompositionModel','PostCodeGenCommand','addDefines(buildInfo,{''-DmyCustomFlag''},''OPTS'');')

This did NOT work!

(1) Anyone knows why or how I can achieve this?
(2) Is there a way, to create a S-Function from a subsystem from the Matlab Command-Line instead of clicking on the subsystem in Simulink?

Any help is appreciated! Thanks in advance!

Subject: Real-Time Workshop - Generate S-Function for Subsystem with custom compile Flags

From: Phil Goddard

Date: 12 Apr, 2013 02:16:07

Message: 2 of 2


> (1) Anyone knows why or how I can achieve this?

If I understand correctly then you want to change the make command with
set_param(gcs,'RTWMakeCommand','make_rtw OPTS=YourOptionsHere');

> (2) Is there a way, to create a S-Function from a subsystem from the Matlab Command-Line instead of clicking on the subsystem in Simulink?

The MATLAB function for starting the build process is called rtwbuild.
I don't think you can specify what target to build, rather it will always use whatever the whole model is setup to use.
If your model isn't setup for the S-Function target then you can change it (from the command line) with,

subName = 'modelName'/.../sybsystemName';
set_param(subName,'RTWSystemTargetFile','rtwsfcn.tlc');
set_param(subName,'RTWTemplateMakefile','rtwsfcn_default_tmf');
rtwbuild(subName);

Phil.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us