LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NON-FATAL RUN-TIME ERROR How to prevent it

Solved!
Go to solution

I am getting a non-fatal run-time error pop-up window using the function ConnectToTCPServer().  Everything works fine, but when I unplug the ethernet cable from the computer (to simulate a lost connection) I get this non-fatal error pop-up box.  This is obviously not good for an application that is unattended and must be able to continue running when the internet connection is restored.

I tried unchecking Break on Library error menu item under the run menu.  The non-fatal error still pops up requiring a human to click a box to continue running the program.

The basic code in a function is like the following:

socketConnectError = ConnectToTCPServer (&gTCPConnectionHandle, portNum, serverIP, TCPCallback, NULL, 5000);

if( socketConnectError < 0 ){ // error
sprintf(buf,"Connection to server error = %d\n",socketConnectError);
SetCtrlVal (panelHandle, PANEL_TEXTBOX, buf);
serverConnectErrorCount++;
}
else if ( socketConnectError > 0 ){ // warning
sprintf(buf,"Connection to server warning = %d\n",socketConnectError);
SetCtrlVal (panelHandle, PANEL_TEXTBOX, buf);
serverConnectWarningCount++;
}
else{ // connected 

// code to make transaction with server

 }

return socketConnectError;

 

Can anyone suggest how I should be handling the error from this function so I do not get a non-fatal pop up?

0 Kudos
Message 1 of 4
(2,913 Views)
Solution
Accepted by topic author barney99

Hi,

Try to disable break on library errors using SetBreakOnLibraryErrors ()

 

From Manual:

int oldValue;
oldValue = SetBreakOnLibraryErrors (0);
/* Function calls that may legitimately return errors. */
SetBreakOnLibraryErrors (oldValue);

 

Jan

0 Kudos
Message 2 of 4
(2,881 Views)

Thanks.  That worked.  But I am not sure why it worked!  The documentation for the function says:

Use this function only when you want to temporarily disable the Run»Break on»Library Errors feature around a segment of code. This function changes the setting for the thread that calls this function.

SetBreakOnLibraryErrors does not affect the state of the Run»Break on»Library Errors option in the Workspace window.

If you disable run-time checking, SetBreakOnLibraryErrors has no effect.

 

I made sure the Breakon>>Library Errors was unchecked.

I also selected release configuration under build options.

 

Something seems to be missing here...

0 Kudos
Message 3 of 4
(2,868 Views)

Hi,

I think you should re-install CVI (repair). You shall not get break on library errors in release mode.

Jan

 

0 Kudos
Message 4 of 4
(2,855 Views)