AUTOSAR adaptive service communication provides the option to configure applications
to use one-time or dynamic discovery to subscribe to services. The default discovery
mode, OneTime
, allows an AUTOSAR application to find and subscribe to
services at initialization. This mode of discovery may require that services are started
before the application. You can change the service discovery mode to
DynamicDiscovery
to enable an AUTOSAR application to find and
subscribe to services as they become available.
You can configure, in your model or programmatically, the service discovery mode of
each required service port as OneTime
or
DynamicDiscovery
:
From your model, you can use the AUTOSAR Dictionary to open the Service discovery attributes of required ports and select their service discovery modes.
This example shows how to set a required port to
DynamicDiscovery
.
Programmatically, you can use the set
function from the getAUTOSARProperties
API to configure the service discovery mode.
This example shows how to set a required port to
DynamicDiscovery
.
hModel = 'autosar_LaneGuidance'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel); apiObj = autosar.api.getAUTOSARProperties(hModel); set(apiObj,"/LaneGuidance_pkg/LaneGuidance_swc/LaneGuidance/RequiredPort/", ... "ServiceDiscoveryMode", "DynamicDiscovery")
The service discovery mode value impacts the generated C++ code (in the model source code file) in the following two locations:
The call site of the StartFindService
API and registration
of the callback (for both the InstanceIdentifier
and
InstanceSpecifier
variants).
The definition of the callback function.