フィルターのクリア

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

6 ビュー (過去 30 日間)
Carlos
Carlos 2012 年 6 月 7 日
編集済み: Walter Roberson 2015 年 12 月 15 日
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

採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 6 月 7 日
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 件のコメント
Suraj Nagaraj
Suraj Nagaraj 2014 年 12 月 13 日
編集済み: Walter Roberson 2015 年 12 月 15 日
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 2015 年 12 月 15 日
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)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by