MATLAB Answers

TCPIP connection timing out when streaming data from MTConnect

1 ビュー (過去 30 日間)
Robert Ward
Robert Ward 2019 年 7 月 31 日
コメント済み: Robert Ward 2019 年 8 月 7 日
When accessing MTConnect string data using a TCPIP connection - the connection keeps intermittently timing out. The data stream works for a time then pauses. I would like to access the data in real-time however when I leave the connection open and repeat the fgets command then it results in errors. This is the code I am currently using:
I'm using the following in a loop:
fopen(tcpObject);
lineMach=fgets(tcpObject) ;% using fgets rather than fscanf prevents TCPIP connection timing out
fclose(tcpObject);
I keep gettting the following error message:
Warning: A timeout occurred before the Terminator was reached.
'tcpip' unable to read any data. For more information on possible reasons, see TCPIP Read Warnings.

  0 件のコメント

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

回答 (1 件)

Jyotsna Talluri
Jyotsna Talluri 2019 年 8 月 6 日
Hi,
The below link provides all the possible causes of errors and ways to solve them
Hope it helps..

  1 件のコメント

Robert Ward
Robert Ward 2019 年 8 月 7 日
Thank you for the link. It doesn't answer my issue unfortunately. I'll try explain a bit more. I am trying to extract data from an MTConnect datastream using a TCPIP connection.
The data is set up over 3 lines of information, so after I open the TCPIP connection and call the data by using fgets/fgetl/fscanf then it reads the first line (which is what I want). When I call it again then it reads the second line (which I dont want). It seems the only way I can repeatedly call the first line is by closing the connection using fclose and then reopen (fopen) followed by fgets/fgetl/fscanf.
This is fine for slow data rates but I'd like to increase the data rate and this is where the issue occurs. It sometimes timesout or tries to open an already open connection.
Thanks again for your advice.

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by