07-17-2012 02:13 PM
Hi, I'm experiencing an NI Vision issue with imaqSnap using a Windows XP machine with a CVI 2009 executable.
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?
07-17-2012 11:18 PM
CVI has a compile-time option of whether to generate this type of failure when an NI function returns an error. It is [presumably] designed to allow easier debugging of code without putting any error checking code in yourself. I believe you can change that option in your compilation and then all error handling is via the standard function methods (return value, GetLastError, etc).
Eric
07-19-2012 11:36 AM
The compile option that I think you're referring to allows disabling the run-time checking which does ignore run-time errors. However, for a fatal error though, the program will still crash and you will get a Windows error popup instead.
NI support was able to point me in the direction of using imgSnap instead of imaqSnap. Apparently, this is a function from the NI-IMAQ library instead of the NI Vision library. The functions are almost equivalent except imgSnap throws a non-fatal run-time error instead. As far as I can tell, the other NI Vision library functions throw non-fatal errors if video is not present so it's just imaqSnap that needed to be replaced.