WriteRTW in a M Level2 S-Function

1 visualización (últimos 30 días)
Thomas
Thomas el 13 de Nov. de 2012
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
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
Kaustubha Govind
Kaustubha Govind el 26 de Nov. de 2012
Thomas: Could you paste the error message please?
Thomas
Thomas el 27 de Nov. de 2012
Matlab Level-2 S-function of myUserBlock:
...
function WriteRTW(block)
block.WriteRTWParam('string', 'MyStringParam', '192.168.1.13');
%end Terminate
...
Error:
### Starting build procedure for model: Model
### Generating code into build folder: C:\...
### Invoking Target Language Compiler on Model.rtw
### Using System Target File: C:\...\ert.tlc
Error: File: C:\...\Model_ert_rtw\Model.rtw Line: 2466 Column: 24
syntax error
### Build procedure for model: 'Model' aborted due to an error.
Model.rtw:
...
MFile MyUserBlock
runAccelOnTLC no
isSimViewDevice no
Start Start
Outputs Outputs
MyStringParam 192.168.1.13
...

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by