TCPIP connection timing out when streaming data from MTConnect

2 views (last 30 days)
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.

Answers (1)

Jyotsna Talluri
Jyotsna Talluri on 6 Aug 2019
Hi,
The below link provides all the possible causes of errors and ways to solve them
Hope it helps..
  1 Comment
Robert Ward
Robert Ward on 7 Aug 2019
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.

Sign in to comment.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!