Main Content

setInternalDataPackaging

Set default internal data packaging for AUTOSAR component model

Description

example

setInternalDataPackaging(slMap,pkgSetting) sets the default data packaging to use for internal data stores, signals, and states in the generated code for an AUTOSAR component model. Valid setting values are:

  • Default — Accept the default internal data packaging provided by the software. Use Default for multi-instance models and submodels referenced from AUTOSAR component models.

  • PrivateGlobal — Package internal variable data without a struct and make it private (visible only to model.c).

  • PrivateStructure — Package internal variable data in a struct and make it private (visible only to model.c).

  • PublicGlobal — Package internal variable data without a struct and make it public (extern declaration in model.h).

  • PublicStructure — Package internal variable data in a struct and make it public (extern declaration in model.h).

If the data packaging is set to PrivateGlobal or PrivateStructure, building the model generates header file model_private.h, even when model configuration parameter File packaging format (Embedded Coder) is set to Compact.

If the model configuration option Generate separate internal data per entry-point function (Embedded Coder) is set for the AUTOSAR model, task-based internal data grouping overrides the AUTOSAR internal data packaging setting. However, the AUTOSAR setting determines the public or private visibility of the generated task-based internal data groups.

Examples

collapse all

Return and modify the default data packaging setting used for internal variables in the generated code for the AUTOSAR component model. Specify to package the internal variable data in a struct and make it private.

hModel = 'autosar_swc';
addpath(fullfile(matlabroot,'/examples/autosarblockset/main'));
open_system(hModel);
slMap = autosar.api.getSimulinkMapping(hModel);
pkgSetting1 = getInternalDataPackaging(slMap)
setInternalDataPackaging(slMap,'PrivateStructure')
pkgSetting2 = getInternalDataPackaging(slMap)
pkgSetting1 =
    'Default'

pkgSetting2 =
    'PrivateStructure'

Input Arguments

collapse all

Simulink to AUTOSAR mapping information for a model, previously returned by slMap = autosar.api.getSimulinkMapping(model). model is a handle, character vector, or string scalar representing the model name.

Example: slMap

Value specifying the default data packaging to use for internal variables in the generated code for the AUTOSAR component model. Valid setting values are Default, PrivateGlobal, PrivateStructure, PublicGlobal, and PublicStructure.

Example: 'PrivateStructure'

Introduced in R2021a