09-03-2013 03:02 PM
I'm learning how to develop an IVI-C specific driver using LabWindows/CVI. When I run my function from its function panel and it returns an error, I would like to display a dialog with both the error code and error message (as opposed to simply returning an error code on the function panel). This would save the user from having to call Prefix_error_message() to translate the error code to its error message. NI-DCPower driver is a good example of this behavior (see attached error dialog). How do I show the "Non-Fatal Run-Time Error In Function Panel" dialog? Any help is greatly appreciated. Thanks!
09-03-2013 03:39 PM
You can use the macros __FUNCTION__, __FILE__ and __LINE__
09-03-2013 04:16 PM
That will be helpful in formatting the error message. However, I don't know yet how to display the error dialog when my function returns an error AND it is executed from LabWindows' front panel...
09-04-2013 12:31 AM
Hm, I am not so sure what you are asking for... Are you looking for MessagePopup (title, message) ?
09-04-2013 06:18 PM
I'm looking for a way to show the "NON-FATAL RUN-TIME ERROR" dialog when my IVI-C specific driver returns an error. This appears to be the standard behavior of IVI library functions. For example, calling Ivi_LockSession() with an invalid session handle will pop-up a "NON-FATAL RUN-TIME ERROR" dialog with "Break" and "Continue" buttons. How can I do similar thing when my IVI-C specific function returns an error?
This behavior is enabled/disabled by the "Run > Break on > Library Errors" setting. I have added the #pragma EnableLibraryRuntimeChecking in the source file. Perhaps there is another setting that I need to do so that my driver is considered as a "library" by LabWindows?
09-04-2013 11:47 PM - edited 09-04-2013 11:47 PM
Will SetBreakOnLibraryErrors () do what you want? Remember that error popups depend on the Run >> Break On >> Library Errors menu item state.
09-05-2013 08:02 AM
I have tried using SetBreakOnLibraryErrors(1) and confirmed that it is enabled using GetBreakOnLibraryErrors() and GetBreakOnProtectionErrors(). When I tested my driver function by running its front panel and deliberately passed an invalid session handle, I got the "NON-FATAL RUN-TIME ERROR" dialog from each of the IVI library functions that I called within the function, but none from my driver function. I want to do the same thing when my driver function returns an error.
It looks to me that I have set up my environment correctly to display the "NON-FATAL RUN-TIME ERROR" dialog when a "library" function returns an error. However, I have not been able to find out a way to display the dialog when my driver function returns an error. Is there an API (similar to MessagePopup or GenericMessagePopup) that I can call to display the "NON-FATAL RUN-TIME ERROR" dialog?
09-10-2013 04:25 PM - edited 09-10-2013 04:29 PM
Hello buckhorn,
I was able to reproduce the Non-Fatal Error popup with a bad session in a shipping example of the specific driver for the hp34401a driver using a call to checkErr. I suggest downloading ICP if you haven't yet as well as the hp34401a specific driver to see how to catch these errors. Hopefully my process and the example code will help you duplicate the popup and aid you in your code development.
You should get the following :
Example failing with a bad session
Let me know how it goes or if you get hung up on anything else.
09-11-2013 05:25 PM
Hi Shawn,
Thank you for replying to my post. The checkErr is just an error handling macro defined in ivi.h to goto Error: tag when the function returns a non-zero value. I have been using the checkErr macro (as well as viCheckErr and other macros) in my driver.
Using the same hp34401a specific driver as an example, please allow me to explain my question in more details:
Let's take the hp34401a_close function as an example. It is a simple function with only a few lines of code:
When the hp34401a_close function is run from its front panel using an invalid session handle (e.g. "8" in this screen capture):
You will get three "Non-Fatal Run-Time Error" popup dialogs, one from each of the IVI library functions that it calls: Ivi_LockSession, Ivi_UnlockSession, and Ivi_Dispose. However, there is no "Non-Fatal Run-Time Error" popup dialog from the hp34401a_close itself.
My IVI-C specific driver is behaving identical to the hp34401a specific driver.
In comparison, if run niDCPower_close function from its front panel using an invalid session handle (using the same "8" in this screen capture):
You will only get one "Non-Fatal Run-Time Error In Function Panel" from the niDCPower_close function itself:
I think the behavior of niDCPower driver is much better than the hp34401a driver. It replaces the three "Non-Fatal Run-Time Error" popup dialogs from the IVI library with a single "Non-Fatal Run-Time Error In Function Panel" popup dialog from the driver function itself. I would like to do the same thing with my driver but have not figured out how to display a "Non-Fatal Run-Time Error In Function Panel" dialog. Thanks in advance for your help!
09-13-2013 12:24 PM - edited 09-13-2013 12:25 PM
Thanks for clarifying. We are going to speak with our LabWindows CVI PSE and will let you know as soon as we have a response.
And thanks for your patience!