WriteRTW in a M Level2 S-Function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi.
I like to write a TLC to inline a Matlab level2 S-Function. Making the S-Function ready for code-generation.
To access the parameter in the RT-Code, I have to write a "WriteRTW" Function. For Arrays it is not a problem, but I don't know how to handle with strings.
M-File:
...
function WriteRTW(block)
b =char([block.DialogPrm(1).Data 0]);
block.WriteRTWParam('matrix', 'Params', cast(b,'uint8'));
%end Terminate
...
TLC-File:
...
char ip[13];
ip[0] = (char)(uint8_T)%<ParamSettings.Params[0][0]>;
ip[1] = (char)(uint8_T)%<ParamSettings.Params[0][1]>;
ip[2] = (char)(uint8_T)%<ParamSettings.Params[0][2]>;
ip[3] = (char)(uint8_T)%<ParamSettings.Params[0][3]>;
ip[4] = (char)(uint8_T)%<ParamSettings.Params[0][4]>;
ip[5] = (char)(uint8_T)%<ParamSettings.Params[0][5]>;
ip[6] = (char)(uint8_T)%<ParamSettings.Params[0][6]>;
ip[7] = (char)(uint8_T)%<ParamSettings.Params[0][7]>;
ip[8] = (char)(uint8_T)%<ParamSettings.Params[0][8]>;
ip[9] = (char)(uint8_T)%<ParamSettings.Params[0][9]>;
ip[10] = (char)(uint8_T)%<ParamSettings.Params[0][10]>;
ip[11] = (char)(uint8_T)%<ParamSettings.Params[0][11]>;
ip[12] = (char)(uint8_T)%<ParamSettings.Params[0][12]>;
...
I like to use it in this way:
block.WriteRTWParam('string', 'Params', block.DialogPrm(1).Data);
Can someone help me?
0 commentaires
Réponses (1)
Kaustubha Govind
le 13 Nov 2012
I experimented a little with the demo file sldemo_msfcn_frame and the contained S-function (run edit msfcn_frame_filt to see the source code), it seems that you should be able towrite:
M-File:
...
function WriteRTW(block)
block.WriteRTWParam('string', 'MyStringParam', block.DialogPrm(1).Data);
...
TLC-File:
%assign myParam = ParamSettings.MyStringParam
const char ip[] = "%<myParam>";
Does this work?
6 commentaires
Voir également
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!