MATLAB: Do the names of particular signals not appear in the “rtBlockSignals” structure generated by Real-Time Workshop 6.0 (R14)

apicc++ apicapicodecodegenexportgenerationgloballabel;namertblocksignalsrtwsignalsimulink coderstructure

I am using the C-API feature of Real-Time Workshop 6.0 (R14) to interface an external signal monitoring application with particular signals in my model. These signals emanate from a Subsystem block at the top-level of the model, where I have named them appropriately and set their storage class to "ExportedGlobal". When I generate C-API code for the model, the "rtBlockSignals" structure in the model_capi.c file does not include the names of the signals. Instead, the "signalLabel" field is populated with "NULL" as shown below:
/* Block output signal information */
static const rtwCAPI_Signals rtBlockSignals[] = {
/* addrMapIndex, sysNum, blockPath,
* signalLabel, portNumber, dataTypeIndex, dimIndex, fxpIndex,
sampTimeIndex
*/
{0, 0, "model/Subsystem/Gain",
"NULL", 0, 0, 0, 0, 0},
{
0, 0, NULL, NULL, 0, 0, 0, 0, 0
}
};

Best Answer

The signal names do not appear in the "rtBlockSignals" structure of the model_capi.c file generated by Real-Time Workshop 6.0 (R14) because SIMULINK cannot propagate signal labels back across virtual subsystem boundaries.
To work around this issue, label the source of the signal within the virtual subsystem boundary. SIMULINK can propagate signal labels forward across virtual subsystem boundaries, such that the output of a Subsystem block shares the same label as the output of the signal source. For example, labeling the output of a Gain block as "my_output" within the Subsystem and appropriately setting its storage class will generate code similar to the following:
/* Block output signal information */
static const rtwCAPI_Signals rtBlockSignals[] = {
/* addrMapIndex, sysNum, blockPath,
* signalLabel, portNumber, dataTypeIndex, dimIndex, fxpIndex,
sampTimeIndex
*/
{0, 0, "testme/Subsystem/Gain",
"my_output", 0, 0, 0, 0, 0},
{
0, 0, NULL, NULL, 0, 0, 0, 0, 0
}
};