Socket Programming with C-Mex

조회 수: 10 (최근 30일)
Jason
Jason 2011년 9월 12일
답변: Silmara da Silva Palmieri 2019년 3월 25일
Hello,
I'm in need of setting up a TCP/IP connection to a Simulink simulation (which will employ a demodulator). I am using RTW (Simulink Coder) to output C Code and an exe for the demod.
I need to send the data to the generated executable via TCP/IP. I'm currently looking to accomplish this via sockets through a C-Mex implementation with an S-function block.
I have C++ server and client code that compiles (and runs via cmd line - Windows XP 32 bit) but crashes MATLAB upon execution.
Any thoughts as to what may be causing the crashing or better ways to implement this architecture would be greatly appreciated.
Thanks,
Jason
  댓글 수: 1
Jason
Jason 2011년 9월 12일
More details:
The code is here:
http://msdn.microsoft.com/en-us/library/ms737593%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms737591%28v=vs.85%29.aspx
After a successful compile with Mex I run the server and get:
------------------------------------------------------------------------
Segmentation violation detected at Mon Sep 12 15:34:23 2011
------------------------------------------------------------------------
Configuration:
MATLAB Version: 7.11.0.584 (R2010b)
MATLAB License: 115723
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 3)
Processor ID: x86 Family 6 Model 10 Stepping 7, GenuineIntel
Virtual Machine: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Default Encoding: windows-1252
Fault Count: 3
Abnormal termination:
Register State (from fault):
EAX = 00000000 EBX = 00000000
ECX = 1d6f7250 EDX = 00000000
ESP = 00c2e71c EBP = 00c2e71c
ESI = 00c2ee3c EDI = 1d225d70
EIP = 7bce1d76 EFL = 00010297
CS = 0000001b DS = 00000023 SS = 00000023
ES = 00000023 FS = 0000003b GS = 00000000
...

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

답변 (2개)

Ed Laurence
Ed Laurence 2011년 11월 5일
Hi Jason,
Did you get anywhere with this problem? I've been trying to get something similar working where I've embedded C code for a WinSock client in a level 2 S-function but as soon as I run the simulation Simulink hangs. I've tried debugging by attaching the MEX file to VS 2008 and have found some errors relating to invalid parameters passed to the C function but haven't managed to solve it yet.
Cheers,
Ed

Silmara da Silva Palmieri
Silmara da Silva Palmieri 2019년 3월 25일
Hi Ed,
Did you get any answer regarding this problem? I am facing the same issue and have no clue how to check where is my problem.
Thank you!
Regards,
Silmara

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by