WriteRTW in a M Level2 S-Function
Mostrar comentarios más antiguos
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?
Respuestas (1)
Kaustubha Govind
el 13 de Nov. de 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 comentarios
Thomas
el 14 de Nov. de 2012
Thomas
el 14 de Nov. de 2012
Kaustubha Govind
el 15 de Nov. de 2012
What is the generated code when you simply enter 192.168.1.13?
Thomas
el 20 de Nov. de 2012
Kaustubha Govind
el 26 de Nov. de 2012
Thomas: Could you paste the error message please?
Thomas
el 27 de Nov. de 2012
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!