hi, I want to make matlab communicate (several socket MATLAB customers) with a socket server (which is not matlab) via TCP/IP communication in real time but I have a delay pro

1 visualización (últimos 30 días)
Here is the identical code of customers matlab
t = tcpip('127.0.0.1', 7777, 'NetworkRole', 'client');
fopen(t);
while true
data =fscanf(t, '%c');
disp(data);
end
T
H
Warning: Unsuccessful read : A Timeout occured before the Terminator was reached...
  1 comentario
Walter Roberson
Walter Roberson el 10 de Nov. de 2021
When reading separate characters, fread() often makes more sense than fscanf() '%c' . It might not fix your problem, but it might reduce it
data = fread(t, [1 1], 'uchar')
Which MATLAB release are you using? These days tcpclient() is recommended

Iniciar sesión para comentar.

Respuestas (3)

Bryan
Bryan el 10 de Nov. de 2021
I've tried but here the client matlab does not accept even the data
  1 comentario
Walter Roberson
Walter Roberson el 10 de Nov. de 2021
I am not clear what you tried? Are you saying that when you used tcpclient() that the connection failed? Are you saying you used tcpclient() but using read() failed for it? [Note: tcpclient() uses read() and readline() not fread() -- and no fgets() for tcpclient() either.)

Iniciar sesión para comentar.


Bryan
Bryan el 10 de Nov. de 2021
sorry sorry i rather believe the problem is from the matlab receiving pad

Bryan
Bryan el 16 de Nov. de 2021
Hi, please how to run matlab and Simulink at the same time. In fact the matlab code must always be executed to recover a value coming from the server and this value must be sent to Simulink at the same time. Me when I run the matlab code it blocks the execution of Simulink. Help me !

Community Treasure Hunt

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

Start Hunting!

Translated by