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 Center および File ExchangeDevelopment Computer Setup についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by