Effacer les filtres
Effacer les filtres

Is possible to collect a string in the mask ? (Embedded Coder)

6 vues (au cours des 30 derniers jours)
Carlos
Carlos le 7 Juin 2012
Hi, I'm generating a driver to generate C code, and I need to pass one string from mask to the generated code. Is possible to pass this string from Simulink, with S-function or mytlc.tlc? I have thought that I can pass a string collecting the block name from mytlc.tlc, but it isn't the correct form. Thanks in advance

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 7 Juin 2012
Yes, I think this should be possible if you register the parameter as nontunable. You will need to implement the mdlRTW method in the S-function and write the parameter using ssWriteRTWParamSettings - the TLC file can access its value from the SFcnParamSettings record . Also, uncheck the "Evaluate" box for the parameter on the Mask .
  4 commentaires
Suraj Nagaraj
Suraj Nagaraj le 13 Déc 2014
Modifié(e) : Walter Roberson le 15 Déc 2015
I dont think this works. I'm missing something trivial, can you please help
S-Function CODE SNIPPET
#define MASK_PARAM_NAME1(S) ssGetSFcnParam(S,1)
#define MASK_PARAM_NAME2(S) ssGetSFcnParam(S,2)
#define MDL_RTW
static void mdlRTW ( SimStruct * S )
{
const char_T *testTLCStr = "maskParam1TLCName";
const char_T *maskParam1TLCName = (const char_T *) (mxGetData(MASK_PARAM_NAME1(S)));
const char_T *maskParam2TLCName = (const char_T *) (mxGetData(MASK_PARAM_NAME2(S)));
if (!ssWriteRTWParamSettings(S, 2,
SSWRITE_VALUE_QSTR,
"maskParam1Name",
testTLCStr,
SSWRITE_VALUE_STR,
"maskParam2Name",
maskParam2TLCName)) {
return; /* An error occurred which will be reported by SL */
}
ssWriteRTWStrParam(S, "maskParam1NewTLCName", maskParam1TLCName);
}
Mask Parameter 1 is
'maskParam1TLCName'
Mask Parameter 2 is
'maskParam2TLCName'
TLC CODE SNIPPET
%assign maskParam1TLCName = SFcnParamSettings.maskParam1Name
%assign maskParam2TLCName = SFcnParamSettings.maskParam2Name
testStringFromMaskFcn( (uint32_T*)&%<maskParam1TLCName>,
(uint32_T*)&%<maskParam2TLCName> );
testStringFromMaskFcn( (uint32_T*)&%<maskParam1TLCName>,
(uint32_T*)"%<maskParam1NewTLCName>");
AUTO GEN CODE SNIPPET
testStringFromMaskFcn( (uint32_T*)&maskParam1TLCName,
(uint32_T*)&);
testStringFromMaskFcn( (uint32_T*)"m",
(uint32_T*)&);
In the above ssWriteRTWParamSettings case only testTLCStr goes through in the form of a string to auto-gen code however maskParam1TLCName and maskParam2TLCName do not go through.
Also in case of ssWriteRTWStrParam only the first character of maskParam1TLCName goes through to auto-gen code
Walter Roberson
Walter Roberson le 15 Déc 2015
shuming comments
yup! This method works! I successfully pass in string variable using Edit UI. Then, retrieve the string parameter in using TLC file (Code generation)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by