developing inline s-function driver block

6 次查看(过去 30 天)
Hi,
I'm developing inline s-function driver block. I have created the .c .tlc and .mex32 files, and I also created the necessary library. And I put all this files in Matlab path. But when I want to generate C files with RTW appears this error:
Error using ==> rtwgen --> Error in S-function myModel/model_DI': S-Function 'model_DI' does not exist.
If I put all the files in the WORK folder I don't have this problem but after I can't pass information from Model to generate files through function MdlRTW because then 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.
Thanks in advance

采纳的回答

Kaustubha Govind
Kaustubha Govind 2011-11-11
Did you add the S-function and corresponding TLC to a directory under the $matlabroot/toolbox folder by any chance? If yes, you may need to run "rehash toolboxcache" for MATLAB to recognize new folders under this directory structure. (Although it is recommended that you place your files outside of the MATLAB installation root, because it could get wiped during upgrades or at un-install) Once you have done that, run "which model_DI" to make sure that MATLAB finds the MEX-file.
Regarding the error about parameters - could you include some code snippets about how you're registering your run-time parameters and how you use them in your mdlRTW function?
  2 个评论
Carlos
Carlos 2011-11-14
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)
...
Kaustubha Govind
Kaustubha Govind 2011-11-14
Answered on your new question: http://www.mathworks.com/matlabcentral/answers/21172-passing-information-parameters-from-simulink-to-embedded-code-generated

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Target Language Compiler 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by