MATLAB Answers

0

TCPIP connection timing out when streaming data from MTConnect

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 件のコメント

サインイン to comment.

製品


リリース

R2018b

1 件の回答

回答者: 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 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.

サインイン to comment.



Translated by