Azzera filtri
Azzera filtri

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

6 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Kaustubha Govind
Kaustubha Govind il 7 Giu 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 Commenti
Suraj Nagaraj
Suraj Nagaraj il 13 Dic 2014
Modificato: Walter Roberson il 15 Dic 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 il 15 Dic 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)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by