Thread Subject: Compiling error with Level-1 M-File

Subject: Compiling error with Level-1 M-File

From: Pedro Villena

Date: 11 Jan, 2007 07:31:17

Message: 1 of 4

Hi,

I wrote a simple Level-1 M-File S-Functions, which I included in a
Simulink Diagram, and I tried to compile it with the Simulink Diagram
with RTWinTgt (Real-Time Windows Target) Toolbox Version 2.6
(R14SP3). I have used the rtwin.tlc System Target File, for the RTW
configuration.

The RTW gives a error in File: utillib.tlc Line: 403 Column: 8, and
in the Matlab Command Line prints the information about the TLC
Function Traceback.

I found that the error are generated by the File: simple_example.m
Line: 18 Column: 24. The change of the value of the sizes.NumOutputs
variable to 0, will produce no error in the compiling time. But with
this change the diagram lose the posibility to output the variable
and also gains some warnings.

sizes.NumOutputs = 0;

Please, Do you have some advice to solve this error correctly? Maybe,
I have to modify the RTWinTgt TLC Files, to make that the TLC files
work properly.

Regards,
Pedro Villena

**** - TLC Function Traceback ****
C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc:SLibReportError(403)
C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc:LibBlockReportFatalError(331)
C:\MATLAB71\rtw\c\tlc\blocks\gensfun.tlc:FcnGetAndCheckSFunctionType(1
23)
C:\MATLAB71\rtw\c\tlc\blocks\gensfun.tlc:BlockTypeSetup(370)
C:\MATLAB71\rtw\c\tlc\mw\commonpass.tlc(149)
**** - END TLC Function Traceback ****

*** RTW error ******************************************
Error: File: C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc Line: 403 Column:
8
%exit directive: Real-Time Workshop Fatal in block:
"testxldde00/S-Function", block type "S-Function": MFile S-functions
without a corresponding TLC file are not supported. You can inline
your S-function (simple_example) by creating a TLC file for it. You
can also remap your S-function to C by creating a corresponding C Mex
source file and a simple_example.tlc file in the same directory as
the MFile S-function which contains (on the first line):
  %% CallAsCMexLevel1
or
  %% CallAsCMexLevel2

*** simple_example.m ***********************************
01 function [sys,x0,str,ts] = simple_example(t,x,u,flag)
02 switch flag,
03 case 0,
04 [sys,x0,str,ts] = mdlInitializeSizes;
05 case 2,
06 sys = mdlUpdate(t,x,u);
07 case 3,
08 sys = mdlOutputs(t,x,u);
09 case 9,
10 sys = [];
11 otherwise
12 sys=[];
13 end

14 function [sys,x0,str,ts]=mdlInitializeSizes
15 sizes = simsizes;
16 sizes.NumContStates = 0;
17 sizes.NumDiscStates = 1;
18 sizes.NumOutputs = 1;
19 sizes.NumInputs = 1;
20 sizes.DirFeedthrough = 0;
21 sizes.NumSampleTimes = 1;
22 sys = simsizes(sizes);

23 x0 = 0;
24 str = [];
25 ts = [0 0];

26 function sys = mdlUpdate(t,x,u)
27 sys = u;

28 function sys = mdlOutputs(t,x,u)
29 sys = x;

Subject: Compiling error with Level-1 M-File S-Functions in RTWinTgt TLC Files

From: Leong Zhang

Date: 11 Jan, 2007 11:28:00

Message: 2 of 4

Do you have a tlc file with the same name as your Sfunction but with .tlc
extension?

- Leong

MFile S-functions
> without a corresponding TLC file are not supported.



"Pedro Villena" <pedro.villena@ieee.org> wrote in message
news:ef4acfd.-1@webcrossing.raydaftYaTP...
> Hi,
>
> I wrote a simple Level-1 M-File S-Functions, which I included in a
> Simulink Diagram, and I tried to compile it with the Simulink Diagram
> with RTWinTgt (Real-Time Windows Target) Toolbox Version 2.6
> (R14SP3). I have used the rtwin.tlc System Target File, for the RTW
> configuration.
>
> The RTW gives a error in File: utillib.tlc Line: 403 Column: 8, and
> in the Matlab Command Line prints the information about the TLC
> Function Traceback.
>
> I found that the error are generated by the File: simple_example.m
> Line: 18 Column: 24. The change of the value of the sizes.NumOutputs
> variable to 0, will produce no error in the compiling time. But with
> this change the diagram lose the posibility to output the variable
> and also gains some warnings.
>
> sizes.NumOutputs = 0;
>
> Please, Do you have some advice to solve this error correctly? Maybe,
> I have to modify the RTWinTgt TLC Files, to make that the TLC files
> work properly.
>
> Regards,
> Pedro Villena
>
> **** - TLC Function Traceback ****
> C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc:SLibReportError(403)
> C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc:LibBlockReportFatalError(331)
> C:\MATLAB71\rtw\c\tlc\blocks\gensfun.tlc:FcnGetAndCheckSFunctionType(1
> 23)
> C:\MATLAB71\rtw\c\tlc\blocks\gensfun.tlc:BlockTypeSetup(370)
> C:\MATLAB71\rtw\c\tlc\mw\commonpass.tlc(149)
> **** - END TLC Function Traceback ****
>
> *** RTW error ******************************************
> Error: File: C:\MATLAB71\rtw\c\tlc\lib\utillib.tlc Line: 403 Column:
> 8
> %exit directive: Real-Time Workshop Fatal in block:
> "testxldde00/S-Function", block type "S-Function": MFile S-functions
> without a corresponding TLC file are not supported. You can inline
> your S-function (simple_example) by creating a TLC file for it. You
> can also remap your S-function to C by creating a corresponding C Mex
> source file and a simple_example.tlc file in the same directory as
> the MFile S-function which contains (on the first line):
> %% CallAsCMexLevel1
> or
> %% CallAsCMexLevel2
>
> *** simple_example.m ***********************************
> 01 function [sys,x0,str,ts] = simple_example(t,x,u,flag)
> 02 switch flag,
> 03 case 0,
> 04 [sys,x0,str,ts] = mdlInitializeSizes;
> 05 case 2,
> 06 sys = mdlUpdate(t,x,u);
> 07 case 3,
> 08 sys = mdlOutputs(t,x,u);
> 09 case 9,
> 10 sys = [];
> 11 otherwise
> 12 sys=[];
> 13 end
>
> 14 function [sys,x0,str,ts]=mdlInitializeSizes
> 15 sizes = simsizes;
> 16 sizes.NumContStates = 0;
> 17 sizes.NumDiscStates = 1;
> 18 sizes.NumOutputs = 1;
> 19 sizes.NumInputs = 1;
> 20 sizes.DirFeedthrough = 0;
> 21 sizes.NumSampleTimes = 1;
> 22 sys = simsizes(sizes);
>
> 23 x0 = 0;
> 24 str = [];
> 25 ts = [0 0];
>
> 26 function sys = mdlUpdate(t,x,u)
> 27 sys = u;
>
> 28 function sys = mdlOutputs(t,x,u)
> 29 sys = x;

Subject: Compiling error with Level-1 M-File

From: Pedro Villena

Date: 12 Jan, 2007 03:59:07

Message: 3 of 4

I made this question, by the cause of a previous test that I had made
with a Level-1 M-File S-Function only with a input signal (see
example_input.m), and I hadn't needed a TLC-File for to compile this
test with rtWinTgt (rtwin.tlc + rtwin.tmf).

So, if I need a TLC-File for a Level-1 M-File S-Function with a
output signal (s_ex.m + s_ex.tlc). Could you send me an example? I
saw every example in the MatLab Help and Documentation and read all
the documentation of RTWinTgt Toolbox, and I didn't found a example
with these characteristics (Level-1 M-File S-Function + TLC-File).

Regards,
Pedro Villena

*** example_input.m **********************************
01 function [sys,x0,str,ts] = example_input(t,x,u,flag)
02 switch flag,
03 case 0,
04 [sys,x0,str,ts] = mdlInitializeSizes;
05 case 2,
06 sys = mdlUpdate(t,x,u);
07 case 9,
08 sys = [];
09 otherwise
10 sys=[];
11 end
 
12 function [sys,x0,str,ts]=mdlInitializeSizes
13 sizes = simsizes;
14 sizes.NumContStates = 0;
15 sizes.NumDiscStates = 1;
16 sizes.NumOutputs = 0;
17 sizes.NumInputs = 1;
18 sizes.DirFeedthrough = 0;
19 sizes.NumSampleTimes = 1;
20 sys = simsizes(sizes);
 
21 x0 = 0;
22 str = [];
23 ts = [0 0];
 
24 function sys = mdlUpdate(t,x,u)
25 sys = u;

 
Leong Zhang wrote:
>
> Do you have a tlc file with the same name as your Sfunction but
with .tlc extension?
>
> - Leong
>
> MFile S-functions without a corresponding TLC file are not
supported.

Subject: Compiling error with Level-1 M-File

From: Xiao Ma

Date: 17 Jan, 2008 21:47:02

Message: 4 of 4

Hi,I met the same problem now.
Have you had any solutions to this?
Or we can just rewrite a C-Mex file S-function and then
create a tlc file for it.

you can send me an email for discussing this.
copyfriend@hotmail.com

Thanks


"Pedro Villena" <pedro.villena@ieee.org> wrote in message
<ef4acfd.1@webcrossing.raydaftYaTP>...
> I made this question, by the cause of a previous test
that I had made
> with a Level-1 M-File S-Function only with a input signal
(see
> example_input.m), and I hadn't needed a TLC-File for to
compile this
> test with rtWinTgt (rtwin.tlc + rtwin.tmf).
>
> So, if I need a TLC-File for a Level-1 M-File S-Function
with a
> output signal (s_ex.m + s_ex.tlc). Could you send me an
example? I
> saw every example in the MatLab Help and Documentation
and read all
> the documentation of RTWinTgt Toolbox, and I didn't found
a example
> with these characteristics (Level-1 M-File S-Function +
TLC-File).
>
> Regards,
> Pedro Villena
>
> *** example_input.m **********************************
> 01 function [sys,x0,str,ts] = example_input(t,x,u,flag)
> 02 switch flag,
> 03 case 0,
> 04 [sys,x0,str,ts] = mdlInitializeSizes;
> 05 case 2,
> 06 sys = mdlUpdate(t,x,u);
> 07 case 9,
> 08 sys = [];
> 09 otherwise
> 10 sys=[];
> 11 end
>
> 12 function [sys,x0,str,ts]=mdlInitializeSizes
> 13 sizes = simsizes;
> 14 sizes.NumContStates = 0;
> 15 sizes.NumDiscStates = 1;
> 16 sizes.NumOutputs = 0;
> 17 sizes.NumInputs = 1;
> 18 sizes.DirFeedthrough = 0;
> 19 sizes.NumSampleTimes = 1;
> 20 sys = simsizes(sizes);
>
> 21 x0 = 0;
> 22 str = [];
> 23 ts = [0 0];
>
> 24 function sys = mdlUpdate(t,x,u)
> 25 sys = u;
>
>
> Leong Zhang wrote:
> >
> > Do you have a tlc file with the same name as your
Sfunction but
> with .tlc extension?
> >
> > - Leong
> >
> > MFile S-functions without a corresponding TLC file are
not
> supported.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com