Hi,
I'm developing inline s-function driver block. I have created the .c .tlc and .mex32 files.
These blocks have a mask with 4 parameters, and I want to pass parameters to the files generated by RTW tool, but when I try to generate the code I have this error:
Error using ==> rtwgen Error in mdlRTW of S-function myModel/model_DI'. This function wrote 0 run-time parameters where as it has registered 4 run-time parameters.
I try to do so:
In my driver, at the top of my .c I have this:
#define param1(S) (mxGetScalar(ssGetSFcnParam(S,1))) #define param2(S) (mxGetScalar(ssGetSFcnParam(S,2))) #define param3(S) (mxGetScalar(ssGetSFcnParam(S,3)))
Then this is the MdlRTW function:
#define MDL_RTW static void mdlRTW(SimStruct *S) {uint8_T Numparam1, Numparam2, Numparam3;Numparam1=(uint8_T)param1(S); if( Numparam1<0 Numparam1>15 ) { sprintf(msg,"Número incorrecto de Numparam1 %d", Numparam1); ssSetErrorStatus(S,msg); return; }Numparam2=(uint8_T)param2(S); if( Numparam2<0 Numparam2>15 ) { sprintf(msg,"Número incorrecto de Numparam2 %d", Numparam2); ssSetErrorStatus(S,msg); return; }Numparam3=(uint8_T)param3(S); if( Numparam3<0 Numparam3>1 ) { sprintf(msg,"Número incorrecto de Numparam3 %d", Numparam3); ssSetErrorStatus(S,msg); return; }// Write out the parameters for this block. if (!ssWriteRTWParamSettings(S, 3, SSWRITE_VALUE_DTYPE_NUM, "Numparam1", &Numparam1, DTINFO (SS_UINT8, COMPLEX_NO), SSWRITE_VALUE_DTYPE_NUM, "Numparam2", &Numparam2, DTINFO (SS_UINT8, COMPLEX_NO), SSWRITE_VALUE_DTYPE_NUM, "Numparam3", &Numparam3, DTINFO (SS_UINT8, COMPLEX_NO))) { sprintf(msg,"Error al pasar parametros de la mascara a model.rtw"); ssSetErrorStatus(S,msg); return; // An error occurred which will be reported by SL } }
And then, to pick in my .tlc I have:
%%Function: mdlOutputs ========================================================
%function Outputs(block, system) Output /* %<Type> Block: %<Name> */
{ %assign Numparam1= CAST( "Number",SFcnParamSettings.Numparam1)
%assign Numparam2= CAST( "Number",SFcnParamSettings.Numparam2)
%assign Numparam3= CAST( "Number",SFcnParamSettings.Numparam3)
...
Best Answer