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 日間)
古いコメントを表示
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
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
2021 年 11 月 10 日
1 件のコメント
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.)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!