C S-Function to TLC conversion sytax help needed

12 Ansichten (letzte 30 Tage)
Rich
Rich am 6 Feb. 2012
Bearbeitet: Image Analyst am 7 Okt. 2013
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];
}
}

Akzeptierte Antwort

Rich
Rich am 9 Feb. 2012
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

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by