From: Amit on
Hello,


I want to generate the auto code using RTW in which the auto code should contain the output port name (output signal name) as export function.
E.g. If Matlab model have outputs as temp_out and batt_out, then in generated C auto code I want them as

extern BOOLEAN temp_out;
extern BOOLEAN batt_out;

#define Gettemp_out()
#define Getbatt_out()

So that these output variables can be accessed by other rings/models during full build generation.
can anybody help on this requirement
From: Phil Goddard on
"Amit " <amit.kamat84(a)gmail.com> wrote in message <hvv06p$hov$1(a)fred.mathworks.com>...
> Hello,
>
>
> I want to generate the auto code using RTW in which the auto code should contain the output port name (output signal name) as export function.
> E.g. If Matlab model have outputs as temp_out and batt_out, then in generated C auto code I want them as
>
> extern BOOLEAN temp_out;
> extern BOOLEAN batt_out;
>
> #define Gettemp_out()
> #define Getbatt_out()
>
> So that these output variables can be accessed by other rings/models during full build generation.
> can anybody help on this requirement

To do this you must name the signals being fed into the outports.
If the signals are not named then RTW uses the name of the Outport block.
If the signal is named then RTW uses the signal name, not the block name, and allows the Storage Class of the signal to be customized.

So, name the signals temp_out and batt_out.
Right click on the signals, go to Signal Properties, then in the UI click the RTW tab.
Change the Storage Class to ExportedGlobal, and specify the modified to be extern.

Assuming that in the model the signal is define as being of boolean dat type then in the generated code you'll get
extern Boolean_T batt_out;

Boolean_T is defined in tmwtypes.h.

To incorporate your #define statements you'll need to put them into the "Custon Code" tab of the RTW configuration section of the Tools->RTW->Options pulldown menu.

Phil.