필터 지우기
필터 지우기

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

조회 수: 11 (최근 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 CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by