Skip to Main Content Skip to Search
Product Documentation

Converting Level-1 C MEX S-Functions to Level-2

Guidelines for Converting Level-1 C MEX S-Functions to Level-2

Level-2 S-functions were introduced with Simulink version 2.2. Level-1 S-functions refer to S-functions that were written to work with Simulink version 2.1 and previous releases. Level-1 S-functions are compatible with Simulink version 2.2 and subsequent releases; you can use them in new models without making any code changes. However, to take advantage of new features in S-functions, Level-1 S-functions must be updated to Level-2 S-functions. Here are some guidelines:

Obsolete Macros

The following macros are obsolete. Replace each obsolete macro with the macro specified in the following table.

Obsolete MacroReplace with
ssGetU(S), ssGetUPtrs(S)ssGetInputPortSignalPtrs(S,port), ssGetInputPortSignal(S,port)
ssGetY(S)ssGetOutputPortRealSignal(S,port)
ssGetX(S)ssGetContStates(S), ssGetRealDiscStates(S)
ssGetStatus(S) Normally not used, but ssGetErrorStatus(S) is available.
ssSetStatus(S,msg) ssSetErrorStatus(S,msg)
ssGetSizes(S) Specific call for the wanted item (i.e., ssGetNumContStates(S))
ssGetMinStepSize(S)No longer supported
ssGetPresentTimeEvent(S,sti)ssGetTaskTime(S,sti)
ssGetSampleTimeEvent(S,sti)ssGetSampleTime(S,sti)
ssSetSampleTimeEvent(S,t)ssSetSampleTime(S,sti,t)
ssGetOffsetTimeEvent(S,sti)ssGetOffsetTime(S,sti)
ssSetOffsetTimeEvent(S,sti,t)ssSetOffsetTime(S,sti,t)
ssIsSampleHitEvent(S,sti,tid) ssIsSampleHit(S,sti,tid)
ssGetNumInputArgs(S) ssGetNumSFcnParams(S)
ssSetNumInputArgs(S, numInputArgs)ssSetNumSFcnParams(S,numInputArgs)
ssGetNumArgs(S)ssGetSFcnParamsCount(S)
ssGetArg(S,argNum)ssGetSFcnParam(S,argNum)
ssGetNumInputsssGetNumInputPorts(S) and ssGetInputPortWidth(S,port)
ssSetNumInputsssSetNumInputPorts(S,nInputPorts) and ssSetInputPortWidth(S,port,val)
ssGetNumOutputsssGetNumOutputPorts(S) and ssGetOutputPortWidth(S,port)
ssSetNumOutputsssSetNumOutputPorts(S,nOutputPorts) and ssSetOutputPortWidth(S,port,val)


[1] UNIX is a registered trademark of The Open Group in the United States and other countries.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS