Main Content

FunctionPortSpecification

Query and configure C Caller block properties

Since R2019b

Description

Query and configure the C Caller block function definition and return argument. Configure the C Caller block input arguments programmatically.

Creation

myCCallerObj = get_param(gcb, 'FunctionPortSpecification') creates a C Caller block configuration object for the selected C Caller block.

Properties

expand all

Displays the mapping of the C function input to the C Caller block in the model. You cannot edit this property using the command line. To edit the C function mapping, edit the source code of the C Caller block.

Example: real_T add(real_T u1, real_T u2);

Data Types: char

Returns the list of function input arguments in a FunctionArgument Object.

Returns a scalar or an empty FunctionArgument Object.

Data Types: char

Returns a scalar or an empty FunctionArgument Object.

Data Types: char

FunctionArgument Object

The FunctionArgument is a class that carries port specification information of a C Caller block programmatically. The FunctionArgument object has these properties:

  1. Name — Name of the variable in the source code, specified as a character vector. This property is read-only.

  2. PortNumber — Port number of the InputArgument that has been edited, specified as uint32. This property is read-only.

  3. Size — Size of the Simulink® port dimensions specified as a character vector. You can edit this property if it is allowed in the function definition.

  4. Type — Simulink data type for the specified port specified as a character vector. You can edit this property if it is allowed in the function definition.

  5. Label — Port label on the Simulink block specified as a character vector. You can change the port label programmatically, for example:

    myCCallerObj.my_CCaller.InputArguments(1).Label = 'inputport1'
    my_CCallerObj = 
    
      FunctionPortSpecification with properties:
    
            CPrototype:  'real_T add(real_T u1, real_T u2);'
        InputArguments:  [1×2 Simulink.CustomCode.FunctionArgument]
        ReturnArgument:  [1×1 Simulink.CustomCode.FunctionArgument]
        GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]

  6. Scope — Mapping of the Simulink scope to the input argument specified as a character vector. If the variable is defined as a constant qualifier, the argument can be an input or a parameter. If no constant qualifier exists, you can change an output argument to an input, inputoutput, or to a parameter. If your scope fits any of the scenarios above, you can change it programmatically:

    my_CCallerObj.InputArguments(1).Scope = 'parameter'
    my_CCallerObj = 
    
      FunctionPortSpecification with properties:
    
            CPrototype:  'extern real_T add(real_T u1, real_T u2);'
        InputArguments:  [1×2 Simulink.CustomCode.FunctionArgument]
        ReturnArgument:  [1×1 Simulink.CustomCode.FunctionArgument]
        GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]

Object Functions

getGlobalArgGet an object definition of a global variable in a C Caller block

Examples

Create a C Caller Configuration Object

This example creates a C Caller configuration object using the 'slexCCallerExample' demo model.

my_CCallerObj = get_param('slexCCallerExample/C Caller','FunctionPortSpecification')
my_CCallerObj = 

  FunctionPortSpecification with properties:

        CPrototype:  'real_T add(real_T u1, real_T u2);'
    InputArguments:  [1×2 Simulink.CustomCode.FunctionArgument]
    ReturnArgument:  [1×1 Simulink.CustomCode.FunctionArgument]
    GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]
Create a FunctionArgument object for the 1st input port:
inargone = my_CCallerObj.InputArguments(1)
inargone = 

  FunctionArgument with properties:

          Name: 'u1'
    PortNumber: 1
          Size: '1'
          Type: 'double'
         Label: 'u1'
         Scope: 'Parameter'
Change the label for the first input port:
inargone.Label = 'inputport1'
inargone = 

  FunctionArgument with properties:

          Name: 'u1'
    PortNumber: 1
          Size: '1'
          Type: 'double'
         Label: 'inputport1'
         Scope: 'Parameter'

Version History

Introduced in R2019b