LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

The Network Operation Timed Out and the Connection Was Lost

Why would I get the error shown in the picture below when no errors pop up on either my host or RT programs?  I'm running in debug mode.

 

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 7
(5,051 Views)

Would you be able to describe your set-up a bit more?  If this error pops up on your PC screen, is that not the host in this case?  What is your host and what is your target?

Michael Keane
National Instruments
0 Kudos
Message 2 of 7
(5,021 Views)

Hello Michael!

 

Thanks for posting! Unfortunately, this error can be caused by lots of different reasons. Essentially, it means that the network lost connection to the device that you were attempting to execute your code on. The most common cause of this I have seen is that the user will put a while loop in their code without any wait timing. This will cause the while loop to rail the processor on the RT device and it will not be able to do any network communication. This would also explain why no error is associated with the loss of connection. Is it possible to post your code to the forum?

Collin D.
Software Product Manager
0 Kudos
Message 3 of 7
(5,009 Views)

There is a program written in CVI running on a RT PXI target which reads AI and TCPs it to a program written in VB.NET.  I've been working on it for a while without seeing this message and I didn't add any while loops lately.  The problem is random.  I can run it for several hours and then I get this message and it stops running.  That makes debugging difficult. 

 

Here are the only two while loops in the main operation.  For now I have deverted the TCP data to the debug window to eliminate that section.

 

while (!RTIsShuttingDown()) // || !flagInProcess)
{
ProcessSystemEvents();
SleepUS (10000);
}

 

while (BytesToWrite > 0)
{
BytesWritten = ServerTCPWrite (gTCPConnectionHandle, msgToSend, BytesToWrite, 0);
BytesToWrite -= BytesWritten;
}

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 4 of 7
(4,986 Views)

Hi Michael,

 

Have you considered implementing a heartbeat check in your code to occasionally check for proper connection?

Michael Keane
National Instruments
0 Kudos
Message 5 of 7
(4,962 Views)

I will probably have to do that eventually, but I know the program is still running.

 

It sends TCP data to a Windows host at 2 Hz, and it is still doing that right now.  This means that Labwindows/CVI lost communication with the PXI system, but to PXI system is still functioning.  Is it possible to reconnect from CVI without restarting the PXI system?

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 6 of 7
(4,022 Views)

Hi Michael,

Have you checked if your Real-Time Target's Memory or CPU Usage is running high when this disconnect occurs? The debugger connection would likely be the lowest priority process on the target, resulting in the behavior Collin mentioned previously above.

Since it is the debugger that is disconnecting and not the actual PXI Controller, there is unfortunately no way to reconnect. As per the following help document, once the debugger is disconnected from the target the program will continue running but the debugger cannot reconnect.
http://zone.ni.com/reference/en-XX/help/372398G-01/cvirtmodulehelp/runninganrtapp/

Charlie J.
National Instruments
0 Kudos
Message 7 of 7
(3,995 Views)