LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

run-time error handling without popup

I'm searching for a way to make a CVI executable more robust by performing an automatic routine if any run-time error occurs.  Basically I don't like the fact that a popup is displayed and the program is halted in the event of a fatal run-time error.  I cannot prevent a fatal run-time error from ever occurring so I was hoping there was a way to handle it automattically when CVI detects it.  So far though, the only thing that I've found is the CVI run-time error popup which suspends the program until user input or in release mode, a Windows popup that suspends the program in a similar manner with more cryptic OS level exception info.  I'm using Windows XP and CVI 2009, thanks.

0 Kudos
Message 1 of 4
(3,793 Views)

You cannot handle fatal run-time errors in code or through the CVI RTE. This is the distinction between fatal and non-fatal errors. Once you have a fatal error, your program terminates immediately. The popup in this case is probably best to be there, because without it, the user would just see the application close with no explanation.

 

Typically, you want to make the best effort possible to never have a fatal run-time error in your application. CVI has a feature known as user protection that tries to anticipate these errors (typically they are memory related) and will give you an error while debugging. If you receive one of these, it's a good clue to a potential source of a fatal run-time error.

National Instruments
0 Kudos
Message 2 of 4
(3,782 Views)

Ok, well, the source of the fatal run-time error seems to be within a function call to imaqSnap within the NI Vision library.  imaqSnap() is a function that just grabs 1 frame of video.  We're using NI Vision 8.5 with a PCI-1422 Imaq card and whenever there is no signal present at the input of the card, we get the following error:

 

FATAL RUN-TIME ERROR:   "Imaq_support.c", line 187, col 18, thread id 0x000004F8:   Function : (errorCode = -1074397150 [0xbff60022]). A timeout error occurred while waiting for the specified event.  If waiting for an image, verify that all video data is acquired within the timeout period.  If waiting for a signal, verify that the signal assertion occurs within the timeout period.

 

Line 187 is the line with the call to imaqSnap shown below:

 

                                            /* Initialize the Image Capture system */
                                            /* Open an interface and a session */
      ApplErrChk(imgInterfaceOpen ("img0", &Iid));
      ApplErrChk(imgSessionOpen (Iid, &Sid));

                                            /* set aquire mode */
    /* Snap a picture : ImaqBuffer is NULL, memory will be allocated by NI-IMAQ */
      AcqImage = NULL;
      AcqImage = imaqSnap (Sid, NULL, IMAQ_NO_RECT);

      if (AcqImage == NULL) {
        ErrNull = TRUE;
        iErrCode = imaqGetLastError();
        if (iErrCode != ERR_SUCCESS) goto tst_exit;
      }

 

It seems to me that this should not be a fatal run-time error, it should instead throw a non-fatal timeout error and allow our calling code to handle the null reference to the image.  Since it's a fatal error though, it doesn't allow me to ignore the run-time error and handle it gracefully.  The Sid and Iid references look fine when it throws the error so I'm unable to detect the problem before the function call.  Any thoughts on how to fix this issue?

0 Kudos
Message 3 of 4
(3,763 Views)

rreis,
I am not familiar with this IMAQ function or the error you are receiving. I tried searching if anyone had a similar problem, but came up empty.

 

You may want to try posting this question to either the Machine Vision or LabVIEW boards for more insight into this issue.

Jared A.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,747 Views)