Simulink TCP/IP Client Send/Receive

17 次查看(过去 30 天)
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 个评论
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
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