WriteRTW in a M Level2 S-Function
Mostra commenti meno recenti
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?
Risposte (1)
Kaustubha Govind
il 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 Commenti
Thomas
il 14 Nov 2012
Thomas
il 14 Nov 2012
Kaustubha Govind
il 15 Nov 2012
What is the generated code when you simply enter 192.168.1.13?
Thomas
il 20 Nov 2012
Kaustubha Govind
il 26 Nov 2012
Thomas: Could you paste the error message please?
Thomas
il 27 Nov 2012
Categorie
Scopri di più su Simulink Coder in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!