Main Content

ssCallSimulinkFunction

Call a declared Simulink function of a given function prototype at run time.

Syntax

void ssCallSimulinkFunction(SimStruct *S, char *scopedFcnName, int_T numInArgs, _ssFcnCallExecArgInfo* execInArgs, int_T numOutArgs, _ssFcnCallExecArgInfo* execOutArgs)

Arguments

S

SimStruct that represents an S-Function block.

scopedFcnName

Scoped name of a Simulink® function. Function must have previously been declared using ssDeclareFunctionCaller.

numInArgs

Number of input arguments.

execInArgs

Pointer to a valid array of _ssFcnCallExecArgInfo struct. The struct fields dataPtr and dataSize are associated with a pre-assigned memory buffer corresponding to the Simulink function argument.

numOutArgs

Number of output arguments.

execOutArgs

Pointer to a valid array of _ssFcnCallExecArgInfo struct. The struct fields dataPtr and dataSize are associated with a pre-assigned memory buffer corresponding to the Simulink function argument.

Note

The _ssFcnCallExecArgInfo struct type is defined in simstruc_types.h as the following:

typedef struct _ssFcnCallExecArgInfo_tag {
    void* dataPtr;
    int_T dataSize;
    void* reserved;
} _ssFcnCallExecArgInfo;

Returns

No return value.

Description

ssCallSimulinkFunction calls a declared Simulink function at run-time. Before using it, ssDeclareFunctionCaller is required to declare the Simulink function prototype to be called in the compile-time method mdlInitializeSizes. To implement a Simulink function with S-Function API, ssDeclareSimulinkFunction can specify the Simulink function implementation at compile time.ssCallSimulinkFunction calls a declared Simulink function at run-time.

Examples

_ssFcnCallExecArgInfo inArgs[1];
_ssFcnCallExecArgInfo outArgs[1];
double inArray[3] = {1, 2, 3};
double outArray[3] = {0, 0, 0};
inArgs [0].dataPtr = inArray;
inArgs [0].dataSize = sizeof(inArray);
outArgs[0].dataPtr = outArray;
outArgs[0].dataSize = sizeof(outArray);
ssCallSimulinkFunction(S, "timestwo", 1, inArgs, 1, outArgs);

Languages

C, C++

Version History

Introduced in R2018a