Effacer les filtres
Effacer les filtres

Simulink TCP/IP Client Send/Receive

28 vues (au cours des 30 derniers jours)
Noman Saied
Noman Saied le 1 Août 2019
Commenté : 鹏铖 le 26 Sep 2024 à 9:29
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 commentaires
Rajani Mishra
Rajani Mishra le 7 Août 2019
Can you provide your Simulink model
Noman Saied
Noman Saied le 7 Août 2019
Modifié(e) : Noman Saied le 7 Août 2019
thanks for your reply, I updated the original post by attaching an example, please let me know if this helps.

Connectez-vous pour commenter.

Réponses (1)

Rajani Mishra
Rajani Mishra le 19 Août 2019
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.
  2 commentaires
Francisco Gonzalez-Longatt
Francisco Gonzalez-Longatt le 9 Août 2021
Dear Rajani, Do you know if this issue have been solved? I still having it. Thanks in advance for your help and support.
鹏铖
鹏铖 le 26 Sep 2024 à 9:29
have you solved the question

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by