Main Content

Configure Sender and Receiver Service Interfaces for Model Inports and Outports

Since R2022b

Within a target environment, a component receives data from and sends data to other components by calling the target platform receiver and sender services. In a component model, use an Inport block or an In Bus Element block to represent calls to the receiver services. Use an Outport block or an Out Bus Element block to represent calls to the sender services. Use the Code Mappings editor to configure the sender and receiver service interfaces when you do not want to use the default value specified in a shared coder dictionary.

In the dialog box that appears if you click the pencil icon or in the Property Inspector, you can specify the identifier that the code generator uses to represent an inport or outport in the generated code.

By default, an Embedded Coder Dictionary provides an interface for each type of data communication method:

  • 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.

  • Direct access: Generated function code communicates with other functions directly by using memory that platform services manage for the target execution environment.

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

Configure Sender and Receiver Service Interfaces by Using the Code Mappings Editor

In this example, the component model references a shared coder dictionary that defines the default sender and receiver service interfaces for model outputs and inputs, respectively. To configure a model input or output to use something other than the default service interface, use the Code Mappings editor.

Open the component model, ComponentDeploymentRate.

openExample('ComponentDeploymentRate');
Screenshot of component model

In this model, the component inputs are represented by In Bus Element blocks, InBus.u and InBus.NVM. Component outputs are represented by Out Bus Element blocks, OutBus.y and OutBus.NVM.

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 sender and receiver service interfaces for the inputs and outputs of the component model.

Open the Embedded Coder app.

To configure an input or output to use a receiver or sender service interface other than the default defined by the coder dictionary, use the Code Mappings editor.

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

On the Inports tab, notice that the Receiver Service of the component inputs, InBus.u and InBus.NVM, is set to Dictionary default: ReceiverOutsideExecution.

Default configuration of the code mappings by using dictionary default values

To configure the input InBus.NVM to communicate data with other functions immediately during function execution instead of before or after execution as specified in the dictionary, on the Inports tab of the Code Mappings editor, set the Receiver Service of InBus.NVM to ReceiverDuringExe.

Code mappings editor with receiver service for InBus.NVM configured to ReceiverDuringExecution.

Configure Sender and Receiver Service Interfaces Programmatically

To configure the sender and receiver service interfaces of a component programmatically, access the code mapping properties of the component model outputs and inputs, respectively.

Open the model.

openExample('ComponentDeploymentRate');

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

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

Get the current receiver service of the input, InBus.NVM, by using the getInport function.

receiver = getInport(cm, 'InNVM', 'ReceiverService')
receiver =

    'Dictionary default'
The model input is configured to use the default receiver service interface defined in the shared coder dictionary.

To configure the input InBus.NVM to communicate data with other functions immediately during function execution instead of before or after execution as specified in the dictionary, use the setInport function and set the ReceiverService property to ReceiverDuringExe.

setInport(cm, 'InNVM', 'ReceiverService', 'ReceiverDuringExe')

See Also

| | |

Related Topics