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 回表示 (過去 30 日間)
Bryan
Bryan 2021 年 11 月 10 日
回答済み: Bryan 2021 年 11 月 16 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 10 日
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

サインインしてコメントする。

回答 (3 件)

Bryan
Bryan 2021 年 11 月 10 日
I've tried but here the client matlab does not accept even the data
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 10 日
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.)

サインインしてコメントする。


Bryan
Bryan 2021 年 11 月 10 日
sorry sorry i rather believe the problem is from the matlab receiving pad

Bryan
Bryan 2021 年 11 月 16 日
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