Main Content

Configure Data Transfer Service Interfaces for Data Transfer Signals

Since R2022b

Within a target environment, execution entry-point functions communicate with other execution entry-point functions by calling the target platform data transfer services. In a component model, signal lines connecting communicating functions represent data transfers in the generated code. Communicating functions are modeled by using Function-Call Subsystem blocks that are aperiodic or periodic functions. Use the Code Mappings editor to configure the data transfer service interfaces when you do not want to use the default value specified in a shared coder dictionary.

By default, an Embedded Coder Dictionary provides an interface for these data communication methods:

  • Outside execution: The platform communicates data with other functions outside (before and after) function execution.

  • During execution: The platform service communicates data with other functions immediately during function execution.

For more information on data communication methods, see Data Communication Methods.

Configure Data Transfer Service Interfaces by Using the Code Mappings Editor

In this example, the component model references a shared coder dictionary that defines the default data transfer service interface for signals representing data transfers. To configure the data transfer to use something other than the default service interface, use the Code Mappings editor.

Open the component model, ComponentDeploymentFcn.

openExample('ComponentDeploymentFcn');

Screenshot of component model

In this model, the data transfer is represented by the signal connecting the two Function-Call Subsystem blocks, Accumulator and Integrator.

Verify that the component model references the shared coder dictionary, ComponentDeploymentCoderDictionary.sldd.

In the Model Configuration Parameters dialog box, verify that the Shared coder dictionary parameter is set to ComponentDeploymentCoderDictionary.sldd. This dictionary defines default service interfaces, including the default data transfer service interface, of the component model.

Open the Embedded Coder app.

To configure a signal representing a data transfer to use a data transfer service interface other than the default defined by the shared coder dictionary, use the Code Mappings editor.

To open the Code Mappings editor, in the C Code tab, click Code Interface > Component Interface.

To populate the data transfer mappings, update the model diagram.

On the Data Transfers tab, notice that the Data Transfer Service of the signal connecting the Function Call Subsystems, DataTransfer, is set to Dictionary default: DataTransferOutsideExe.

Default configuration of the code mappings by using dictionary default values

To configure the signal to communicate data with other functions immediately during function execution instead of before or after execution as specified in the dictionary, on the Data Transfers tab of the Code Mappings editor, set the Data Transfer Service of DataTransfer to DataTransferDuringExe.

Code mappings editor with data transfer service for DataTransfer signal configured to DataTransferDuringExe

Configure Data Transfer Service Interfaces Programmatically

To configure the data transfer service interfaces of a component programmatically, access the code mapping properties of signals representing data transfers in the component model.

Open the model.

openExample('ComponentDeploymentFcn');

Get the code mappings for the model by using the coder.mapping.api.get function.

cm = coder.mapping.api.get('ComponentDeploymentFcn');

In this model, the signal connecting the two Function-Call Subsystem blocks, Accumulator and Integrator represents a data transfer. Get the current data transfer service interface configuration by using the getDataTransfer function.

ph = get_param('ComponentDeploymentFcn/Integrator', 'PortHandles');
dataTransServ = getDataTransfer(cm, ph.Outport, 'DataTransferService')
dataTransServ =

    'Dictionary default'
The signal representing the data transfer is configured to use the default data transfer service interface defined in the shared coder dictionary.

To configure the signal to communicate data with other functions immediately during function execution instead of before or after execution as specified in the dictionary, use the setDataTransfer function and set the DataTransferService property to DataTransferDuringExe.

setInport(cm, ph.Outport, 'DataTransferService',...
 'DataTransferDuringExe')

See Also

|

Related Topics