Compiling/inlining an M-file S-Function (which calls a MEX file)

Hello,
working with Real-Time Workshop (7.6.1) for the first time I am a bit unsure about the possibilities and whether I'm on the right track at all.
I wrote a relatively simple Level-2 MATLAB S-Function which converts its input to a string and utilizes Peter Rydesäter's TCP/UDP/IP toolbox to set up a UDP socket and send data. The TCP toolbox is made up by the source file, pnet.c, and the compiled pnet.mexw32, which I guess I call in my S-function.
The documentation regarding inlining S-functions contains a simple example for writing a TLC file, but as far as I understand that, it is merely replicating the output generation of the S-function in TLC code. Is that what TLC files do? Is there a chance to do the same for my task?
I'm still quite lost, so I'd appreciate any hints.
Thank you
Silvan

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 11월 21일

0 개 추천

Yes, TLC files do indeed define how the outputs are to be calculated in the generated code (this may or may not match simulation - although that is preferred). For example, an S-function that is supposed to represent an LCD Display driver may do nothing in simulation, but generates code that calls into the LCD Display API for the target platform.
In your case, you will need to find the C/C++ equivalent of the TCP toolbox functions that you are currently calling, and call into those C/C++ functions in your TLC code. You can then compile those C files into the generated code. You may contact the author of the toolbox in question to see if they can provide a native binary for your target platform. Since they are already using MEX-functions underneath, it is possible that they are calling into C libraries already.

댓글 수: 1

If I recall, that contribution is based upon the fairly standard netcat distribution, which can be downloaded from a number of places.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Silvan
Silvan 2011년 11월 23일

0 개 추천

Thank you for your answers! As my M-file S-function is basically useless for Real-Time Workshop -- and not too complicated anyway -- I have started to implement it as a C MEX S-function.

댓글 수: 1

Silvan: Even if you implement your S-function as a C-MEX S-function, I think you might still need to deal with the problem of calling MEX-functions underneath. MEX-functions need MATLAB-based libraries to execute and would never run in a standalone environment.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by