Simulink TCP/IP Client Send/Receive

조회 수: 17 (최근 30일)
Noman Saied
Noman Saied 2019년 8월 1일
Simulink TCP/IP Client Send and receive works on same computer but not between 2 computers any suggestion? If I write a code it works but not using Simulink
This matlab code working between the same 2 computers fine:
PC1:
t = tcpip('192.168.10.203', 50000, 'NetworkRole', 'server');
fopen(t);
k = 1;
while t.BytesAvailable == 0
fprintf('Found Data %d\n', k);
k = k + 1;
pause(.05)
end
data = fread(t, floor(t.BytesAvailable / 8), 'double');
fprintf('Server: %.12f\n', data);
fprintf('Done...\n');
Output:
Found Data 1
Found Data 2
Found Data 3
Server: 3.141592650000
Done...
Elapsed time is 2.849084 seconds.
>>
PC2:
data = 3.14159265;
fprintf('Client: %.12f\n', data);
t = tcpip(192.168.10.202', 50000, 'NetworkRole', 'client');
fopen(t);
pause(1);
fwrite(t, data, 'double');
fprintf('Done...\n');
Output:
Client: 3.141592650000
Done ...
Elapsed time is 0.104154 seconds.
Screenshot01: This works in the same compute no issues
Screenshots02: The same setting 2 different comuters not working no error no worning.
Any Help will be appreciated.
email: noman-saied@utc.edu
Updated: Attached samePC_example.slx this can be breaked into send/recieve to acommodate 2 different PCs (for sure you will need to adjust IP addressing) aslo you will need to run this command
echotcpip('ON', 50000);
to enable the socekt in matlab
  댓글 수: 2
Rajani Mishra
Rajani Mishra 2019년 8월 7일
Can you provide your Simulink model
Noman Saied
Noman Saied 2019년 8월 7일
편집: Noman Saied 2019년 8월 7일
thanks for your reply, I updated the original post by attaching an example, please let me know if this helps.

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

답변 (1개)

Rajani Mishra
Rajani Mishra 2019년 8월 19일
Hi,
The TCP/IP Client Send and Client Receive blocks are both client blocks, operate only in TCP/IP client mode (they need to connect to a TCP/IP server) These blocks do not support TCP/IP server functionality. You can use a MATLAB function block to achieve the communication or UDP Send and UDP Receive blocks.
This issue is known and the concerned parties may be looking into it.
  댓글 수: 1
Francisco Gonzalez-Longatt
Francisco Gonzalez-Longatt 2021년 8월 9일
Dear Rajani, Do you know if this issue have been solved? I still having it. Thanks in advance for your help and support.

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

카테고리

Help CenterFile Exchange에서 Development Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by