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

8 views (last 30 days)
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

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 7 Jun 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 Comments
Suraj Nagaraj
Suraj Nagaraj on 13 Dec 2014
Edited: Walter Roberson on 15 Dec 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 on 15 Dec 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)

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!