Simulink TCP/IP Client Send/Receive

17 visualizaciones (últimos 30 días)
Noman Saied
Noman Saied el 1 de Ag. de 2019
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 comentarios
Rajani Mishra
Rajani Mishra el 7 de Ag. de 2019
Can you provide your Simulink model
Noman Saied
Noman Saied el 7 de Ag. de 2019
Editada: Noman Saied el 7 de Ag. de 2019
thanks for your reply, I updated the original post by attaching an example, please let me know if this helps.

Iniciar sesión para comentar.

Respuestas (1)

Rajani Mishra
Rajani Mishra el 19 de Ag. de 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.
  1 comentario
Francisco Gonzalez-Longatt
Francisco Gonzalez-Longatt el 9 de Ag. de 2021
Dear Rajani, Do you know if this issue have been solved? I still having it. Thanks in advance for your help and support.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by