C S-Function to TLC conversion sytax help needed

11 ビュー (過去 30 日間)
Rich
Rich 2012 年 2 月 6 日
編集済み: Image Analyst 2013 年 10 月 7 日
I need some help converting some simple C code from an S-Function to a TLC file, but I'm not familiar with the syntax enough to do so. I'm not even sure if it can be done or not.
Here's the C code:
/* Function: mdlOutputs =======================================================*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
union {real32_T x; uint8_T c[4];} sp;
real32_T *in;
uint8_T *out[4];
int_T i;
in = (real32_T *) ssGetInputPortSignal(S, 0);
sp.x = *in;
for (i=0; i<4; i++)
{
out[i] = (uint8_T *) ssGetOutputPortSignal(S, i);
*(out[i]) = sp.c[i];
}
}

採用された回答

Rich
Rich 2012 年 2 月 9 日
Figured it out...
%%File : sfun_Single2FourBytes.tlc
%%Description:
Real-Time Workshop interface for S-function "sfun_Single2FourBytes.c"
%implements sfun_Single2FourBytes "C"
%function Outputs(block, system) Output
/* S-Function "sfun_Single2FourBytes" Block: %<Name> */
%assign in = LibBlockInputSignal(0, "", "", 0)
{
union {real32_T x; uint8_T c[4];} sp;
sp.x = %<in>;
%foreach i = 4
%assign out = LibBlockOutputSignal(i, "", "", 0)
%<out> = sp.c[%<i>];
%endforeach
}
%endfunction
%%[EOF] sfun_Single2FourBytes.tlc
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 2 月 9 日
Thanks for posting back with the answer!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by